@opengis/surveyor 0.0.13 → 0.0.15

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 (71) hide show
  1. package/dist/chunks/{AppIcon-CO70tpMX.js → AppIcon-Di5F4Bu_.js} +1 -1
  2. package/dist/chunks/{AppealDetailField-DNRGpnyD.js → AppealDetailField-DNpsGpPY.js} +2 -2
  3. package/dist/chunks/{AppealStatusBadge-Ct3EcB4_.js → AppealStatusBadge-COxcUM2Q.js} +1 -1
  4. package/dist/chunks/{AppealStatusBadge-BlAaNUSK.js → AppealStatusBadge-z77wwkFD.js} +2 -2
  5. package/dist/chunks/{ApplicationHistorySection-D7KPV2cX.js → ApplicationHistorySection-DHq-iJla.js} +4 -4
  6. package/dist/chunks/{BaseModal-SjP521X9.js → BaseModal-DP_ilBdg.js} +2 -2
  7. package/dist/chunks/{FormFilePicker-DxPQlxgy.js → FormFilePicker-D5fAUE0Z.js} +2 -2
  8. package/dist/chunks/{MapLayerMenu-AUeTqgEp.js → MapLayerMenu-CI5cbLEC.js} +1 -1
  9. package/dist/chunks/{RegistryForm-BlK1lExt.js → RegistryForm-Ct8xiLV0.js} +1 -1
  10. package/dist/chunks/{RegistryFormModal-DhzEpxys.js → RegistryFormModal-DTi3g3CX.js} +3 -3
  11. package/dist/chunks/{RegistryToolbar-DXOEcD84.js → RegistryToolbar-v7DdReH2.js} +5 -5
  12. package/dist/chunks/{SurveyorTeleport-CnSF0Ptl.js → SurveyorTeleport-D6-KXe_5.js} +1 -1
  13. package/dist/chunks/{TablePagination-CUtnDQQ_.js → TablePagination-Iri38U68.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-DEJs9IIP.js → card-Ba8_kfj9.js} +4 -4
  18. package/dist/chunks/{card-C-ohjNkC.js → card-CF5Lo4ui.js} +5 -5
  19. package/dist/chunks/{card-BBx1zR0E.js → card-CJhdeB6f.js} +10 -10
  20. package/dist/chunks/{card-Bj4zFzbe.js → card-CVujkVkR.js} +10 -10
  21. package/dist/chunks/{card-_YyJbLNI.js → card-DcYkb_aF.js} +6 -6
  22. package/dist/chunks/{card-VnUCFC7v.js → card-TP5UFJb2.js} +5 -5
  23. package/dist/chunks/{certificates-DtfZTFN9.js → certificates-Ew5AekPn.js} +6 -6
  24. package/dist/chunks/{create-Cgeu7aKO.js → create-CSIDl4gP.js} +9 -9
  25. package/dist/chunks/{forgot-DoG6vXhq.js → forgot-DnixBqdc.js} +2 -2
  26. package/dist/chunks/{login-BWGylcSU.js → login-BWCQdEkv.js} +2 -2
  27. package/dist/chunks/{map-layers-BmuIMLHa.js → map-layers-BdWEHPLx.js} +6 -6
  28. package/dist/chunks/{map-DkKsEnCM.js → map-mZ8Rn4aR.js} +11 -11
  29. package/dist/chunks/{organizations-BO1dIl7v.js → organizations-D0o0e_ps.js} +7 -7
  30. package/dist/chunks/{profile-CkwMFh82.js → profile-F7mr0poI.js} +3 -3
  31. package/dist/chunks/{registration-3GLgq-ae.js → registration-BRF4985_.js} +2 -2
  32. package/dist/chunks/{requests-rWq8ok3C.js → requests-BCJN-CNx.js} +5 -5
  33. package/dist/chunks/{requests-BZ2jrt5J.js → requests-F0Kp8OPp.js} +5 -5
  34. package/dist/chunks/{reset-CP9LsLkC.js → reset-OZCgLi6f.js} +2 -2
  35. package/dist/chunks/{useEntityPath-C5Owtidc.js → useEntityPath-8s0Y1tjA.js} +1 -1
  36. package/dist/chunks/{users-DOiQeVwn.js → users-Dr543AYk.js} +7 -7
  37. package/dist/index.css +1 -1
  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 +83 -83
  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 +13 -12
  48. package/server/modules/surveyor/services/applicationTile.ts +3 -3
  49. package/server/modules/surveyor/services/cancelApplication.ts +2 -1
  50. package/server/modules/surveyor/services/changeSurveyorPasswordByAdmin.ts +1 -1
  51. package/server/modules/surveyor/services/completeApplication.ts +1 -1
  52. package/server/modules/surveyor/services/identifyApplications.ts +2 -2
  53. package/server/modules/surveyor/services/issueSourceData.ts +1 -1
  54. package/server/modules/surveyor/services/mapLayers.ts +61 -61
  55. package/server/modules/surveyor/services/registerSurveyor.ts +1 -1
  56. package/server/modules/surveyor/services/resendRegistration.ts +1 -1
  57. package/server/modules/surveyor/services/searchApplications.ts +2 -2
  58. package/server/modules/surveyor/services/updateSurveyorAccountStatus.ts +1 -1
  59. package/server/modules/surveyor/services/updateSurveyorStatus.ts +1 -1
  60. package/server/modules/surveyor/services/verifyApplication.ts +1 -1
  61. package/server/modules/surveyor/utils/shared.ts +28 -6
  62. package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -79
  63. package/server/resources/helpers/settlement_lookup.ts +7 -7
  64. package/server/resources/surveyor-admin/application_comments.ts +1 -1
  65. package/server/resources/surveyor-admin/application_status_history.ts +1 -1
  66. package/server/resources/surveyor-admin/applications.ts +1 -1
  67. package/server/resources/surveyor-admin/certificates.ts +1 -1
  68. package/server/resources/surveyor-admin/map_layers.ts +1 -1
  69. package/server/resources/surveyor-admin/organization_surveyors.ts +31 -31
  70. package/server/resources/surveyor-admin/organizations.ts +1 -1
  71. package/server/resources/surveyor-admin/surveyors.ts +1 -1
