@opengis/surveyor 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/chunks/{AppIcon-CO70tpMX.js → AppIcon-Di5F4Bu_.js} +1 -1
  2. package/dist/chunks/{AppealDetailField-ByK9ZqR4.js → AppealDetailField-CWayoaII.js} +2 -2
  3. package/dist/chunks/AppealStatusBadge-RQkpbDmk.js +430 -0
  4. package/dist/chunks/{AppealStatusBadge-BlAaNUSK.js → AppealStatusBadge-z77wwkFD.js} +2 -2
  5. package/dist/chunks/{ApplicationGeometryExportModal-DhKC31To.js → ApplicationGeometryExportModal-CH9VrqxO.js} +312 -324
  6. package/dist/chunks/{BaseModal-BJxKuONh.js → BaseModal-X-hzV_I2.js} +2 -2
  7. package/dist/chunks/{FormFilePicker-DxPQlxgy.js → FormFilePicker-D5fAUE0Z.js} +2 -2
  8. package/dist/chunks/{MapLayerMenu-B0TEoCJm.js → MapLayerMenu-CyVxRSNX.js} +1 -1
  9. package/dist/chunks/{RegistryForm-Dpis_ncj.js → RegistryForm-J7R4RWO3.js} +1 -1
  10. package/dist/chunks/{RegistryFormModal-CH4DbTvC.js → RegistryFormModal-B_EDwu9O.js} +3 -3
  11. package/dist/chunks/{RegistryToolbar-DisEejvi.js → RegistryToolbar-BDVaZ2Rf.js} +5 -5
  12. package/dist/chunks/{SurveyorTeleport-Cd6D92mo.js → SurveyorTeleport-Y-NJhfsb.js} +1 -1
  13. package/dist/chunks/{TablePagination-thQkE5iA.js → TablePagination-CZhRgCVr.js} +2 -2
  14. package/dist/chunks/{UserAccessBadge-DyZDv7Oo.js → UserAccessBadge-B5Q1LvNv.js} +1 -1
  15. package/dist/chunks/{UserTypeBadge-LvnMuKGo.js → UserTypeBadge-CuAMctTK.js} +1 -1
  16. package/dist/chunks/{VerifiedBadge-bk0n-rlC.js → VerifiedBadge-D6L7mCdp.js} +2 -2
  17. package/dist/chunks/{card-n83dNORm.js → card-BMe6jQRR.js} +10 -10
  18. package/dist/chunks/{card-DVuqR0rL.js → card-Bw_EXY3D.js} +4 -4
  19. package/dist/chunks/{card-Cs8_8A8i.js → card-Cll0FQ0z.js} +6 -6
  20. package/dist/chunks/{card-u5I--_Gb.js → card-DMt5SAoD.js} +5 -5
  21. package/dist/chunks/{card-DuGbROGY.js → card-Dy333mEd.js} +9 -9
  22. package/dist/chunks/card-pTFhEtmI.js +1264 -0
  23. package/dist/chunks/{certificates-CDunSANR.js → certificates-URuwsRqg.js} +6 -6
  24. package/dist/chunks/{create-DQPxIZMW.js → create-CJXITPL0.js} +9 -9
  25. package/dist/chunks/downloadAttachmentFilename-B_4jZuOa.js +11 -0
  26. package/dist/chunks/{forgot-DfsFu-yY.js → forgot-JFlAKndO.js} +2 -2
  27. package/dist/chunks/{login-Dl0nTWs9.js → login-Bd6krLDP.js} +2 -2
  28. package/dist/chunks/{map-BoHEgBCw.js → map-BZg1CvsE.js} +44 -44
  29. package/dist/chunks/{map-layers-CRE8lZzH.js → map-layers-BgK6h6AD.js} +6 -6
  30. package/dist/chunks/{organizations-D6aazMAe.js → organizations-BLYhVQwf.js} +7 -7
  31. package/dist/chunks/{profile-CkwMFh82.js → profile-F7mr0poI.js} +3 -3
  32. package/dist/chunks/{registration-BSz1iLbO.js → registration-DIA4xV-t.js} +2 -2
  33. package/dist/chunks/{requests-D1ix8U5f.js → requests-CPVQ1Yy_.js} +5 -5
  34. package/dist/chunks/{requests-B9Ejt4av.js → requests-DhLUiL_6.js} +9 -9
  35. package/dist/chunks/{reset-D5G0x5Zi.js → reset-DR3GXwrH.js} +2 -2
  36. package/dist/chunks/{useEntityPath-C5Owtidc.js → useEntityPath-8s0Y1tjA.js} +1 -1
  37. package/dist/chunks/{users-DMe6JYI0.js → users-BsWV3iTt.js} +7 -7
  38. package/dist/index.js +40 -40
  39. package/migrations/20261016120000_map_layers.sql +156 -156
  40. package/migrations/20261016150000_password_reset.sql +15 -15
  41. package/migrations/20261016180000_settlement_lookup.sql +16 -16
  42. package/package.json +80 -80
  43. package/server/dictionaries/index.ts +17 -17
  44. package/server/dictionaries/surveyor/map_layer_components.ts +11 -11
  45. package/server/dictionaries/surveyor/map_layer_groups.ts +10 -10
  46. package/server/dictionaries/surveyor/map_layer_types.ts +11 -11
  47. package/server/modules/surveyor/route.ts +20 -0
  48. package/server/modules/surveyor/schema.ts +11 -0
  49. package/server/modules/surveyor/services/changeApplicationStatus.ts +100 -0
  50. package/server/modules/surveyor/services/mapLayers.ts +61 -61
  51. package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -79
  52. package/server/resources/helpers/settlement_lookup.ts +7 -7
  53. package/server/resources/surveyor-admin/applications.ts +126 -126
  54. package/server/resources/surveyor-admin/certificates.ts +113 -113
  55. package/server/resources/surveyor-admin/organization_surveyors.ts +31 -31
  56. package/dist/chunks/AppealStatusBadge-DzMn4RVy.js +0 -295
  57. package/dist/chunks/card-BP2byleo.js +0 -1327
