@thisisagile/easy 15.15.2 → 15.15.4

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,6 +1,9 @@
1
- import { Enum, IdName, Text } from '../types';
1
+ import { Enum, IdName, List, Text } from '../types';
2
2
  export declare class Scope extends Enum {
3
3
  readonly name: string;
4
- protected constructor(name: string, id?: Text);
4
+ readonly subs: List<Scope>;
5
+ protected constructor(name: string, id?: Text, subs?: List<Scope>);
5
6
  for(item: string | IdName): Scope;
7
+ combines(...scopes: Scope[]): this;
8
+ expand(): List<Scope>;
6
9
  }
@@ -23,16 +23,21 @@ __export(Scope_exports, {
23
23
  module.exports = __toCommonJS(Scope_exports);
24
24
  var import_types = require("../types");
25
25
  class Scope extends import_types.Enum {
26
- // static readonly Basic = new Scope('Basic');
27
- // static readonly Auth = new Scope('Authorization', 'auth');
28
- // static readonly Admin = new Scope('Administration', 'admin');
29
- constructor(name, id = (0, import_types.text)(name).kebab) {
26
+ constructor(name, id = (0, import_types.text)(name).kebab, subs = (0, import_types.toList)()) {
30
27
  super(name, id.toString());
31
28
  this.name = name;
29
+ this.subs = subs;
32
30
  }
33
31
  for(item) {
34
32
  return new Scope(`${this.name} ${(0, import_types.isString)(item) ? (0, import_types.text)(item).title : item.name}`, (0, import_types.kebab)(`${this.id} ${(0, import_types.isString)(item) ? item : item.id}`));
35
33
  }
34
+ combines(...scopes) {
35
+ this.subs.add(scopes);
36
+ return this;
37
+ }
38
+ expand() {
39
+ return this.subs.flatMap((s) => s.expand()).add(this).distinct();
40
+ }
36
41
  }
37
42
  // Annotate the CommonJS export names for ESM import in node:
38
43
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/process/Scope.ts"],"sourcesContent":["import { Enum, IdName, isString, kebab, Text, text } from '../types';\n\nexport class Scope extends Enum {\n // static readonly Basic = new Scope('Basic');\n // static readonly Auth = new Scope('Authorization', 'auth');\n // static readonly Admin = new Scope('Administration', 'admin');\n\n protected constructor(readonly name: string, id: Text = text(name).kebab) {\n super(name, id.toString());\n }\n\n for(item: string | IdName): Scope {\n return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0D;AAEnD,MAAM,cAAc,kBAAK;AAAA;AAAA;AAAA;AAAA,EAKpB,YAAqB,MAAc,SAAW,mBAAK,IAAI,EAAE,OAAO;AACxE,UAAM,MAAM,GAAG,SAAS,CAAC;AADI;AAAA,EAE/B;AAAA,EAEA,IAAI,MAA8B;AAChC,WAAO,IAAI,MAAM,GAAG,KAAK,IAAI,QAAI,uBAAS,IAAI,QAAI,mBAAK,IAAI,EAAE,QAAQ,KAAK,IAAI,QAAI,oBAAM,GAAG,KAAK,EAAE,QAAI,uBAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;AAAA,EAC1I;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/process/Scope.ts"],"sourcesContent":["import { Enum, IdName, isString, kebab, List, Text, text, toList } from '../types';\n\nexport class Scope extends Enum {\n\n protected constructor(readonly name: string, id: Text = text(name).kebab, readonly subs: List<Scope> = toList()) {\n super(name, id.toString());\n }\n\n for(item: string | IdName): Scope {\n return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));\n }\n\n combines(...scopes: Scope[]): this {\n this.subs.add(scopes);\n return this;\n }\n\n expand(): List<Scope> {\n return this.subs.flatMap(s => s.expand()).add(this).distinct();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwE;AAEjE,MAAM,cAAc,kBAAK;AAAA,EAEpB,YAAqB,MAAc,SAAW,mBAAK,IAAI,EAAE,OAAgB,WAAoB,qBAAO,GAAG;AAC/G,UAAM,MAAM,GAAG,SAAS,CAAC;AADI;AAAoD;AAAA,EAEnF;AAAA,EAEA,IAAI,MAA8B;AAChC,WAAO,IAAI,MAAM,GAAG,KAAK,IAAI,QAAI,uBAAS,IAAI,QAAI,mBAAK,IAAI,EAAE,QAAQ,KAAK,IAAI,QAAI,oBAAM,GAAG,KAAK,EAAE,QAAI,uBAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;AAAA,EAC1I;AAAA,EAEA,YAAY,QAAuB;AACjC,SAAK,KAAK,IAAI,MAAM;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,SAAsB;AACpB,WAAO,KAAK,KAAK,QAAQ,OAAK,EAAE,OAAO,CAAC,EAAE,IAAI,IAAI,EAAE,SAAS;AAAA,EAC/D;AACF;","names":[]}
@@ -1,16 +1,21 @@
1
1
  import "../chunk-4N72FQFX.mjs";
2
- import { Enum, isString, kebab, text } from "../types";
2
+ import { Enum, isString, kebab, text, toList } from "../types";
3
3
  class Scope extends Enum {
4
- // static readonly Basic = new Scope('Basic');
5
- // static readonly Auth = new Scope('Authorization', 'auth');
6
- // static readonly Admin = new Scope('Administration', 'admin');
7
- constructor(name, id = text(name).kebab) {
4
+ constructor(name, id = text(name).kebab, subs = toList()) {
8
5
  super(name, id.toString());
9
6
  this.name = name;
7
+ this.subs = subs;
10
8
  }
11
9
  for(item) {
12
10
  return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));
13
11
  }
12
+ combines(...scopes) {
13
+ this.subs.add(scopes);
14
+ return this;
15
+ }
16
+ expand() {
17
+ return this.subs.flatMap((s) => s.expand()).add(this).distinct();
18
+ }
14
19
  }
15
20
  export {
16
21
  Scope
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/process/Scope.ts"],"sourcesContent":["import { Enum, IdName, isString, kebab, Text, text } from '../types';\n\nexport class Scope extends Enum {\n // static readonly Basic = new Scope('Basic');\n // static readonly Auth = new Scope('Authorization', 'auth');\n // static readonly Admin = new Scope('Administration', 'admin');\n\n protected constructor(readonly name: string, id: Text = text(name).kebab) {\n super(name, id.toString());\n }\n\n for(item: string | IdName): Scope {\n return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));\n }\n}\n"],"mappings":";AAAA,SAAS,MAAc,UAAU,OAAa,YAAY;AAEnD,MAAM,cAAc,KAAK;AAAA;AAAA;AAAA;AAAA,EAKpB,YAAqB,MAAc,KAAW,KAAK,IAAI,EAAE,OAAO;AACxE,UAAM,MAAM,GAAG,SAAS,CAAC;AADI;AAAA,EAE/B;AAAA,EAEA,IAAI,MAA8B;AAChC,WAAO,IAAI,MAAM,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,QAAQ,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,EAAE,IAAI,SAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;AAAA,EAC1I;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/process/Scope.ts"],"sourcesContent":["import { Enum, IdName, isString, kebab, List, Text, text, toList } from '../types';\n\nexport class Scope extends Enum {\n\n protected constructor(readonly name: string, id: Text = text(name).kebab, readonly subs: List<Scope> = toList()) {\n super(name, id.toString());\n }\n\n for(item: string | IdName): Scope {\n return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));\n }\n\n combines(...scopes: Scope[]): this {\n this.subs.add(scopes);\n return this;\n }\n\n expand(): List<Scope> {\n return this.subs.flatMap(s => s.expand()).add(this).distinct();\n }\n}\n"],"mappings":";AAAA,SAAS,MAAc,UAAU,OAAmB,MAAM,cAAc;AAEjE,MAAM,cAAc,KAAK;AAAA,EAEpB,YAAqB,MAAc,KAAW,KAAK,IAAI,EAAE,OAAgB,OAAoB,OAAO,GAAG;AAC/G,UAAM,MAAM,GAAG,SAAS,CAAC;AADI;AAAoD;AAAA,EAEnF;AAAA,EAEA,IAAI,MAA8B;AAChC,WAAO,IAAI,MAAM,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,QAAQ,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,EAAE,IAAI,SAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;AAAA,EAC1I;AAAA,EAEA,YAAY,QAAuB;AACjC,SAAK,KAAK,IAAI,MAAM;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,SAAsB;AACpB,WAAO,KAAK,KAAK,QAAQ,OAAK,EAAE,OAAO,CAAC,EAAE,IAAI,IAAI,EAAE,SAAS;AAAA,EAC/D;AACF;","names":[]}
@@ -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
  }
@@ -32,14 +32,14 @@ class UseCase extends import_types.Enum {
32
32
  this.scopes.add(...s);
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(...s);\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,GAAG,CAAC;AACpB,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":[]}
@@ -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());
@@ -10,14 +10,14 @@ class UseCase extends Enum {
10
10
  this.scopes.add(...s);
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(...s);\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,CAAC;AACpB,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":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/Identity.ts"],"sourcesContent":["import { Id } from './Id';\n\nexport type Identity = {\n id: Id;\n user?: string;\n};\n\nexport type IdName = { id: Id; name: string, slug?: string };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/Identity.ts"],"sourcesContent":["import { Id } from './Id';\n\nexport type Identity = { id: Id; user?: string };\n\nexport type IdName = { id: Id; name: string, slug?: string };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "15.15.2",
3
+ "version": "15.15.4",
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.2",
36
+ "@thisisagile/easy-test": "15.15.4",
37
37
  "@types/form-urlencoded": "^4.4.0",
38
38
  "@types/jsonwebtoken": "^9.0.2",
39
39
  "@types/luxon": "3.2.0",
@@ -1,15 +1,21 @@
1
- import { Enum, IdName, isString, kebab, Text, text } from '../types';
1
+ import { Enum, IdName, isString, kebab, List, Text, text, toList } from '../types';
2
2
 
3
3
  export class Scope extends Enum {
4
- // static readonly Basic = new Scope('Basic');
5
- // static readonly Auth = new Scope('Authorization', 'auth');
6
- // static readonly Admin = new Scope('Administration', 'admin');
7
4
 
8
- protected constructor(readonly name: string, id: Text = text(name).kebab) {
5
+ protected constructor(readonly name: string, id: Text = text(name).kebab, readonly subs: List<Scope> = toList()) {
9
6
  super(name, id.toString());
10
7
  }
11
8
 
12
9
  for(item: string | IdName): Scope {
13
10
  return new Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));
14
11
  }
12
+
13
+ combines(...scopes: Scope[]): this {
14
+ this.subs.add(scopes);
15
+ return this;
16
+ }
17
+
18
+ expand(): List<Scope> {
19
+ return this.subs.flatMap(s => s.expand()).add(this).distinct();
20
+ }
15
21
  }
@@ -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
 
@@ -12,13 +12,13 @@ export class UseCase extends Enum {
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
  }
@@ -1,8 +1,5 @@
1
1
  import { Id } from './Id';
2
2
 
3
- export type Identity = {
4
- id: Id;
5
- user?: string;
6
- };
3
+ export type Identity = { id: Id; user?: string };
7
4
 
8
5
  export type IdName = { id: Id; name: string, slug?: string };