@iveri/contracts 0.91.1 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/platform/index.d.ts +4 -0
- package/dist/api/platform/index.js +4 -0
- package/dist/api/platform/iveri-product.enum.d.ts +16 -0
- package/dist/api/platform/iveri-product.enum.js +17 -0
- package/dist/api/platform/licence-kind.enum.d.ts +5 -0
- package/dist/api/platform/licence-kind.enum.js +6 -0
- package/dist/api/platform/licence-status.enum.d.ts +11 -0
- package/dist/api/platform/licence-status.enum.js +12 -0
- package/dist/api/platform/platform.type.d.ts +100 -0
- package/dist/api/platform/platform.type.js +6 -0
- package/dist/enum/user-permission.enum.d.ts +26 -2
- package/dist/enum/user-permission.enum.js +36 -2
- package/package.json +5 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The products Iveri sells to companies, each licensed on its own. A company can hold several, and a product refuses
|
|
3
|
+
* a company that holds no live licence for it once enforcement is switched on.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum IveriProduct {
|
|
6
|
+
HR = "hr",
|
|
7
|
+
CLINIC = "clinic",
|
|
8
|
+
COMMERCE = "commerce",
|
|
9
|
+
RESTAURANT = "restaurant",
|
|
10
|
+
GYM = "gym",
|
|
11
|
+
TAXI = "taxi",
|
|
12
|
+
DELIVERY = "delivery",
|
|
13
|
+
UNIBOX = "unibox",
|
|
14
|
+
CONDUIT = "conduit",
|
|
15
|
+
CHAT = "chat"
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The products Iveri sells to companies, each licensed on its own. A company can hold several, and a product refuses
|
|
3
|
+
* a company that holds no live licence for it once enforcement is switched on.
|
|
4
|
+
*/
|
|
5
|
+
export var IveriProduct;
|
|
6
|
+
(function (IveriProduct) {
|
|
7
|
+
IveriProduct["HR"] = "hr";
|
|
8
|
+
IveriProduct["CLINIC"] = "clinic";
|
|
9
|
+
IveriProduct["COMMERCE"] = "commerce";
|
|
10
|
+
IveriProduct["RESTAURANT"] = "restaurant";
|
|
11
|
+
IveriProduct["GYM"] = "gym";
|
|
12
|
+
IveriProduct["TAXI"] = "taxi";
|
|
13
|
+
IveriProduct["DELIVERY"] = "delivery";
|
|
14
|
+
IveriProduct["UNIBOX"] = "unibox";
|
|
15
|
+
IveriProduct["CONDUIT"] = "conduit";
|
|
16
|
+
IveriProduct["CHAT"] = "chat";
|
|
17
|
+
})(IveriProduct || (IveriProduct = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a licence stands, worked out from its dates on every read and never stored: one that has not started yet is
|
|
3
|
+
* `scheduled`, one inside its dates is `active`, one past its last day is `expired`, and one Iveri called off is
|
|
4
|
+
* `cancelled`. Only `active` opens the product.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum LicenceStatus {
|
|
7
|
+
SCHEDULED = "scheduled",
|
|
8
|
+
ACTIVE = "active",
|
|
9
|
+
EXPIRED = "expired",
|
|
10
|
+
CANCELLED = "cancelled"
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a licence stands, worked out from its dates on every read and never stored: one that has not started yet is
|
|
3
|
+
* `scheduled`, one inside its dates is `active`, one past its last day is `expired`, and one Iveri called off is
|
|
4
|
+
* `cancelled`. Only `active` opens the product.
|
|
5
|
+
*/
|
|
6
|
+
export var LicenceStatus;
|
|
7
|
+
(function (LicenceStatus) {
|
|
8
|
+
LicenceStatus["SCHEDULED"] = "scheduled";
|
|
9
|
+
LicenceStatus["ACTIVE"] = "active";
|
|
10
|
+
LicenceStatus["EXPIRED"] = "expired";
|
|
11
|
+
LicenceStatus["CANCELLED"] = "cancelled";
|
|
12
|
+
})(LicenceStatus || (LicenceStatus = {}));
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { Paginated } from '../../type/paginated.type.js';
|
|
4
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
5
|
+
import type { TenantStatus } from '../identity/tenant-status.enum.js';
|
|
6
|
+
import type { IveriProduct } from './iveri-product.enum.js';
|
|
7
|
+
import type { LicenceKind } from './licence-kind.enum.js';
|
|
8
|
+
import type { LicenceStatus } from './licence-status.enum.js';
|
|
9
|
+
/** A company on Iveri, as Iveri's operators see it. Nothing about its people beyond a count and who owns it. */
|
|
10
|
+
export interface PlatformTenant {
|
|
11
|
+
id: UUID;
|
|
12
|
+
name: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
status: TenantStatus;
|
|
15
|
+
/** Why it was last suspended or reactivated, as the operator wrote it. */
|
|
16
|
+
statusReason: Nullable<string>;
|
|
17
|
+
statusChangedAt: Nullable<IsoDateTime>;
|
|
18
|
+
/** People with an active or invited membership. */
|
|
19
|
+
memberCount: number;
|
|
20
|
+
ownerName: Nullable<string>;
|
|
21
|
+
ownerEmail: Nullable<string>;
|
|
22
|
+
createdAt: IsoDateTime;
|
|
23
|
+
}
|
|
24
|
+
export type PlatformTenantsPage = Paginated<PlatformTenant>;
|
|
25
|
+
/** Adds a company with its first owner, who is invited rather than given a password. */
|
|
26
|
+
export interface CreatePlatformTenantRequest {
|
|
27
|
+
name: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
ownerEmail: string;
|
|
30
|
+
ownerFirstName: string;
|
|
31
|
+
ownerLastName: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The new company and the owner's invitation. The token is shown to the operator once, to pass on, because no email
|
|
35
|
+
* can be sent for a company from outside it yet.
|
|
36
|
+
*/
|
|
37
|
+
export interface CreatedPlatformTenant {
|
|
38
|
+
tenant: PlatformTenant;
|
|
39
|
+
ownerInvitationToken: string;
|
|
40
|
+
}
|
|
41
|
+
/** Suspend or reactivate a company. The reason is required, because it is what the next operator reads. */
|
|
42
|
+
export interface UpdatePlatformTenantStatusRequest {
|
|
43
|
+
status: TenantStatus.ACTIVE | TenantStatus.SUSPENDED;
|
|
44
|
+
reason: string;
|
|
45
|
+
}
|
|
46
|
+
/** A company's licence for one product. Its dates are calendar days in UTC, the last day included. */
|
|
47
|
+
export interface ProductLicence {
|
|
48
|
+
id: UUID;
|
|
49
|
+
tenantId: UUID;
|
|
50
|
+
product: IveriProduct;
|
|
51
|
+
kind: LicenceKind;
|
|
52
|
+
/** How many people may be on the product's staff list at once, or null for no limit. */
|
|
53
|
+
seats: Nullable<number>;
|
|
54
|
+
startsOn: string;
|
|
55
|
+
/** The last day it covers, or null when it runs until cancelled. */
|
|
56
|
+
endsOn: Nullable<string>;
|
|
57
|
+
status: LicenceStatus;
|
|
58
|
+
note: Nullable<string>;
|
|
59
|
+
cancelledAt: Nullable<IsoDateTime>;
|
|
60
|
+
createdAt: IsoDateTime;
|
|
61
|
+
updatedAt: IsoDateTime;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateProductLicenceRequest {
|
|
64
|
+
tenantId: UUID;
|
|
65
|
+
product: IveriProduct;
|
|
66
|
+
kind: LicenceKind;
|
|
67
|
+
seats?: Nullable<number>;
|
|
68
|
+
startsOn: string;
|
|
69
|
+
endsOn?: Nullable<string>;
|
|
70
|
+
note?: Nullable<string>;
|
|
71
|
+
}
|
|
72
|
+
/** Renewing is moving `endsOn`; turning a trial into a paid licence is changing `kind`. */
|
|
73
|
+
export interface UpdateProductLicenceRequest {
|
|
74
|
+
kind?: LicenceKind;
|
|
75
|
+
seats?: Nullable<number>;
|
|
76
|
+
endsOn?: Nullable<string>;
|
|
77
|
+
note?: Nullable<string>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* What a product is told about one company's licence for it. A company with no licence at all reads as not active,
|
|
81
|
+
* with every other field null.
|
|
82
|
+
*/
|
|
83
|
+
export interface ProductLicenceCheck {
|
|
84
|
+
tenantId: UUID;
|
|
85
|
+
product: IveriProduct;
|
|
86
|
+
isActive: boolean;
|
|
87
|
+
status: Nullable<LicenceStatus>;
|
|
88
|
+
seats: Nullable<number>;
|
|
89
|
+
endsOn: Nullable<string>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Carried in the `details` of the 403 a product answers when the company's licence for it is not live, so an app can
|
|
93
|
+
* show "your company's licence has ended" rather than a bare refusal. Seats running out is an ordinary 409 instead,
|
|
94
|
+
* because it refuses one action rather than the whole product.
|
|
95
|
+
*/
|
|
96
|
+
export declare const LICENCE_INACTIVE_REASON = "licence-inactive";
|
|
97
|
+
export interface LicenceInactiveDetails {
|
|
98
|
+
reason: typeof LICENCE_INACTIVE_REASON;
|
|
99
|
+
product: IveriProduct;
|
|
100
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carried in the `details` of the 403 a product answers when the company's licence for it is not live, so an app can
|
|
3
|
+
* show "your company's licence has ended" rather than a bare refusal. Seats running out is an ordinary 409 instead,
|
|
4
|
+
* because it refuses one action rather than the whole product.
|
|
5
|
+
*/
|
|
6
|
+
export const LICENCE_INACTIVE_REASON = 'licence-inactive';
|
|
@@ -613,10 +613,34 @@ export declare enum UserPermission {
|
|
|
613
613
|
* Run Baasi inside another company's product: create its apps, issue and revoke their secrets, change who may
|
|
614
614
|
* start conversations, and refuse tokens signed before a moment. Held by that company's own staff.
|
|
615
615
|
*/
|
|
616
|
-
CHAT_APP_MANAGE = "chat:app:manage"
|
|
616
|
+
CHAT_APP_MANAGE = "chat:app:manage",
|
|
617
|
+
/** List every company on Iveri and read one: its status, its people count and its owner. */
|
|
618
|
+
PLATFORM_TENANT_READ = "platform:tenant:read",
|
|
619
|
+
/** Add a company with its owner's invitation, and suspend or reactivate one. */
|
|
620
|
+
PLATFORM_TENANT_MANAGE = "platform:tenant:manage",
|
|
621
|
+
/** Read every company's product licences. */
|
|
622
|
+
PLATFORM_LICENCE_READ = "platform:licence:read",
|
|
623
|
+
/** Give a company a licence for a product, change its seats or dates, and cancel it. */
|
|
624
|
+
PLATFORM_LICENCE_MANAGE = "platform:licence:manage",
|
|
625
|
+
/**
|
|
626
|
+
* Ask whether a company's licence for one product is live. Held by the products' own service credentials, so a
|
|
627
|
+
* product can refuse a company whose licence has ended without reading anything else about it.
|
|
628
|
+
*/
|
|
629
|
+
PLATFORM_LICENCE_CHECK = "platform:licence:check"
|
|
617
630
|
}
|
|
618
631
|
/**
|
|
619
|
-
*
|
|
632
|
+
* The permissions that act across companies. They are granted only inside Iveri's own operator workspace, which each
|
|
633
|
+
* service knows as `PLATFORM_TENANT_ID`, and a service honours one only from that workspace: identity refuses them on
|
|
634
|
+
* any other workspace's role or key, and a route that uses one also checks where the token came from.
|
|
635
|
+
*/
|
|
636
|
+
export declare const PLATFORM_PERMISSIONS: readonly UserPermission[];
|
|
637
|
+
/** Whether a permission acts across companies, and so may only be held in Iveri's operator workspace. */
|
|
638
|
+
export declare function isPlatformPermission(permission: string): boolean;
|
|
639
|
+
/**
|
|
640
|
+
* Every permission a company can hold, for seeding the owner role and validating custom-role input.
|
|
641
|
+
*
|
|
642
|
+
* It leaves out `PLATFORM_PERMISSIONS`. `OWNER` is derived from this list, so a cross-company permission in it would be
|
|
643
|
+
* handed to the owner of every company that signs up.
|
|
620
644
|
*
|
|
621
645
|
* Frozen because it is shared mutable state in a browser bundle otherwise: one caller sorting
|
|
622
646
|
* it in place reorders it for everyone.
|
|
@@ -679,11 +679,45 @@ export var UserPermission;
|
|
|
679
679
|
* start conversations, and refuse tokens signed before a moment. Held by that company's own staff.
|
|
680
680
|
*/
|
|
681
681
|
UserPermission["CHAT_APP_MANAGE"] = "chat:app:manage";
|
|
682
|
+
// ── Iveri's own operators ───────────────────────────────────────────────
|
|
683
|
+
// Held only in Iveri's operator workspace, never by a company: see `PLATFORM_PERMISSIONS`.
|
|
684
|
+
/** List every company on Iveri and read one: its status, its people count and its owner. */
|
|
685
|
+
UserPermission["PLATFORM_TENANT_READ"] = "platform:tenant:read";
|
|
686
|
+
/** Add a company with its owner's invitation, and suspend or reactivate one. */
|
|
687
|
+
UserPermission["PLATFORM_TENANT_MANAGE"] = "platform:tenant:manage";
|
|
688
|
+
/** Read every company's product licences. */
|
|
689
|
+
UserPermission["PLATFORM_LICENCE_READ"] = "platform:licence:read";
|
|
690
|
+
/** Give a company a licence for a product, change its seats or dates, and cancel it. */
|
|
691
|
+
UserPermission["PLATFORM_LICENCE_MANAGE"] = "platform:licence:manage";
|
|
692
|
+
/**
|
|
693
|
+
* Ask whether a company's licence for one product is live. Held by the products' own service credentials, so a
|
|
694
|
+
* product can refuse a company whose licence has ended without reading anything else about it.
|
|
695
|
+
*/
|
|
696
|
+
UserPermission["PLATFORM_LICENCE_CHECK"] = "platform:licence:check";
|
|
682
697
|
})(UserPermission || (UserPermission = {}));
|
|
683
698
|
/**
|
|
684
|
-
*
|
|
699
|
+
* The permissions that act across companies. They are granted only inside Iveri's own operator workspace, which each
|
|
700
|
+
* service knows as `PLATFORM_TENANT_ID`, and a service honours one only from that workspace: identity refuses them on
|
|
701
|
+
* any other workspace's role or key, and a route that uses one also checks where the token came from.
|
|
702
|
+
*/
|
|
703
|
+
export const PLATFORM_PERMISSIONS = Object.freeze([
|
|
704
|
+
UserPermission.PLATFORM_TENANT_READ,
|
|
705
|
+
UserPermission.PLATFORM_TENANT_MANAGE,
|
|
706
|
+
UserPermission.PLATFORM_LICENCE_READ,
|
|
707
|
+
UserPermission.PLATFORM_LICENCE_MANAGE,
|
|
708
|
+
UserPermission.PLATFORM_LICENCE_CHECK,
|
|
709
|
+
]);
|
|
710
|
+
/** Whether a permission acts across companies, and so may only be held in Iveri's operator workspace. */
|
|
711
|
+
export function isPlatformPermission(permission) {
|
|
712
|
+
return PLATFORM_PERMISSIONS.includes(permission);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Every permission a company can hold, for seeding the owner role and validating custom-role input.
|
|
716
|
+
*
|
|
717
|
+
* It leaves out `PLATFORM_PERMISSIONS`. `OWNER` is derived from this list, so a cross-company permission in it would be
|
|
718
|
+
* handed to the owner of every company that signs up.
|
|
685
719
|
*
|
|
686
720
|
* Frozen because it is shared mutable state in a browser bundle otherwise: one caller sorting
|
|
687
721
|
* it in place reorders it for everyone.
|
|
688
722
|
*/
|
|
689
|
-
export const ALL_USER_PERMISSIONS = Object.freeze(Object.values(UserPermission));
|
|
723
|
+
export const ALL_USER_PERMISSIONS = Object.freeze(Object.values(UserPermission).filter((permission) => !isPlatformPermission(permission)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iveri/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0",
|
|
4
4
|
"description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
"types": "./dist/api/mobility/index.d.ts",
|
|
77
77
|
"default": "./dist/api/mobility/index.js"
|
|
78
78
|
},
|
|
79
|
+
"./platform": {
|
|
80
|
+
"types": "./dist/api/platform/index.d.ts",
|
|
81
|
+
"default": "./dist/api/platform/index.js"
|
|
82
|
+
},
|
|
79
83
|
"./package.json": "./package.json"
|
|
80
84
|
},
|
|
81
85
|
"sideEffects": false,
|