@@ -1,11 +1,11 @@
1
- import type { DictionaryDefinition } from "@opengis/fcore";
2
-
3
- export default {
4
- code: "map-layer-types",
5
- name: "Типи шарів карти",
6
- items: [
7
- { code: "raster", name: "Растрові тайли" },
8
- { code: "vector", name: "Векторні тайли" },
9
- { code: "applications", name: "Заявки" },
10
- ],
11
- } satisfies DictionaryDefinition;
1
+ import type { DictionaryDefinition } from "@opengis/fcore";
2
+
3
+ export default {
4
+ code: "map-layer-types",
5
+ name: "Типи шарів карти",
6
+ items: [
7
+ { code: "raster", name: "Растрові тайли" },
8
+ { code: "vector", name: "Векторні тайли" },
9
+ { code: "applications", name: "Заявки" },
10
+ ],
11
+ } satisfies DictionaryDefinition;
@@ -1,6 +1,8 @@
1
1
  import type { AppContext } from "@opengis/fcore";
2
2
  import type { FastifyPluginAsync, FastifySchema } from "fastify";
3
3
  import { cancelApplication } from "./services/cancelApplication.js";
4
+ import { changeApplicationStatus } from "./services/changeApplicationStatus.js";
5
+ import type { Status } from "./utils/shared.js";
4
6
  import { completeApplication } from "./services/completeApplication.js";
5
7
  import { createApplication } from "./services/createApplication.js";
6
8
  import { issueSourceData } from "./services/issueSourceData.js";
@@ -99,6 +101,24 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
99
101
  ctx,
100
102
  })
101
103
  );
