@opengis/surveyor 0.0.9 → 0.0.10
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 +4 -3
- package/dist/chunks/{AppIcon-CO70tpMX.js → AppIcon-Di5F4Bu_.js} +1 -1
- package/dist/chunks/{AppealDetailField-DNRGpnyD.js → AppealDetailField-DNpsGpPY.js} +2 -2
- package/dist/chunks/{AppealStatusBadge-Cu-UzdzA.js → AppealStatusBadge-MP1qD952.js} +1 -1
- package/dist/chunks/{AppealStatusBadge-BlAaNUSK.js → AppealStatusBadge-z77wwkFD.js} +2 -2
- package/dist/chunks/{ApplicationHistorySection-Cwq0-Frd.js → ApplicationHistorySection-DIoFZwH6.js} +4 -4
- package/dist/chunks/{BaseModal-SQXvRRNW.js → BaseModal-DP_ilBdg.js} +21 -11
- package/dist/chunks/{FormFilePicker-DxPQlxgy.js → FormFilePicker-D5fAUE0Z.js} +2 -2
- package/dist/chunks/{MapLayerMenu-AUeTqgEp.js → MapLayerMenu-CI5cbLEC.js} +1 -1
- package/dist/chunks/{RegistryForm-wG-c8GKf.js → RegistryForm-DbCxZsr0.js} +1 -1
- package/dist/chunks/{RegistryFormModal-R_iZYqGE.js → RegistryFormModal-D_KLGj2d.js} +3 -3
- package/dist/chunks/{RegistryToolbar-322DKUXi.js → RegistryToolbar-DvbrASlj.js} +6 -6
- package/dist/chunks/{SurveyorTeleport-CnSF0Ptl.js → SurveyorTeleport-D6-KXe_5.js} +1 -1
- package/dist/chunks/{UserAccessBadge-DyZDv7Oo.js → UserAccessBadge-B5Q1LvNv.js} +1 -1
- package/dist/chunks/{UserTypeBadge-LvnMuKGo.js → UserTypeBadge-CuAMctTK.js} +1 -1
- package/dist/chunks/{VerifiedBadge-bk0n-rlC.js → VerifiedBadge-D6L7mCdp.js} +2 -2
- package/dist/chunks/{card-CWqi1K-x.js → card--XUb1kFK.js} +4 -4
- package/dist/chunks/{card-C3y-j2TA.js → card-BrjnXf1N.js} +6 -6
- package/dist/chunks/{card-6z-m7UkM.js → card-BsTSF6aL.js} +10 -10
- package/dist/chunks/{card-Dlp8_KhV.js → card-CI7ntIHf.js} +5 -5
- package/dist/chunks/{card-DWpAv92l.js → card-Cu8QOSIw.js} +4 -4
- package/dist/chunks/{card-X9UVFgdR.js → card-ylC5NYbz.js} +241 -208
- package/dist/chunks/certificates-BnseQylH.js +209 -0
- package/dist/chunks/certificates-aJ-hvaP-.js +236 -0
- package/dist/chunks/{create-DR8tXNYj.js → create-Bi7-j9Ri.js} +9 -9
- package/dist/chunks/{forgot-DoG6vXhq.js → forgot-DnixBqdc.js} +2 -2
- package/dist/chunks/{login-BWGylcSU.js → login-BWCQdEkv.js} +2 -2
- package/dist/chunks/{map-DvwFkxAS.js → map-CwsVIW79.js} +940 -831
- package/dist/chunks/{map-layers-sT-gTiD_.js → map-layers-BLiEYC4C.js} +5 -5
- package/dist/chunks/{organizations-ByVE2f0c.js → organizations-mc6FlSwe.js} +6 -6
- package/dist/chunks/{profile-CkwMFh82.js → profile-F7mr0poI.js} +3 -3
- package/dist/chunks/{registration-3GLgq-ae.js → registration-BRF4985_.js} +2 -2
- package/dist/chunks/{requests-BTpLXrNj.js → requests-7pD2ckdx.js} +4 -4
- package/dist/chunks/{requests-rWq8ok3C.js → requests-BCJN-CNx.js} +5 -5
- package/dist/chunks/{reset-CP9LsLkC.js → reset-OZCgLi6f.js} +2 -2
- package/dist/chunks/{useEntityPath-C5Owtidc.js → useEntityPath-8s0Y1tjA.js} +1 -1
- package/dist/chunks/{users-U1P6xCP4.js → users-CAEjpaI1.js} +6 -6
- package/dist/index.css +1 -1
- package/dist/index.js +40 -40
- package/migrations/20261016120000_map_layers.sql +156 -156
- package/migrations/20261016150000_password_reset.sql +15 -15
- package/migrations/20261016180000_settlement_lookup.sql +16 -16
- package/package.json +1 -1
- package/server/dictionaries/index.ts +17 -17
- package/server/dictionaries/surveyor/map_layer_components.ts +11 -11
- package/server/dictionaries/surveyor/map_layer_groups.ts +10 -10
- package/server/dictionaries/surveyor/map_layer_types.ts +11 -11
- package/server/modules/surveyor/services/createApplication.ts +2 -3
- package/server/modules/surveyor/services/mapLayers.ts +61 -61
- package/server/modules/surveyor/services/registerSurveyor.ts +3 -4
- package/server/modules/surveyor/services/requestPasswordReset.ts +1 -0
- package/server/modules/surveyor/services/resetSurveyorPassword.ts +1 -0
- package/server/modules/surveyor/services/updateSurveyorAccountStatus.ts +52 -52
- package/server/modules/surveyor/services/updateSurveyorStatus.ts +53 -53
- package/server/modules/surveyor/utils/certificateStatus.ts +15 -0
- package/server/modules/surveyor/utils/mail.ts +49 -20
- package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -79
- package/server/resources/helpers/settlement_lookup.ts +7 -7
- package/server/resources/surveyor-admin/certificates.ts +27 -1
- package/server/resources/surveyor-admin/map_layers.ts +69 -69
- package/server/resources/surveyor-admin/organization_surveyors.ts +31 -31
- package/server/resources/surveyor-admin/organizations.ts +61 -61
- package/dist/chunks/certificates-Cwch72-o.js +0 -425
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
-- Settlement lookup labels with the settlement type: "м. Львів", "с. Лисиничі".
|
|
2
|
-
CREATE OR REPLACE VIEW surveyor.settlement_lookup AS
|
|
3
|
-
SELECT
|
|
4
|
-
settlement.katottg,
|
|
5
|
-
settlement.level,
|
|
6
|
-
concat_ws(' ',
|
|
7
|
-
CASE settlement.type
|
|
8
|
-
WHEN 201 THEN 'м.'
|
|
9
|
-
WHEN 501 THEN 'м.'
|
|
10
|
-
WHEN 503 THEN 'смт'
|
|
11
|
-
WHEN 504 THEN 'с.'
|
|
12
|
-
WHEN 505 THEN 'с-ще'
|
|
13
|
-
END,
|
|
14
|
-
trim(settlement.name)
|
|
15
|
-
) AS settlement_text
|
|
16
|
-
FROM data_address.atu AS settlement;
|
|
1
|
+
-- Settlement lookup labels with the settlement type: "м. Львів", "с. Лисиничі".
|
|
2
|
+
CREATE OR REPLACE VIEW surveyor.settlement_lookup AS
|
|
3
|
+
SELECT
|
|
4
|
+
settlement.katottg,
|
|
5
|
+
settlement.level,
|
|
6
|
+
concat_ws(' ',
|
|
7
|
+
CASE settlement.type
|
|
8
|
+
WHEN 201 THEN 'м.'
|
|
9
|
+
WHEN 501 THEN 'м.'
|
|
10
|
+
WHEN 503 THEN 'смт'
|
|
11
|
+
WHEN 504 THEN 'с.'
|
|
12
|
+
WHEN 505 THEN 'с-ще'
|
|
13
|
+
END,
|
|
14
|
+
trim(settlement.name)
|
|
15
|
+
) AS settlement_text
|
|
16
|
+
FROM data_address.atu AS settlement;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import applicationStatus from "./surveyor/application_status.js";
|
|
2
|
-
import workTypes from "./surveyor/work_types.js";
|
|
3
|
-
import accountTypes from "./surveyor/account_types.js";
|
|
4
|
-
import yesNo from "./surveyor/yes_no.js";
|
|
5
|
-
import mapLayerGroups from "./surveyor/map_layer_groups.js";
|
|
6
|
-
import mapLayerTypes from "./surveyor/map_layer_types.js";
|
|
7
|
-
import mapLayerComponents from "./surveyor/map_layer_components.js";
|
|
8
|
-
|
|
9
|
-
export default [
|
|
10
|
-
applicationStatus,
|
|
11
|
-
workTypes,
|
|
12
|
-
accountTypes,
|
|
13
|
-
yesNo,
|
|
14
|
-
mapLayerGroups,
|
|
15
|
-
mapLayerTypes,
|
|
16
|
-
mapLayerComponents,
|
|
17
|
-
];
|
|
1
|
+
import applicationStatus from "./surveyor/application_status.js";
|
|
2
|
+
import workTypes from "./surveyor/work_types.js";
|
|
3
|
+
import accountTypes from "./surveyor/account_types.js";
|
|
4
|
+
import yesNo from "./surveyor/yes_no.js";
|
|
5
|
+
import mapLayerGroups from "./surveyor/map_layer_groups.js";
|
|
6
|
+
import mapLayerTypes from "./surveyor/map_layer_types.js";
|
|
7
|
+
import mapLayerComponents from "./surveyor/map_layer_components.js";
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
applicationStatus,
|
|
11
|
+
workTypes,
|
|
12
|
+
accountTypes,
|
|
13
|
+
yesNo,
|
|
14
|
+
mapLayerGroups,
|
|
15
|
+
mapLayerTypes,
|
|
16
|
+
mapLayerComponents,
|
|
17
|
+
];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { DictionaryDefinition } from "@opengis/fcore";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
code: "map-layer-components",
|
|
5
|
-
name: "Компоненти карти",
|
|
6
|
-
items: [
|
|
7
|
-
{ code: "map", name: "Карта" },
|
|
8
|
-
{ code: "application-form", name: "Форма окреслення геометрії заявки" },
|
|
9
|
-
{ code: "application-card", name: "Картка заявки" },
|
|
10
|
-
],
|
|
11
|
-
} satisfies DictionaryDefinition;
|
|
1
|
+
import type { DictionaryDefinition } from "@opengis/fcore";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
code: "map-layer-components",
|
|
5
|
+
name: "Компоненти карти",
|
|
6
|
+
items: [
|
|
7
|
+
{ code: "map", name: "Карта" },
|
|
8
|
+
{ code: "application-form", name: "Форма окреслення геометрії заявки" },
|
|
9
|
+
{ code: "application-card", name: "Картка заявки" },
|
|
10
|
+
],
|
|
11
|
+
} satisfies DictionaryDefinition;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { DictionaryDefinition } from "@opengis/fcore";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
code: "map-layer-groups",
|
|
5
|
-
name: "Групи шарів карти",
|
|
6
|
-
items: [
|
|
7
|
-
{ code: "base", name: "Базовий шар" },
|
|
8
|
-
{ code: "overlay", name: "Додатковий шар" },
|
|
9
|
-
],
|
|
10
|
-
} satisfies DictionaryDefinition;
|
|
1
|
+
import type { DictionaryDefinition } from "@opengis/fcore";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
code: "map-layer-groups",
|
|
5
|
+
name: "Групи шарів карти",
|
|
6
|
+
items: [
|
|
7
|
+
{ code: "base", name: "Базовий шар" },
|
|
8
|
+
{ code: "overlay", name: "Додатковий шар" },
|
|
9
|
+
],
|
|
10
|
+
} satisfies DictionaryDefinition;
|
|
@@ -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;
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type Db,
|
|
9
9
|
} from "../utils/shared.js";
|
|
10
10
|
import { limit, polygon, type CreateInput } from "../utils/application.js";
|
|
11
|
+
import { certificateStatusSql } from "../utils/certificateStatus.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Створює заявку після перевірки сертифіката, членства, адреси, площі та перетинів.
|
|
@@ -36,9 +37,7 @@ export async function createApplication(
|
|
|
36
37
|
WHERE s.surveyor_id = $1
|
|
37
38
|
AND os.org_id = $2
|
|
38
39
|
AND os.enabled = true
|
|
39
|
-
AND c
|
|
40
|
-
AND c.certificate_suspension IS NULL
|
|
41
|
-
AND c.isvalid IS NOT FALSE`,
|
|
40
|
+
AND ${certificateStatusSql("c")} = 'valid'`,
|
|
42
41
|
[surveyorId, orgId]
|
|
43
42
|
);
|
|
44
43
|
if (!profile.rowCount) {
|
|
@@ -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
|
+
}
|
|
@@ -3,6 +3,7 @@ import { ConflictError, NotFoundError } from "@opengis/fcore";
|
|
|
3
3
|
import { admin, type Db } from "../utils/shared.js";
|
|
4
4
|
import { token, tokenHash } from "../utils/registration.js";
|
|
5
5
|
import { sendActivationEmail } from "../utils/mail.js";
|
|
6
|
+
import { certificateStatusSql } from "../utils/certificateStatus.js";
|
|
6
7
|
|
|
7
8
|
export type RegisterInput = {
|
|
8
9
|
organization_id: string;
|
|
@@ -38,11 +39,9 @@ export async function registerSurveyor(
|
|
|
38
39
|
middle_name: string | null;
|
|
39
40
|
}>(
|
|
40
41
|
`SELECT first_name, last_name, middle_name
|
|
41
|
-
FROM surveyor.certificates
|
|
42
|
+
FROM surveyor.certificates AS c
|
|
42
43
|
WHERE certificate_id = $1
|
|
43
|
-
AND
|
|
44
|
-
AND certificate_suspension IS NULL
|
|
45
|
-
AND isvalid IS NOT FALSE`,
|
|
44
|
+
AND ${certificateStatusSql("c")} = 'valid'`,
|
|
46
45
|
[certId]
|
|
47
46
|
);
|
|
48
47
|
if (!cert.rows[0]) {
|
|
@@ -38,6 +38,7 @@ export async function requestPasswordReset(
|
|
|
38
38
|
await sendPasswordResetEmail({ email: surveyor.email, token: rawToken });
|
|
39
39
|
} catch (err) {
|
|
40
40
|
ctx.logger.error({ err, surveyorId: surveyor.surveyor_id }, "Failed to send password reset email");
|
|
41
|
+
throw err;
|
|
41
42
|
}
|
|
42
43
|
await ctx.audit.write({
|
|
43
44
|
module: "surveyor",
|
|
@@ -48,6 +48,7 @@ export async function resetSurveyorPassword(
|
|
|
48
48
|
await sendPasswordChangedEmail({ email: surveyor.email });
|
|
49
49
|
} catch (err) {
|
|
50
50
|
ctx.logger.error({ err, surveyorId: surveyor.surveyor_id }, "Failed to send password changed email");
|
|
51
|
+
throw err;
|
|
51
52
|
}
|
|
52
53
|
return { success: true };
|
|
53
54
|
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import type { AppContext, User } from "@opengis/fcore";
|
|
2
|
-
import { BadRequestError, NotFoundError } from "@opengis/fcore";
|
|
3
|
-
import { admin } from "../utils/shared.js";
|
|
4
|
-
|
|
5
|
-
export type SurveyorAccountStatusInput = { enabled: boolean };
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Повністю блокує або розблоковує обліковий запис геодезиста (`surveyors.enabled`)
|
|
9
|
-
* та записує автора і значення зміни в аудит FCore. Членство в організаціях не змінюється.
|
|
10
|
-
*/
|
|
11
|
-
export async function updateSurveyorAccountStatus(
|
|
12
|
-
{ id, input, user, ctx }: {
|
|
13
|
-
id: string;
|
|
14
|
-
input: SurveyorAccountStatusInput;
|
|
15
|
-
user: User | undefined;
|
|
16
|
-
ctx: AppContext;
|
|
17
|
-
}
|
|
18
|
-
) {
|
|
19
|
-
const uid = admin(user);
|
|
20
|
-
if (typeof input.enabled !== "boolean") {
|
|
21
|
-
throw new BadRequestError("Enabled must be a boolean");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const updated = await ctx.pg.query<{ surveyor_id: string }>(
|
|
25
|
-
`UPDATE surveyor.surveyors
|
|
26
|
-
SET enabled = $2, updated_by = $3, updated_at = now()
|
|
27
|
-
WHERE surveyor_id = $1 AND enabled <> $2
|
|
28
|
-
RETURNING surveyor_id`,
|
|
29
|
-
[id, input.enabled, uid]
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
if (!updated.rows[0]) {
|
|
33
|
-
const existing = await ctx.pg.query(
|
|
34
|
-
"SELECT 1 FROM surveyor.surveyors WHERE surveyor_id = $1",
|
|
35
|
-
[id]
|
|
36
|
-
);
|
|
37
|
-
if (!existing.rowCount) {
|
|
38
|
-
throw new NotFoundError("Surveyor not found");
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
await ctx.audit.write({
|
|
42
|
-
module: "surveyor",
|
|
43
|
-
resource: "surveyors",
|
|
44
|
-
resourceId: id,
|
|
45
|
-
action: input.enabled ? "unblock" : "block",
|
|
46
|
-
userId: uid,
|
|
47
|
-
fields: ["enabled"],
|
|
48
|
-
changes: [{ field: "enabled", oldValue: !input.enabled, newValue: input.enabled }],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return { id, enabled: input.enabled };
|
|
52
|
-
}
|
|
1
|
+
import type { AppContext, User } from "@opengis/fcore";
|
|
2
|
+
import { BadRequestError, NotFoundError } from "@opengis/fcore";
|
|
3
|
+
import { admin } from "../utils/shared.js";
|
|
4
|
+
|
|
5
|
+
export type SurveyorAccountStatusInput = { enabled: boolean };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Повністю блокує або розблоковує обліковий запис геодезиста (`surveyors.enabled`)
|
|
9
|
+
* та записує автора і значення зміни в аудит FCore. Членство в організаціях не змінюється.
|
|
10
|
+
*/
|
|
11
|
+
export async function updateSurveyorAccountStatus(
|
|
12
|
+
{ id, input, user, ctx }: {
|
|
13
|
+
id: string;
|
|
14
|
+
input: SurveyorAccountStatusInput;
|
|
15
|
+
user: User | undefined;
|
|
16
|
+
ctx: AppContext;
|
|
17
|
+
}
|
|
18
|
+
) {
|
|
19
|
+
const uid = admin(user);
|
|
20
|
+
if (typeof input.enabled !== "boolean") {
|
|
21
|
+
throw new BadRequestError("Enabled must be a boolean");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const updated = await ctx.pg.query<{ surveyor_id: string }>(
|
|
25
|
+
`UPDATE surveyor.surveyors
|
|
26
|
+
SET enabled = $2, updated_by = $3, updated_at = now()
|
|
27
|
+
WHERE surveyor_id = $1 AND enabled <> $2
|
|
28
|
+
RETURNING surveyor_id`,
|
|
29
|
+
[id, input.enabled, uid]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (!updated.rows[0]) {
|
|
33
|
+
const existing = await ctx.pg.query(
|
|
34
|
+
"SELECT 1 FROM surveyor.surveyors WHERE surveyor_id = $1",
|
|
35
|
+
[id]
|
|
36
|
+
);
|
|
37
|
+
if (!existing.rowCount) {
|
|
38
|
+
throw new NotFoundError("Surveyor not found");
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
await ctx.audit.write({
|
|
42
|
+
module: "surveyor",
|
|
43
|
+
resource: "surveyors",
|
|
44
|
+
resourceId: id,
|
|
45
|
+
action: input.enabled ? "unblock" : "block",
|
|
46
|
+
userId: uid,
|
|
47
|
+
fields: ["enabled"],
|
|
48
|
+
changes: [{ field: "enabled", oldValue: !input.enabled, newValue: input.enabled }],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return { id, enabled: input.enabled };
|
|
52
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import type { AppContext, User } from "@opengis/fcore";
|
|
2
|
-
import { BadRequestError, NotFoundError } from "@opengis/fcore";
|
|
3
|
-
import { admin } from "../utils/shared.js";
|
|
4
|
-
|
|
5
|
-
export type SurveyorStatusInput = { org_id: string; enabled: boolean };
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Змінює доступ геодезиста до однієї організації (членство в `organization_surveyors`)
|
|
9
|
-
* та записує автора і значення зміни в аудит FCore. Обліковий запис геодезиста не змінюється.
|
|
10
|
-
*/
|
|
11
|
-
export async function updateSurveyorStatus(
|
|
12
|
-
{ id, input, user, ctx }: {
|
|
13
|
-
id: string;
|
|
14
|
-
input: SurveyorStatusInput;
|
|
15
|
-
user: User | undefined;
|
|
16
|
-
ctx: AppContext;
|
|
17
|
-
}
|
|
18
|
-
) {
|
|
19
|
-
const uid = admin(user);
|
|
20
|
-
if (typeof input.enabled !== "boolean") {
|
|
21
|
-
throw new BadRequestError("Enabled must be a boolean");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const updated = await ctx.pg.query<{ surveyor_id: string }>(
|
|
25
|
-
`UPDATE surveyor.organization_surveyors
|
|
26
|
-
SET enabled = $3
|
|
27
|
-
WHERE org_id = $1 AND surveyor_id = $2 AND enabled <> $3
|
|
28
|
-
RETURNING surveyor_id`,
|
|
29
|
-
[input.org_id, id, input.enabled]
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
if (!updated.rows[0]) {
|
|
33
|
-
const existing = await ctx.pg.query(
|
|
34
|
-
"SELECT 1 FROM surveyor.organization_surveyors WHERE org_id = $1 AND surveyor_id = $2",
|
|
35
|
-
[input.org_id, id]
|
|
36
|
-
);
|
|
37
|
-
if (!existing.rowCount) {
|
|
38
|
-
throw new NotFoundError("Surveyor is not a member of this organization");
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
await ctx.audit.write({
|
|
42
|
-
module: "surveyor",
|
|
43
|
-
resource: "surveyors",
|
|
44
|
-
resourceId: id,
|
|
45
|
-
action: input.enabled ? "enable" : "disable",
|
|
46
|
-
userId: uid,
|
|
47
|
-
fields: ["enabled"],
|
|
48
|
-
changes: [{ field: "enabled", oldValue: !input.enabled, newValue: input.enabled }],
|
|
49
|
-
metadata: { org_id: input.org_id },
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return { id, org_id: input.org_id, enabled: input.enabled };
|
|
53
|
-
}
|
|
1
|
+
import type { AppContext, User } from "@opengis/fcore";
|
|
2
|
+
import { BadRequestError, NotFoundError } from "@opengis/fcore";
|
|
3
|
+
import { admin } from "../utils/shared.js";
|
|
4
|
+
|
|
5
|
+
export type SurveyorStatusInput = { org_id: string; enabled: boolean };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Змінює доступ геодезиста до однієї організації (членство в `organization_surveyors`)
|
|
9
|
+
* та записує автора і значення зміни в аудит FCore. Обліковий запис геодезиста не змінюється.
|
|
10
|
+
*/
|
|
11
|
+
export async function updateSurveyorStatus(
|
|
12
|
+
{ id, input, user, ctx }: {
|
|
13
|
+
id: string;
|
|
14
|
+
input: SurveyorStatusInput;
|
|
15
|
+
user: User | undefined;
|
|
16
|
+
ctx: AppContext;
|
|
17
|
+
}
|
|
18
|
+
) {
|
|
19
|
+
const uid = admin(user);
|
|
20
|
+
if (typeof input.enabled !== "boolean") {
|
|
21
|
+
throw new BadRequestError("Enabled must be a boolean");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const updated = await ctx.pg.query<{ surveyor_id: string }>(
|
|
25
|
+
`UPDATE surveyor.organization_surveyors
|
|
26
|
+
SET enabled = $3
|
|
27
|
+
WHERE org_id = $1 AND surveyor_id = $2 AND enabled <> $3
|
|
28
|
+
RETURNING surveyor_id`,
|
|
29
|
+
[input.org_id, id, input.enabled]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (!updated.rows[0]) {
|
|
33
|
+
const existing = await ctx.pg.query(
|
|
34
|
+
"SELECT 1 FROM surveyor.organization_surveyors WHERE org_id = $1 AND surveyor_id = $2",
|
|
35
|
+
[input.org_id, id]
|
|
36
|
+
);
|
|
37
|
+
if (!existing.rowCount) {
|
|
38
|
+
throw new NotFoundError("Surveyor is not a member of this organization");
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
await ctx.audit.write({
|
|
42
|
+
module: "surveyor",
|
|
43
|
+
resource: "surveyors",
|
|
44
|
+
resourceId: id,
|
|
45
|
+
action: input.enabled ? "enable" : "disable",
|
|
46
|
+
userId: uid,
|
|
47
|
+
fields: ["enabled"],
|
|
48
|
+
changes: [{ field: "enabled", oldValue: !input.enabled, newValue: input.enabled }],
|
|
49
|
+
metadata: { org_id: input.org_id },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return { id, org_id: input.org_id, enabled: input.enabled };
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type CertificateStatus = "valid" | "stopped" | "suspended" | "invalid";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SQL-вираз статусу сертифіката. Порожній рядок у certificate_stopping означає, що дію не припинено.
|
|
5
|
+
* Лише статус `valid` дозволяє реєстрацію геодезиста та подання заяв.
|
|
6
|
+
* @param alias Аліас таблиці surveyor.certificates у запиті.
|
|
7
|
+
*/
|
|
8
|
+
export function certificateStatusSql(alias: string) {
|
|
9
|
+
return `CASE
|
|
10
|
+
WHEN nullif(trim(${alias}.certificate_stopping), '') IS NOT NULL THEN 'stopped'
|
|
11
|
+
WHEN ${alias}.certificate_suspension IS NOT NULL THEN 'suspended'
|
|
12
|
+
WHEN ${alias}.isvalid IS FALSE THEN 'invalid'
|
|
13
|
+
ELSE 'valid'
|
|
14
|
+
END`;
|
|
15
|
+
}
|