@@ -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,83 +1,83 @@
1
- {
2
- "name": "@opengis/surveyor",
3
- "version": "0.0.13",
4
- "type": "module",
5
- "author": "Softpro",
6
- "description": "Surveyor admin and geodesist cabinet UI for embedded host applications",
7
- "main": "./dist/index.js",
8
- "types": "./surveyor-types.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./surveyor-types.d.ts",
12
- "import": "./dist/index.js"
13
- },
14
- "./style.css": "./dist/index.css",
15
- "./plugin": {
16
- "types": "./plugin.d.ts",
17
- "import": "./plugin.js"
18
- },
19
- "./plugin.js": {
20
- "types": "./plugin.d.ts",
21
- "import": "./plugin.js"
22
- }
23
- },
24
- "files": [
25
- "dist",
26
- "plugin.js",
27
- "plugin.d.ts",
28
- "server",
29
- "migrations",
30
- "README.md",
31
- "CHANGELOG.md",
32
- "surveyor-types.d.ts"
33
- ],
34
- "scripts": {
35
- "build:lib": "vite build --config vite.lib.config.ts",
36
- "build:admin": "vue-tsc --noEmit -p admin/tsconfig.json && vite build --config admin/vite.config.ts",
37
- "build:cabinet": "vue-tsc --noEmit -p cabinet/tsconfig.json && vite build --config cabinet/vite.config.ts",
38
- "build": "bun run build:lib && bun run build:admin && bun run build:cabinet",
39
- "prepublishOnly": "bun run build:lib",
40
- "start": "bun server/index.ts",
41
- "admin": "bun server/index.ts --admin",
42
- "cabinet": "bun server/index.ts --cabinet",
43
- "prod": "bun server/index.ts --production",
44
- "prod:cabinet": "bun server/index.ts --production --cabinet",
45
- "server:typecheck": "bunx tsc --noEmit -p tsconfig.server.json",
46
- "migrate": "bunx fcore-migrate"
47
- },
48
- "peerDependencies": {
49
- "@opengis/core": "^0.0.37",
50
- "@opengis/filter": "^0.1.59",
51
- "@opengis/form": "^0.1.32",
52
- "vue": "^3.5.0",
53
- "vue-router": "^4.6.0",
54
- "lucide-vue-next": "^0.446.0"
55
- },
56
- "dependencies": {
57
- "@fastify/static": "9.3.0",
58
- "@fastify/swagger": "9.9.0",
59
- "@grpc/grpc-js": "1.14.5",
60
- "@grpc/proto-loader": "0.8.1",
61
- "@opengis/fcore": "0.0.42",
62
- "fastify": "^5.12.3",
63
- "fastify-plugin": "^5.0.1",
64
- "nodemailer": "^10.0.12"
65
- },
66
- "devDependencies": {
67
- "@opengis/core": "^0.0.37",
68
- "@opengis/filter": "^0.1.59",
69
- "@opengis/form": "^0.1.32",
70
- "@tailwindcss/vite": "^4.3.3",
71
- "@types/node": "^26.4.1",
72
- "@vitejs/plugin-vue": "^6.0.1",
73
- "@vue/tsconfig": "^0.8.1",
74
- "lucide-vue-next": "0.446.0",
75
- "postcss-prefix-selector": "^2.2.1",
76
- "tailwindcss": "^4.3.3",
77
- "typescript": "~6.0.2",
78
- "vite": "^8.2.2",
79
- "vue": "^3.5.22",
80
- "vue-router": "^4.6.4",
81
- "vue-tsc": "^3.0.8"
82
- }
83
- }
1
+ {
2
+ "name": "@opengis/surveyor",
3
+ "version": "0.0.15",
4
+ "type": "module",
5
+ "author": "Softpro",
6
+ "description": "Surveyor admin and geodesist cabinet UI for embedded host applications",
7
+ "main": "./dist/index.js",
8
+ "types": "./surveyor-types.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./surveyor-types.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./style.css": "./dist/index.css",
15
+ "./plugin": {
16
+ "types": "./plugin.d.ts",
17
+ "import": "./plugin.js"
18
+ },
19
+ "./plugin.js": {
20
+ "types": "./plugin.d.ts",
21
+ "import": "./plugin.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "plugin.js",
27
+ "plugin.d.ts",
28
+ "server",
29
+ "migrations",
30
+ "README.md",
31
+ "CHANGELOG.md",
32
+ "surveyor-types.d.ts"
33
+ ],
34
+ "scripts": {
35
+ "build:lib": "vite build --config vite.lib.config.ts",
36
+ "build:admin": "vue-tsc --noEmit -p admin/tsconfig.json && vite build --config admin/vite.config.ts",
37
+ "build:cabinet": "vue-tsc --noEmit -p cabinet/tsconfig.json && vite build --config cabinet/vite.config.ts",
38
+ "build": "bun run build:lib && bun run build:admin && bun run build:cabinet",
39
+ "prepublishOnly": "bun run build:lib",
40
+ "start": "bun server/index.ts",
41
+ "admin": "bun server/index.ts --admin",
42
+ "cabinet": "bun server/index.ts --cabinet",
43
+ "prod": "bun server/index.ts --production",
44
+ "prod:cabinet": "bun server/index.ts --production --cabinet",
45
+ "server:typecheck": "bunx tsc --noEmit -p tsconfig.server.json",
46
+ "migrate": "bunx fcore-migrate"
47
+ },
48
+ "peerDependencies": {
49
+ "@opengis/core": "^0.0.37",
50
+ "@opengis/filter": "^0.1.59",
51
+ "@opengis/form": "^0.1.32",
52
+ "vue": "^3.5.0",
53
+ "vue-router": "^4.6.0",
54
+ "lucide-vue-next": "^0.446.0"
55
+ },
56
+ "dependencies": {
57
+ "@fastify/static": "9.3.0",
58
+ "@fastify/swagger": "9.9.0",
59
+ "@grpc/grpc-js": "1.14.5",
60
+ "@grpc/proto-loader": "0.8.1",
61
+ "@opengis/fcore": "0.0.42",
62
+ "fastify": "^5.12.3",
63
+ "fastify-plugin": "^5.0.1",
64
+ "nodemailer": "^10.0.12"
65
+ },
66
+ "devDependencies": {
67
+ "@opengis/core": "^0.0.37",
68
+ "@opengis/filter": "^0.1.59",
69
+ "@opengis/form": "^0.1.32",
70
+ "@tailwindcss/vite": "^4.3.3",
71
+ "@types/node": "^26.4.1",
72
+ "@vitejs/plugin-vue": "^6.0.1",
73
+ "@vue/tsconfig": "^0.8.1",
74
+ "lucide-vue-next": "0.446.0",
75
+ "postcss-prefix-selector": "^2.2.1",
76
+ "tailwindcss": "^4.3.3",
77
+ "typescript": "~6.0.2",
78
+ "vite": "^8.2.2",
79
+ "vue": "^3.5.22",
80
+ "vue-router": "^4.6.4",
81
+ "vue-tsc": "^3.0.8"
82
+ }
83
+ }
@@ -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;
@@ -43,11 +43,12 @@ const user: FastifySchema = {
43
43
  access: "user",
44
44
  permissions: [],
45
45
  };
