@pax2pay/model-banking 0.1.47 → 0.1.49

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.
Files changed (41) hide show
  1. package/Card/Creatable.ts +3 -0
  2. package/Card/index.ts +4 -0
  3. package/Client/index.ts +2 -14
  4. package/Treasury/index.ts +0 -3
  5. package/dist/Card/Creatable.d.ts +2 -0
  6. package/dist/Card/Creatable.js +2 -0
  7. package/dist/Card/Creatable.js.map +1 -1
  8. package/dist/Card/index.d.ts +2 -0
  9. package/dist/Card/index.js +3 -0
  10. package/dist/Card/index.js.map +1 -1
  11. package/dist/Client/index.d.ts +1 -13
  12. package/dist/Client/index.js +2 -12
  13. package/dist/Client/index.js.map +1 -1
  14. package/dist/Treasury/index.d.ts +0 -3
  15. package/dist/Treasury/index.js +0 -2
  16. package/dist/Treasury/index.js.map +1 -1
  17. package/package.json +8 -8
  18. package/Client/Application.ts +0 -27
  19. package/Client/Me.ts +0 -42
  20. package/Client/Organization.ts +0 -69
  21. package/Client/User.ts +0 -63
  22. package/Treasury/Client/Treasury.ts +0 -20
  23. package/Treasury/Client/index.ts +0 -55
  24. package/dist/Client/Application.d.ts +0 -16
  25. package/dist/Client/Application.js +0 -20
  26. package/dist/Client/Application.js.map +0 -1
  27. package/dist/Client/Me.d.ts +0 -8
  28. package/dist/Client/Me.js +0 -39
  29. package/dist/Client/Me.js.map +0 -1
  30. package/dist/Client/Organization.d.ts +0 -19
  31. package/dist/Client/Organization.js +0 -45
  32. package/dist/Client/Organization.js.map +0 -1
  33. package/dist/Client/User.d.ts +0 -18
  34. package/dist/Client/User.js +0 -36
  35. package/dist/Client/User.js.map +0 -1
  36. package/dist/Treasury/Client/Treasury.d.ts +0 -11
  37. package/dist/Treasury/Client/Treasury.js +0 -14
  38. package/dist/Treasury/Client/Treasury.js.map +0 -1
  39. package/dist/Treasury/Client/index.d.ts +0 -39
  40. package/dist/Treasury/Client/index.js +0 -40
  41. package/dist/Treasury/Client/index.js.map +0 -1
package/Card/Creatable.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isoly } from "isoly"
2
2
  import { isly } from "isly"
3
+ import { Realm } from "../Realm"
3
4
  import { Expiry } from "./Expiry"
4
5
  import { Meta } from "./Meta"
5
6
  import { Preset } from "./Preset"