104
+ app.post<ApplicationRoute & { Body: { status: Status; reason?: string | null } }>(
105
+ "/api/surveyor/applications/:applicationId/status",
106
+ {
107
+ schema: {
108
+ ...staff("applications:update"),
109
+ params: surveyorSchemas.applicationParams,
110
+ body: surveyorSchemas.changeApplicationStatus,
111
+ },
112
+ },
113
+ async (req) =>
114
+ changeApplicationStatus({
115
+ id: req.params.applicationId,
116
+ status: req.body.status,
117
+ reason: req.body.reason,
118
+ user: req.user,
119
+ ctx,
120
+ })
121
+ );
102
122
  app.post<ApplicationRoute & { Body: FileInput }>(
103
123
  "/api/surveyor/applications/:applicationId/upload-source-data",
104
124
  {
@@ -181,6 +181,17 @@ export const surveyorSchemas = {
181
181
  properties: { reason: nonBlank },
182
182
  additionalProperties: false,
183
183
  },
184
+ changeApplicationStatus: {
185
+ type: "object",
186
+ required: ["status"],
187
+ properties: {
188
+ status: { type: "string", enum: applicationStatus },
189
+ reason: { type: ["string", "null"] },
190
+ },
191
+ if: { properties: { status: { const: "cancelled" } } },
192
+ then: { required: ["reason"], properties: { reason: nonBlank } },
193
+ additionalProperties: false,
194
+ },
184
195
  fileBody,
185
196
  verifyApplication: {
186
197
  type: "object",
@@ -0,0 +1,100 @@
1
+ import type { AppContext, User } from "@opengis/fcore";
2
+ import { BadRequestError, ConflictError, FCoreError, ForbiddenError } from "@opengis/fcore";
3
+ import {
4
+ admin,
5
+ audit,
6
+ history,
7
+ readApplication,
8
+ releaseReservesForParent,
9
+ type Db,
10
+ type Status,
11
+ } from "../utils/shared.js";
12
+
13
+ /** Статуси, з яких службовий користувач (не адміністратор) може скасувати заявку. */
14
+ export const STAFF_CANCELLABLE_STATUSES: Status[] = ["reserve", "awaitingData", "dataIssued"];
15
+
16
+ /**
17
+ * Ручна зміна статусу заявки з адмінки.
18
+ * Адміністратор (`type = admin`) може встановити будь-який статус на будь-якому етапі;
19
+ * користувач із правом `applications:update` (через роль) — лише скасувати заявку
20
+ * в статусах `reserve`, `awaitingData`, `dataIssued`.
21
+ * @param params Заявка, новий статус, причина, користувач і контекст FCore.
22
+ * @returns Новий статус і перелік заявок, знятих із резерву.
23
+ */
24
+ export async function changeApplicationStatus({
25
+ id,
26
+ status,
27
+ reason,
28
+ user,
29
+ ctx,
30
+ }: {
31
+ id: string;
32
+ status: Status;
33
+ reason?: string | null;
34
+ user: User | undefined;
35
+ ctx: AppContext;
36
+ }) {
37
+ const uid = admin(user, "applications:update");
38
+ const isAdmin = user?.type === "admin";
39
+ const text = reason?.trim() || null;
40
+
41
+ if (!isAdmin && status !== "cancelled") {
42
+ throw new ForbiddenError("Only administrator can change application status");
43
+ }
44
+ if (status === "cancelled" && !text) {
45
+ throw new BadRequestError("Cancel reason is required");
46
+ }
47
+
48
+ const result = await ctx.pg.transaction(async (db: Db) => {
49
+ // Узгоджує зміну статусу та звільнення резервів із паралельним створенням заявок.
50
+ await db.query("SELECT pg_advisory_xact_lock(85437120)");
51
+ const app = await readApplication({ db, id });
52
+ const from = app.status;
53
+
54
+ if (from === status) {
55
+ throw new FCoreError("APPLICATION_INVALID_STATUS", `Application is already in ${status} status`, 409);
56
+ }
57
+ if (!isAdmin && !STAFF_CANCELLABLE_STATUSES.includes(from)) {
58
+ throw new FCoreError(
59
+ "APPLICATION_INVALID_STATUS",
60
+ `Application can be cancelled only in ${STAFF_CANCELLABLE_STATUSES.join(", ")} status`,
61
+ 409
62
+ );
63
+ }
64
+
65
+ const cancelled = status === "cancelled";
66
+ const updated = await db.query<{ app_id: string }>(
67
+ `UPDATE surveyor.applications
68
+ SET status = $2,
69
+ cancel_reason = CASE WHEN $4 THEN $5 ELSE NULL END,
70
+ cancelled_at = CASE WHEN $4 THEN now() ELSE NULL END,
71
+ cancelled_by = CASE WHEN $4 THEN $3 ELSE NULL END,
72
+ verified_at = CASE WHEN $2 = 'verified' THEN coalesce(verified_at, now()) ELSE verified_at END,
73
+ verified_by = CASE WHEN $2 = 'verified' THEN coalesce(verified_by, $3) ELSE verified_by END,
74
+ integrated_at = CASE WHEN $2 = 'completed' THEN coalesce(integrated_at, now()) ELSE integrated_at END,
75
+ integrated_by = CASE WHEN $2 = 'completed' THEN coalesce(integrated_by, $3) ELSE integrated_by END,
76
+ updated_by = $3,
77
+ updated_at = now()
78
+ WHERE app_id = $1 AND status = $6
79
+ RETURNING app_id`,
80
+ [id, status, uid, cancelled, text, from]
81
+ );
82
+ if (!updated.rows[0]) {
83
+ throw new ConflictError("Application changed concurrently");
84
+ }
85
+
86
+ await history({ db, appId: id, from, to: status, by: uid, reason: text });
87
+
88
+ const released =
89
+ status === "cancelled" || status === "completed"
90
+ ? await releaseReservesForParent({ db, parentId: id, uid })
91
+ : [];
92
+ return { id, status, released };
93
+ });
94
+
95
+ await audit({ ctx, action: status === "cancelled" ? "cancel" : "changeStatus", appId: id, uid });
96
+ for (const released of result.released) {
97
+ await audit({ ctx, action: "releaseReserve", appId: released, uid });
98
+ }
99
+ return result;
100
+ }
@@ -1,61 +1,61 @@
1
- import type { AppContext, User } from "@opengis/fcore";
2
- import { actor } from "../utils/shared.js";
3
-
4
- export type MapLayerComponent = "map" | "application-form" | "application-card";
5
-
6
- export type MapLayersInput = { component?: MapLayerComponent };
7
-
8
- export type MapLayer = {
9
- code: string;
10
- name: string;
11
- layer_group: "base" | "overlay";
12
- layer_type: "raster" | "vector" | "applications";
13
- tiles: string[];
14
- scheme: "xyz" | "tms";
15
- source_layer: string | null;
16
- attribution: string | null;
17
- minzoom: number | null;
18
- maxzoom: number | null;
19
- opacity: number;
20
- style: Record<string, unknown> | null;
21
- legend: Record<string, unknown> | null;
22
- preview: string | null;
23
- components: MapLayerComponent[];
24
- is_default: boolean;
25
- has_filters: boolean;
26
- };
27
-
28
- export type MapLayersResult = {
29
- default_base: string | null;
30
- base: MapLayer[];
31
- overlays: MapLayer[];
32
- };
33
-
34
- /**
35
- * Повертає увімкнені шари панелі карти, згруповані на базові та додаткові у порядку відображення.
36
- * Додаткові шари йдуть від верхнього до нижнього: перший у списку малюється поверх.
37
- * Якщо передано `component`, повертаються лише шари, налаштовані для цього компонента.
38
- */
39
- export async function mapLayers(
40
- { input, user, ctx }: { input: MapLayersInput; user: User | undefined; ctx: AppContext }
41
- ): Promise<MapLayersResult> {
42
- actor(user);
43
-
44
- const { rows }: { rows: MapLayer[] } = await ctx.pg.query(
45
- `SELECT code, name, layer_group, layer_type, tiles, scheme, source_layer, attribution,
46
- minzoom, maxzoom, opacity::float AS opacity, style, legend, preview, components,
47
- is_default, has_filters
48
- FROM surveyor.map_layers
49
- WHERE enabled
50
- AND ($1::text IS NULL OR components @> ARRAY[$1::text])
51
- ORDER BY layer_group, sort_order, name`,
52
- [input.component ?? null]
53
- );
54
-
55
- const base = rows.filter((layer) => layer.layer_group === "base");
56
- const overlays = rows.filter((layer) => layer.layer_group === "overlay");
57
- // Підложку вимкнути не можна, тому без явного значення активна перша.
58
- const defaultBase = base.find((layer) => layer.is_default) ?? base[0];
59
-
60
- return { default_base: defaultBase?.code ?? null, base, overlays };
61
- }
1
+ import type { AppContext, User } from "@opengis/fcore";
2
+ import { actor } from "../utils/shared.js";
3
+
4
+ export type MapLayerComponent = "map" | "application-form" | "application-card";
5
+
6
+ export type MapLayersInput = { component?: MapLayerComponent };
7
+
8
+ export type MapLayer = {
9
+ code: string;
10
+ name: string;
11
+ layer_group: "base" | "overlay";
12
+ layer_type: "raster" | "vector" | "applications";
13
+ tiles: string[];
14
+ scheme: "xyz" | "tms";
15
+ source_layer: string | null;
16
+ attribution: string | null;
17
+ minzoom: number | null;
18
+ maxzoom: number | null;
19
+ opacity: number;
20
+ style: Record<string, unknown> | null;
21
+ legend: Record<string, unknown> | null;
22
+ preview: string | null;
23
+ components: MapLayerComponent[];
24
+ is_default: boolean;
25
+ has_filters: boolean;
26
+ };
27
+
28
+ export type MapLayersResult = {
29
+ default_base: string | null;
30
+ base: MapLayer[];
31
+ overlays: MapLayer[];
32
+ };
33
+
34
+ /**
35
+ * Повертає увімкнені шари панелі карти, згруповані на базові та додаткові у порядку відображення.
36
+ * Додаткові шари йдуть від верхнього до нижнього: перший у списку малюється поверх.
37
+ * Якщо передано `component`, повертаються лише шари, налаштовані для цього компонента.
38
+ */
39
+ export async function mapLayers(
40
+ { input, user, ctx }: { input: MapLayersInput; user: User | undefined; ctx: AppContext }
41
+ ): Promise<MapLayersResult> {
42
+ actor(user);
43
+
44
+ const { rows }: { rows: MapLayer[] } = await ctx.pg.query(
45
+ `SELECT code, name, layer_group, layer_type, tiles, scheme, source_layer, attribution,
46
+ minzoom, maxzoom, opacity::float AS opacity, style, legend, preview, components,
47
+ is_default, has_filters
48
+ FROM surveyor.map_layers
49
+ WHERE enabled
50
+ AND ($1::text IS NULL OR components @> ARRAY[$1::text])
51
+ ORDER BY layer_group, sort_order, name`,
52
+ [input.component ?? null]
53
+ );
54
+
55
+ const base = rows.filter((layer) => layer.layer_group === "base");
56
+ const overlays = rows.filter((layer) => layer.layer_group === "overlay");
57
+ // Підложку вимкнути не можна, тому без явного значення активна перша.
58
+ const defaultBase = base.find((layer) => layer.is_default) ?? base[0];
59
+
60
+ return { default_base: defaultBase?.code ?? null, base, overlays };
61
+ }
@@ -1,79 +1,79 @@
1
- <!DOCTYPE html>
2
- <html lang="uk">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Відновлення пароля</title>
8
- <style>
9
- body {
10
- font-family: Arial, sans-serif;
11
- color: #333;
12
- background-color: #f4f4f4;
13
- padding: 20px;
14
- }
15
-
16
- .email-container {
17
- max-width: 600px;
18
- margin: 0 auto;
19
- background-color: #ffffff;
20
- padding: 20px;
21
- border-radius: 5px;
22
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
23
- }
24
-
25
- h1 {
26
- font-size: 20px;
27
- color: #000;
28
- margin-bottom: 20px;
29
- }
30
-
31
- p {
32
- line-height: 1.6;
33
- margin: 10px 0;
34
- }
35
-
36
- .credentials {
37
- font-weight: bold;
38
- margin-top: 10px;
39
- }
40
-
41
- a {
42
- color: #007bff;
43
- text-decoration: none;
44
- }
45
-
46
- a:hover {
47
- text-decoration: underline;
48
- }
49
-
50
- .footer {
51
- font-size: 12px;
52
- color: #777;
53
- margin-top: 20px;
54
- text-align: center;
55
- }
56
- </style>
57
- </head>
58
-
59
- <body>
60
- <div class="email-container">
61
- <h1>Відновлення пароля до
62
- <a target="_blank" href="{{protocol}}://{{host}}">кабінету геодезиста</a>
63
- </h1>
64
- <p class="credentials">
65
- Логін: <strong>{{login}}</strong>
66
- </p>
67
- <p>
68
- Щоб встановити новий пароль, відкрийте це посилання або скопіюйте його в адресний рядок вашого браузера:<br>
69
- <a target="_blank" href="{{resetUrl}}">{{resetUrl}}</a>
70
- </p>
71
- <p>Посилання дійсне протягом 1 години і може бути використане лише один раз.</p>
72
- <p>Якщо ви не надсилали запит на відновлення пароля, проігноруйте цей лист — ваш поточний пароль залишиться без змін.</p>
73
- <div class="footer">
74
- Це автоматично створений лист, будь ласка, не відповідайте на нього.
75
- </div>
76
- </div>
77
- </body>
78
-
79
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="uk">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Відновлення пароля</title>
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ color: #333;
12
+ background-color: #f4f4f4;
13
+ padding: 20px;
14
+ }
15
+
16
+ .email-container {
17
+ max-width: 600px;
18
+ margin: 0 auto;
19
+ background-color: #ffffff;
20
+ padding: 20px;
21
+ border-radius: 5px;
22
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
23
+ }
24
+
25
+ h1 {
26
+ font-size: 20px;
27
+ color: #000;
28
+ margin-bottom: 20px;
29
+ }
30
+
31
+ p {
32
+ line-height: 1.6;
33
+ margin: 10px 0;
34
+ }
35
+
36
+ .credentials {
37
+ font-weight: bold;
38
+ margin-top: 10px;
39
+ }
40
+
41
+ a {
42
+ color: #007bff;
43
+ text-decoration: none;
44
+ }
45
+
46
+ a:hover {
47
+ text-decoration: underline;
48
+ }
49
+
50
+ .footer {
51
+ font-size: 12px;
52
+ color: #777;
53
+ margin-top: 20px;
54
+ text-align: center;
55
+ }
56
+ </style>
57
+ </head>
58
+
59
+ <body>
60
+ <div class="email-container">
61
+ <h1>Відновлення пароля до
62
+ <a target="_blank" href="{{protocol}}://{{host}}">кабінету геодезиста</a>
63
+ </h1>
64
+ <p class="credentials">
65
+ Логін: <strong>{{login}}</strong>
66
+ </p>
67
+ <p>
68
+ Щоб встановити новий пароль, відкрийте це посилання або скопіюйте його в адресний рядок вашого браузера:<br>
69
+ <a target="_blank" href="{{resetUrl}}">{{resetUrl}}</a>
70
+ </p>
71
+ <p>Посилання дійсне протягом 1 години і може бути використане лише один раз.</p>
72
+ <p>Якщо ви не надсилали запит на відновлення пароля, проігноруйте цей лист — ваш поточний пароль залишиться без змін.</p>
73
+ <div class="footer">
74
+ Це автоматично створений лист, будь ласка, не відповідайте на нього.
75
+ </div>
76
+ </div>
77
+ </body>
78
+
79
+ </html>
@@ -1,7 +1,7 @@
1
- // The view prefixes the settlement name with its type for lookup labels.
2
- export const settlementLookup = {
3
- table: "surveyor.settlement_lookup",
4
- value: "katottg",
5
- text: "settlement_text",
6
- filterFields: ["level"],
7
- };
1
+ // The view prefixes the settlement name with its type for lookup labels.
2
+ export const settlementLookup = {
3
+ table: "surveyor.settlement_lookup",
4
+ value: "katottg",
5
+ text: "settlement_text",
6
+ filterFields: ["level"],
7
+ };