@opengis/surveyor 0.0.0-stage → 0.0.1
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 +46 -3
- package/README.npm.md +51 -0
- package/dist/chunks/AppIcon-C-4QykTP.js +85 -0
- package/dist/chunks/AppealDetailField-DNRGpnyD.js +58 -0
- package/dist/chunks/AppealStatusBadge-CefimzY3.js +132 -0
- package/dist/chunks/AppealStatusBadge-Cu-UzdzA.js +171 -0
- package/dist/chunks/ApplicationHistorySection-PwToBfej.js +769 -0
- package/dist/chunks/BaseModal-DrTTkLmR.js +85 -0
- package/dist/chunks/FormFilePicker-CKVdZJU9.js +76 -0
- package/dist/chunks/MapLayerMenu-AUeTqgEp.js +145 -0
- package/dist/chunks/RegistryForm-pvIcFR-V.js +99 -0
- package/dist/chunks/RegistryFormModal-BjGu7Upv.js +85 -0
- package/dist/chunks/RegistryToolbar-CiUgsjpU.js +452 -0
- package/dist/chunks/UserAccessBadge-DyZDv7Oo.js +44 -0
- package/dist/chunks/UserTypeBadge-LvnMuKGo.js +188 -0
- package/dist/chunks/VerifiedBadge-B6droMOf.js +34 -0
- package/dist/chunks/_plugin-vue_export-helper-B3ysoDQm.js +8 -0
- package/dist/chunks/account-types-Br7gx_D_.js +35 -0
- package/dist/chunks/account_types-DLL1w122.js +25 -0
- package/dist/chunks/appealMapLayers-CQMK3rrz.js +115 -0
- package/dist/chunks/application_status-BhNGiY2I.js +45 -0
- package/dist/chunks/applications-CsCsndMV.js +132 -0
- package/dist/chunks/buildSchema-nkA4Y0YG.js +37 -0
- package/dist/chunks/card--DHsMNBd.js +330 -0
- package/dist/chunks/card-9LaB42Ol.js +538 -0
- package/dist/chunks/card-BZn5CDw9.js +739 -0
- package/dist/chunks/card-CNqXSyqX.js +297 -0
- package/dist/chunks/card-CgGOgGyd.js +973 -0
- package/dist/chunks/card-DCyBFoDZ.js +607 -0
- package/dist/chunks/certificates-DueBDDvc.js +424 -0
- package/dist/chunks/create-l28e-bWl.js +1033 -0
- package/dist/chunks/filterQuery-B9XNx1f1.js +99 -0
- package/dist/chunks/form-CdGS1nVO.js +315 -0
- package/dist/chunks/form-QTkkzwbC.js +89 -0
- package/dist/chunks/geometry-DyhIVRcw.js +67 -0
- package/dist/chunks/map-BW3iOhQg.js +2763 -0
- package/dist/chunks/map-layers-qxWjos2V.js +400 -0
- package/dist/chunks/mapLayersApi-CWoQ2be-.js +251 -0
- package/dist/chunks/organizations-BtuMZ5s_.js +14 -0
- package/dist/chunks/organizations-CZOINYMq.js +476 -0
- package/dist/chunks/profile-CuxlkEev.js +243 -0
- package/dist/chunks/profile-DxZHxGum.js +164 -0
- package/dist/chunks/requests-Bt8fEdRc.js +530 -0
- package/dist/chunks/requests-DQJIhz00.js +232 -0
- package/dist/chunks/resendSurveyorRegistration-DopjOHaM.js +27 -0
- package/dist/chunks/resources-Cl_EvaIy.js +129 -0
- package/dist/chunks/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/chunks/surveyorAccount-BceNQypZ.js +78 -0
- package/dist/chunks/users-DlaogjC_.js +291 -0
- package/dist/chunks/work_types-Hwme-FEX.js +34 -0
- package/dist/index.css +3 -0
- package/dist/index.js +259 -0
- package/migrations/20260924120000_surveyor_schema.sql +450 -0
- package/migrations/20261008170000_address_lookup.sql +20 -0
- package/migrations/20261016120000_map_layers.sql +156 -0
- package/migrations/20261016150000_password_reset.sql +15 -0
- package/migrations/20261016170000_address_lookup_format.sql +37 -0
- package/migrations/20261016180000_settlement_lookup.sql +16 -0
- package/migrations/20261019170000_actor_lookup.sql +15 -0
- package/package.json +75 -4
- package/plugin.js +10 -0
- package/server/app.ts +50 -0
- package/server/dictionaries/index.ts +17 -0
- package/server/dictionaries/surveyor/account_types.ts +12 -0
- package/server/dictionaries/surveyor/application_status.ts +16 -0
- package/server/dictionaries/surveyor/map_layer_components.ts +11 -0
- package/server/dictionaries/surveyor/map_layer_groups.ts +10 -0
- package/server/dictionaries/surveyor/map_layer_types.ts +11 -0
- package/server/dictionaries/surveyor/work_types.ts +15 -0
- package/server/dictionaries/surveyor/yes_no.ts +11 -0
- package/server/embed.ts +49 -0
- package/server/fastify.d.ts +12 -0
- package/server/index.ts +23 -0
- package/server/modules/surveyor/route.ts +410 -0
- package/server/modules/surveyor/schema.ts +439 -0
- package/server/modules/surveyor/services/applicationTile.ts +53 -0
- package/server/modules/surveyor/services/cancelApplication.ts +74 -0
- package/server/modules/surveyor/services/changeSurveyorPassword.ts +52 -0
- package/server/modules/surveyor/services/changeSurveyorPasswordByAdmin.ts +41 -0
- package/server/modules/surveyor/services/completeApplication.ts +46 -0
- package/server/modules/surveyor/services/completeSurveyorRegistration.ts +48 -0
- package/server/modules/surveyor/services/createApplication.ts +169 -0
- package/server/modules/surveyor/services/geometryExport.ts +34 -0
- package/server/modules/surveyor/services/geometryImport.ts +66 -0
- package/server/modules/surveyor/services/getSurveyorUser.ts +56 -0
- package/server/modules/surveyor/services/identifyApplications.ts +82 -0
- package/server/modules/surveyor/services/issueSourceData.ts +55 -0
- package/server/modules/surveyor/services/loginSurveyor.ts +67 -0
- package/server/modules/surveyor/services/mapLayers.ts +61 -0
- package/server/modules/surveyor/services/rasterExport.ts +15 -0
- package/server/modules/surveyor/services/registerSurveyor.ts +161 -0
- package/server/modules/surveyor/services/requestPasswordReset.ts +49 -0
- package/server/modules/surveyor/services/resendRegistration.ts +42 -0
- package/server/modules/surveyor/services/resetSurveyorPassword.ts +53 -0
- package/server/modules/surveyor/services/searchApplications.ts +63 -0
- package/server/modules/surveyor/services/submitSurvey.ts +70 -0
- package/server/modules/surveyor/services/updateSurveyorAccountStatus.ts +52 -0
- package/server/modules/surveyor/services/updateSurveyorStatus.ts +53 -0
- package/server/modules/surveyor/services/vectorExport.ts +86 -0
- package/server/modules/surveyor/services/verifyApplication.ts +59 -0
- package/server/modules/surveyor/utils/accessibleApplication.ts +37 -0
- package/server/modules/surveyor/utils/application.ts +68 -0
- package/server/modules/surveyor/utils/export.ts +39 -0
- package/server/modules/surveyor/utils/firstBoundary.ts +48 -0
- package/server/modules/surveyor/utils/mail.ts +161 -0
- package/server/modules/surveyor/utils/permissions.ts +29 -0
- package/server/modules/surveyor/utils/registration.ts +33 -0
- package/server/modules/surveyor/utils/shared.ts +305 -0
- package/server/modules/surveyor/utils/templates/ds.surveyor_admin_password.pt.hbs +79 -0
- package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -0
- package/server/modules/surveyor/utils/templates/ds.surveyor_registration.pt.hbs +80 -0
- package/server/modules/surveyor/utils/templates/ds.surveyor_send_mail.pt.hbs +79 -0
- package/server/modules/surveyor/utils/vectorLayer.ts +41 -0
- package/server/plugins/convertVector.ts +74 -0
- package/server/plugins/proto/convertVector.proto +21 -0
- package/server/plugins/swagger.ts +54 -0
- package/server/plugins/vite.dev.ts +52 -0
- package/server/plugins/vite.prod.ts +55 -0
- package/server/resources/helpers/actor_lookup.ts +5 -0
- package/server/resources/helpers/address_lookup.ts +8 -0
- package/server/resources/helpers/settlement_lookup.ts +7 -0
- package/server/resources/helpers/user_lookup.ts +5 -0
- package/server/resources/index.ts +30 -0
- package/server/resources/surveyor-admin/application_comments.ts +24 -0
- package/server/resources/surveyor-admin/application_status_history.ts +46 -0
- package/server/resources/surveyor-admin/applications.ts +125 -0
- package/server/resources/surveyor-admin/certificates.ts +87 -0
- package/server/resources/surveyor-admin/map_layers.ts +69 -0
- package/server/resources/surveyor-admin/organization_surveyors.ts +32 -0
- package/server/resources/surveyor-admin/organizations.ts +61 -0
- package/server/resources/surveyor-admin/surveyors.ts +71 -0
- package/server/resources/surveyor-user/application_status_history.ts +52 -0
- package/server/resources/surveyor-user/applications.ts +131 -0
- package/server/resources/surveyor-user/certificates.ts +67 -0
- package/server/resources/surveyor-user/organizations.ts +40 -0
- package/server/resources/surveyor-user/surveyors.ts +69 -0
- package/server/tsconfig.json +3 -0
- package/surveyor-types.d.ts +30 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import * as grpc from "@grpc/grpc-js";
|
|
3
|
+
import * as protoLoader from "@grpc/proto-loader";
|
|
4
|
+
import { BadRequestError, FCoreError } from "@opengis/fcore";
|
|
5
|
+
|
|
6
|
+
type ConvertInput = { data: Buffer; format: string; filename: string; encoding?: string };
|
|
7
|
+
type ConvertResult = { geojson: string; err?: string };
|
|
8
|
+
type MapClient = grpc.Client & {
|
|
9
|
+
ConvertVector(
|
|
10
|
+
input: ConvertInput & { srs: number },
|
|
11
|
+
options: grpc.CallOptions,
|
|
12
|
+
callback: (error: grpc.ServiceError | null, result: ConvertResult) => void
|
|
13
|
+
): grpc.ClientUnaryCall;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const definition = protoLoader.loadSync(
|
|
17
|
+
fileURLToPath(new URL("./proto/convertVector.proto", import.meta.url)),
|
|
18
|
+
{ keepCase: true, longs: String, defaults: true }
|
|
19
|
+
);
|
|
20
|
+
const protocol = grpc.loadPackageDefinition(definition) as unknown as {
|
|
21
|
+
map: {
|
|
22
|
+
MapService: new (
|
|
23
|
+
address: string,
|
|
24
|
+
credentials: grpc.ChannelCredentials,
|
|
25
|
+
options: grpc.ClientOptions
|
|
26
|
+
) => MapClient;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export async function convertVector(input: ConvertInput): Promise<unknown> {
|
|
31
|
+
const address = process.env.MAPNIK_SERVER?.trim();
|
|
32
|
+
if (!address) {
|
|
33
|
+
throw new FCoreError("VECTOR_CONVERTER_UNAVAILABLE", "Не налаштовано MAPNIK_SERVER", 503);
|
|
34
|
+
}
|
|
35
|
+
const client = new protocol.map.MapService(address, grpc.credentials.createInsecure(), {
|
|
36
|
+
"grpc.max_send_message_length": 512 * 1024 * 1024,
|
|
37
|
+
"grpc.max_receive_message_length": 512 * 1024 * 1024,
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
let result: ConvertResult;
|
|
41
|
+
try {
|
|
42
|
+
result = await new Promise<ConvertResult>((resolve, reject) => {
|
|
43
|
+
client.ConvertVector(
|
|
44
|
+
{ ...input, srs: 4326 },
|
|
45
|
+
{ deadline: Date.now() + 120_000 },
|
|
46
|
+
(error, response) => {
|
|
47
|
+
if (error) reject(error);
|
|
48
|
+
else resolve(response);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const message =
|
|
54
|
+
(error as grpc.ServiceError).code === grpc.status.UNIMPLEMENTED
|
|
55
|
+
? "Сервер Mapnik не підтримує ConvertVector. Потрібне оновлення сервісу"
|
|
56
|
+
: "Сервіс конвертації геоданих недоступний";
|
|
57
|
+
throw new FCoreError("VECTOR_CONVERTER_UNAVAILABLE", message, 503);
|
|
58
|
+
}
|
|
59
|
+
if (result.err) {
|
|
60
|
+
throw new BadRequestError(`Не вдалося імпортувати геометрію: ${result.err}`);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(result.geojson);
|
|
64
|
+
} catch {
|
|
65
|
+
throw new FCoreError(
|
|
66
|
+
"VECTOR_CONVERTER_INVALID_RESPONSE",
|
|
67
|
+
"Сервер конвертації повернув некоректний GeoJSON",
|
|
68
|
+
502
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} finally {
|
|
72
|
+
client.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package map;
|
|
4
|
+
|
|
5
|
+
service MapService {
|
|
6
|
+
rpc ConvertVector(ConvertVectorRequest) returns (ConvertVectorOut);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message ConvertVectorRequest {
|
|
10
|
+
bytes data = 1;
|
|
11
|
+
string format = 2;
|
|
12
|
+
int32 srs = 3;
|
|
13
|
+
string filename = 4;
|
|
14
|
+
string encoding = 5;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message ConvertVectorOut {
|
|
18
|
+
string geojson = 1;
|
|
19
|
+
string err = 2;
|
|
20
|
+
int64 size = 3;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import swagger from "@fastify/swagger";
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import type { FastifyBaseLogger, FastifyInstance, RawServerDefault } from "fastify";
|
|
4
|
+
|
|
5
|
+
type SwaggerApp<Logger extends FastifyBaseLogger> =
|
|
6
|
+
FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse, Logger>;
|
|
7
|
+
|
|
8
|
+
const swaggerPage = `<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8" />
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
13
|
+
<title>Surveyor API - Swagger</title>
|
|
14
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css" />
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="swagger-ui"></div>
|
|
18
|
+
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
window.onload = () => {
|
|
21
|
+
SwaggerUIBundle({
|
|
22
|
+
url: '/openapi.json',
|
|
23
|
+
dom_id: '#swagger-ui',
|
|
24
|
+
deepLinking: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`;
|
|
30
|
+
|
|
31
|
+
/** Registers the OpenAPI generator before any application routes. */
|
|
32
|
+
export async function registerSwaggerPlugin<Logger extends FastifyBaseLogger>(app: SwaggerApp<Logger>): Promise<void> {
|
|
33
|
+
await app.register(swagger, {
|
|
34
|
+
openapi: {
|
|
35
|
+
openapi: "3.0.3",
|
|
36
|
+
info: {
|
|
37
|
+
title: "Surveyor API",
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
description: "Surveyor backend API.",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Registers documentation routes after FCore installs its access hooks. */
|
|
46
|
+
export function registerSwaggerRoutes<Logger extends FastifyBaseLogger>(app: SwaggerApp<Logger>): void {
|
|
47
|
+
const env = process.env.NODE_ENV?.toLowerCase() || "production";
|
|
48
|
+
const access = env === "production" ? "admin" : "public";
|
|
49
|
+
|
|
50
|
+
app.get("/openapi.json", { schema: { hide: true, access } }, async () => app.swagger());
|
|
51
|
+
app.get("/swagger", { schema: { hide: true, access } }, async (_request, reply) =>
|
|
52
|
+
reply.type("text/html; charset=utf-8").send(swaggerPage)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createServer } from 'vite';
|
|
2
|
+
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
3
|
+
const env = process.env['NODE_ENV']?.toLowerCase();
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function pathName(url: string): string {
|
|
7
|
+
return url.split("?", 1)[0] || "/";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isBackendRequest(url: string): boolean {
|
|
11
|
+
return url === "/user" || url === "/openapi.json" || url === "/swagger" || url === "/api" || url.startsWith("/api/");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function plugin(app: any, part = env) {
|
|
15
|
+
|
|
16
|
+
if (env === 'production') return;
|
|
17
|
+
|
|
18
|
+
const viteServer = await createServer({
|
|
19
|
+
root: part,
|
|
20
|
+
server: {
|
|
21
|
+
middlewareMode: true,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
app.addHook("onClose", async () => {
|
|
26
|
+
await viteServer.close();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// hot reload
|
|
30
|
+
viteServer.watcher.on('all', (d, t) => {
|
|
31
|
+
viteServer.ws.send({ type: 'full-reload' });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
app.get('*', { schema: { access: 'public' } }, async (req: FastifyRequest, reply: FastifyReply) => {
|
|
35
|
+
const url = pathName(req.url);
|
|
36
|
+
if (isBackendRequest(url)) {
|
|
37
|
+
return reply.callNotFound();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// this is middleware for vite's dev server
|
|
42
|
+
app.addHook('onRequest', async (req: FastifyRequest, reply: FastifyReply) => {
|
|
43
|
+
const url = pathName(req.url);
|
|
44
|
+
if ((req.method !== "GET" && req.method !== "HEAD") || isBackendRequest(url)) return;
|
|
45
|
+
const next = () => new Promise((resolve) => {
|
|
46
|
+
viteServer.middlewares(req.raw, reply.raw, () => resolve(1));
|
|
47
|
+
});
|
|
48
|
+
await next();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default plugin;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
type StaticFileResult = { type: string, payload: Buffer } | null;
|
|
5
|
+
|
|
6
|
+
function staticFile(url: string, assetsDir = 'admin/dist/'): StaticFileResult {
|
|
7
|
+
const pathname = url.split('?', 1)[0] || '/';
|
|
8
|
+
const root = path.resolve(assetsDir);
|
|
9
|
+
const filePath = path.resolve(root, pathname);
|
|
10
|
+
// console.log('Serving static file:', filePath);
|
|
11
|
+
// Do not let a request escape the Vite build directory.
|
|
12
|
+
if (filePath !== root && !filePath.startsWith(`${root}${path.sep}`)) return null;
|
|
13
|
+
const ext = path.extname(filePath);
|
|
14
|
+
|
|
15
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) return null;
|
|
16
|
+
const mime = {
|
|
17
|
+
'.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.html': 'text/html; charset=utf-8',
|
|
18
|
+
'.woff2': 'font/woff2', '.png': 'image/png', '.svg': 'image/svg+xml', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',
|
|
19
|
+
}[ext];
|
|
20
|
+
|
|
21
|
+
// Fastify running under Bun does not reliably detect Node ReadStream as a
|
|
22
|
+
// stream, treating it as an invalid object payload. A Buffer is accepted by
|
|
23
|
+
// both runtimes and is appropriate for the built static assets.
|
|
24
|
+
return { type: mime ?? 'application/octet-stream', payload: fs.readFileSync(filePath) };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
28
|
+
const env = process.env['NODE_ENV']?.toLocaleLowerCase() || 'production';
|
|
29
|
+
|
|
30
|
+
/** Serves the built Vite site from Fastify in production mode. */
|
|
31
|
+
async function plugin(app: any, part: string, base = '/', user_type?: string[]) {
|
|
32
|
+
|
|
33
|
+
if (env !== 'production') return;
|
|
34
|
+
|
|
35
|
+
// vite static assets for admin
|
|
36
|
+
app.get(`${base}assets/*`, async (req: FastifyRequest, reply: FastifyReply) => {
|
|
37
|
+
const url = (req.params as { '*': string })['*'];
|
|
38
|
+
const result = staticFile(url, `${part}/dist/assets`);
|
|
39
|
+
if (!result) return reply.status(404).send('Not found');
|
|
40
|
+
return reply.type(result.type).send(result.payload);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// index.html fallback for admin routes
|
|
44
|
+
app.get(`${base}*`, async (req: FastifyRequest, reply: FastifyReply) => {
|
|
45
|
+
if (req.url.startsWith(`/api/`)) return reply.status(404).send('Not found');
|
|
46
|
+
|
|
47
|
+
if (user_type && req.user && !user_type.includes(req.user?.type || '')) return reply.status(403).send('Forbidden');
|
|
48
|
+
|
|
49
|
+
const index = staticFile('index.html', `${part}/dist/`);
|
|
50
|
+
if (!index) return reply.status(503).send('Admin build is not available');
|
|
51
|
+
return reply.type(index.type).send(index.payload);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
export default plugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The view combines the house number with its street and settlement for lookup labels.
|
|
2
|
+
export const addressLookup = {
|
|
3
|
+
table: "surveyor.address_lookup",
|
|
4
|
+
value: "addr_id",
|
|
5
|
+
text: "address_text",
|
|
6
|
+
fields: ["geom"],
|
|
7
|
+
filterFields: ["settlement_id", "parent"],
|
|
8
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import applications from "./surveyor-admin/applications.js";
|
|
2
|
+
import applicationComments from "./surveyor-admin/application_comments.js";
|
|
3
|
+
import applicationStatusHistory from "./surveyor-admin/application_status_history.js";
|
|
4
|
+
import certificates from "./surveyor-admin/certificates.js";
|
|
5
|
+
import organizations from "./surveyor-admin/organizations.js";
|
|
6
|
+
import surveyors from "./surveyor-admin/surveyors.js";
|
|
7
|
+
|
|
8
|
+
import publicApplications from "./surveyor-user/applications.js";
|
|
9
|
+
import publicApplicationStatusHistory from "./surveyor-user/application_status_history.js";
|
|
10
|
+
import publicCertificates from "./surveyor-user/certificates.js";
|
|
11
|
+
import publicOrganizations from "./surveyor-user/organizations.js";
|
|
12
|
+
import publicSurveyors from "./surveyor-user/surveyors.js";
|
|
13
|
+
import organization_surveyors from "./surveyor-admin/organization_surveyors.js";
|
|
14
|
+
import mapLayers from "./surveyor-admin/map_layers.js";
|
|
15
|
+
export default [
|
|
16
|
+
applications,
|
|
17
|
+
applicationComments,
|
|
18
|
+
organizations,
|
|
19
|
+
surveyors,
|
|
20
|
+
certificates,
|
|
21
|
+
applicationStatusHistory,
|
|
22
|
+
organization_surveyors,
|
|
23
|
+
mapLayers,
|
|
24
|
+
|
|
25
|
+
publicApplications,
|
|
26
|
+
publicOrganizations,
|
|
27
|
+
publicSurveyors,
|
|
28
|
+
publicCertificates,
|
|
29
|
+
publicApplicationStatusHistory,
|
|
30
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ResourceContract } from "@opengis/fcore";
|
|
2
|
+
import { userLookup } from "../helpers/user_lookup.js";
|
|
3
|
+
|
|
4
|
+
// Internal read-only target for application relations; direct CRUD is disabled.
|
|
5
|
+
export default {
|
|
6
|
+
version: 1,
|
|
7
|
+
name: "application_comments",
|
|
8
|
+
module: "surveyor",
|
|
9
|
+
title: "Коментарі заявок",
|
|
10
|
+
table: "admin.notes",
|
|
11
|
+
key: "note_id",
|
|
12
|
+
access: "admin",
|
|
13
|
+
operations: [],
|
|
14
|
+
fields: {
|
|
15
|
+
note_id: { type: "text", read: true, write: false },
|
|
16
|
+
resource: { type: "string", read: true, write: false },
|
|
17
|
+
resource_id: { type: "text", read: true, write: false },
|
|
18
|
+
body: { type: "text", read: true, write: false },
|
|
19
|
+
created_by: { type: "string", read: true, write: false, lookup: userLookup },
|
|
20
|
+
created_at: { type: "timestamp", read: true, write: false },
|
|
21
|
+
updated_by: { type: "string", read: true, write: false, lookup: userLookup },
|
|
22
|
+
updated_at: { type: "timestamp", read: true, write: false },
|
|
23
|
+
},
|
|
24
|
+
} satisfies ResourceContract;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ResourceContract } from "@opengis/fcore";
|
|
2
|
+
import applicationStatus from "../../dictionaries/surveyor/application_status.js";
|
|
3
|
+
import { actorLookup } from "../helpers/actor_lookup.js";
|
|
4
|
+
|
|
5
|
+
const applicationStatusCodes = applicationStatus.items.map(({ code }) => code);
|
|
6
|
+
|
|
7
|
+
// Business services write history in the same transaction as a status change.
|
|
8
|
+
export default {
|
|
9
|
+
version: 1,
|
|
10
|
+
name: "application_status_history",
|
|
11
|
+
module: "surveyor",
|
|
12
|
+
title: "Історія статусів заявок",
|
|
13
|
+
table: "surveyor.application_status_history",
|
|
14
|
+
key: "history_id",
|
|
15
|
+
access: "admin",
|
|
16
|
+
operations: ["read"],
|
|
17
|
+
fields: {
|
|
18
|
+
history_id: { type: "text", write: false },
|
|
19
|
+
application_id: {
|
|
20
|
+
type: "text",
|
|
21
|
+
write: false,
|
|
22
|
+
filterable: true,
|
|
23
|
+
lookup: { table: "surveyor.applications", value: "app_id", text: "number" },
|
|
24
|
+
},
|
|
25
|
+
status_from: {
|
|
26
|
+
type: "string",
|
|
27
|
+
write: false,
|
|
28
|
+
nullable: true,
|
|
29
|
+
dictionary: applicationStatus.code,
|
|
30
|
+
enum: applicationStatusCodes,
|
|
31
|
+
},
|
|
32
|
+
status_to: {
|
|
33
|
+
type: "string",
|
|
34
|
+
write: false,
|
|
35
|
+
dictionary: applicationStatus.code,
|
|
36
|
+
enum: applicationStatusCodes,
|
|
37
|
+
},
|
|
38
|
+
reason: { type: "text", write: false },
|
|
39
|
+
file: { type: "file", write: false },
|
|
40
|
+
changed_by: { type: "string", write: false, lookup: actorLookup },
|
|
41
|
+
created_at: { type: "timestamp", write: false, sortable: true },
|
|
42
|
+
},
|
|
43
|
+
relations: {
|
|
44
|
+
application: { resource: "applications", localKey: "application_id" },
|
|
45
|
+
},
|
|
46
|
+
} satisfies ResourceContract;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ResourceContract } from "@opengis/fcore";
|
|
2
|
+
import applicationStatus from "../../dictionaries/surveyor/application_status.js";
|
|
3
|
+
import workTypes from "../../dictionaries/surveyor/work_types.js";
|
|
4
|
+
import { addressLookup } from "../helpers/address_lookup.js";
|
|
5
|
+
import { actorLookup } from "../helpers/actor_lookup.js";
|
|
6
|
+
import { settlementLookup } from "../helpers/settlement_lookup.js";
|
|
7
|
+
import { userLookup } from "../helpers/user_lookup.js";
|
|
8
|
+
|
|
9
|
+
const applicationStatusCodes = applicationStatus.items.map(({ code }) => code);
|
|
10
|
+
const workTypeCodes = workTypes.items.map(({ code }) => code);
|
|
11
|
+
|
|
12
|
+
// Status changes, area checks, and file workflow belong to Business API services.
|
|
13
|
+
// Generic update is limited to replacing already issued source data (file_output).
|
|
14
|
+
export default {
|
|
15
|
+
version: 1,
|
|
16
|
+
name: "applications",
|
|
17
|
+
module: "surveyor",
|
|
18
|
+
title: "Заявки на геодезичні роботи",
|
|
19
|
+
table: "surveyor.applications",
|
|
20
|
+
key: "app_id",
|
|
21
|
+
access: "admin",
|
|
22
|
+
operations: ["read", "update"],
|
|
23
|
+
searchable: ["number", "location", "description"],
|
|
24
|
+
capabilities: ["notes", "files"],
|
|
25
|
+
summary: {
|
|
26
|
+
awaitingData: { aggregate: "count", where: "t.status = 'awaitingData'" },
|
|
27
|
+
dataIssued: { aggregate: "count", where: "t.status = 'dataIssued'" },
|
|
28
|
+
reserve: { aggregate: "count", where: "t.status = 'reserve'" },
|
|
29
|
+
underReview: { aggregate: "count", where: "t.status = 'underReview'" },
|
|
30
|
+
verified: { aggregate: "count", where: "t.status = 'verified'" },
|
|
31
|
+
completed: { aggregate: "count", where: "t.status = 'completed'" },
|
|
32
|
+
cancelled: { aggregate: "count", where: "t.status = 'cancelled'" },
|
|
33
|
+
},
|
|
34
|
+
fields: {
|
|
35
|
+
app_id: { type: "text", write: false, filterable: true, sortable: true },
|
|
36
|
+
number: { type: "string", write: false, searchable: true, sortable: true },
|
|
37
|
+
org_id: {
|
|
38
|
+
type: "text",
|
|
39
|
+
write: false,
|
|
40
|
+
filterable: true,
|
|
41
|
+
lookup: { table: "surveyor.organizations", value: "org_id", text: "name" },
|
|
42
|
+
},
|
|
43
|
+
surveyor_id: {
|
|
44
|
+
type: "text",
|
|
45
|
+
write: false,
|
|
46
|
+
filterable: true,
|
|
47
|
+
lookup: { table: "surveyor.surveyors", value: "surveyor_id", text: "email" },
|
|
48
|
+
},
|
|
49
|
+
status: {
|
|
50
|
+
type: "string",
|
|
51
|
+
write: false,
|
|
52
|
+
filterable: true,
|
|
53
|
+
dictionary: applicationStatus.code,
|
|
54
|
+
enum: applicationStatusCodes,
|
|
55
|
+
},
|
|
56
|
+
work_type: {
|
|
57
|
+
type: "string",
|
|
58
|
+
write: false,
|
|
59
|
+
filterable: true,
|
|
60
|
+
dictionary: workTypes.code,
|
|
61
|
+
enum: workTypeCodes,
|
|
62
|
+
},
|
|
63
|
+
description: { type: "text", write: false, searchable: true },
|
|
64
|
+
execution_basis: { type: "text", write: false },
|
|
65
|
+
settlement_id: {
|
|
66
|
+
type: "string",
|
|
67
|
+
write: false,
|
|
68
|
+
filterable: true,
|
|
69
|
+
lookup: settlementLookup,
|
|
70
|
+
},
|
|
71
|
+
is_found_address_id: { type: "boolean", write: false, filterable: true, dictionary: "yes-no" },
|
|
72
|
+
address_id: { type: "string", write: false, filterable: true, lookup: addressLookup },
|
|
73
|
+
location: { type: "text", write: false, searchable: true },
|
|
74
|
+
area: { type: "number", write: false, sortable: true },
|
|
75
|
+
geom: { type: "geometry", write: false },
|
|
76
|
+
file_output: { type: "file", write: true },
|
|
77
|
+
file_geodetic_survey: { type: "file", write: false },
|
|
78
|
+
file_corrected_geodetic_survey: { type: "file", write: false },
|
|
79
|
+
note_4_file_corrected_geodetic_survey: { type: "text", write: false },
|
|
80
|
+
notes: { type: "text", write: false },
|
|
81
|
+
signature: { type: "text", write: false },
|
|
82
|
+
cancel_reason: { type: "text", write: false },
|
|
83
|
+
source_data_issued_at: { type: "timestamp", write: false, sortable: true },
|
|
84
|
+
survey_uploaded_at: { type: "timestamp", write: false, sortable: true },
|
|
85
|
+
verified_at: { type: "timestamp", write: false, sortable: true },
|
|
86
|
+
integrated_at: { type: "timestamp", write: false, sortable: true },
|
|
87
|
+
cancelled_at: { type: "timestamp", write: false, sortable: true },
|
|
88
|
+
verified_by: { type: "string", write: false, lookup: userLookup },
|
|
89
|
+
integrated_by: { type: "string", write: false, lookup: userLookup },
|
|
90
|
+
cancelled_by: { type: "string", write: false, lookup: userLookup },
|
|
91
|
+
created_by: { type: "string", write: false, lookup: actorLookup },
|
|
92
|
+
updated_by: { type: "string", write: false, lookup: actorLookup },
|
|
93
|
+
created_at: { type: "timestamp", write: false, filterable: true, sortable: true },
|
|
94
|
+
updated_at: { type: "timestamp", write: false, sortable: true },
|
|
95
|
+
},
|
|
96
|
+
relations: {
|
|
97
|
+
comments: {
|
|
98
|
+
type: "many",
|
|
99
|
+
resource: "application_comments",
|
|
100
|
+
localKey: "app_id",
|
|
101
|
+
foreignKey: "resource_id",
|
|
102
|
+
where: "t.resource IN ('applications', 'public_applications')",
|
|
103
|
+
},
|
|
104
|
+
organization: { resource: "organizations", localKey: "org_id" },
|
|
105
|
+
surveyor: {
|
|
106
|
+
resource: "surveyors",
|
|
107
|
+
localKey: "surveyor_id",
|
|
108
|
+
fields: [
|
|
109
|
+
't."surveyor_id"',
|
|
110
|
+
't."certificate_id"',
|
|
111
|
+
't."first_name"',
|
|
112
|
+
't."last_name"',
|
|
113
|
+
't."middle_name"',
|
|
114
|
+
't."email"',
|
|
115
|
+
't."phone"',
|
|
116
|
+
't."enabled"',
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
history: {
|
|
120
|
+
resource: "application_status_history",
|
|
121
|
+
localKey: "app_id",
|
|
122
|
+
foreignKey: "application_id",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
} satisfies ResourceContract;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ResourceContract } from "@opengis/fcore";
|
|
2
|
+
import accountTypes from "../../dictionaries/surveyor/account_types.js";
|
|
3
|
+
import { userLookup } from "../helpers/user_lookup.js";
|
|
4
|
+
|
|
5
|
+
const accountTypeCodes = accountTypes.items.map(({ code }) => code);
|
|
6
|
+
|
|
7
|
+
// Certificates are imported from the external registry, so Resource API only reads them.
|
|
8
|
+
export default {
|
|
9
|
+
version: 1,
|
|
10
|
+
name: "certificates",
|
|
11
|
+
module: "surveyor",
|
|
12
|
+
title: "Сертифікати",
|
|
13
|
+
table: "surveyor.certificates",
|
|
14
|
+
key: "certificate_id",
|
|
15
|
+
display: ["surveyor_name", "number_certificate"],
|
|
16
|
+
displayFields: ["number_certificate", "surveyor_phone", "surveyor_email"],
|
|
17
|
+
access: "admin",
|
|
18
|
+
operations: ["read"],
|
|
19
|
+
searchable: ["surveyor_name", "last_name", "first_name", "number_certificate"],
|
|
20
|
+
fields: {
|
|
21
|
+
certificate_id: {
|
|
22
|
+
type: "text",
|
|
23
|
+
write: false,
|
|
24
|
+
filterable: true,
|
|
25
|
+
lookup: {
|
|
26
|
+
table: "surveyor.certificates",
|
|
27
|
+
value: "certificate_id",
|
|
28
|
+
text: "surveyor_name",
|
|
29
|
+
fields: ["surveyor_email", "surveyor_phone", "number_certificate"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
certificate_type: {
|
|
33
|
+
type: "string",
|
|
34
|
+
write: false,
|
|
35
|
+
filterable: true,
|
|
36
|
+
dictionary: accountTypes.code,
|
|
37
|
+
enum: accountTypeCodes,
|
|
38
|
+
},
|
|
39
|
+
surveyor_name: {
|
|
40
|
+
type: "string",
|
|
41
|
+
write: false,
|
|
42
|
+
searchable: true,
|
|
43
|
+
},
|
|
44
|
+
last_name: { type: "string", write: false, searchable: true },
|
|
45
|
+
first_name: { type: "string", write: false, searchable: true },
|
|
46
|
+
middle_name: { type: "string", write: false },
|
|
47
|
+
surveyor_phone: { type: "string", write: false },
|
|
48
|
+
surveyor_email: { type: "string", write: false },
|
|
49
|
+
date_certificate: {
|
|
50
|
+
type: "date",
|
|
51
|
+
write: false,
|
|
52
|
+
filterable: true,
|
|
53
|
+
sortable: true,
|
|
54
|
+
},
|
|
55
|
+
number_certificate: { type: "string", write: false, searchable: true },
|
|
56
|
+
name_school: { type: "text", write: false },
|
|
57
|
+
date_protocol: { type: "date", write: false },
|
|
58
|
+
number_protocol: { type: "string", write: false },
|
|
59
|
+
certificate_increase: { type: "text", write: false },
|
|
60
|
+
certificate_stopping: { type: "text", write: false },
|
|
61
|
+
certificate_suspension: { type: "date", write: false },
|
|
62
|
+
certificate_renewal: { type: "text", write: false },
|
|
63
|
+
work_place: { type: "text", write: false },
|
|
64
|
+
economic_activity: { type: "text", write: false },
|
|
65
|
+
created_by: { type: "string", write: false, lookup: userLookup },
|
|
66
|
+
created_at: { type: "timestamp", write: false, sortable: true },
|
|
67
|
+
updated_by: { type: "string", write: false, lookup: userLookup },
|
|
68
|
+
updated_at: { type: "timestamp", write: false, sortable: true },
|
|
69
|
+
is_membership: {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
write: false,
|
|
72
|
+
filterable: true,
|
|
73
|
+
dictionary: "yes-no",
|
|
74
|
+
},
|
|
75
|
+
membership: { type: "text", write: false },
|
|
76
|
+
last_qualification_date: { type: "date", write: false },
|
|
77
|
+
isvalid: { type: "boolean", write: false, filterable: true },
|
|
78
|
+
qualification_level: { type: "string", write: false },
|
|
79
|
+
},
|
|
80
|
+
relations: {
|
|
81
|
+
surveyors: {
|
|
82
|
+
resource: "surveyors",
|
|
83
|
+
localKey: "certificate_id"
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
} satisfies ResourceContract;
|