@@ -7,6 +8,7 @@ import { Preset } from "./Preset"
7
8
  export interface Creatable {
8
9
  account: string
9
10
  number?: string
11
+ realm: Realm
10
12
  preset: Preset
11
13
  details: {
12
14
  iin: string
@@ -22,6 +24,7 @@ export namespace Creatable {
22
24
  export const type = isly.object<Creatable>({
23
25
  account: isly.string(),
24
26
  number: isly.string().optional(),
27
+ realm: isly.fromIs("Realm", Realm.is),
25
28
  preset: Preset.type,
26
29
  details: isly.object({
27
30
  iin: isly.string(),
package/Card/index.ts CHANGED
@@ -2,6 +2,7 @@ import { cryptly } from "cryptly"
2
2
  import { isoly } from "isoly"
3
3
  import { isly } from "isly"
4
4
  import { Operation as BankingOperation } from "../Operation"
5
+ import { Realm } from "../Realm"
5
6
  import { Changeable as CardChangeable } from "./Changeable"
6
7
  import { Creatable as CardCreatable } from "./Creatable"
7
8
  import { Expiry as CardExpiry } from "./Expiry"
@@ -16,6 +17,7 @@ export interface Card {
16
17
  created: isoly.DateTime
17
18
  organization: string
18
19
  account: string
20
+ realm: Realm
19
21
  preset: CardPreset
20
22
  reference?: string
21
23
  details: {
@@ -42,6 +44,7 @@ export namespace Card {
42
44
  created: created,
43
45
  organization: organization,
44
46
  account: card.account,
47
+ realm: card.realm,
45
48
  preset: card.preset,
46
49
  details: { iin: card.details.iin, last4: last4, expiry: card.details.expiry, holder: card.details.holder },
47
50
  limit: card.limit,
@@ -59,6 +62,7 @@ export namespace Card {
59
62
  created: isly.string(),
60
63
  organization: isly.string(),
61
64
  account: isly.string(),
65
+ realm: isly.fromIs("Realm", Realm.is),
62
66
  preset: CardPreset.type,
63
67
  reference: isly.string().optional(),
64
68
  details: isly.object({
package/Client/index.ts CHANGED
@@ -1,23 +1,19 @@
1
1
  import { gracely } from "gracely"
2
2
  import { userwidgets } from "@userwidgets/model"
3
3
  import { http } from "cloudly-http"
4
- import * as rest from "cloudly-rest"
4
+ import { rest } from "cloudly-rest"
5
5
  import { Accounts } from "./Accounts"
6
- import { Application as ClientApplication } from "./Application"
7
6
  import { Cards } from "./Cards"
8
- import { Me as ClientMe } from "./Me"
9
7
  import { Operations } from "./Operations"
10
- import { Organization as ClientOrganization } from "./Organization"
11
8
  import { Organizations } from "./Organizations"
12
9
  import { Transactions } from "./Transactions"
13
10
  import { Treasury } from "./Treasury"
14
- import { User as ClientUser } from "./User"
15
11
  import { Version } from "./Version"
16
12
 
17
13
  export class Client extends rest.Client<gracely.Error> {
18
14
  realm?: string
19
15
  organization?: string
20
- readonly userwidgets = new userwidgets.ClientCollection(this.client, "/widgets")
16
+ readonly userwidgets = new userwidgets.ClientCollection(this.client, { pathPrefix: "/widgets" })
21
17
  readonly accounts = new Accounts(this.client)
22
18
  readonly operations = new Operations(this.client)
23
19
  readonly organizations = new Organizations(this.client)
@@ -39,13 +35,5 @@ export class Client extends rest.Client<gracely.Error> {
39
35
  }
40
36
  }
41
37
  export namespace Client {
42
- export type Application = ClientApplication
43
- export const Application = ClientApplication
44
- export type Organization = ClientOrganization
45
- export const Organization = ClientOrganization
46
- export type Me = ClientMe
47
- export const Me = ClientMe
48
- export type User = ClientUser
49
- export const User = ClientUser
50
38
  export type Unauthorized = (client: rest.Client<never>) => Promise<boolean>
51
39
  }
package/Treasury/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Account as TreasuryAccount } from "./Account"
2
2
  import { Balance as TreasuryBalance } from "./Balance"
3
- import { Client as TreasuryClient } from "./Client"
4
3
  import { Fiat as TreasuryFiat } from "./Fiat"
5
4
  export { Treasury } from "./Treasury"
6
5
 
@@ -8,9 +7,7 @@ export namespace Treasury {
8
7
  export type Account = TreasuryAccount
9
8
  export type Balance = TreasuryBalance
10
9
  export type Fiat = TreasuryFiat
11
- export type Client = TreasuryClient
12
10
  export const Balance = TreasuryBalance
13
- export const Client = TreasuryClient
14
11
  export namespace Account {
15
12
  export type Creatable = TreasuryAccount.Creatable
16
13
  export const Creatable = TreasuryAccount.Creatable
@@ -1,11 +1,13 @@
1
1
  import { isoly } from "isoly";
2
2
  import { isly } from "isly";
3
+ import { Realm } from "../Realm";
3
4
  import { Expiry } from "./Expiry";
4
5
  import { Meta } from "./Meta";
5
6
  import { Preset } from "./Preset";
6
7
  export interface Creatable {
7
8
  account: string;
8
9
  number?: string;
10
+ realm: Realm;
9
11
  preset: Preset;
10
12
  details: {
11
13
  iin: string;
@@ -1,5 +1,6 @@
1
1
  import { isoly } from "isoly";
2
2
  import { isly } from "isly";
3
+ import { Realm } from "../Realm";
3
4
  import { Expiry } from "./Expiry";
4
5
  import { Meta } from "./Meta";
5
6
  import { Preset } from "./Preset";
@@ -8,6 +9,7 @@ export var Creatable;
8
9
  Creatable.type = isly.object({
9
10
  account: isly.string(),
10
11
  number: isly.string().optional(),
12
+ realm: isly.fromIs("Realm", Realm.is),
11
13
  preset: Preset.type,
12
14
  details: isly.object({
13
15
  iin: isly.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Card/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAgBjC,MAAM,KAAW,SAAS,CAezB;AAfD,WAAiB,SAAS;IACZ,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;QAC1C,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;QACtB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QA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C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,MAAM,CAAC,IAAI;QACnB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;YACpB,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;YAClB,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACrB,CAAC;QACF,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAClF,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;KAClD,CAAC,CAAA;IACW,YAAE,GAAG,UAAA,IAAI,CAAC,EAAE,CAAA;AAC1B,CAAC,EAhBgB,SAAS,KAAT,SAAS,QAgBzB"}
@@ -1,6 +1,7 @@
1
1
  import { isoly } from "isoly";
2
2
  import { isly } from "isly";
3
3
  import { Operation as BankingOperation } from "../Operation";
4
+ import { Realm } from "../Realm";
4
5
  import { Changeable as CardChangeable } from "./Changeable";
5
6
  import { Creatable as CardCreatable } from "./Creatable";
6
7
  import { Expiry as CardExpiry } from "./Expiry";
@@ -14,6 +15,7 @@ export interface Card {
14
15
  created: isoly.DateTime;
15
16
  organization: string;
16
17
  account: string;
18
+ realm: Realm;
17
19
  preset: CardPreset;
18
20
  reference?: string;
19
21
  details: {
@@ -2,6 +2,7 @@ import { cryptly } from "cryptly";
2
2
  import { isoly } from "isoly";
3
3
  import { isly } from "isly";
4
4
  import { Operation as BankingOperation } from "../Operation";
5
+ import { Realm } from "../Realm";
5
6
  import { Changeable as CardChangeable } from "./Changeable";
6
7
  import { Creatable as CardCreatable } from "./Creatable";
7
8
  import { Expiry as CardExpiry } from "./Expiry";
@@ -19,6 +20,7 @@ export var Card;
19
20
  created: created,
20
21
  organization: organization,
21
22
  account: card.account,
23
+ realm: card.realm,
22
24
  preset: card.preset,
23
25
  details: { iin: card.details.iin, last4: last4, expiry: card.details.expiry, holder: card.details.holder },
24
26
  limit: card.limit,
@@ -37,6 +39,7 @@ export var Card;
37
39
  created: isly.string(),
38
40
  organization: isly.string(),
39
41
  account: isly.string(),
42
+ realm: isly.fromIs("Realm", Realm.is),
40
43
  preset: CardPreset.type,
41
44
  reference: isly.string().optional(),
42
45
  details: isly.object({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAyB/C,MAAM,KAAW,IAAI,CAuDpB;AAvDD,WAAiB,IAAI;IACpB,SAAgB,aAAa,CAAC,IAAe,EAAE,YAAoB,EAAE,KAAa,EAAE,KAAa;QAChG,MAAM,OAAO,GAAG,KAAK,CAAC,QAA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I,CAAC,MAAM,EAAE;SACrB,CAAC;QACF,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAClF,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAClF,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;QACtG,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;KACtD,CAAC,CAAA;IACW,OAAE,GAAG,KAAA,IAAI,CAAC,EAAE,CAAA;IAEZ,cAAS,GAAG,aAAa,CAAA;IAEzB,WAAM,GAAG,UAAU,CAAA;IAEnB,SAAI,GAAG,QAAQ,CAAA;IAEf,WAAM,GAAG,UAAU,CAAA;IAEnB,eAAU,GAAG,cAAc,CAAA;IAE3B,cAAS,GAAG,aAAa,CAAA;AACvC,CAAC,EAzDgB,IAAI,KAAJ,IAAI,QAyDpB"}
@@ -1,17 +1,13 @@
1
1
  import { gracely } from "gracely";
2
2
  import { userwidgets } from "@userwidgets/model";
3
3
  import { http } from "cloudly-http";
4
- import * as rest from "cloudly-rest";
4
+ import { rest } from "cloudly-rest";
5
5
  import { Accounts } from "./Accounts";
6
- import { Application as ClientApplication } from "./Application";
7
6
  import { Cards } from "./Cards";
8
- import { Me as ClientMe } from "./Me";
9
7
  import { Operations } from "./Operations";
10
- import { Organization as ClientOrganization } from "./Organization";
11
8
  import { Organizations } from "./Organizations";
12
9
  import { Transactions } from "./Transactions";
13
10
  import { Treasury } from "./Treasury";
14
- import { User as ClientUser } from "./User";
15
11
  import { Version } from "./Version";
16
12
  export declare class Client extends rest.Client<gracely.Error> {
17
13
  realm?: string;
@@ -27,13 +23,5 @@ export declare class Client extends rest.Client<gracely.Error> {
27
23
  static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T;
28
24
  }
29
25
  export declare namespace Client {
30
- type Application = ClientApplication;
31
- const Application: typeof ClientApplication;
32
- type Organization = ClientOrganization;
33
- const Organization: typeof ClientOrganization;
34
- type Me = ClientMe;
35
- const Me: typeof ClientMe;
36
- type User = ClientUser;
37
- const User: typeof ClientUser;
38
26
  type Unauthorized = (client: rest.Client<never>) => Promise<boolean>;
39
27
  }
@@ -1,21 +1,17 @@
1
1
  import { userwidgets } from "@userwidgets/model";
2
2
  import { http } from "cloudly-http";
3
- import * as rest from "cloudly-rest";
3
+ import { rest } from "cloudly-rest";
4
4
  import { Accounts } from "./Accounts";
5
- import { Application as ClientApplication } from "./Application";
6
5
  import { Cards } from "./Cards";
7
- import { Me as ClientMe } from "./Me";
8
6
  import { Operations } from "./Operations";
9
- import { Organization as ClientOrganization } from "./Organization";
10
7
  import { Organizations } from "./Organizations";
11
8
  import { Transactions } from "./Transactions";
12
9
  import { Treasury } from "./Treasury";
13
- import { User as ClientUser } from "./User";
14
10
  import { Version } from "./Version";
15
11
  export class Client extends rest.Client {
16
12
  constructor() {
17
13
  super(...arguments);
18
- this.userwidgets = new userwidgets.ClientCollection(this.client, "/widgets");
14
+ this.userwidgets = new userwidgets.ClientCollection(this.client, { pathPrefix: "/widgets" });
19
15
  this.accounts = new Accounts(this.client);
20
16
  this.operations = new Operations(this.client);
21
17
  this.organizations = new Organizations(this.client);
@@ -34,10 +30,4 @@ export class Client extends rest.Client {
34
30
  return result;
35
31
  }
36
32
  }
37
- (function (Client) {
38
- Client.Application = ClientApplication;
39
- Client.Organization = ClientOrganization;
40
- Client.Me = ClientMe;
41
- Client.User = ClientUser;
42
- })(Client || (Client = {}));
43
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,OAAO,MAAO,SAAQ,IAAI,CAAC,MAAqB;IAAtD;;QAGU,gBAAW,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QACvE,aAAQ,GAAG,IAAI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E,IAAiC;QACpG,IAAI,UAAsC,CAAA;QAC1C,MAAM,MAAM,GAAW,IAAI,MAAM,CAChC,CAAC,UAAU,GAAG,IAAI,IAAI,CAAC,MAAM,CAAgB,MAAM,EAAE,GAAG,EAAE;YACzD,YAAY,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;SACxG,CAAC,CAAC,CACH,CAAA;QACD,IAAI,IAAI;YACP,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;QACxC,OAAO,MAAoB,CAAA;IAC5B,CAAC;CACD"}
@@ -1,15 +1,12 @@
1
1
  import { Account as TreasuryAccount } from "./Account";
2
2
  import { Balance as TreasuryBalance } from "./Balance";
3
- import { Client as TreasuryClient } from "./Client";
4
3
  import { Fiat as TreasuryFiat } from "./Fiat";
5
4
  export { Treasury } from "./Treasury";
6
5
  export declare namespace Treasury {
7
6
  type Account = TreasuryAccount;
8
7
  type Balance = TreasuryBalance;
9
8
  type Fiat = TreasuryFiat;
10
- type Client = TreasuryClient;
11
9
  const Balance: typeof TreasuryBalance;
12
- const Client: typeof TreasuryClient;
13
10
  namespace Account {
14
11
  type Creatable = TreasuryAccount.Creatable;
15
12
  const Creatable: typeof import("./Account/Creatable").Creatable;
@@ -1,10 +1,8 @@
1
1
  import { Account as TreasuryAccount } from "./Account";
2
2
  import { Balance as TreasuryBalance } from "./Balance";
3
- import { Client as TreasuryClient } from "./Client";
4
3
  export var Treasury;
5
4
  (function (Treasury) {
6
5
  Treasury.Balance = TreasuryBalance;
7
- Treasury.Client = TreasuryClient;
8
6
  let Account;
9
7
  (function (Account) {
10
8
  Account.Creatable = TreasuryAccount.Creatable;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/index.ts"],"names":[],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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",
@@ -54,22 +54,22 @@
54
54
  "clean": "rimraf dist node_modules coverage"
55
55
  },
56
56
  "devDependencies": {
57
- "@types/jest": "^29.5.1",
58
- "@typescript-eslint/eslint-plugin": "5.59.7",
59
- "@typescript-eslint/parser": "5.59.7",
60
- "eslint": "^8.41.0",
57
+ "@types/jest": "^29.5.2",
58
+ "@typescript-eslint/eslint-plugin": "5.59.11",
59
+ "@typescript-eslint/parser": "5.59.11",
60
+ "eslint": "^8.42.0",
61
61
  "eslint-plugin-prettierx": "github:utily/eslint-plugin-prettierx#utily-20221229",
62
62
  "eslint-plugin-simple-import-sort": "^10.0.0",
63
63
  "jest": "^29.5.0",
64
64
  "prettierx": "github:utily/prettierx#utily-20221229",
65
65
  "rimraf": "^5.0.1",
66
66
  "ts-jest": "^29.1.0",
67
- "typescript": "^5.0.4"
67
+ "typescript": "^5.1.3"
68
68
  },
69
69
  "dependencies": {
70
- "@userwidgets/model": "^0.2.4",
70
+ "@userwidgets/model": "^0.4.3",
71
71
  "cloudly-http": "^0.1.6",
72
- "cloudly-rest": "^0.1.2",
72
+ "cloudly-rest": "^0.1.3",
73
73
  "cryptly": "^3.0.4",
74
74
  "gracely": "^2.0.4",
75
75
  "isoly": "^2.0.20",
@@ -1,27 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { isoly } from "isoly"
3
- import { userwidgets } from "@userwidgets/model"
4
- import { http } from "cloudly-http"
5
- import * as rest from "cloudly-rest"
6
-
7
- export interface EntityTags {
8
- application: Record<string, isoly.DateTime | undefined>
9
- organization: Record<string, isoly.DateTime | undefined>
10
- user: Record<string, isoly.DateTime | undefined>
11
- }
12
-
13
- export class Application extends rest.Collection<gracely.Error> {
14
- constructor(client: http.Client, readonly entityTags: EntityTags) {
15
- super(client)
16
- }
17
- async create(application: userwidgets.Application.Creatable): Promise<userwidgets.Application | gracely.Error> {
18
- const result = await this.client.post<userwidgets.Application>("/widgets/application", application)
19
- !gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now())
20
- return result
21
- }
22
- async fetch(): Promise<userwidgets.Application | gracely.Error> {
23
- const result = await this.client.get<userwidgets.Application>(`/widgets/application`)
24
- !gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now())
25
- return result
26
- }
27
- }
package/Client/Me.ts DELETED
@@ -1,42 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { userwidgets } from "@userwidgets/model"
3
- import * as rest from "cloudly-rest"
4
-
5
- export class Me extends rest.Collection<gracely.Error> {
6
- async login(credentials: userwidgets.User.Credentials): Promise<userwidgets.User.Key | gracely.Error> {
7
- let result: gracely.Error | userwidgets.User.Key
8
- if (credentials.password == undefined)
9
- result = gracely.client.malformedContent("password", "string", "Password is required for login.")
10
- else {
11
- const token = await this.client.get<string>("/widgets/me", {
12
- authorization: userwidgets.User.Credentials.toBasic({ user: credentials.user, password: credentials.password }),
13
- })
14
- result = gracely.Error.is(token)
15
- ? token
16
- : (await userwidgets.User.Key.unpack(token)) ?? gracely.client.unauthorized("Failed to verify token.")
17
- if (!gracely.Error.is(result)) {
18
- this.client.key = result.token
19
- }
20
- }
21
- return result
22
- }
23
- async register(
24
- tag: userwidgets.User.Tag,
25
- credentials: userwidgets.User.Credentials.Register
26
- ): Promise<userwidgets.User.Key | gracely.Error> {
27
- const token = await this.client.post<string>(`/widgets/me/${tag.token}`, credentials)
28
- const result = gracely.Error.is(token)
29
- ? token
30
- : (await userwidgets.User.Key.unpack(token)) ?? gracely.client.unauthorized("Failed to verify token.")
31
- !gracely.Error.is(result) && (this.client.key = result.token)
32
- return result
33
- }
34
- async join(tag: userwidgets.User.Tag): Promise<userwidgets.User.Key | gracely.Error> {
35
- const response = await this.client.patch<string>(`/widgets/me/${tag.token}`, undefined)
36
- const result = gracely.Error.is(response)
37
- ? response
38
- : (await userwidgets.User.Key.unpack(response)) ?? gracely.client.unauthorized("Failed to verify token.")
39
- !gracely.Error.is(result) && (this.client.key = result.token)
40
- return result
41
- }
42
- }
@@ -1,69 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { isoly } from "isoly"
3
- import { userwidgets } from "@userwidgets/model"
4
- import { http } from "cloudly-http"
5
- import * as rest from "cloudly-rest"
6
-
7
- export interface EntityTags {
8
- application: Record<string, isoly.DateTime | undefined>
9
- organization: Record<string, isoly.DateTime | undefined>
10
- user: Record<string, isoly.DateTime | undefined>
11
- }
12
-
13
- export class Organization extends rest.Collection<gracely.Error> {
14
- constructor(client: http.Client, readonly entityTags: EntityTags) {
15
- super(client)
16
- }
17
- async create(
18
- organization: userwidgets.Organization.Creatable,
19
- applicationId: string
20
- ): Promise<userwidgets.Organization | gracely.Error> {
21
- const result = await this.client.post<userwidgets.Organization>("/api/organization", organization, {
22
- application: applicationId,
23
- })
24
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now())
25
- return result
26
- }
27
- async fetch(organizationId: string): Promise<userwidgets.Organization | gracely.Error> {
28
- const result = await this.client.get<userwidgets.Organization>(`/api/organization/${organizationId}`)
29
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now())
30
- return result
31
- }
32
- async list(): Promise<userwidgets.Organization[] | gracely.Error> {
33
- const result = await this.client.get<userwidgets.Organization[]>(`/api/organization`)
34
- !gracely.Error.is(result) &&
35
- result.reduce(
36
- (entityTags, organization) => ((entityTags.organization[organization.id] = isoly.DateTime.now()), entityTags),
37
- this.entityTags
38
- )
39
- return result
40
- }
41
- async changeName(
42
- organizationId: string,
43
- organization: userwidgets.Organization.Creatable,
44
- applicationId: string
45
- ): Promise<userwidgets.Organization | gracely.Error> {
46
- const entityTag = this.entityTags.organization[organizationId]
47
- const result = await this.client.put<userwidgets.Organization>(
48
- `/api/organization/${organizationId}/name`,
49
- organization,
50
- {
51
- ...(entityTag && { ifMatch: [entityTag] }),
52
- application: applicationId,
53
- }
54
- )
55
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now())
56
- return result
57
- }
58
- async removeUser(organizationId: string, email: string) {
59
- const entityTag = this.entityTags.organization[organizationId]
60
- const result = await this.client.delete<userwidgets.Organization>(
61
- `/api/organization/${organizationId}/user/${email}`,
62
- {
63
- ...(entityTag && { ifMatch: [entityTag] }),
64
- }
65
- )
66
- !gracely.Error.is(result) && (this.entityTags.organization[organizationId] = isoly.DateTime.now())
67
- return result
68
- }
69
- }
package/Client/User.ts DELETED
@@ -1,63 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { isoly } from "isoly"
3
- import { userwidgets } from "@userwidgets/model"
4
- import { http } from "cloudly-http"
5
- import * as rest from "cloudly-rest"
6
-
7
- export interface EntityTags {
8
- application: Record<string, isoly.DateTime | undefined>
9
- organization: Record<string, isoly.DateTime | undefined>
10
- user: Record<string, isoly.DateTime | undefined>
11
- }
12
-
13
- export class User extends rest.Collection<gracely.Error> {
14
- constructor(client: http.Client, readonly entityTags: EntityTags) {
15
- super(client)
16
- }
17
- async list(): Promise<userwidgets.User.Readable[] | gracely.Error> {
18
- const result = await this.client.get<userwidgets.User.Readable[]>("/widgets/user")
19
- !gracely.Error.is(result) &&
20
- result.forEach(user => ((this.entityTags.user[user.email] = isoly.DateTime.now()), this.entityTags))
21
- return result
22
- }
23
-
24
- async changePassword(
25
- email: string,
26
- passwords: userwidgets.User.Password.Change
27
- ): Promise<gracely.Result | gracely.Error> {
28
- const entityTag = this.entityTags?.user?.[email]
29
- const response = await this.client.put<"">(
30
- `/widgets/user/${email}/password`,
31
- passwords,
32
- !entityTag ? undefined : { ifMatch: [entityTag] }
33
- )
34
- !gracely.Error.is(response) && (this.entityTags.user[email] = isoly.DateTime.now())
35
- return response == "" ? gracely.success.noContent() : response
36
- }
37
- async changeName(email: string, name: userwidgets.User.Name): Promise<userwidgets.User | gracely.Error> {
38
- const entityTag = this.entityTags.user[email]
39
- const result = await this.client.put<userwidgets.User>(
40
- `/widgets/user/${email}/name`,
41
- name,
42
- !entityTag ? undefined : { ifMatch: [entityTag] }
43
- )
44
- !gracely.Error.is(result) && (this.entityTags.user[email] = isoly.DateTime.now())
45
- return result
46
- }
47
- async updatePermissions(
48
- email: string,
49
- organizationId: string,
50
- permissions: userwidgets.User.Permissions.Readable
51
- ): Promise<userwidgets.User.Readable | gracely.Error> {
52
- const entityTag = this.entityTags.user[email]
53
- const result = await this.client.patch<userwidgets.User.Readable>(
54
- `/widgets/user/${email}/permission/${organizationId}`,
55
- permissions,
56
- !entityTag ? undefined : { ifMatch: [entityTag] }
57
- )
58
- !gracely.Error.is(result) &&
59
- ((this.entityTags.user[email] = isoly.DateTime.now()),
60
- (this.entityTags.organization[organizationId] = isoly.DateTime.now()))
61
- return result
62
- }
63
- }
@@ -1,20 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { isoly } from "isoly"
3
- import { http } from "cloudly-http"
4
- import * as rest from "cloudly-rest"
5
- import { Result } from "../Balance"
6
- import { Treasury as TreasuryModel } from "../Treasury"
7
-
8
- export class Treasury extends rest.Collection<gracely.Error> {
9
- constructor(client: http.Client) {
10
- super(client)
11
- }
12
-
13
- async change(currency: isoly.Currency, changes: Result[]): Promise<gracely.Result> {
14
- return this.client.patch(`/treasury/${currency}/fiat`, changes)
15
- }
16
- async fetch(hour?: isoly.DateTime): Promise<TreasuryModel | gracely.Error> {
17
- const path = hour ? `?time=${hour}` : ""
18
- return this.client.get<TreasuryModel>(`/treasury${path}`)
19
- }
20
- }
@@ -1,55 +0,0 @@
1
- import { gracely } from "gracely"
2
- import { isoly } from "isoly"
3
- import { http } from "cloudly-http"
4
- import * as rest from "cloudly-rest"
5
- import { Application as ClientApplication } from "./../../Client/Application"
6
- import { Me as ClientMe } from "./../../Client/Me"
7
- import { Organization as ClientOrganization } from "./../../Client/Organization"
8
- import { User as ClientUser } from "./../../Client/User"
9
- import { Treasury } from "./Treasury"
10
-
11
- export interface EntityTags {
12
- application: Record<string, isoly.DateTime | undefined>
13
- organization: Record<string, isoly.DateTime | undefined>
14
- user: Record<string, isoly.DateTime | undefined>
15
- }
16
-
17
- export class Client extends rest.Client<gracely.Error> {
18
- realm?: string
19
- treasury = new Treasury(this.client)
20
- entityTags: EntityTags = { application: {}, organization: {}, user: {} }
21
- readonly userwidgets = {
22
- me: new ClientMe(this.client),
23
- user: new ClientUser(this.client, this.entityTags),
24
- application: new ClientApplication(this.client, this.entityTags),
25
- organization: new ClientOrganization(this.client, this.entityTags),
26
- set onUnauthorized(callback: (client: rest.Client<never>) => Promise<boolean>) {
27
- this.client.onUnauthorized = callback
28
- },
29
- client: this as Client,
30
- }
31
-
32
- static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T {
33
- let httpClient: http.Client<gracely.Error>
34
- const result: Client = new Client(
35
- (httpClient = new http.Client<gracely.Error>(server, key, {
36
- appendHeader: request => ({ realm: result.realm }),
37
- }))
38
- )
39
- if (load)
40
- Object.assign(result, load(httpClient))
41
- return result as Client & T
42
- }
43
- }
44
-
45
- export namespace Client {
46
- export type Application = ClientApplication
47
- export const Application = ClientApplication
48
- export type Organization = ClientOrganization
49
- export const Organization = ClientOrganization
50
- export type Me = ClientMe
51
- export const Me = ClientMe
52
- export type User = ClientUser
53
- export const User = ClientUser
54
- export type Unauthorized = (client: rest.Client<never>) => Promise<boolean>
55
- }
@@ -1,16 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import { userwidgets } from "@userwidgets/model";
4
- import { http } from "cloudly-http";
5
- import * as rest from "cloudly-rest";
6
- export interface EntityTags {
7
- application: Record<string, isoly.DateTime | undefined>;
8
- organization: Record<string, isoly.DateTime | undefined>;
9
- user: Record<string, isoly.DateTime | undefined>;
10
- }
11
- export declare class Application extends rest.Collection<gracely.Error> {
12
- readonly entityTags: EntityTags;
13
- constructor(client: http.Client, entityTags: EntityTags);
14
- create(application: userwidgets.Application.Creatable): Promise<userwidgets.Application | gracely.Error>;
15
- fetch(): Promise<userwidgets.Application | gracely.Error>;
16
- }
@@ -1,20 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import * as rest from "cloudly-rest";
4
- export class Application extends rest.Collection {
5
- constructor(client, entityTags) {
6
- super(client);
7
- this.entityTags = entityTags;
8
- }
9
- async create(application) {
10
- const result = await this.client.post("/widgets/application", application);
11
- !gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now());
12
- return result;
13
- }
14
- async fetch() {
15
- const result = await this.client.get(`/widgets/application`);
16
- !gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now());
17
- return result;
18
- }
19
- }
20
- //# sourceMappingURL=Application.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Application.js","sourceRoot":"../","sources":["Client/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAG7B,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAQpC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,UAAyB;IAC9D,YAAY,MAAmB,EAAW,UAAsB;QAC/D,KAAK,CAAC,MAAM,CAAC,CAAA;QAD4B,eAAU,GAAV,UAAU,CAAY;IAEhE,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,WAA8C;QAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAA0B,sBAAsB,EAAE,WAAW,CAAC,CAAA;QACnG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;QAC5F,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,KAAK;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAA0B,sBAAsB,CAAC,CAAA;QACrF,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;QAC5F,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
@@ -1,8 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { userwidgets } from "@userwidgets/model";
3
- import * as rest from "cloudly-rest";
4
- export declare class Me extends rest.Collection<gracely.Error> {
5
- login(credentials: userwidgets.User.Credentials): Promise<userwidgets.User.Key | gracely.Error>;
6
- register(tag: userwidgets.User.Tag, credentials: userwidgets.User.Credentials.Register): Promise<userwidgets.User.Key | gracely.Error>;
7
- join(tag: userwidgets.User.Tag): Promise<userwidgets.User.Key | gracely.Error>;
8
- }
package/dist/Client/Me.js DELETED
@@ -1,39 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { userwidgets } from "@userwidgets/model";
3
- import * as rest from "cloudly-rest";
4
- export class Me extends rest.Collection {
5
- async login(credentials) {
6
- let result;
7
- if (credentials.password == undefined)
8
- result = gracely.client.malformedContent("password", "string", "Password is required for login.");
9
- else {
10
- const token = await this.client.get("/widgets/me", {
11
- authorization: userwidgets.User.Credentials.toBasic({ user: credentials.user, password: credentials.password }),
12
- });
13
- result = gracely.Error.is(token)
14
- ? token
15
- : (await userwidgets.User.Key.unpack(token)) ?? gracely.client.unauthorized("Failed to verify token.");
16
- if (!gracely.Error.is(result)) {
17
- this.client.key = result.token;
18
- }
19
- }
20
- return result;
21
- }
22
- async register(tag, credentials) {
23
- const token = await this.client.post(`/widgets/me/${tag.token}`, credentials);
24
- const result = gracely.Error.is(token)
25
- ? token
26
- : (await userwidgets.User.Key.unpack(token)) ?? gracely.client.unauthorized("Failed to verify token.");
27
- !gracely.Error.is(result) && (this.client.key = result.token);
28
- return result;
29
- }
30
- async join(tag) {
31
- const response = await this.client.patch(`/widgets/me/${tag.token}`, undefined);
32
- const result = gracely.Error.is(response)
33
- ? response
34
- : (await userwidgets.User.Key.unpack(response)) ?? gracely.client.unauthorized("Failed to verify token.");
35
- !gracely.Error.is(result) && (this.client.key = result.token);
36
- return result;
37
- }
38
- }
39
- //# sourceMappingURL=Me.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Me.js","sourceRoot":"../","sources":["Client/Me.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAEpC,MAAM,OAAO,EAAG,SAAQ,IAAI,CAAC,UAAyB;IACrD,KAAK,CAAC,KAAK,CAAC,WAAyC;QACpD,IAAI,MAA4C,CAAA;QAChD,IAAI,WAAW,CAAC,QAAQ,IAAI,SAAS;YACpC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,QAAQ,EAAE,iCAAiC,CAAC,CAAA;aAC7F;YACJ,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,aAAa,EAAE;gBAC1D,aAAa,EAAE,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC;aAC/G,CAAC,CAAA;YACF,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;gBAC/B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,M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I,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAA;QAC1G,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
@@ -1,19 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import { userwidgets } from "@userwidgets/model";
4
- import { http } from "cloudly-http";
5
- import * as rest from "cloudly-rest";
6
- export interface EntityTags {
7
- application: Record<string, isoly.DateTime | undefined>;
8
- organization: Record<string, isoly.DateTime | undefined>;
9
- user: Record<string, isoly.DateTime | undefined>;
10
- }
11
- export declare class Organization extends rest.Collection<gracely.Error> {
12
- readonly entityTags: EntityTags;
13
- constructor(client: http.Client, entityTags: EntityTags);
14
- create(organization: userwidgets.Organization.Creatable, applicationId: string): Promise<userwidgets.Organization | gracely.Error>;
15
- fetch(organizationId: string): Promise<userwidgets.Organization | gracely.Error>;
16
- list(): Promise<userwidgets.Organization[] | gracely.Error>;
17
- changeName(organizationId: string, organization: userwidgets.Organization.Creatable, applicationId: string): Promise<userwidgets.Organization | gracely.Error>;
18
- removeUser(organizationId: string, email: string): Promise<gracely.Error | userwidgets.Organization>;
19
- }
@@ -1,45 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import * as rest from "cloudly-rest";
4
- export class Organization extends rest.Collection {
5
- constructor(client, entityTags) {
6
- super(client);
7
- this.entityTags = entityTags;
8
- }
9
- async create(organization, applicationId) {
10
- const result = await this.client.post("/api/organization", organization, {
11
- application: applicationId,
12
- });
13
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now());
14
- return result;
15
- }
16
- async fetch(organizationId) {
17
- const result = await this.client.get(`/api/organization/${organizationId}`);
18
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now());
19
- return result;
20
- }
21
- async list() {
22
- const result = await this.client.get(`/api/organization`);
23
- !gracely.Error.is(result) &&
24
- result.reduce((entityTags, organization) => ((entityTags.organization[organization.id] = isoly.DateTime.now()), entityTags), this.entityTags);
25
- return result;
26
- }
27
- async changeName(organizationId, organization, applicationId) {
28
- const entityTag = this.entityTags.organization[organizationId];
29
- const result = await this.client.put(`/api/organization/${organizationId}/name`, organization, {
30
- ...(entityTag && { ifMatch: [entityTag] }),
31
- application: applicationId,
32
- });
33
- !gracely.Error.is(result) && (this.entityTags.organization[result.id] = isoly.DateTime.now());
34
- return result;
35
- }
36
- async removeUser(organizationId, email) {
37
- const entityTag = this.entityTags.organization[organizationId];
38
- const result = await this.client.delete(`/api/organization/${organizationId}/user/${email}`, {
39
- ...(entityTag && { ifMatch: [entityTag] }),
40
- });
41
- !gracely.Error.is(result) && (this.entityTags.organization[organizationId] = isoly.DateTime.now());
42
- return result;
43
- }
44
- }
45
- //# sourceMappingURL=Organization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Organization.js","sourceRoot":"../","sources":["Client/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAG7B,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAQpC,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,UAAyB;IAC/D,YAAY,MAAmB,EAAW,UAAsB;QAC/D,KAAK,CAAC,MAAM,CAAC,CAAA;QAD4B,eAAU,GAAV,UAAU,CAAY;IAEhE,CAAC;IACD,KAAK,CAAC,MAAM,CACX,YAAgD,EAChD,aAAqB;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAA2B,mBAAmB,EAAE,YAAY,EAAE;YAClG,WAAW,EAAE,aAAa;SAC1B,CAAC,CAAA;QACF,CAAC,OAAO,CAAC,KAAK,CAA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Z;YACC,GAAG,CAAC,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1C,WAAW,EAAE,aAAa;SAC1B,CACD,CAAA;QACD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;QAC7F,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,cAAsB,EAAE,KAAa;QACrD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CACtC,qBAAqB,cAAc,SAAS,KAAK,EAAE,EACnD;YACC,GAAG,CAAC,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;SAC1C,CACD,CAAA;QACD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;QAClG,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
@@ -1,18 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import { userwidgets } from "@userwidgets/model";
4
- import { http } from "cloudly-http";
5
- import * as rest from "cloudly-rest";
6
- export interface EntityTags {
7
- application: Record<string, isoly.DateTime | undefined>;
8
- organization: Record<string, isoly.DateTime | undefined>;
9
- user: Record<string, isoly.DateTime | undefined>;
10
- }
11
- export declare class User extends rest.Collection<gracely.Error> {
12
- readonly entityTags: EntityTags;
13
- constructor(client: http.Client, entityTags: EntityTags);
14
- list(): Promise<userwidgets.User.Readable[] | gracely.Error>;
15
- changePassword(email: string, passwords: userwidgets.User.Password.Change): Promise<gracely.Result | gracely.Error>;
16
- changeName(email: string, name: userwidgets.User.Name): Promise<userwidgets.User | gracely.Error>;
17
- updatePermissions(email: string, organizationId: string, permissions: userwidgets.User.Permissions.Readable): Promise<userwidgets.User.Readable | gracely.Error>;
18
- }
@@ -1,36 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import * as rest from "cloudly-rest";
4
- export class User extends rest.Collection {
5
- constructor(client, entityTags) {
6
- super(client);
7
- this.entityTags = entityTags;
8
- }
9
- async list() {
10
- const result = await this.client.get("/widgets/user");
11
- !gracely.Error.is(result) &&
12
- result.forEach(user => ((this.entityTags.user[user.email] = isoly.DateTime.now()), this.entityTags));
13
- return result;
14
- }
15
- async changePassword(email, passwords) {
16
- const entityTag = this.entityTags?.user?.[email];
17
- const response = await this.client.put(`/widgets/user/${email}/password`, passwords, !entityTag ? undefined : { ifMatch: [entityTag] });
18
- !gracely.Error.is(response) && (this.entityTags.user[email] = isoly.DateTime.now());
19
- return response == "" ? gracely.success.noContent() : response;
20
- }
21
- async changeName(email, name) {
22
- const entityTag = this.entityTags.user[email];
23
- const result = await this.client.put(`/widgets/user/${email}/name`, name, !entityTag ? undefined : { ifMatch: [entityTag] });
24
- !gracely.Error.is(result) && (this.entityTags.user[email] = isoly.DateTime.now());
25
- return result;
26
- }
27
- async updatePermissions(email, organizationId, permissions) {
28
- const entityTag = this.entityTags.user[email];
29
- const result = await this.client.patch(`/widgets/user/${email}/permission/${organizationId}`, permissions, !entityTag ? undefined : { ifMatch: [entityTag] });
30
- !gracely.Error.is(result) &&
31
- ((this.entityTags.user[email] = isoly.DateTime.now()),
32
- (this.entityTags.organization[organizationId] = isoly.DateTime.now()));
33
- return result;
34
- }
35
- }
36
- //# sourceMappingURL=User.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"User.js","sourceRoot":"../","sources":["Client/User.ts"],"names":[],"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AAE,CAAC;gBACrD,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACvE,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
@@ -1,11 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import { http } from "cloudly-http";
4
- import * as rest from "cloudly-rest";
5
- import { Result } from "../Balance";
6
- import { Treasury as TreasuryModel } from "../Treasury";
7
- export declare class Treasury extends rest.Collection<gracely.Error> {
8
- constructor(client: http.Client);
9
- change(currency: isoly.Currency, changes: Result[]): Promise<gracely.Result>;
10
- fetch(hour?: isoly.DateTime): Promise<TreasuryModel | gracely.Error>;
11
- }
@@ -1,14 +0,0 @@
1
- import * as rest from "cloudly-rest";
2
- export class Treasury extends rest.Collection {
3
- constructor(client) {
4
- super(client);
5
- }
6
- async change(currency, changes) {
7
- return this.client.patch(`/treasury/${currency}/fiat`, changes);
8
- }
9
- async fetch(hour) {
10
- const path = hour ? `?time=${hour}` : "";
11
- return this.client.get(`/treasury${path}`);
12
- }
13
- }
14
- //# sourceMappingURL=Treasury.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Treasury.js","sourceRoot":"../","sources":["Treasury/Client/Treasury.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAIpC,MAAM,OAAO,QAAS,SAAQ,IAAI,CAAC,UAAyB;IAC3D,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAwB,EAAE,OAAiB;QACvD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAA;IAChE,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,IAAqB;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgB,YAAY,IAAI,EAAE,CAAC,CAAA;IAC1D,CAAC;CACD"}
@@ -1,39 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { isoly } from "isoly";
3
- import { http } from "cloudly-http";
4
- import * as rest from "cloudly-rest";
5
- import { Application as ClientApplication } from "./../../Client/Application";
6
- import { Me as ClientMe } from "./../../Client/Me";
7
- import { Organization as ClientOrganization } from "./../../Client/Organization";
8
- import { User as ClientUser } from "./../../Client/User";
9
- import { Treasury } from "./Treasury";
10
- export interface EntityTags {
11
- application: Record<string, isoly.DateTime | undefined>;
12
- organization: Record<string, isoly.DateTime | undefined>;
13
- user: Record<string, isoly.DateTime | undefined>;
14
- }
15
- export declare class Client extends rest.Client<gracely.Error> {
16
- realm?: string;
17
- treasury: Treasury;
18
- entityTags: EntityTags;
19
- readonly userwidgets: {
20
- me: ClientMe;
21
- user: ClientUser;
22
- application: ClientApplication;
23
- organization: ClientOrganization;
24
- onUnauthorized: (client: rest.Client<never>) => Promise<boolean>;
25
- client: Client;
26
- };
27
- static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T;
28
- }
29
- export declare namespace Client {
30
- type Application = ClientApplication;
31
- const Application: typeof ClientApplication;
32
- type Organization = ClientOrganization;
33
- const Organization: typeof ClientOrganization;
34
- type Me = ClientMe;
35
- const Me: typeof ClientMe;
36
- type User = ClientUser;
37
- const User: typeof ClientUser;
38
- type Unauthorized = (client: rest.Client<never>) => Promise<boolean>;
39
- }
@@ -1,40 +0,0 @@
1
- import { http } from "cloudly-http";
2
- import * as rest from "cloudly-rest";
3
- import { Application as ClientApplication } from "./../../Client/Application";
4
- import { Me as ClientMe } from "./../../Client/Me";
5
- import { Organization as ClientOrganization } from "./../../Client/Organization";
6
- import { User as ClientUser } from "./../../Client/User";
7
- import { Treasury } from "./Treasury";
8
- export class Client extends rest.Client {
9
- constructor() {
10
- super(...arguments);
11
- this.treasury = new Treasury(this.client);
12
- this.entityTags = { application: {}, organization: {}, user: {} };
13
- this.userwidgets = {
14
- me: new ClientMe(this.client),
15
- user: new ClientUser(this.client, this.entityTags),
16
- application: new ClientApplication(this.client, this.entityTags),
17
- organization: new ClientOrganization(this.client, this.entityTags),
18
- set onUnauthorized(callback) {
19
- this.client.onUnauthorized = callback;
20
- },
21
- client: this,
22
- };
23
- }
24
- static create(server, key, load) {
25
- let httpClient;
26
- const result = new Client((httpClient = new http.Client(server, key, {
27
- appendHeader: request => ({ realm: result.realm }),
28
- })));
29
- if (load)
30
- Object.assign(result, load(httpClient));
31
- return result;
32
- }
33
- }
34
- (function (Client) {
35
- Client.Application = ClientApplication;
36
- Client.Organization = ClientOrganization;
37
- Client.Me = ClientMe;
38
- Client.User = ClientUser;
39
- })(Client || (Client = {}));
40
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChF,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAQrC,MAAM,OAAO,MAAO,SAAQ,IAAI,CAAC,MAAqB;IAAtD;;QAEC,aAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,eAAU,GAAe,EAAE,WAAW,EAAE,EAAE,E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