@pax2pay/model-banking 0.1.15 → 0.1.16
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/Client/Application.ts +27 -0
- package/Client/Me.ts +42 -0
- package/Client/Organization.ts +66 -0
- package/Client/User.ts +63 -0
- package/Client/index.ts +29 -2
- package/Treasury/Client/index.ts +28 -0
- package/dist/Client/Application.d.ts +16 -0
- package/dist/Client/Application.js +20 -0
- package/dist/Client/Application.js.map +1 -0
- package/dist/Client/Me.d.ts +8 -0
- package/dist/Client/Me.js +39 -0
- package/dist/Client/Me.js.map +1 -0
- package/dist/Client/Organization.d.ts +19 -0
- package/dist/Client/Organization.js +45 -0
- package/dist/Client/Organization.js.map +1 -0
- package/dist/Client/User.d.ts +18 -0
- package/dist/Client/User.js +36 -0
- package/dist/Client/User.js.map +1 -0
- package/dist/Client/index.d.ts +27 -1
- package/dist/Client/index.js +16 -1
- package/dist/Client/index.js.map +1 -1
- package/dist/Treasury/Client/index.d.ts +26 -0
- package/dist/Treasury/Client/index.js +15 -0
- package/dist/Treasury/Client/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as gracely from "gracely"
|
|
2
|
+
import * as isoly from "isoly"
|
|
3
|
+
import { userwidgets } from "@userwidgets/model"
|
|
4
|
+
import * as 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, private 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>("/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>(`/application`)
|
|
24
|
+
!gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now())
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
}
|
package/Client/Me.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as 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>("/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>(`/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>(`/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
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as gracely from "gracely"
|
|
2
|
+
import * as isoly from "isoly"
|
|
3
|
+
import { userwidgets } from "@userwidgets/model"
|
|
4
|
+
import * as 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, private 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>("/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>(`/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[]>(`/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
|
+
`/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>(`/organization/${organizationId}/user/${email}`, {
|
|
61
|
+
...(entityTag && { ifMatch: [entityTag] }),
|
|
62
|
+
})
|
|
63
|
+
!gracely.Error.is(result) && (this.entityTags.organization[organizationId] = isoly.DateTime.now())
|
|
64
|
+
return result
|
|
65
|
+
}
|
|
66
|
+
}
|
package/Client/User.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as gracely from "gracely"
|
|
2
|
+
import * as isoly from "isoly"
|
|
3
|
+
import { userwidgets } from "@userwidgets/model"
|
|
4
|
+
import * as 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, private 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[]>("/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
|
+
`/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
|
+
`/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
|
+
`/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
|
+
}
|
package/Client/index.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import * as gracely from "gracely"
|
|
2
|
+
import * as isoly from "isoly"
|
|
2
3
|
import * as http from "cloudly-http"
|
|
3
4
|
import * as rest from "cloudly-rest"
|
|
4
5
|
import { Accounts } from "./Accounts"
|
|
6
|
+
import { Application as ClientApplication } from "./Application"
|
|
7
|
+
import { Me as ClientMe } from "./Me"
|
|
5
8
|
import { Operations } from "./Operations"
|
|
9
|
+
import { Organization as ClientOrganization } from "./Organization"
|
|
6
10
|
import { Organizations } from "./Organizations"
|
|
7
11
|
import { Transactions } from "./Transactions"
|
|
12
|
+
import { User as ClientUser } from "./User"
|
|
8
13
|
import { Version } from "./Version"
|
|
9
14
|
|
|
15
|
+
export interface EntityTags {
|
|
16
|
+
application: Record<string, isoly.DateTime | undefined>
|
|
17
|
+
organization: Record<string, isoly.DateTime | undefined>
|
|
18
|
+
user: Record<string, isoly.DateTime | undefined>
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
export class Client extends rest.Client<gracely.Error> {
|
|
11
22
|
realm?: string
|
|
12
|
-
|
|
23
|
+
organizationId?: string
|
|
24
|
+
private entityTags: EntityTags = { application: {}, organization: {}, user: {} }
|
|
25
|
+
readonly user = new Client.User(this.client, this.entityTags)
|
|
26
|
+
readonly me = new Client.Me(this.client)
|
|
27
|
+
readonly organization = new Client.Organization(this.client, this.entityTags)
|
|
28
|
+
readonly application = new Client.Application(this.client, this.entityTags)
|
|
13
29
|
readonly accounts = new Accounts(this.client)
|
|
14
30
|
readonly operations = new Operations(this.client)
|
|
15
31
|
readonly organizations = new Organizations(this.client)
|
|
@@ -20,7 +36,7 @@ export class Client extends rest.Client<gracely.Error> {
|
|
|
20
36
|
let httpClient: http.Client<gracely.Error>
|
|
21
37
|
const result: Client = new Client(
|
|
22
38
|
(httpClient = new http.Client<gracely.Error>(server, key, {
|
|
23
|
-
appendHeader: request => ({ ...request.header, realm: result.realm, organization: result.
|
|
39
|
+
appendHeader: request => ({ ...request.header, realm: result.realm, organization: result.organizationId }),
|
|
24
40
|
}))
|
|
25
41
|
)
|
|
26
42
|
if (load)
|
|
@@ -28,3 +44,14 @@ export class Client extends rest.Client<gracely.Error> {
|
|
|
28
44
|
return result as Client & T
|
|
29
45
|
}
|
|
30
46
|
}
|
|
47
|
+
export namespace Client {
|
|
48
|
+
export type Application = ClientApplication
|
|
49
|
+
export const Application = ClientApplication
|
|
50
|
+
export type Organization = ClientOrganization
|
|
51
|
+
export const Organization = ClientOrganization
|
|
52
|
+
export type Me = ClientMe
|
|
53
|
+
export const Me = ClientMe
|
|
54
|
+
export type User = ClientUser
|
|
55
|
+
export const User = ClientUser
|
|
56
|
+
export type Unauthorized = (client: rest.Client<never>) => Promise<boolean>
|
|
57
|
+
}
|
package/Treasury/Client/index.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import * as gracely from "gracely"
|
|
2
|
+
import * as isoly from "isoly"
|
|
2
3
|
import * as http from "cloudly-http"
|
|
3
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"
|
|
4
9
|
import { Treasury } from "./Treasury"
|
|
5
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
|
+
|
|
6
17
|
export class Client extends rest.Client<gracely.Error> {
|
|
7
18
|
realm?: string
|
|
8
19
|
treasury = new Treasury(this.client)
|
|
20
|
+
private entityTags: EntityTags = { application: {}, organization: {}, user: {} }
|
|
21
|
+
readonly user = new Client.User(this.client, this.entityTags)
|
|
22
|
+
readonly me = new Client.Me(this.client)
|
|
23
|
+
readonly organization = new Client.Organization(this.client, this.entityTags)
|
|
24
|
+
readonly application = new Client.Application(this.client, this.entityTags)
|
|
9
25
|
|
|
10
26
|
static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T {
|
|
11
27
|
let httpClient: http.Client<gracely.Error>
|
|
@@ -19,3 +35,15 @@ export class Client extends rest.Client<gracely.Error> {
|
|
|
19
35
|
return result as Client & T
|
|
20
36
|
}
|
|
21
37
|
}
|
|
38
|
+
|
|
39
|
+
export namespace Client {
|
|
40
|
+
export type Application = ClientApplication
|
|
41
|
+
export const Application = ClientApplication
|
|
42
|
+
export type Organization = ClientOrganization
|
|
43
|
+
export const Organization = ClientOrganization
|
|
44
|
+
export type Me = ClientMe
|
|
45
|
+
export const Me = ClientMe
|
|
46
|
+
export type User = ClientUser
|
|
47
|
+
export const User = ClientUser
|
|
48
|
+
export type Unauthorized = (client: rest.Client<never>) => Promise<boolean>
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as isoly from "isoly";
|
|
3
|
+
import { userwidgets } from "@userwidgets/model";
|
|
4
|
+
import * as 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
|
+
private readonly 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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as 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("/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(`/application`);
|
|
16
|
+
!gracely.Error.is(result) && (this.entityTags.application[result.id] = isoly.DateTime.now());
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"../","sources":["Client/Application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAQpC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,UAAyB;IAC9D,YAAY,MAAmB,EAAmB,UAAsB;QACvE,KAAK,CAAC,MAAM,CAAC,CAAA;QADoC,eAAU,GAAV,UAAU,CAAY;IAExE,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,WAA8C;QAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAA0B,cAAc,EAAE,WAAW,CAAC,CAAA;QAC3F,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,cAAc,CAAC,CAAA;QAC7E,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as 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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as 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("/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(`/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(`/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Me.js","sourceRoot":"../","sources":["Client/Me.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,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,KAAK,EAAE;gBAClD,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,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAA;YACvG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CA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AAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as isoly from "isoly";
|
|
3
|
+
import { userwidgets } from "@userwidgets/model";
|
|
4
|
+
import * as 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
|
+
private readonly 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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as 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("/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(`/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(`/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(`/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(`/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Organization.js","sourceRoot":"../","sources":["Client/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;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ClG,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as isoly from "isoly";
|
|
3
|
+
import { userwidgets } from "@userwidgets/model";
|
|
4
|
+
import * as 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
|
+
private readonly 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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as gracely from "gracely";
|
|
2
|
+
import * as 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("/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(`/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(`/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(`/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"../","sources":["Client/User.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAQpC,MAAM,OAAO,IAAK,SAAQ,IAAI,CAAC,UAAyB;IACvD,YAAY,MAAmB,EAAmB,UAAsB;QACvE,KAAK,CAAC,MAAM,CAAC,CAAA;QADoC,eAAU,GAAV,UAAU,CAAY;IAExE,CAAC;IACD,KAAK,CAAC,IAAI;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAA8B,OAAO,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AC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CACjD,CAAA;QACD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;QACjF,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,iBAAiB,CACtB,KAAa,EACb,cAAsB,EACtB,WAAkD;QAElD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACrC,SAAS,KAAK,eAAe,cAAc,EAAE,EAC7C,WAAW,EACX,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CACjD,CAAA;QACD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC;YACxB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,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"}
|
package/dist/Client/index.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import * as gracely from "gracely";
|
|
2
|
+
import * as isoly from "isoly";
|
|
2
3
|
import * as http from "cloudly-http";
|
|
3
4
|
import * as rest from "cloudly-rest";
|
|
4
5
|
import { Accounts } from "./Accounts";
|
|
6
|
+
import { Application as ClientApplication } from "./Application";
|
|
7
|
+
import { Me as ClientMe } from "./Me";
|
|
5
8
|
import { Operations } from "./Operations";
|
|
9
|
+
import { Organization as ClientOrganization } from "./Organization";
|
|
6
10
|
import { Organizations } from "./Organizations";
|
|
7
11
|
import { Transactions } from "./Transactions";
|
|
12
|
+
import { User as ClientUser } from "./User";
|
|
8
13
|
import { Version } from "./Version";
|
|
14
|
+
export interface EntityTags {
|
|
15
|
+
application: Record<string, isoly.DateTime | undefined>;
|
|
16
|
+
organization: Record<string, isoly.DateTime | undefined>;
|
|
17
|
+
user: Record<string, isoly.DateTime | undefined>;
|
|
18
|
+
}
|
|
9
19
|
export declare class Client extends rest.Client<gracely.Error> {
|
|
10
20
|
realm?: string;
|
|
11
|
-
|
|
21
|
+
organizationId?: string;
|
|
22
|
+
private entityTags;
|
|
23
|
+
readonly user: ClientUser;
|
|
24
|
+
readonly me: ClientMe;
|
|
25
|
+
readonly organization: ClientOrganization;
|
|
26
|
+
readonly application: ClientApplication;
|
|
12
27
|
readonly accounts: Accounts;
|
|
13
28
|
readonly operations: Operations;
|
|
14
29
|
readonly organizations: Organizations;
|
|
@@ -16,3 +31,14 @@ export declare class Client extends rest.Client<gracely.Error> {
|
|
|
16
31
|
readonly version: Version;
|
|
17
32
|
static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T;
|
|
18
33
|
}
|
|
34
|
+
export declare namespace Client {
|
|
35
|
+
type Application = ClientApplication;
|
|
36
|
+
const Application: typeof ClientApplication;
|
|
37
|
+
type Organization = ClientOrganization;
|
|
38
|
+
const Organization: typeof ClientOrganization;
|
|
39
|
+
type Me = ClientMe;
|
|
40
|
+
const Me: typeof ClientMe;
|
|
41
|
+
type User = ClientUser;
|
|
42
|
+
const User: typeof ClientUser;
|
|
43
|
+
type Unauthorized = (client: rest.Client<never>) => Promise<boolean>;
|
|
44
|
+
}
|
package/dist/Client/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as http from "cloudly-http";
|
|
2
2
|
import * as rest from "cloudly-rest";
|
|
3
3
|
import { Accounts } from "./Accounts";
|
|
4
|
+
import { Application as ClientApplication } from "./Application";
|
|
5
|
+
import { Me as ClientMe } from "./Me";
|
|
4
6
|
import { Operations } from "./Operations";
|
|
7
|
+
import { Organization as ClientOrganization } from "./Organization";
|
|
5
8
|
import { Organizations } from "./Organizations";
|
|
6
9
|
import { Transactions } from "./Transactions";
|
|
10
|
+
import { User as ClientUser } from "./User";
|
|
7
11
|
import { Version } from "./Version";
|
|
8
12
|
export class Client extends rest.Client {
|
|
9
13
|
constructor() {
|
|
10
14
|
super(...arguments);
|
|
15
|
+
this.entityTags = { application: {}, organization: {}, user: {} };
|
|
16
|
+
this.user = new Client.User(this.client, this.entityTags);
|
|
17
|
+
this.me = new Client.Me(this.client);
|
|
18
|
+
this.organization = new Client.Organization(this.client, this.entityTags);
|
|
19
|
+
this.application = new Client.Application(this.client, this.entityTags);
|
|
11
20
|
this.accounts = new Accounts(this.client);
|
|
12
21
|
this.operations = new Operations(this.client);
|
|
13
22
|
this.organizations = new Organizations(this.client);
|
|
@@ -17,11 +26,17 @@ export class Client extends rest.Client {
|
|
|
17
26
|
static create(server, key, load) {
|
|
18
27
|
let httpClient;
|
|
19
28
|
const result = new Client((httpClient = new http.Client(server, key, {
|
|
20
|
-
appendHeader: request => ({ ...request.header, realm: result.realm, organization: result.
|
|
29
|
+
appendHeader: request => ({ ...request.header, realm: result.realm, organization: result.organizationId }),
|
|
21
30
|
})));
|
|
22
31
|
if (load)
|
|
23
32
|
Object.assign(result, load(httpClient));
|
|
24
33
|
return result;
|
|
25
34
|
}
|
|
26
35
|
}
|
|
36
|
+
(function (Client) {
|
|
37
|
+
Client.Application = ClientApplication;
|
|
38
|
+
Client.Organization = ClientOrganization;
|
|
39
|
+
Client.Me = ClientMe;
|
|
40
|
+
Client.User = ClientUser;
|
|
41
|
+
})(Client || (Client = {}));
|
|
27
42
|
//# sourceMappingURL=index.js.map
|
package/dist/Client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AACpC,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,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,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,MAAM,OAAO,MAAO,SAAQ,IAAI,CAAC,MAAqB;IAAtD;;QAGS,eAAU,GAAe,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;QACvE,SAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QACpD,OAAE,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,iBAAY,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QACpE,gBAAW,GAAG,IAAI,MAAM,CAAC,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|
2
3
|
import * as http from "cloudly-http";
|
|
3
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";
|
|
4
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
|
+
}
|
|
5
15
|
export declare class Client extends rest.Client<gracely.Error> {
|
|
6
16
|
realm?: string;
|
|
7
17
|
treasury: Treasury;
|
|
18
|
+
private entityTags;
|
|
19
|
+
readonly user: ClientUser;
|
|
20
|
+
readonly me: ClientMe;
|
|
21
|
+
readonly organization: ClientOrganization;
|
|
22
|
+
readonly application: ClientApplication;
|
|
8
23
|
static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T;
|
|
9
24
|
}
|
|
25
|
+
export declare namespace Client {
|
|
26
|
+
type Application = ClientApplication;
|
|
27
|
+
const Application: typeof ClientApplication;
|
|
28
|
+
type Organization = ClientOrganization;
|
|
29
|
+
const Organization: typeof ClientOrganization;
|
|
30
|
+
type Me = ClientMe;
|
|
31
|
+
const Me: typeof ClientMe;
|
|
32
|
+
type User = ClientUser;
|
|
33
|
+
const User: typeof ClientUser;
|
|
34
|
+
type Unauthorized = (client: rest.Client<never>) => Promise<boolean>;
|
|
35
|
+
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import * as http from "cloudly-http";
|
|
2
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";
|
|
3
7
|
import { Treasury } from "./Treasury";
|
|
4
8
|
export class Client extends rest.Client {
|
|
5
9
|
constructor() {
|
|
6
10
|
super(...arguments);
|
|
7
11
|
this.treasury = new Treasury(this.client);
|
|
12
|
+
this.entityTags = { application: {}, organization: {}, user: {} };
|
|
13
|
+
this.user = new Client.User(this.client, this.entityTags);
|
|
14
|
+
this.me = new Client.Me(this.client);
|
|
15
|
+
this.organization = new Client.Organization(this.client, this.entityTags);
|
|
16
|
+
this.application = new Client.Application(this.client, this.entityTags);
|
|
8
17
|
}
|
|
9
18
|
static create(server, key, load) {
|
|
10
19
|
let httpClient;
|
|
@@ -16,4 +25,10 @@ export class Client extends rest.Client {
|
|
|
16
25
|
return result;
|
|
17
26
|
}
|
|
18
27
|
}
|
|
28
|
+
(function (Client) {
|
|
29
|
+
Client.Application = ClientApplication;
|
|
30
|
+
Client.Organization = ClientOrganization;
|
|
31
|
+
Client.Me = ClientMe;
|
|
32
|
+
Client.User = ClientUser;
|
|
33
|
+
})(Client || (Client = {}));
|
|
19
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AACpC,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,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AAG,QAAQ,CAAA;IAEb,WAAI,GAAG,UAAU,CAAA;AAE/B,CAAC,EAVgB,MAAM,KAAN,MAAM,QAUtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pax2pay/model-banking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
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,10 +54,10 @@
|
|
|
54
54
|
"clean": "rimraf dist node_modules coverage"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@cloudflare/workers-types": "^4.20230321.0",
|
|
57
58
|
"@types/jest": "^29.5.0",
|
|
58
59
|
"@typescript-eslint/eslint-plugin": "5.57.0",
|
|
59
60
|
"@typescript-eslint/parser": "5.57.0",
|
|
60
|
-
"@cloudflare/workers-types": "^4.20230321.0",
|
|
61
61
|
"eslint": "^8.37.0",
|
|
62
62
|
"eslint-plugin-prettierx": "github:utily/eslint-plugin-prettierx#utily-20221229",
|
|
63
63
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.0.2"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
+
"@userwidgets/model": "^0.0.34",
|
|
71
72
|
"cloudly-http": "^0.1.3",
|
|
72
73
|
"cloudly-rest": "^0.1.1",
|
|
73
74
|
"cryptly": "^3.0.2",
|