@opengis/surveyor 0.0.7 → 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", {
@@ -140,7 +140,7 @@ var K = /*#__PURE__*/ r(W, [["render", G], ["__file", "C:/softpro/surveyor/src/w
140
140
  t();
141
141
  let n = {
142
142
  Index: S(() => import("./chunks/requests-BTpLXrNj.js")),
143
- Card: S(() => import("./chunks/card-9r6Si3cz.js")),
143
+ Card: S(() => import("./chunks/card-6z-m7UkM.js")),
144
144
  BaseEntityWrapper: K,
145
145
  SurveyorEmbedShell: B
146
146
  };
@@ -279,9 +279,9 @@ var Se = /*#__PURE__*/ r(be, [["render", xe], ["__file", "C:/softpro/surveyor/sr
279
279
  setup(e, { expose: t }) {
280
280
  t();
281
281
  let n = {
282
- Index: S(() => import("./chunks/requests-BM6XqgpC.js")),
283
- Create: S(() => import("./chunks/create-BAsyL76t.js")),
284
- Card: S(() => import("./chunks/card-rXkTqZqA.js")),
282
+ Index: S(() => import("./chunks/requests-rWq8ok3C.js")),
283
+ Create: S(() => import("./chunks/create-DR8tXNYj.js")),
284
+ Card: S(() => import("./chunks/card-Dlp8_KhV.js")),
285
285
  BaseEntityWrapper: K,
286
286
  SurveyorEmbedShell: B
287
287
  };
@@ -674,7 +674,7 @@ var X = [
674
674
  {
675
675
  path: "requests",
676
676
  name: "requests",
677
- component: () => import("./chunks/requests-BM6XqgpC.js"),
677
+ component: () => import("./chunks/requests-rWq8ok3C.js"),
678
678
  meta: {
679
679
  title: "Звернення",
680
680
  label: "Звернення на видачу та прийом матеріалів",
@@ -684,7 +684,7 @@ var X = [
684
684
  {
685
685
  path: "requests/new",
686
686
  name: "request-create",
687
- component: () => import("./chunks/create-BAsyL76t.js"),
687
+ component: () => import("./chunks/create-DR8tXNYj.js"),
688
688
  meta: {
689
689
  title: "Нове звернення",
690
690
  section: "requests"
@@ -693,7 +693,7 @@ var X = [
693
693
  {
694
694
  path: "requests/:number",
695
695
  name: "request-detail",
696
- component: () => import("./chunks/card-rXkTqZqA.js"),
696
+ component: () => import("./chunks/card-Dlp8_KhV.js"),
697
697
  meta: {
698
698
  title: "Звернення",
699
699
  section: "requests"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/surveyor",
3
- "version": "0.0.7",
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
  });
@@ -138,6 +138,7 @@ export const surveyorSchemas = {
138
138
  work_type: { type: "string", enum: workTypes.items.map((item) => item.code) },
139
139
  description: { type: "string" },
140
140
  execution_basis: { type: "string" },
141
+ notes: { type: "string" },
141
142
  settlement_id: nonBlank,
142
143
  is_found_address_id: { type: "boolean" },
143
144
  address_id: nonBlank,
@@ -418,7 +419,24 @@ export const surveyorSchemas = {
418
419
  },
419
420
  tileQuery: {
420
421
  type: "object",
421
- 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
+ },
422
440
  additionalProperties: false,
423
441
  },
424
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
  }
@@ -137,10 +137,10 @@ export async function createApplication(
137
137
  `INSERT INTO surveyor.applications (
138
138
  number, org_id, surveyor_id, status, work_type, description,
139
139
  execution_basis, settlement_id, is_found_address_id, address_id,
140
- location, area, geom, created_by
140
+ location, area, geom, created_by, notes
141
141
  ) VALUES (
142
142
  $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12,
143
- ST_SetSRID(ST_GeomFromGeoJSON($13), 4326), $14
143
+ ST_SetSRID(ST_GeomFromGeoJSON($13), 4326), $14, $15
144
144
  ) RETURNING app_id`,
145
145
  [
146
146
  number,
@@ -157,6 +157,7 @@ export async function createApplication(
157
157
  area.toFixed(4),
158
158
  geojson,
159
159
  uid,
160
+ input.notes ?? null,
160
161
  ]
161
162
  );
162
163
  const id = inserted.rows[0]!.app_id;
@@ -5,6 +5,7 @@ export type CreateInput = {
5
5
  work_type: string;
6
6
  description?: string;
7
7
  execution_basis?: string;
8
+ notes?: string;
8
9
  settlement_id: string;
9
10
  is_found_address_id: boolean;
10
11
  address_id?: string;
@@ -116,7 +116,7 @@ export default {
116
116
  't."enabled"',
117
117
  ],
118
118
  },
119
- history: {
119
+ status_history: {
120
120
  resource: "application_status_history",
121
121
  localKey: "app_id",
122
122
  foreignKey: "application_id",
@@ -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: {
@@ -122,7 +122,7 @@ export default {
122
122
  't."enabled"',
123
123
  ],
124
124
  },
125
- history: {
125
+ status_history: {
126
126
  resource: "public_application_status_history",
127
127
  localKey: "app_id",
128
128
  foreignKey: "application_id",