@opengis/surveyor 0.0.8 → 0.0.9

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.js CHANGED
@@ -63,7 +63,7 @@ var B = /*#__PURE__*/ r(I, [
63
63
  setup(e, { expose: t }) {
64
64
  t();
65
65
  let n = {
66
- MapPage: S(() => import("./chunks/map-UTBxwT7-.js")),
66
+ MapPage: S(() => import("./chunks/map-DvwFkxAS.js")),
67
67
  SurveyorEmbedShell: B
68
68
  };
69
69
  return Object.defineProperty(n, "__isScriptSetup", {
@@ -280,7 +280,7 @@ var Se = /*#__PURE__*/ r(be, [["render", xe], ["__file", "C:/softpro/surveyor/sr
280
280
  t();
281
281
  let n = {
282
282
  Index: S(() => import("./chunks/requests-rWq8ok3C.js")),
283
- Create: S(() => import("./chunks/create-CAVC1qXJ.js")),
283
+ Create: S(() => import("./chunks/create-DR8tXNYj.js")),
284
284
  Card: S(() => import("./chunks/card-Dlp8_KhV.js")),
285
285
  BaseEntityWrapper: K,
286
286
  SurveyorEmbedShell: B
@@ -684,7 +684,7 @@ var X = [
684
684
  {
685
685
  path: "requests/new",
686
686
  name: "request-create",
687
- component: () => import("./chunks/create-CAVC1qXJ.js"),
687
+ component: () => import("./chunks/create-DR8tXNYj.js"),
688
688
  meta: {
689
689
  title: "Нове звернення",
690
690
  section: "requests"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/surveyor",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "description": "Surveyor admin and geodesist cabinet UI for embedded host applications",
@@ -20,7 +20,7 @@ import {
20
20
  updateSurveyorAccountStatus,
21
21
  type SurveyorAccountStatusInput,
22
22
  } from "./services/updateSurveyorAccountStatus.js";
23
- import { applicationTile } from "./services/applicationTile.js";
23
+ import { applicationTile, type ApplicationTileQuery } from "./services/applicationTile.js";
24
24
  import { searchApplications, type ApplicationSearchInput } from "./services/searchApplications.js";
25
25
  import { identifyApplications, type ApplicationIdentifyInput } from "./services/identifyApplications.js";
26
26
  import { mapLayers, type MapLayersInput } from "./services/mapLayers.js";
@@ -384,7 +384,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
384
384
  },
385
385
  async (req) => mapLayers({ input: req.query, user: req.user, ctx })
386
386
  );
387
- app.get<{ Params: { z: string; x: string; y: string }; Querystring: { filter?: string } }>(
387
+ app.get<{ Params: { z: string; x: string; y: string }; Querystring: ApplicationTileQuery }>(
388
388
  "/api/surveyor/vtile/applications/:z/:x/:y",
389
389
  {
390
390
  schema: {
@@ -400,6 +400,8 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
400
400
  x: Number(x),
401
401
  y: Number(y),
402
402
  filter: req.query.filter,
403
+ year: req.query.year,
404
+ scope: req.query.scope,
403
405
  user: req.user,
404
406
  ctx,
405
407
  });
@@ -419,7 +419,24 @@ export const surveyorSchemas = {
419
419
  },
420
420
  tileQuery: {
421
421
  type: "object",
422
- properties: { filter: { type: "string", enum: applicationStatus } },
422
+ properties: {
423
+ filter: {
424
+ type: "object",
425
+ additionalProperties: true,
426
+ description: "Фільтри FCore, наприклад filter[created_at][gte]=2026-01-01",
427
+ },
428
+ year: {
429
+ type: "string",
430
+ pattern: "^(all|[1-9][0-9]{3}(,[1-9][0-9]{3})*)$",
431
+ description: "Роки створення заявок через кому або all; за замовчуванням поточний рік",
432
+ },
433
+ scope: {
434
+ type: "string",
435
+ enum: ["all", "active"],
436
+ default: "all",
437
+ description: "all — усі статуси; active — awaitingData, dataIssued, reserve, underReview, verified",
438
+ },
439
+ },
423
440
  additionalProperties: false,
424
441
  },
425
442
  mapLayersQuery: {
@@ -1,18 +1,23 @@
1
1
  import type { AppContext, User } from "@opengis/fcore";
2
- import { BadRequestError } from "@opengis/fcore";
2
+ import { BadRequestError, buildFilters } from "@opengis/fcore";
3
3
  import { actor, surveyorForUser } from "../utils/shared.js";
4
4
 
5
+ export type ApplicationTileQuery = {
6
+ filter?: Record<string, unknown>;
7
+ year?: string;
8
+ scope?: "all" | "active";
9
+ };
10
+
5
11
  /**
6
- * Будує векторний тайл заявок, доступних користувачу, з необов'язковим фільтром статусу.
7
- * @param params Координати тайла, фільтр, користувач і контекст FCore.
12
+ * Будує векторний тайл доступних заявок із фільтрами ресурсу та роками створення.
13
+ * @param params Координати тайла, фільтри, роки, користувач і контекст FCore.
8
14
  * @returns Вміст тайла у форматі MVT.
9
15
  */
10
16
  export async function applicationTile(
11
- { z, x, y, filter, user, ctx }: {
17
+ { z, x, y, filter, year = String(new Date().getFullYear()), scope = "all", user, ctx }: ApplicationTileQuery & {
12
18
  z: number;
13
19
  x: number;
14
20
  y: number;
15
- filter: string | undefined;
16
21
  user: User | undefined;
17
22
  ctx: AppContext;
18
23
  }
@@ -22,16 +27,32 @@ export async function applicationTile(
22
27
  throw new BadRequestError("Invalid tile coordinates");
23
28
  }
24
29
 
30
+ const resource = ctx.resource.get(user?.type === "admin" ? "applications" : "public_applications");
31
+
32
+ const filters = buildFilters(resource, filter, 6);
33
+ const scopeFilter = scope === "active"
34
+ ? "AND a.status IN ('awaitingData', 'dataIssued', 'reserve', 'underReview', 'verified')"
35
+ : "";
36
+
25
37
  const surveyorId = user?.type === "admin" ? null : await surveyorForUser({ db: ctx.pg, user });
38
+
26
39
  const result = await ctx.pg.query<{ tile: Buffer }>(
27
40
  `WITH bounds AS (
28
41
  SELECT ST_TileEnvelope($1, $2, $3) AS box
42
+ ), filtered_applications AS (
43
+ SELECT * FROM surveyor.applications ${filters.sql}
29
44
  ), features AS (
30
45
  SELECT a.app_id::text AS id,
31
46
  a.status::text AS status,
32
47
  a.number,
48
+ a.work_type::text AS work_type,
49
+ organization.name AS organization,
50
+ a.area::double precision AS area,
51
+ concat_ws(', ', NULLIF(address.address_text, ''), NULLIF(a.location, '')) AS address,
33
52
  ST_AsMVTGeom(ST_Transform(a.geom, 3857), bounds.box) AS geom
34
- FROM surveyor.applications AS a
53
+ FROM filtered_applications AS a
54
+ LEFT JOIN surveyor.organizations AS organization ON organization.org_id = a.org_id
55
+ LEFT JOIN surveyor.address_lookup AS address ON address.addr_id = a.address_id
35
56
  CROSS JOIN bounds
36
57
  WHERE ST_Intersects(ST_Transform(a.geom, 3857), bounds.box)
37
58
  AND (
@@ -43,11 +64,18 @@ export async function applicationTile(
43
64
  AND os.enabled = true
44
65
  )
45
66
  )
46
- AND ($5::text IS NULL OR a.status::text = $5)
67
+ AND ($5::text = 'all' OR EXISTS (
68
+ SELECT 1
69
+ FROM unnest(string_to_array(NULLIF($5::text, 'all'), ',')::integer[]) AS selected_year(year)
70
+ WHERE a.created_at >= make_date(selected_year.year, 1, 1)
71
+ AND a.created_at < make_date(selected_year.year + 1, 1, 1)
72
+ ))
73
+ ${scopeFilter}
47
74
  )
48
75
  SELECT ST_AsMVT(features, 'applications', 4096, 'geom') AS tile
49
76
  FROM features`,
50
- [z, x, y, surveyorId, filter ?? null]
77
+ [z, x, y, surveyorId, year, ...filters.values]
51
78
  );
79
+
52
80
  return result.rows[0]?.tile ?? Buffer.alloc(0);
53
81
  }
@@ -96,7 +96,7 @@ export default {
96
96
  cancelled_by: { type: "string", write: false, lookup: userLookup },
97
97
  created_by: { type: "string", write: false, lookup: actorLookup },
98
98
  updated_by: { type: "string", write: false, lookup: actorLookup },
99
- created_at: { type: "timestamp", write: false, sortable: true },
99
+ created_at: { type: "timestamp", write: false, filterable: true, sortable: true },
100
100
  updated_at: { type: "timestamp", write: false, sortable: true },
101
101
  },
102
102
  relations: {