46
- const administrator: FastifySchema = {
46
+ /** Службовий маршрут: адміністратор або користувач із правом `resource:action`. */
47
+ const staff = (permission: string): FastifySchema => ({
47
48
  tags: ["surveyor"],
48
- access: "admin",
49
- permissions: [],
50
- };
49
+ access: "user",
50
+ permissions: [permission],
51
+ });
51
52
  const publicRoute: FastifySchema = {
52
53
  tags: ["surveyor"],
53
54
  access: "public",
@@ -102,7 +103,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
102
103
  "/api/surveyor/applications/:applicationId/upload-source-data",
103
104
  {
104
105
  schema: {
105
- ...administrator,
106
+ ...staff("applications:update"),
106
107
  params: surveyorSchemas.applicationParams,
107
108
  body: surveyorSchemas.fileBody,
108
109
  },
@@ -136,7 +137,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
136
137
  "/api/surveyor/applications/:applicationId/verify",
137
138
  {
138
139
  schema: {
139
- ...administrator,
140
+ ...staff("applications:update"),
140
141
  params: surveyorSchemas.applicationParams,
141
142
  body: surveyorSchemas.verifyApplication,
142
143
  },
@@ -151,7 +152,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
151
152
  );
152
153
  app.post<ApplicationRoute>(
153
154
  "/api/surveyor/applications/:applicationId/complete",
154
- { schema: { ...administrator, params: surveyorSchemas.applicationParams } },
155
+ { schema: { ...staff("applications:update"), params: surveyorSchemas.applicationParams } },
155
156
  async (req) => completeApplication({ id: req.params.applicationId, user: req.user, ctx })
156
157
  );
157
158
 
@@ -223,7 +224,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
223
224
  );
224
225
  app.post<{ Body: RegisterInput }>(
225
226
  "/api/surveyor/surveyors",
226
- { schema: { ...administrator, body: surveyorSchemas.registerSurveyor } },
227
+ { schema: { ...staff("surveyors:create"), body: surveyorSchemas.registerSurveyor } },
227
228
  async (req) => registerSurveyor({ input: req.body, user: req.user, ctx })
228
229
  );
229
230
  app.post<RegistrationRoute & { Body: PasswordInput }>(
@@ -296,7 +297,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
296
297
  "/api/surveyor/surveyors/:surveyorId/password",
297
298
  {
298
299
  schema: {
299
- ...administrator,
300
+ ...staff("surveyors:update"),
300
301
  summary: "Зміна пароля геодезиста адміністратором",
301
302
  params: surveyorSchemas.surveyorParams,
302
303
  },
@@ -309,14 +310,14 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
309
310
  );
310
311
  app.post<SurveyorRoute>(
311
312
  "/api/surveyor/surveyors/:surveyorId/registration/resend",
312
- { schema: { ...administrator, params: surveyorSchemas.surveyorParams } },
313
+ { schema: { ...staff("surveyors:update"), params: surveyorSchemas.surveyorParams } },
313
314
  async (req) => resendRegistration({ id: req.params.surveyorId, user: req.user, ctx })
314
315
  );
315
316
  app.put<SurveyorRoute & { Body: SurveyorStatusInput }>(
316
317
  "/api/surveyor/surveyors/:surveyorId/status",
317
318
  {
318
319
  schema: {
319
- ...administrator,
320
+ ...staff("surveyors:update"),
320
321
  summary: "Увімкнення або вимкнення доступу геодезиста до організації",
321
322
  params: surveyorSchemas.surveyorParams,
322
323
  body: surveyorSchemas.surveyorStatus,
@@ -333,7 +334,7 @@ export function createSurveyorRoutes(ctx: AppContext): FastifyPluginAsync {
333
334
  "/api/surveyor/surveyors/:surveyorId/account-status",
334
335
  {
335
336
  schema: {
336
- ...administrator,
337
+ ...staff("surveyors:update"),
337
338
  summary: "Повне блокування або розблокування облікового запису геодезиста",
338
339
  params: surveyorSchemas.surveyorParams,
339
340
  body: surveyorSchemas.surveyorAccountStatus,
@@ -1,6 +1,6 @@
1
1
  import type { AppContext, User } from "@opengis/fcore";
2
2
  import { BadRequestError, buildFilters } from "@opengis/fcore";
3
- import { actor, surveyorForUser } from "../utils/shared.js";
3
+ import { actor, isStaff, surveyorForUser } from "../utils/shared.js";
4
4
 
5
5
  export type ApplicationTileQuery = {
6
6
  filter?: Record<string, unknown>;
@@ -27,14 +27,14 @@ export async function applicationTile(
27
27
  throw new BadRequestError("Invalid tile coordinates");
28
28
  }
29
29
 
30
- const resource = ctx.resource.get(user?.type === "admin" ? "applications" : "public_applications");
30
+ const resource = ctx.resource.get(isStaff(user) ? "applications" : "public_applications");
31
31
 
32
32
  const filters = buildFilters(resource, filter, 6);
33
33
  const scopeFilter = scope === "active"
34
34
  ? "AND a.status IN ('awaitingData', 'dataIssued', 'reserve', 'underReview', 'verified')"
35
35
  : "";
36
36
 
37
- const surveyorId = user?.type === "admin" ? null : await surveyorForUser({ db: ctx.pg, user });
37
+ const surveyorId = isStaff(user) ? null : await surveyorForUser({ db: ctx.pg, user });
38
38
 
39
39
  const result = await ctx.pg.query<{ tile: Buffer }>(
40
40
  `WITH bounds AS (
@@ -5,6 +5,7 @@ import {
5
5
  assertStatus,
6
6
  audit,
7
7
  history,
8
+ isStaff,
8
9
  readApplication,
9
10
  releaseReservesForParent,
10
11
  surveyorForUser,
@@ -28,7 +29,7 @@ export async function cancelApplication({
28
29
  ctx: AppContext;
29
30
  }) {
30
31
  const uid = actor(user);
31
- if (user?.type === "admin") {
32
+ if (isStaff(user)) {
32
33
  throw new ForbiddenError("Administrator cannot cancel an application");
33
34
  }
34
35
 
@@ -12,7 +12,7 @@ export async function changeSurveyorPasswordByAdmin(
12
12
  ctx: AppContext;
13
13
  }
14
14
  ) {
15
- const uid = admin(user);
15
+ const uid = admin(user, "surveyors:update");
16
16
  const password = randomBytes(16).toString("hex");
17
17
  const passwordHash = await hashPassword(password);
18
18
  const surveyor = await ctx.pg.query<{ surveyor_id: string; email: string }>(
@@ -16,7 +16,7 @@ import {
16
16
  export async function completeApplication(
17
17
  { id, user, ctx }: { id: string; user: User | undefined; ctx: AppContext }
18
18
  ) {
19
- const uid = admin(user);
19
+ const uid = admin(user, "applications:update");
20
20
  const result = await ctx.pg.transaction(async (db: Db) => {
21
21
  // Узгоджує завершення та звільнення резервів із паралельним створенням заявок.
22
22
  await db.query("SELECT pg_advisory_xact_lock(85437120)");
@@ -1,7 +1,7 @@
1
1
  import type { AppContext, User } from "@opengis/fcore";
2
2
  import { BadRequestError } from "@opengis/fcore";
3
3
  import applicationStatus from "../../../dictionaries/surveyor/application_status.js";
4
- import { actor, surveyorForUser, type Status } from "../utils/shared.js";
4
+ import { actor, isStaff, surveyorForUser, type Status } from "../utils/shared.js";
5
5
 
6
6
  const statusCodes = new Set(applicationStatus.items.map((item) => item.code));
7
7
 
@@ -38,7 +38,7 @@ export async function identifyApplications({
38
38
  const page = input.page ?? 1;
39
39
  const limit = input.limit ?? 10;
40
40
 
41
- const isAdmin = user?.type === "admin";
41
+ const isAdmin = isStaff(user);
42
42
  if (!isAdmin) await surveyorForUser({ db: ctx.pg, user });
43
43
 
44
44
  const resourceName = isAdmin ? "applications" : "public_applications";
@@ -22,7 +22,7 @@ export async function issueSourceData(
22
22
  ctx: AppContext;
23
23
  }
24
24
  ) {
25
- const uid = admin(user);
25
+ const uid = admin(user, "applications:update");
26
26
  const file = await attachedFile({ ctx, appId: id, filePath: input.file_path });
27
27
  const result = await ctx.pg.transaction(async (db: Db) => {
28
28
  const updated = await db.query<{ app_id: string }>(
@@ -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
+ }
@@ -21,7 +21,7 @@ export type RegisterInput = {
21
21
  export async function registerSurveyor(
22
22
  { input, user, ctx }: { input: RegisterInput; user: User | undefined; ctx: AppContext }
23
23
  ) {
24
- const uid = admin(user);
24
+ const uid = admin(user, "surveyors:create");
25
25
  const orgId = input.organization_id;
26
26
  const certId = input.certificate_id;
27
27
  const email = input.email.toLowerCase();
@@ -12,7 +12,7 @@ import { sendActivationEmail } from "../utils/mail.js";
12
12
  export async function resendRegistration(
13
13
  { id, user, ctx }: { id: string; user: User | undefined; ctx: AppContext }
14
14
  ) {
15
- const uid = admin(user);
15
+ const uid = admin(user, "surveyors:update");
16
16
  const rawToken = token();
17
17
  const result = await ctx.pg.query<{ email: string }>(
18
18
  `UPDATE surveyor.surveyors
@@ -1,5 +1,5 @@
1
1
  import type { AppContext, User } from "@opengis/fcore";
2
- import { actor, surveyorForUser, type Status } from "../utils/shared.js";
2
+ import { actor, isStaff, surveyorForUser, type Status } from "../utils/shared.js";
3
3
 
4
4
  export type ApplicationSearchInput = {
5
5
  search: string;
@@ -25,7 +25,7 @@ export async function searchApplications(
25
25
  const page = input.page ?? 1;
26
26
  const limit = input.limit ?? 20;
27
27
 
28
- const surveyorId = user?.type === "admin" ? null : await surveyorForUser({ db: ctx.pg, user });
28
+ const surveyorId = isStaff(user) ? null : await surveyorForUser({ db: ctx.pg, user });
29
29
  const pattern = `%${search.replace(/[\\%_]/g, "\\$&")}%`;
30
30
 
31
31
  const fromWhere = `FROM surveyor.applications AS a