@wasto/sdk 1.0.3 → 1.0.5
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/index.d.mts +60 -3
- package/dist/index.d.ts +60 -3
- package/dist/index.js +79 -0
- package/dist/index.mjs +79 -0
- package/package.json +1 -1
- package/src/client.ts +791 -692
- package/src/dashboard-apps.ts +367 -350
- package/src/dto/cms-app-settings.ts +91 -91
- package/src/enums.ts +298 -298
- package/src/free-tier.ts +56 -56
- package/src/index.ts +35 -35
- package/src/opening-hours/constants.ts +48 -48
- package/src/opening-hours/convert.ts +276 -276
- package/src/opening-hours/format.ts +99 -99
- package/src/opening-hours/index.ts +9 -9
- package/src/opening-hours/is-open-now.ts +38 -38
- package/src/opening-hours/resolve.ts +71 -71
- package/src/opening-hours/time.ts +74 -74
- package/src/opening-hours/timezone.ts +34 -34
- package/src/opening-hours/types.ts +53 -53
- package/src/opening-hours/validate.ts +182 -182
- package/src/roi/calculations.ts +732 -732
- package/src/roi/index.ts +1 -1
- package/src/types/app-preload.types.ts +10 -0
- package/src/types/asset-bookings.types.ts +19 -19
- package/src/types/asset-interventions.types.ts +24 -24
- package/src/types/assets.types.ts +68 -68
- package/src/types/auth.types.ts +37 -37
- package/src/types/blog-posts.types.ts +19 -19
- package/src/types/calendar-pdf.types.ts +24 -24
- package/src/types/calendo-events.types.ts +64 -64
- package/src/types/challenges.types.ts +30 -30
- package/src/types/chatbot.types.ts +82 -82
- package/src/types/cities.types.ts +27 -27
- package/src/types/city-groups.types.ts +46 -46
- package/src/types/cms.types.ts +87 -87
- package/src/types/field-reports.types.ts +66 -66
- package/src/types/free-tier.types.ts +54 -54
- package/src/types/index.ts +33 -32
- package/src/types/iot.types.ts +31 -31
- package/src/types/maintenance.types.ts +44 -44
- package/src/types/mapso.types.ts +146 -146
- package/src/types/notifications.types.ts +68 -68
- package/src/types/onboarding.types.ts +117 -117
- package/src/types/operational-zones.types.ts +70 -70
- package/src/types/pagination.types.ts +33 -33
- package/src/types/providers.types.ts +29 -29
- package/src/types/quiz-questions.types.ts +59 -59
- package/src/types/recycling-points.types.ts +47 -47
- package/src/types/roi.types.ts +60 -60
- package/src/types/surveys.types.ts +103 -103
- package/src/types/tickets.types.ts +65 -65
- package/src/types/users.types.ts +30 -30
- package/src/types/waste-collection-places-query.types.ts +4 -4
- package/src/types/waste-collection-places.types.ts +34 -33
- package/src/types/waste-types.types.ts +21 -21
package/src/dashboard-apps.ts
CHANGED
|
@@ -1,350 +1,367 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalogue des sections Wast-O.
|
|
3
|
-
* @deprecated Préférer WASTO_SECTIONS pour les libellés UI ; DASHBOARD_APPS reste pour l'API permissions.
|
|
4
|
-
*/
|
|
5
|
-
export enum DashboardAppSlug {
|
|
6
|
-
WORKSPACE = 'WORKSPACE',
|
|
7
|
-
WASTO = 'WASTO',
|
|
8
|
-
APPSO = 'APPSO',
|
|
9
|
-
CALENDO = 'CALENDO',
|
|
10
|
-
ACTO = 'ACTO',
|
|
11
|
-
ASSISTO = 'ASSISTO',
|
|
12
|
-
PLAYO = 'PLAYO',
|
|
13
|
-
MAPSO = 'MAPSO',
|
|
14
|
-
IAGO = 'IAGO',
|
|
15
|
-
PEDAGO = 'PEDAGO',
|
|
16
|
-
MARKETO = 'MARKETO',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
dashboardPath: '/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
export function
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
]
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Catalogue des sections Wast-O.
|
|
3
|
+
* @deprecated Préférer WASTO_SECTIONS pour les libellés UI ; DASHBOARD_APPS reste pour l'API permissions.
|
|
4
|
+
*/
|
|
5
|
+
export enum DashboardAppSlug {
|
|
6
|
+
WORKSPACE = 'WORKSPACE',
|
|
7
|
+
WASTO = 'WASTO',
|
|
8
|
+
APPSO = 'APPSO',
|
|
9
|
+
CALENDO = 'CALENDO',
|
|
10
|
+
ACTO = 'ACTO',
|
|
11
|
+
ASSISTO = 'ASSISTO',
|
|
12
|
+
PLAYO = 'PLAYO',
|
|
13
|
+
MAPSO = 'MAPSO',
|
|
14
|
+
IAGO = 'IAGO',
|
|
15
|
+
PEDAGO = 'PEDAGO',
|
|
16
|
+
MARKETO = 'MARKETO',
|
|
17
|
+
/** Connect'O — API agents / MCP (hors free self-serve) */
|
|
18
|
+
CONNECTO = 'CONNECTO',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type DashboardAppDefinition = {
|
|
22
|
+
slug: DashboardAppSlug;
|
|
23
|
+
/** Clé utilisée dans les URLs (ex. `wasto`, `appso`) */
|
|
24
|
+
key: string;
|
|
25
|
+
label: string;
|
|
26
|
+
dashboardPath: string;
|
|
27
|
+
isDevOnly?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type WastoSectionDefinition = {
|
|
31
|
+
slug: DashboardAppSlug;
|
|
32
|
+
key: string;
|
|
33
|
+
label: string;
|
|
34
|
+
sectionLabel: string;
|
|
35
|
+
dashboardPath: string;
|
|
36
|
+
isDevOnly?: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const WASTO_SECTIONS: WastoSectionDefinition[] = [
|
|
40
|
+
{
|
|
41
|
+
slug: DashboardAppSlug.WORKSPACE,
|
|
42
|
+
key: 'workspace',
|
|
43
|
+
label: 'WORKSPACE',
|
|
44
|
+
sectionLabel: 'Tableau de bord',
|
|
45
|
+
dashboardPath: '/dashboard',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
slug: DashboardAppSlug.WASTO,
|
|
49
|
+
key: 'wasto',
|
|
50
|
+
label: "WAST'O",
|
|
51
|
+
sectionLabel: 'Référentiel & collecte',
|
|
52
|
+
dashboardPath: '/referentiel',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
slug: DashboardAppSlug.PLAYO,
|
|
56
|
+
key: 'playo',
|
|
57
|
+
label: "PLAY'O",
|
|
58
|
+
sectionLabel: 'Engagement',
|
|
59
|
+
dashboardPath: '/engagement',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
slug: DashboardAppSlug.ACTO,
|
|
63
|
+
key: 'acto',
|
|
64
|
+
label: "ACT'O",
|
|
65
|
+
sectionLabel: 'Animation terrain',
|
|
66
|
+
dashboardPath: '/terrain/enquetes',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
slug: DashboardAppSlug.IAGO,
|
|
70
|
+
key: 'iago',
|
|
71
|
+
label: "AGENT'O",
|
|
72
|
+
sectionLabel: 'Scan & IA',
|
|
73
|
+
dashboardPath: '/scan',
|
|
74
|
+
isDevOnly: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
slug: DashboardAppSlug.MAPSO,
|
|
78
|
+
key: 'mapso',
|
|
79
|
+
label: "MAPS'O",
|
|
80
|
+
sectionLabel: 'Cartographie',
|
|
81
|
+
dashboardPath: '/cartographie/infrastructures',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
slug: DashboardAppSlug.CALENDO,
|
|
85
|
+
key: 'calendo',
|
|
86
|
+
label: "CALEND'O",
|
|
87
|
+
sectionLabel: 'Événements',
|
|
88
|
+
dashboardPath: '/evenements',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
slug: DashboardAppSlug.APPSO,
|
|
92
|
+
key: 'appso',
|
|
93
|
+
label: "APP'O",
|
|
94
|
+
sectionLabel: 'Studio app',
|
|
95
|
+
dashboardPath: '/studio-app/apps',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
slug: DashboardAppSlug.PEDAGO,
|
|
99
|
+
key: 'pedago',
|
|
100
|
+
label: "PEDAG'O",
|
|
101
|
+
sectionLabel: 'Analyses & ROI',
|
|
102
|
+
dashboardPath: '/analyses',
|
|
103
|
+
isDevOnly: true,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
slug: DashboardAppSlug.ASSISTO,
|
|
107
|
+
key: 'assisto',
|
|
108
|
+
label: "ASSIST'O",
|
|
109
|
+
sectionLabel: 'Support',
|
|
110
|
+
dashboardPath: '/support',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
slug: DashboardAppSlug.CONNECTO,
|
|
114
|
+
key: 'connecto',
|
|
115
|
+
label: "CONNECT'O",
|
|
116
|
+
sectionLabel: 'API & agents',
|
|
117
|
+
dashboardPath: '/integrations',
|
|
118
|
+
isDevOnly: true,
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
export const DASHBOARD_APPS: DashboardAppDefinition[] = [
|
|
123
|
+
{
|
|
124
|
+
slug: DashboardAppSlug.WORKSPACE,
|
|
125
|
+
key: 'workspace',
|
|
126
|
+
label: 'WORKSPACE',
|
|
127
|
+
dashboardPath: '/dashboard',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
slug: DashboardAppSlug.WASTO,
|
|
131
|
+
key: 'wasto',
|
|
132
|
+
label: "WAST'O",
|
|
133
|
+
dashboardPath: '/referentiel',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
slug: DashboardAppSlug.APPSO,
|
|
137
|
+
key: 'appso',
|
|
138
|
+
label: "APP'O",
|
|
139
|
+
dashboardPath: '/studio-app/apps',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
slug: DashboardAppSlug.CALENDO,
|
|
143
|
+
key: 'calendo',
|
|
144
|
+
label: "CALEND'O",
|
|
145
|
+
dashboardPath: '/evenements',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
slug: DashboardAppSlug.ACTO,
|
|
149
|
+
key: 'acto',
|
|
150
|
+
label: "ACT'O",
|
|
151
|
+
dashboardPath: '/terrain/enquetes',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
slug: DashboardAppSlug.ASSISTO,
|
|
155
|
+
key: 'assisto',
|
|
156
|
+
label: "ASSIST'O",
|
|
157
|
+
dashboardPath: '/support',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
slug: DashboardAppSlug.PLAYO,
|
|
161
|
+
key: 'playo',
|
|
162
|
+
label: "PLAY'O",
|
|
163
|
+
dashboardPath: '/engagement',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
slug: DashboardAppSlug.MAPSO,
|
|
167
|
+
key: 'mapso',
|
|
168
|
+
label: "MAPS'O",
|
|
169
|
+
dashboardPath: '/cartographie/infrastructures',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
slug: DashboardAppSlug.IAGO,
|
|
173
|
+
key: 'iago',
|
|
174
|
+
label: "AGENT'O",
|
|
175
|
+
dashboardPath: '/scan',
|
|
176
|
+
isDevOnly: true,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
slug: DashboardAppSlug.PEDAGO,
|
|
180
|
+
key: 'pedago',
|
|
181
|
+
label: "PEDAG'O",
|
|
182
|
+
dashboardPath: '/analyses',
|
|
183
|
+
isDevOnly: true,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
slug: DashboardAppSlug.MARKETO,
|
|
187
|
+
key: 'marketo',
|
|
188
|
+
label: "MARKET'O",
|
|
189
|
+
dashboardPath: '/analyses',
|
|
190
|
+
isDevOnly: true,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
slug: DashboardAppSlug.CONNECTO,
|
|
194
|
+
key: 'connecto',
|
|
195
|
+
label: "CONNECT'O",
|
|
196
|
+
dashboardPath: '/integrations',
|
|
197
|
+
isDevOnly: true,
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
export const WASTO_SECTION_BY_KEY = Object.fromEntries(
|
|
202
|
+
WASTO_SECTIONS.map((s) => [s.key, s]),
|
|
203
|
+
) as Record<string, WastoSectionDefinition>;
|
|
204
|
+
|
|
205
|
+
export const DASHBOARD_APP_BY_SLUG = Object.fromEntries(
|
|
206
|
+
DASHBOARD_APPS.map((a) => [a.slug, a]),
|
|
207
|
+
) as Record<DashboardAppSlug, DashboardAppDefinition>;
|
|
208
|
+
|
|
209
|
+
export const DASHBOARD_APP_BY_KEY = Object.fromEntries(
|
|
210
|
+
DASHBOARD_APPS.map((a) => [a.key, a]),
|
|
211
|
+
) as Record<string, DashboardAppDefinition>;
|
|
212
|
+
|
|
213
|
+
/** Apps activées par défaut si le groupement n'a aucune configuration explicite. */
|
|
214
|
+
export const DEFAULT_ENABLED_DASHBOARD_APP_SLUGS: DashboardAppSlug[] = DASHBOARD_APPS.filter(
|
|
215
|
+
(a) => !a.isDevOnly,
|
|
216
|
+
).map((a) => a.slug);
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Preset self-serve / compte gratuit (mode restreint).
|
|
220
|
+
* WORKSPACE + WASTO (référentiel, calendriers, planche) + APPSO (PWA light tri+calendrier).
|
|
221
|
+
* Hors scope / hors nav : Analyses & ROI, Annonces, Centres de tri, Points de collecte,
|
|
222
|
+
* Engagement (PLAYO), ACTO, IAGO, PEDAGO, MAPSO, CALENDO, invite membres.
|
|
223
|
+
*/
|
|
224
|
+
export const FREE_SELF_SERVE_DASHBOARD_APP_SLUGS: DashboardAppSlug[] = [
|
|
225
|
+
DashboardAppSlug.WORKSPACE,
|
|
226
|
+
DashboardAppSlug.WASTO,
|
|
227
|
+
DashboardAppSlug.APPSO,
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Apps encore présentes sur d’anciens comptes free (désactivées au sync).
|
|
232
|
+
* Conservées pour la détection `isFreeSelfServeAppAccess` jusqu’à resync.
|
|
233
|
+
*/
|
|
234
|
+
const FREE_SELF_SERVE_LEGACY_EXTRA_SLUGS: DashboardAppSlug[] = [
|
|
235
|
+
DashboardAppSlug.PLAYO,
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
/** Normalise slug API (`WORKSPACE`) ou clé URL (`workspace`) vers DashboardAppSlug. */
|
|
239
|
+
export function normalizeDashboardAppSlug(
|
|
240
|
+
value: string,
|
|
241
|
+
): DashboardAppSlug | null {
|
|
242
|
+
const upper = value.toUpperCase();
|
|
243
|
+
if (DASHBOARD_APP_BY_SLUG[upper as DashboardAppSlug]) {
|
|
244
|
+
return upper as DashboardAppSlug;
|
|
245
|
+
}
|
|
246
|
+
return dashboardAppKeyToSlug(value.toLowerCase());
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* True si la whitelist explicite du groupement est limitée au preset free
|
|
251
|
+
* (aucune app hors FREE_SELF_SERVE, hors extras legacy). Aucune ligne / defaults plein → false.
|
|
252
|
+
* Accepte slugs (`WORKSPACE`) ou clés (`workspace`).
|
|
253
|
+
*/
|
|
254
|
+
export function isFreeSelfServeAppAccess(
|
|
255
|
+
enabledSlugs: ReadonlyArray<string>,
|
|
256
|
+
): boolean {
|
|
257
|
+
if (enabledSlugs.length === 0) return false;
|
|
258
|
+
const free = new Set<string>([
|
|
259
|
+
...FREE_SELF_SERVE_DASHBOARD_APP_SLUGS,
|
|
260
|
+
...FREE_SELF_SERVE_LEGACY_EXTRA_SLUGS,
|
|
261
|
+
]);
|
|
262
|
+
return enabledSlugs.every((slug) => {
|
|
263
|
+
const normalized = normalizeDashboardAppSlug(slug);
|
|
264
|
+
return normalized != null && free.has(normalized);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Résout les apps actives à partir des lignes `city_group_app_access`.
|
|
270
|
+
* - Aucune ligne → defaults « plein » (compat collectivités existantes).
|
|
271
|
+
* - Au moins une ligne → **whitelist stricte** des `enabled: true` (mode restreint possible).
|
|
272
|
+
*/
|
|
273
|
+
export function resolveEnabledDashboardAppSlugs(
|
|
274
|
+
rows: ReadonlyArray<{ appSlug: string; enabled: boolean }>,
|
|
275
|
+
): DashboardAppSlug[] {
|
|
276
|
+
if (rows.length === 0) {
|
|
277
|
+
return [...DEFAULT_ENABLED_DASHBOARD_APP_SLUGS];
|
|
278
|
+
}
|
|
279
|
+
const enabled = rows
|
|
280
|
+
.filter((r) => r.enabled)
|
|
281
|
+
.map((r) => r.appSlug as DashboardAppSlug)
|
|
282
|
+
.filter((slug) => DASHBOARD_APPS.some((a) => a.slug === slug));
|
|
283
|
+
return [...new Set(enabled)];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function dashboardAppSlugToKey(slug: DashboardAppSlug): string {
|
|
287
|
+
return DASHBOARD_APP_BY_SLUG[slug]?.key ?? slug.toLowerCase();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function dashboardAppKeyToSlug(key: string): DashboardAppSlug | null {
|
|
291
|
+
return DASHBOARD_APP_BY_KEY[key]?.slug ?? null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** Domaine racine des landings Wast-O (ex. `wasto.localhost` en dev). */
|
|
295
|
+
export const WASTO_LANDINGS_DOMAIN = 'wasto.localhost';
|
|
296
|
+
|
|
297
|
+
/** Hôte de l’index des landings (catalogue de toutes les apps). */
|
|
298
|
+
export const WASTO_LANDINGS_INDEX_HOST = `apps.${WASTO_LANDINGS_DOMAIN}`;
|
|
299
|
+
|
|
300
|
+
/** Hôtes Traefik déjà réservés sous `*.wasto.localhost` (hors landings par module). */
|
|
301
|
+
export const WASTO_RESERVED_SUBDOMAINS = new Set([
|
|
302
|
+
'api',
|
|
303
|
+
'admin',
|
|
304
|
+
'dashboard',
|
|
305
|
+
'docs',
|
|
306
|
+
'field-survey',
|
|
307
|
+
'apps',
|
|
308
|
+
]);
|
|
309
|
+
|
|
310
|
+
export function isDashboardAppLandingHost(host: string): boolean {
|
|
311
|
+
const normalized = host.split(':')[0]?.toLowerCase() ?? '';
|
|
312
|
+
if (normalized === WASTO_LANDINGS_INDEX_HOST) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
const match = normalized.match(/^([a-z]+)\.wasto\.localhost$/);
|
|
316
|
+
if (!match) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const subdomain = match[1];
|
|
320
|
+
if (WASTO_RESERVED_SUBDOMAINS.has(subdomain)) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
return Boolean(DASHBOARD_APP_BY_KEY[subdomain]);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function dashboardAppKeyFromLandingHost(host: string): string | null {
|
|
327
|
+
const normalized = host.split(':')[0]?.toLowerCase() ?? '';
|
|
328
|
+
if (normalized === WASTO_LANDINGS_INDEX_HOST) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
const match = normalized.match(/^([a-z]+)\.wasto\.localhost$/);
|
|
332
|
+
if (!match) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const key = match[1];
|
|
336
|
+
if (WASTO_RESERVED_SUBDOMAINS.has(key) || !DASHBOARD_APP_BY_KEY[key]) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
return key;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
type ResolveLandingUrlOptions = {
|
|
343
|
+
/** Domaine racine (défaut : `wasto.localhost`). */
|
|
344
|
+
domain?: string;
|
|
345
|
+
/** Protocole (défaut : `http` en dev, `https` si `NODE_ENV=production`). */
|
|
346
|
+
protocol?: string;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/** URL publique de la landing d’un module (ex. `http://acto.wasto.localhost`). */
|
|
350
|
+
export function resolveDashboardAppLandingUrl(
|
|
351
|
+
key: string,
|
|
352
|
+
options?: ResolveLandingUrlOptions,
|
|
353
|
+
): string | null {
|
|
354
|
+
if (!DASHBOARD_APP_BY_KEY[key]) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
const domain = options?.domain ?? WASTO_LANDINGS_DOMAIN;
|
|
358
|
+
const protocol = options?.protocol ?? 'http';
|
|
359
|
+
return `${protocol}://${key}.${domain}`;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** URL de l’index des landings Wast-O (ex. `http://apps.wasto.localhost`). */
|
|
363
|
+
export function resolveWastoLandingsIndexUrl(options?: ResolveLandingUrlOptions): string {
|
|
364
|
+
const domain = options?.domain ?? WASTO_LANDINGS_DOMAIN;
|
|
365
|
+
const protocol = options?.protocol ?? 'http';
|
|
366
|
+
return `${protocol}://apps.${domain}`;
|
|
367
|
+
}
|