@jaws-developers-customers/consulca-types 1.1.0 → 1.1.23
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/README.md +23 -8
- package/index.d.ts +77 -34
- package/index.js +5 -1
- package/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,18 +10,22 @@ npm install @jaws-developers-customers/consulca-types
|
|
|
10
10
|
|
|
11
11
|
## Pubblicazione automatica
|
|
12
12
|
|
|
13
|
-
Ogni push su `
|
|
13
|
+
Ogni push su `master` esegue i test e pubblica automaticamente il pacchetto su npm tramite GitHub Actions.
|
|
14
14
|
|
|
15
15
|
Prerequisito:
|
|
16
16
|
|
|
17
|
-
- npm Trusted Publisher configurato per
|
|
17
|
+
- npm Trusted Publisher configurato nelle impostazioni del pacchetto su npm per l'organizzazione `JAWS-Developers-Customers`, il repository `15-NPMPackage` e il workflow `publish.yml` (senza environment).
|
|
18
18
|
|
|
19
|
-
Il workflow
|
|
19
|
+
Il trusted publishing richiede npm 11.5.1 o successivo: il workflow installa npm 11.21.0 prima della pubblicazione, senza usare `NPM_TOKEN`. La versione npm 10 inclusa in Node.js 22 non supporta questa autenticazione, anche se può generare la provenance.
|
|
20
|
+
|
|
21
|
+
Il pacchetto viene sempre pubblicato con accesso pubblico. La visibilità del pacchetto npm è distinta da quella del repository GitHub: npm abilita automaticamente la provenance quando il token OIDC identifica un repository sorgente pubblico e il pacchetto è pubblico. Il workflow non forza `--provenance`, perché npm rifiuta la provenance di un repository identificato come privato con errore `E422`, anche se il pacchetto è pubblico. L'autenticazione OIDC rimane attiva anche senza provenance.
|
|
22
|
+
|
|
23
|
+
Il workflow genera una versione unica per ogni run su `master`, così la pubblicazione non fallisce per versioni duplicate.
|
|
20
24
|
|
|
21
25
|
## Cosa esporta
|
|
22
26
|
|
|
23
27
|
- tipi TypeScript per le entità principali (`User`, `Property`, `Lease`, `Inspection`, `Claim`, `Work`, ...)
|
|
24
|
-
- cataloghi `ENUM` dello schema (`USER_ROLES`, `ACCESS_CHANNELS`, `
|
|
28
|
+
- cataloghi `ENUM` dello schema (`USER_ROLES`, `ACCESS_CHANNELS`, `ACCESS_ROLES`, `DEVICE_TYPES`, ...)
|
|
25
29
|
- helper:
|
|
26
30
|
- `formatDate`
|
|
27
31
|
- `formatDateTime`
|
|
@@ -62,12 +66,17 @@ import {
|
|
|
62
66
|
const user: User = {
|
|
63
67
|
id: 'uuid',
|
|
64
68
|
email: 'mario.rossi@example.com',
|
|
65
|
-
password_hash: 'hashed',
|
|
66
69
|
first_name: 'Mario',
|
|
67
70
|
last_name: 'Rossi',
|
|
68
71
|
status: 'active',
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
country_code: 'CH',
|
|
73
|
+
access_channels: [{
|
|
74
|
+
channel: 'intranet_dashboard',
|
|
75
|
+
role: 'employee',
|
|
76
|
+
status: 'active',
|
|
77
|
+
created_at: '2026-10-05 18:29:50',
|
|
78
|
+
revoked_at: null,
|
|
79
|
+
}],
|
|
71
80
|
};
|
|
72
81
|
|
|
73
82
|
const inspection: Inspection = {
|
|
@@ -81,4 +90,10 @@ const inspection: Inspection = {
|
|
|
81
90
|
};
|
|
82
91
|
|
|
83
92
|
console.log(formatDateTime(inspection.created_at, 'it-CH'));
|
|
84
|
-
```
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`User` accetta direttamente i dati di `/user/get/me`: `password_hash`, `created_at` e `updated_at` non sono obbligatori. Non salvare la password o il suo hash nello stato client. I canali sono contenuti in `user.access_channels`, senza richiedere `user_id` per ogni elemento; `AccessChannelAssignment` rappresenta invece una riga della tabella con `user_id` obbligatorio.
|
|
96
|
+
|
|
97
|
+
`ACCESS_ROLES` descrive i ruoli di `access_channels` e `user_invites`, mentre `USER_ROLES` descrive quelli della tabella `user_roles`. Per verificare l'accesso usa `hasAccessChannel(user.access_channels, 'intranet_dashboard')`: i canali revocati vengono esclusi.
|
|
98
|
+
|
|
99
|
+
I riferimenti agli appartamenti usano `apartment_id`, `Property` usa `apartment_number` e gli allegati delle ispezioni usano `inspection_item_id`. Sono disponibili anche `Device`, `UserInvite`, `Room`, `ApartmentRoom`, `ApartmentLessor` e `ApartmentManager`. I campi SQL nullable accettano `null`; i decimali accettano numeri o stringhe restituiti dal driver MariaDB.
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type UserStatus = 'active' | 'invited' | 'suspended' | 'disabled';
|
|
2
2
|
export type UserRole = 'lessor' | 'manager' | 'website_manager' | 'inspector';
|
|
3
3
|
export type AccessChannel = 'intranet_dashboard' | 'mobile_app' | 'website_admin';
|
|
4
|
+
export type AccessRole = 'admin' | 'manager' | 'employee' | 'lessor' | 'inspector' | 'editor';
|
|
4
5
|
export type AccessStatus = 'active' | 'revoked';
|
|
6
|
+
export type DeviceType = 'web' | 'mobile';
|
|
5
7
|
export type PropertyStatus = 'active' | 'inactive' | 'archived';
|
|
6
8
|
export type ManagementRole = 'primary' | 'secondary' | 'accounting' | 'technical' | 'other';
|
|
7
9
|
export type LeaseStatus = 'planned' | 'active' | 'ended' | 'cancelled';
|
|
@@ -40,15 +42,17 @@ export interface Addressable {
|
|
|
40
42
|
export interface User extends Addressable {
|
|
41
43
|
id: string;
|
|
42
44
|
email: string;
|
|
43
|
-
password_hash
|
|
45
|
+
password_hash?: string;
|
|
44
46
|
first_name: string;
|
|
45
47
|
last_name: string;
|
|
46
48
|
phone?: string | null;
|
|
49
|
+
country_code: string;
|
|
47
50
|
status: UserStatus;
|
|
48
51
|
email_verified_at?: string | Date | null;
|
|
49
52
|
last_login_at?: string | Date | null;
|
|
50
|
-
created_at
|
|
51
|
-
updated_at
|
|
53
|
+
created_at?: string | Date;
|
|
54
|
+
updated_at?: string | Date;
|
|
55
|
+
access_channels?: UserAccessChannel[];
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
export interface UserRoleAssignment {
|
|
@@ -58,30 +62,56 @@ export interface UserRoleAssignment {
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export interface UserAccessChannel {
|
|
61
|
-
user_id
|
|
65
|
+
user_id?: string;
|
|
62
66
|
channel: AccessChannel;
|
|
67
|
+
role: AccessRole;
|
|
63
68
|
status: AccessStatus;
|
|
64
69
|
created_at: string | Date;
|
|
65
70
|
revoked_at?: string | Date | null;
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
export interface
|
|
69
|
-
id: string;
|
|
73
|
+
export interface AccessChannelAssignment extends UserAccessChannel {
|
|
70
74
|
user_id: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface UserInvite {
|
|
78
|
+
email: string;
|
|
79
|
+
token_hash: string;
|
|
71
80
|
channel: AccessChannel;
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
role: AccessRole;
|
|
82
|
+
inviter_id: string;
|
|
74
83
|
expires_at: string | Date;
|
|
75
|
-
|
|
76
|
-
user_agent?: string | null;
|
|
77
|
-
ip_address?: Uint8Array | string | null;
|
|
84
|
+
used_at?: string | Date | null;
|
|
78
85
|
created_at: string | Date;
|
|
79
|
-
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface Device {
|
|
89
|
+
uuid: string;
|
|
90
|
+
user_id?: string | null;
|
|
91
|
+
type: DeviceType;
|
|
92
|
+
allowed: boolean | number;
|
|
93
|
+
os: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface Session {
|
|
97
|
+
token: string;
|
|
98
|
+
type: string;
|
|
99
|
+
expire: string | Date;
|
|
100
|
+
refresh_token: string;
|
|
101
|
+
refresh_expire: string | Date;
|
|
102
|
+
code?: string | null;
|
|
103
|
+
code_expire: string | Date;
|
|
104
|
+
user_id: string;
|
|
105
|
+
device_uuid: string;
|
|
106
|
+
ip: string;
|
|
80
107
|
}
|
|
81
108
|
|
|
82
109
|
export interface Building extends Addressable {
|
|
83
110
|
id: string;
|
|
84
111
|
name: string;
|
|
112
|
+
address_line1: string;
|
|
113
|
+
postal_code: string;
|
|
114
|
+
city: string;
|
|
85
115
|
created_at: string | Date;
|
|
86
116
|
updated_at: string | Date;
|
|
87
117
|
}
|
|
@@ -89,24 +119,24 @@ export interface Building extends Addressable {
|
|
|
89
119
|
export interface Property {
|
|
90
120
|
id: string;
|
|
91
121
|
building_id: string;
|
|
92
|
-
|
|
122
|
+
apartment_number: string;
|
|
93
123
|
floor?: string | null;
|
|
94
|
-
area_m2?: number | null;
|
|
124
|
+
area_m2?: number | string | null;
|
|
95
125
|
status: PropertyStatus;
|
|
96
126
|
created_at: string | Date;
|
|
97
127
|
updated_at: string | Date;
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
export interface PropertyLessor {
|
|
101
|
-
|
|
131
|
+
apartment_id: string;
|
|
102
132
|
user_id: string;
|
|
103
|
-
ownership_share?: number | null;
|
|
133
|
+
ownership_share?: number | string | null;
|
|
104
134
|
is_primary: boolean | number;
|
|
105
135
|
created_at: string | Date;
|
|
106
136
|
}
|
|
107
137
|
|
|
108
138
|
export interface PropertyManager {
|
|
109
|
-
|
|
139
|
+
apartment_id: string;
|
|
110
140
|
user_id: string;
|
|
111
141
|
management_role: ManagementRole;
|
|
112
142
|
valid_from?: string | Date | null;
|
|
@@ -116,7 +146,7 @@ export interface PropertyManager {
|
|
|
116
146
|
|
|
117
147
|
export interface Lease {
|
|
118
148
|
id: string;
|
|
119
|
-
|
|
149
|
+
apartment_id: string;
|
|
120
150
|
tenant_name?: string | null;
|
|
121
151
|
tenant_email?: string | null;
|
|
122
152
|
tenant_phone?: string | null;
|
|
@@ -144,7 +174,7 @@ export interface Inspection {
|
|
|
144
174
|
export interface InspectionItem {
|
|
145
175
|
id: string;
|
|
146
176
|
inspection_id: string;
|
|
147
|
-
|
|
177
|
+
room_id?: string | null;
|
|
148
178
|
item_name: string;
|
|
149
179
|
condition_status: ConditionStatus;
|
|
150
180
|
comment?: string | null;
|
|
@@ -153,8 +183,7 @@ export interface InspectionItem {
|
|
|
153
183
|
|
|
154
184
|
export interface InspectionAttachment {
|
|
155
185
|
id: string;
|
|
156
|
-
|
|
157
|
-
item_id?: string | null;
|
|
186
|
+
inspection_item_id: string;
|
|
158
187
|
file_name: string;
|
|
159
188
|
storage_key: string;
|
|
160
189
|
mime_type?: string | null;
|
|
@@ -164,13 +193,13 @@ export interface InspectionAttachment {
|
|
|
164
193
|
|
|
165
194
|
export interface Claim {
|
|
166
195
|
id: string;
|
|
167
|
-
|
|
196
|
+
apartment_id: string;
|
|
168
197
|
submitted_by: string;
|
|
169
198
|
status: ClaimStatus;
|
|
170
199
|
incident_date?: string | Date | null;
|
|
171
200
|
title: string;
|
|
172
201
|
description: string;
|
|
173
|
-
amount_estimate?: number | null;
|
|
202
|
+
amount_estimate?: number | string | null;
|
|
174
203
|
submitted_at?: string | Date | null;
|
|
175
204
|
created_at: string | Date;
|
|
176
205
|
updated_at: string | Date;
|
|
@@ -186,7 +215,7 @@ export interface ClaimAttachment {
|
|
|
186
215
|
created_at: string | Date;
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
export interface Manufacturer extends Addressable {
|
|
218
|
+
export interface Manufacturer extends Pick<Addressable, 'address_line1' | 'postal_code' | 'city'> {
|
|
190
219
|
id: string;
|
|
191
220
|
name: string;
|
|
192
221
|
country_code: string;
|
|
@@ -198,7 +227,7 @@ export interface Manufacturer extends Addressable {
|
|
|
198
227
|
|
|
199
228
|
export interface Work {
|
|
200
229
|
id: string;
|
|
201
|
-
|
|
230
|
+
apartment_id: string;
|
|
202
231
|
manufacturer_id?: string | null;
|
|
203
232
|
created_by: string;
|
|
204
233
|
title: string;
|
|
@@ -211,20 +240,34 @@ export interface Work {
|
|
|
211
240
|
}
|
|
212
241
|
|
|
213
242
|
export interface AuditLog {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
243
|
+
action_id: string;
|
|
244
|
+
timestamp: string | Date;
|
|
245
|
+
user_id: string;
|
|
217
246
|
action: string;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
247
|
+
other_data?: string | null;
|
|
248
|
+
ip: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type ApartmentLessor = PropertyLessor;
|
|
252
|
+
export type ApartmentManager = PropertyManager;
|
|
253
|
+
|
|
254
|
+
export interface Room {
|
|
255
|
+
id: string;
|
|
256
|
+
name: string;
|
|
257
|
+
weight: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface ApartmentRoom {
|
|
261
|
+
apartment_id: string;
|
|
262
|
+
room_id: string;
|
|
222
263
|
}
|
|
223
264
|
|
|
224
265
|
export declare const USER_STATUSES: readonly UserStatus[];
|
|
225
266
|
export declare const USER_ROLES: readonly UserRole[];
|
|
226
267
|
export declare const ACCESS_CHANNELS: readonly AccessChannel[];
|
|
268
|
+
export declare const ACCESS_ROLES: readonly AccessRole[];
|
|
227
269
|
export declare const ACCESS_STATUSES: readonly AccessStatus[];
|
|
270
|
+
export declare const DEVICE_TYPES: readonly DeviceType[];
|
|
228
271
|
export declare const PROPERTY_STATUSES: readonly PropertyStatus[];
|
|
229
272
|
export declare const MANAGEMENT_ROLES: readonly ManagementRole[];
|
|
230
273
|
export declare const LEASE_STATUSES: readonly LeaseStatus[];
|
|
@@ -259,10 +302,10 @@ export declare function getUserFullName(
|
|
|
259
302
|
): string;
|
|
260
303
|
export declare function formatAddress(entity: Addressable | null | undefined): string;
|
|
261
304
|
export declare function hasUserRole(
|
|
262
|
-
userRoles:
|
|
305
|
+
userRoles: ReadonlyArray<Pick<UserRoleAssignment, 'role'> | UserRole> | null | undefined,
|
|
263
306
|
role: UserRole
|
|
264
307
|
): boolean;
|
|
265
308
|
export declare function hasAccessChannel(
|
|
266
|
-
accessChannels:
|
|
309
|
+
accessChannels: ReadonlyArray<Pick<UserAccessChannel, 'channel'> & Partial<Pick<UserAccessChannel, 'status'>> | AccessChannel> | null | undefined,
|
|
267
310
|
channel: AccessChannel
|
|
268
311
|
): boolean;
|
package/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
const USER_STATUSES = Object.freeze(['active', 'invited', 'suspended', 'disabled']);
|
|
4
4
|
const USER_ROLES = Object.freeze(['lessor', 'manager', 'website_manager', 'inspector']);
|
|
5
5
|
const ACCESS_CHANNELS = Object.freeze(['intranet_dashboard', 'mobile_app', 'website_admin']);
|
|
6
|
+
const ACCESS_ROLES = Object.freeze(['admin', 'manager', 'employee', 'lessor', 'inspector', 'editor']);
|
|
6
7
|
const ACCESS_STATUSES = Object.freeze(['active', 'revoked']);
|
|
8
|
+
const DEVICE_TYPES = Object.freeze(['web', 'mobile']);
|
|
7
9
|
const PROPERTY_STATUSES = Object.freeze(['active', 'inactive', 'archived']);
|
|
8
10
|
const MANAGEMENT_ROLES = Object.freeze(['primary', 'secondary', 'accounting', 'technical', 'other']);
|
|
9
11
|
const LEASE_STATUSES = Object.freeze(['planned', 'active', 'ended', 'cancelled']);
|
|
@@ -20,7 +22,7 @@ const COLOR_PALETTE = Object.freeze({
|
|
|
20
22
|
text: '#102A43',
|
|
21
23
|
});
|
|
22
24
|
const CONSTANTS = Object.freeze({
|
|
23
|
-
API_DEV: 'https://
|
|
25
|
+
API_DEV: 'https://test.jawsdevelopers.ch',
|
|
24
26
|
API: 'https://api.consulca.ch',
|
|
25
27
|
ICON: 'https://www.consulca.ch/wp-content/themes/consulca_theme2020/img/default_user.png'
|
|
26
28
|
});
|
|
@@ -124,10 +126,12 @@ function hasAccessChannel(accessChannels, channel) {
|
|
|
124
126
|
|
|
125
127
|
module.exports = {
|
|
126
128
|
ACCESS_CHANNELS,
|
|
129
|
+
ACCESS_ROLES,
|
|
127
130
|
ACCESS_STATUSES,
|
|
128
131
|
CLAIM_STATUSES,
|
|
129
132
|
COLOR_PALETTE,
|
|
130
133
|
CONDITION_STATUSES,
|
|
134
|
+
DEVICE_TYPES,
|
|
131
135
|
INSPECTION_STATUSES,
|
|
132
136
|
INSPECTION_TYPES,
|
|
133
137
|
LEASE_STATUSES,
|
package/index.mjs
CHANGED
|
@@ -2,16 +2,17 @@ import pkg from './index.js';
|
|
|
2
2
|
|
|
3
3
|
export const {
|
|
4
4
|
ACCESS_CHANNELS,
|
|
5
|
+
ACCESS_ROLES,
|
|
5
6
|
ACCESS_STATUSES,
|
|
6
7
|
CLAIM_STATUSES,
|
|
7
8
|
COLOR_PALETTE,
|
|
8
9
|
CONDITION_STATUSES,
|
|
10
|
+
DEVICE_TYPES,
|
|
9
11
|
INSPECTION_STATUSES,
|
|
10
12
|
INSPECTION_TYPES,
|
|
11
13
|
LEASE_STATUSES,
|
|
12
14
|
MANAGEMENT_ROLES,
|
|
13
15
|
PROPERTY_STATUSES,
|
|
14
|
-
PROPERTY_TYPES,
|
|
15
16
|
USER_ROLES,
|
|
16
17
|
USER_STATUSES,
|
|
17
18
|
WORK_STATUSES,
|
|
@@ -20,7 +21,6 @@ export const {
|
|
|
20
21
|
formatCurrency,
|
|
21
22
|
formatDate,
|
|
22
23
|
formatDateTime,
|
|
23
|
-
getColorPalette,
|
|
24
24
|
getUserFullName,
|
|
25
25
|
hasAccessChannel,
|
|
26
26
|
hasUserRole,
|