@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.
Files changed (63) hide show
  1. package/README.md +4 -3
  2. package/dist/chunks/{AppIcon-CO70tpMX.js → AppIcon-Di5F4Bu_.js} +1 -1
  3. package/dist/chunks/{AppealDetailField-DNRGpnyD.js → AppealDetailField-DNpsGpPY.js} +2 -2
  4. package/dist/chunks/{AppealStatusBadge-Cu-UzdzA.js → AppealStatusBadge-MP1qD952.js} +1 -1
  5. package/dist/chunks/{AppealStatusBadge-BlAaNUSK.js → AppealStatusBadge-z77wwkFD.js} +2 -2
  6. package/dist/chunks/{ApplicationHistorySection-Cwq0-Frd.js → ApplicationHistorySection-DIoFZwH6.js} +4 -4
  7. package/dist/chunks/{BaseModal-SQXvRRNW.js → BaseModal-DP_ilBdg.js} +21 -11
  8. package/dist/chunks/{FormFilePicker-DxPQlxgy.js → FormFilePicker-D5fAUE0Z.js} +2 -2
  9. package/dist/chunks/{MapLayerMenu-AUeTqgEp.js → MapLayerMenu-CI5cbLEC.js} +1 -1
  10. package/dist/chunks/{RegistryForm-wG-c8GKf.js → RegistryForm-DbCxZsr0.js} +1 -1
  11. package/dist/chunks/{RegistryFormModal-R_iZYqGE.js → RegistryFormModal-D_KLGj2d.js} +3 -3
  12. package/dist/chunks/{RegistryToolbar-322DKUXi.js → RegistryToolbar-DvbrASlj.js} +6 -6
  13. package/dist/chunks/{SurveyorTeleport-CnSF0Ptl.js → SurveyorTeleport-D6-KXe_5.js} +1 -1
  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-CWqi1K-x.js → card--XUb1kFK.js} +4 -4
  18. package/dist/chunks/{card-C3y-j2TA.js → card-BrjnXf1N.js} +6 -6
  19. package/dist/chunks/{card-6z-m7UkM.js → card-BsTSF6aL.js} +10 -10
  20. package/dist/chunks/{card-Dlp8_KhV.js → card-CI7ntIHf.js} +5 -5
  21. package/dist/chunks/{card-DWpAv92l.js → card-Cu8QOSIw.js} +4 -4
  22. package/dist/chunks/{card-X9UVFgdR.js → card-ylC5NYbz.js} +241 -208
  23. package/dist/chunks/certificates-BnseQylH.js +209 -0
  24. package/dist/chunks/certificates-aJ-hvaP-.js +236 -0
  25. package/dist/chunks/{create-DR8tXNYj.js → create-Bi7-j9Ri.js} +9 -9
  26. package/dist/chunks/{forgot-DoG6vXhq.js → forgot-DnixBqdc.js} +2 -2
  27. package/dist/chunks/{login-BWGylcSU.js → login-BWCQdEkv.js} +2 -2
  28. package/dist/chunks/{map-DvwFkxAS.js → map-CwsVIW79.js} +940 -831
  29. package/dist/chunks/{map-layers-sT-gTiD_.js → map-layers-BLiEYC4C.js} +5 -5
  30. package/dist/chunks/{organizations-ByVE2f0c.js → organizations-mc6FlSwe.js} +6 -6
  31. package/dist/chunks/{profile-CkwMFh82.js → profile-F7mr0poI.js} +3 -3
  32. package/dist/chunks/{registration-3GLgq-ae.js → registration-BRF4985_.js} +2 -2
  33. package/dist/chunks/{requests-BTpLXrNj.js → requests-7pD2ckdx.js} +4 -4
  34. package/dist/chunks/{requests-rWq8ok3C.js → requests-BCJN-CNx.js} +5 -5
  35. package/dist/chunks/{reset-CP9LsLkC.js → reset-OZCgLi6f.js} +2 -2
  36. package/dist/chunks/{useEntityPath-C5Owtidc.js → useEntityPath-8s0Y1tjA.js} +1 -1
  37. package/dist/chunks/{users-U1P6xCP4.js → users-CAEjpaI1.js} +6 -6
  38. package/dist/index.css +1 -1
  39. package/dist/index.js +40 -40
  40. package/migrations/20261016120000_map_layers.sql +156 -156
  41. package/migrations/20261016150000_password_reset.sql +15 -15
  42. package/migrations/20261016180000_settlement_lookup.sql +16 -16
  43. package/package.json +1 -1
  44. package/server/dictionaries/index.ts +17 -17
  45. package/server/dictionaries/surveyor/map_layer_components.ts +11 -11
  46. package/server/dictionaries/surveyor/map_layer_groups.ts +10 -10
  47. package/server/dictionaries/surveyor/map_layer_types.ts +11 -11
  48. package/server/modules/surveyor/services/createApplication.ts +2 -3
  49. package/server/modules/surveyor/services/mapLayers.ts +61 -61
  50. package/server/modules/surveyor/services/registerSurveyor.ts +3 -4
  51. package/server/modules/surveyor/services/requestPasswordReset.ts +1 -0
  52. package/server/modules/surveyor/services/resetSurveyorPassword.ts +1 -0
  53. package/server/modules/surveyor/services/updateSurveyorAccountStatus.ts +52 -52
  54. package/server/modules/surveyor/services/updateSurveyorStatus.ts +53 -53
  55. package/server/modules/surveyor/utils/certificateStatus.ts +15 -0
  56. package/server/modules/surveyor/utils/mail.ts +49 -20
  57. package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -79
  58. package/server/resources/helpers/settlement_lookup.ts +7 -7
  59. package/server/resources/surveyor-admin/certificates.ts +27 -1
  60. package/server/resources/surveyor-admin/map_layers.ts +69 -69
  61. package/server/resources/surveyor-admin/organization_surveyors.ts +31 -31
  62. package/server/resources/surveyor-admin/organizations.ts +61 -61
  63. package/dist/chunks/certificates-Cwch72-o.js +0 -425
@@ -25,29 +25,56 @@ function mailSetting(name: string): string {
25
25
  return value;
26
26
  }
27
27
 
28
- function mailDisabled(): boolean {
29
- return process.env["mail.disable"]?.trim().toLowerCase() === "true";
28
+ function assertMailEnabled(): void {
29
+ if (process.env["mail.disable"]?.trim().toLowerCase() === "true") {
30
+ throw new FCoreError("MAIL_DISABLED", "Email sending is disabled", 503);
31
+ }
30
32
  }
31
33
 
32
34
  function activationLink(token: string): URL {
33
35
  return tokenLink("activation_url", token);
34
36
  }
35
37
 
38
+ function isHttpUrl(url: URL): boolean {
39
+ return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password;
40
+ }
41
+
42
+ /** Домен для посилань, заданих шляхом (`/cabinet/registration/{token}`). */
43
+ function baseUrl(): URL {
44
+ const value = mailSetting("base_url").trim();
45
+ try {
46
+ const url = new URL(value);
47
+ if (!isHttpUrl(url)) {
48
+ throw new Error();
49
+ }
50
+ return url;
51
+ } catch {
52
+ throw new FCoreError("MAIL_NOT_CONFIGURED", "mail.base_url must be an HTTP(S) URL", 500);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Будує посилання з mail.<setting>: повний HTTP(S) URL або шлях від кореня, який доповнюється mail.base_url.
58
+ * Лист потребує абсолютного посилання, тому шлях без mail.base_url вважається помилкою конфігурації.
59
+ */
36
60
  function tokenLink(setting: "activation_url" | "password_reset_url", token: string): URL {
37
61
  const template = mailSetting(setting).trim();
62
+ // "//host/..." — це вже інший домен, тому шляхом вважаємо лише "/..." без другого слеша.
63
+ const isPath = template.startsWith("/") && !template.startsWith("//");
64
+ const base = isPath ? baseUrl() : undefined;
38
65
  try {
39
66
  if (!template.includes("{token}")) {
40
67
  throw new Error();
41
68
  }
42
- const url = new URL(template.replaceAll("{token}", encodeURIComponent(token)));
43
- if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
69
+ const url = new URL(template.replaceAll("{token}", encodeURIComponent(token)), base);
70
+ if (!isHttpUrl(url)) {
44
71
  throw new Error();
45
72
  }
46
73
  return url;
47
74
  } catch {
48
75
  throw new FCoreError(
49
76
  "MAIL_NOT_CONFIGURED",
50
- `mail.${setting} must be an HTTP(S) URL containing {token}`,
77
+ `mail.${setting} must be an HTTP(S) URL or a path starting with / containing {token}`,
51
78
  500
52
79
  );
53
80
  }
@@ -60,7 +87,7 @@ async function sendEmail(
60
87
  template: MailTemplate;
61
88
  data: Record<string, string>;
62
89
  }
63
- ): Promise<boolean> {
90
+ ): Promise<true> {
64
91
  let html: string;
65
92
  try {
66
93
  const source = await readFile(new URL(`./templates/${template}.hbs`, import.meta.url), "utf8");
@@ -76,7 +103,7 @@ async function sendEmail(
76
103
  }
77
104
 
78
105
  const from = mailSetting("from");
79
- const transport = nodemailer.createTransport({
106
+ const options = {
80
107
  service: mailSetting("service").trim(),
81
108
  auth: { user: mailSetting("auth.user"), pass: mailSetting("auth.pass") },
82
109
  requireTLS: true,
@@ -85,29 +112,31 @@ async function sendEmail(
85
112
  socketTimeout: 20_000,
86
113
  logger: false,
87
114
  debug: false,
88
- });
115
+ };
89
116
 
117
+ let transport: ReturnType<typeof nodemailer.createTransport> | undefined;
90
118
  try {
119
+ transport = nodemailer.createTransport(options);
91
120
  const result = await transport.sendMail({ from, to: email, subject, html });
92
- if (!result.accepted.length) {
121
+ if (!result.accepted?.length || result.rejected?.length) {
93
122
  throw new Error();
94
123
  }
95
124
  return true;
96
125
  } catch {
97
126
  throw new FCoreError("MAIL_SEND_FAILED", "Failed to send email", 502);
98
127
  } finally {
99
- transport.close();
128
+ transport?.close();
100
129
  }
101
130
  }
102
131
 
103
132
  /**
104
133
  * Надсилає лист реєстрації зі старого шаблону та одноразовим посиланням активації.
105
- * @returns Чи прийняв поштовий сервер лист; false, якщо mail.disable=true.
134
+ * @returns true, якщо поштовий сервер прийняв лист; інакше викидає помилку.
106
135
  */
107
136
  export async function sendActivationEmail(
108
137
  { email, token }: { email: string; token: string }
109
- ): Promise<boolean> {
110
- if (mailDisabled()) return false;
138
+ ): Promise<true> {
139
+ assertMailEnabled();
111
140
  const url = activationLink(token);
112
141
  return sendEmail({
113
142
  email,
@@ -119,12 +148,12 @@ export async function sendActivationEmail(
119
148
 
120
149
  /**
121
150
  * Надсилає одноразове посилання відновлення пароля (mail.password_reset_url).
122
- * @returns Чи прийняв поштовий сервер лист; false, якщо mail.disable=true.
151
+ * @returns true, якщо поштовий сервер прийняв лист; інакше викидає помилку.
123
152
  */
124
153
  export async function sendPasswordResetEmail(
125
154
  { email, token }: { email: string; token: string }
126
- ): Promise<boolean> {
127
- if (mailDisabled()) return false;
155
+ ): Promise<true> {
156
+ assertMailEnabled();
128
157
  const url = tokenLink("password_reset_url", token);
129
158
  return sendEmail({
130
159
  email,
@@ -135,8 +164,8 @@ export async function sendPasswordResetEmail(
135
164
  }
136
165
 
137
166
  /** Повідомляє геодезиста про зміну пароля через шаблон ds.surveyor_send_mail.pt. */
138
- export async function sendPasswordChangedEmail({ email }: { email: string }): Promise<boolean> {
139
- if (mailDisabled()) return false;
167
+ export async function sendPasswordChangedEmail({ email }: { email: string }): Promise<true> {
168
+ assertMailEnabled();
140
169
  const url = activationLink("");
141
170
  return sendEmail({
142
171
  email,
@@ -149,8 +178,8 @@ export async function sendPasswordChangedEmail({ email }: { email: string }): Pr
149
178
  /** Надсилає логін і згенерований адміністратором пароль. */
150
179
  export async function sendAdminPasswordChangedEmail(
151
180
  { email, password }: { email: string; password: string }
152
- ): Promise<boolean> {
153
- if (mailDisabled()) return false;
181
+ ): Promise<true> {
182
+ assertMailEnabled();
154
183
  const url = activationLink("");
155
184
  return sendEmail({
156
185
  email,
@@ -1,79 +1,79 @@
1
- <!DOCTYPE html>
2
- <html lang="uk">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Відновлення пароля</title>
8
- <style>
9
- body {
10
- font-family: Arial, sans-serif;
11
- color: #333;
12
- background-color: #f4f4f4;
13
- padding: 20px;
14
- }
15
-
16
- .email-container {
17
- max-width: 600px;
18
- margin: 0 auto;
19
- background-color: #ffffff;
20
- padding: 20px;
21
- border-radius: 5px;
22
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
23
- }
24
-
25
- h1 {
26
- font-size: 20px;
27
- color: #000;
28
- margin-bottom: 20px;
29
- }
30
-
31
- p {
32
- line-height: 1.6;
33
- margin: 10px 0;
34
- }
35
-
36
- .credentials {
37
- font-weight: bold;
38
- margin-top: 10px;
39
- }
40
-
41
- a {
42
- color: #007bff;
43
- text-decoration: none;
44
- }
45
-
46
- a:hover {
47
- text-decoration: underline;
48
- }
49
-
50
- .footer {
51
- font-size: 12px;
52
- color: #777;
53
- margin-top: 20px;
54
- text-align: center;
55
- }
56
- </style>
57
- </head>
58
-
59
- <body>
60
- <div class="email-container">
61
- <h1>Відновлення пароля до
62
- <a target="_blank" href="{{protocol}}://{{host}}">кабінету геодезиста</a>
63
- </h1>
64
- <p class="credentials">
65
- Логін: <strong>{{login}}</strong>
66
- </p>
67
- <p>
68
- Щоб встановити новий пароль, відкрийте це посилання або скопіюйте його в адресний рядок вашого браузера:<br>
69
- <a target="_blank" href="{{resetUrl}}">{{resetUrl}}</a>
70
- </p>
71
- <p>Посилання дійсне протягом 1 години і може бути використане лише один раз.</p>
72
- <p>Якщо ви не надсилали запит на відновлення пароля, проігноруйте цей лист — ваш поточний пароль залишиться без змін.</p>
73
- <div class="footer">
74
- Це автоматично створений лист, будь ласка, не відповідайте на нього.
75
- </div>
76
- </div>
77
- </body>
78
-
79
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="uk">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Відновлення пароля</title>
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ color: #333;
12
+ background-color: #f4f4f4;
13
+ padding: 20px;
14
+ }
15
+
16
+ .email-container {
17
+ max-width: 600px;
18
+ margin: 0 auto;
19
+ background-color: #ffffff;
20
+ padding: 20px;
21
+ border-radius: 5px;
22
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
23
+ }
24
+
25
+ h1 {
26
+ font-size: 20px;
27
+ color: #000;
28
+ margin-bottom: 20px;
29
+ }
30
+
31
+ p {
32
+ line-height: 1.6;
33
+ margin: 10px 0;
34
+ }
35
+
36
+ .credentials {
37
+ font-weight: bold;
38
+ margin-top: 10px;
39
+ }
40
+
41
+ a {
42
+ color: #007bff;
43
+ text-decoration: none;
44
+ }
45
+
46
+ a:hover {
47
+ text-decoration: underline;
48
+ }
49
+
50
+ .footer {
51
+ font-size: 12px;
52
+ color: #777;
53
+ margin-top: 20px;
54
+ text-align: center;
55
+ }
56
+ </style>
57
+ </head>
58
+
59
+ <body>
60
+ <div class="email-container">
61
+ <h1>Відновлення пароля до
62
+ <a target="_blank" href="{{protocol}}://{{host}}">кабінету геодезиста</a>
63
+ </h1>
64
+ <p class="credentials">
65
+ Логін: <strong>{{login}}</strong>
66
+ </p>
67
+ <p>
68
+ Щоб встановити новий пароль, відкрийте це посилання або скопіюйте його в адресний рядок вашого браузера:<br>
69
+ <a target="_blank" href="{{resetUrl}}">{{resetUrl}}</a>
70
+ </p>
71
+ <p>Посилання дійсне протягом 1 години і може бути використане лише один раз.</p>
72
+ <p>Якщо ви не надсилали запит на відновлення пароля, проігноруйте цей лист — ваш поточний пароль залишиться без змін.</p>
73
+ <div class="footer">
74
+ Це автоматично створений лист, будь ласка, не відповідайте на нього.
75
+ </div>
76
+ </div>
77
+ </body>
78
+
79
+ </html>
@@ -1,7 +1,7 @@
1
- // The view prefixes the settlement name with its type for lookup labels.
2
- export const settlementLookup = {
3
- table: "surveyor.settlement_lookup",
4
- value: "katottg",
5
- text: "settlement_text",
6
- filterFields: ["level"],
7
- };
1
+ // The view prefixes the settlement name with its type for lookup labels.
2
+ export const settlementLookup = {
3
+ table: "surveyor.settlement_lookup",
4
+ value: "katottg",
5
+ text: "settlement_text",
6
+ filterFields: ["level"],
7
+ };
@@ -1,6 +1,7 @@
1
1
  import type { ResourceContract } from "@opengis/fcore";
2
2
  import accountTypes from "../../dictionaries/surveyor/account_types.js";
3
3
  import { userLookup } from "../helpers/user_lookup.js";
4
+ import { certificateStatusSql } from "../../modules/surveyor/utils/certificateStatus.js";
4
5
 
5
6
  const accountTypeCodes = accountTypes.items.map(({ code }) => code);
6
7
 
@@ -13,7 +14,18 @@ export default {
13
14
  table: "surveyor.certificates",
14
15
  key: "certificate_id",
15
16
  display: ["surveyor_name", "number_certificate"],
16
- displayFields: ["number_certificate", "surveyor_phone", "surveyor_email"],
17
+ // Форма додавання користувача бере з /list статус сертифіката та наявний обліковий запис.
18
+ displayFields: [
19
+ "number_certificate",
20
+ "surveyor_phone",
21
+ "surveyor_email",
22
+ `${certificateStatusSql("t")} AS certificate_status`,
23
+ "account_id",
24
+ "account_name",
25
+ "account_email",
26
+ "account_phone",
27
+ "account_registered_at",
28
+ ],
17
29
  access: "admin",
18
30
  operations: ["read"],
19
31
  searchable: ["surveyor_name", "last_name", "first_name", "number_certificate"],
@@ -77,6 +89,20 @@ export default {
77
89
  isvalid: { type: "boolean", write: false, filterable: true },
78
90
  qualification_level: { type: "string", write: false },
79
91
  },
92
+ // Колонки мають префікс account_, щоб не конфліктувати з полями сертифіката.
93
+ // scope "item" не додає join до основного списку сертифікатів.
94
+ joins: [{
95
+ scope: "item",
96
+ sql: `LEFT JOIN LATERAL (
97
+ SELECT s.surveyor_id AS account_id,
98
+ concat_ws(' ', s.last_name, s.first_name, s.middle_name) AS account_name,
99
+ s.email AS account_email,
100
+ s.phone AS account_phone,
101
+ s.registered_at AS account_registered_at
102
+ FROM surveyor.surveyors s
103
+ WHERE s.certificate_id = t.certificate_id
104
+ ) AS account ON true`,
105
+ }],
80
106
  relations: {
81
107
  surveyors: {
82
108
  resource: "surveyors",
@@ -1,69 +1,69 @@
1
- import type { ResourceContract } from "@opengis/fcore";
2
- import mapLayerComponents from "../../dictionaries/surveyor/map_layer_components.js";
3
- import mapLayerGroups from "../../dictionaries/surveyor/map_layer_groups.js";
4
- import mapLayerTypes from "../../dictionaries/surveyor/map_layer_types.js";
5
- import { userLookup } from "../helpers/user_lookup.js";
6
-
7
- // Panel order is sort_order inside each group; the cabinet reads the list via /api/surveyor/map/layers.
8
- export default {
9
- version: 1,
10
- name: "map_layers",
11
- module: "surveyor",
12
- title: "Шари карти",
13
- table: "surveyor.map_layers",
14
- key: "layer_id",
15
- display: ["name"],
16
- displayFields: ["code", "layer_group", "layer_type"],
17
- access: "admin",
18
- operations: ["read", "create", "update", "delete"],
19
- searchable: ["name", "code"],
20
- fields: {
21
- layer_id: { type: "text", write: false, filterable: true },
22
- code: { type: "string", write: true, required: true, searchable: true, sortable: true, pattern: "^[a-z0-9_-]+$" },
23
- name: { type: "string", write: true, required: true, searchable: true, sortable: true },
24
- layer_group: {
25
- type: "string",
26
- write: true,
27
- required: true,
28
- filterable: true,
29
- sortable: true,
30
- dictionary: mapLayerGroups.code,
31
- enum: mapLayerGroups.items.map(({ code }) => code),
32
- },
33
- layer_type: {
34
- type: "string",
35
- write: true,
36
- required: true,
37
- filterable: true,
38
- dictionary: mapLayerTypes.code,
39
- enum: mapLayerTypes.items.map(({ code }) => code),
40
- },
41
- tiles: { type: "string", array: true, write: true },
42
- scheme: { type: "string", write: true, enum: ["xyz", "tms"] },
43
- source_layer: { type: "string", write: true },
44
- attribution: { type: "string", write: true },
45
- minzoom: { type: "integer", write: true, minimum: 0, maximum: 24 },
46
- maxzoom: { type: "integer", write: true, minimum: 0, maximum: 24 },
47
- opacity: { type: "number", write: true, minimum: 0, maximum: 1 },
48
- style: { type: "json", write: true },
49
- legend: { type: "json", write: true },
50
- preview: { type: "string", write: true },
51
- // No `enum`: FCore checks it against the whole value, so arrays never pass.
52
- // Allowed values are enforced by map_layers_components_check.
53
- components: {
54
- type: "string",
55
- array: true,
56
- write: true,
57
- filterable: true,
58
- dictionary: mapLayerComponents.code,
59
- },
60
- sort_order: { type: "integer", write: true, sortable: true },
61
- is_default: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
62
- has_filters: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
63
- enabled: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
64
- created_by: { type: "string", write: false, lookup: userLookup },
65
- created_at: { type: "timestamp", write: false, sortable: true },
66
- updated_by: { type: "string", write: false, lookup: userLookup },
67
- updated_at: { type: "timestamp", write: false, sortable: true },
68
- },
69
- } satisfies ResourceContract;
1
+ import type { ResourceContract } from "@opengis/fcore";
2
+ import mapLayerComponents from "../../dictionaries/surveyor/map_layer_components.js";
3
+ import mapLayerGroups from "../../dictionaries/surveyor/map_layer_groups.js";
4
+ import mapLayerTypes from "../../dictionaries/surveyor/map_layer_types.js";
5
+ import { userLookup } from "../helpers/user_lookup.js";
6
+
7
+ // Panel order is sort_order inside each group; the cabinet reads the list via /api/surveyor/map/layers.
8
+ export default {
9
+ version: 1,
10
+ name: "map_layers",
11
+ module: "surveyor",
12
+ title: "Шари карти",
13
+ table: "surveyor.map_layers",
14
+ key: "layer_id",
15
+ display: ["name"],
16
+ displayFields: ["code", "layer_group", "layer_type"],
17
+ access: "admin",
18
+ operations: ["read", "create", "update", "delete"],
19
+ searchable: ["name", "code"],
20
+ fields: {
21
+ layer_id: { type: "text", write: false, filterable: true },
22
+ code: { type: "string", write: true, required: true, searchable: true, sortable: true, pattern: "^[a-z0-9_-]+$" },
23
+ name: { type: "string", write: true, required: true, searchable: true, sortable: true },
24
+ layer_group: {
25
+ type: "string",
26
+ write: true,
27
+ required: true,
28
+ filterable: true,
29
+ sortable: true,
30
+ dictionary: mapLayerGroups.code,
31
+ enum: mapLayerGroups.items.map(({ code }) => code),
32
+ },
33
+ layer_type: {
34
+ type: "string",
35
+ write: true,
36
+ required: true,
37
+ filterable: true,
38
+ dictionary: mapLayerTypes.code,
39
+ enum: mapLayerTypes.items.map(({ code }) => code),
40
+ },
41
+ tiles: { type: "string", array: true, write: true },
42
+ scheme: { type: "string", write: true, enum: ["xyz", "tms"] },
43
+ source_layer: { type: "string", write: true },
44
+ attribution: { type: "string", write: true },
45
+ minzoom: { type: "integer", write: true, minimum: 0, maximum: 24 },
46
+ maxzoom: { type: "integer", write: true, minimum: 0, maximum: 24 },
47
+ opacity: { type: "number", write: true, minimum: 0, maximum: 1 },
48
+ style: { type: "json", write: true },
49
+ legend: { type: "json", write: true },
50
+ preview: { type: "string", write: true },
51
+ // No `enum`: FCore checks it against the whole value, so arrays never pass.
52
+ // Allowed values are enforced by map_layers_components_check.
53
+ components: {
54
+ type: "string",
55
+ array: true,
56
+ write: true,
57
+ filterable: true,
58
+ dictionary: mapLayerComponents.code,
59
+ },
60
+ sort_order: { type: "integer", write: true, sortable: true },
61
+ is_default: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
62
+ has_filters: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
63
+ enabled: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
64
+ created_by: { type: "string", write: false, lookup: userLookup },
65
+ created_at: { type: "timestamp", write: false, sortable: true },
66
+ updated_by: { type: "string", write: false, lookup: userLookup },
67
+ updated_at: { type: "timestamp", write: false, sortable: true },
68
+ },
69
+ } satisfies ResourceContract;
@@ -1,32 +1,32 @@
1
- import type { ResourceContract } from '@opengis/fcore';
2
-
3
- export default {
4
- name: 'organization_surveyors',
5
- version: 1,
6
- table: 'surveyor.organization_surveyors',
7
- key: 'org_id',
8
- module: 'surveyor',
9
- operations: ["read"],
10
- fields: {
11
- org_id: { type: 'text', read: true, },
12
- surveyor_id: { type: 'text', read: true },
13
- first_name: { type: 'text', read: true },
14
- last_name: { type: 'text', read: true },
15
- middle_name: { type: 'text', read: true },
16
- enabled: { type: 'boolean', read: true },
17
- created_by: { type: 'text', read: true },
18
- created_at: { type: 'timestamp', read: true },
19
- registered_at: { type: 'timestamp', read: true },
20
- email: { type: 'text', read: true },
21
- phone: { type: 'text', read: true },
22
- certificate_id: {
23
- type: 'text',
24
- read: true,
25
- lookup: { table: 'surveyor.certificates', value: 'certificate_id', text: 'number_certificate' },
26
- },
27
- },
28
- joins: [{
29
- sql: `LEFT JOIN LATERAL (select first_name, last_name, middle_name, registered_at, email, phone, certificate_id, enabled AS surveyor_enabled from surveyor.surveyors s where s.surveyor_id = t.surveyor_id) as s on true`
30
- }]
31
-
1
+ import type { ResourceContract } from '@opengis/fcore';
2
+
3
+ export default {
4
+ name: 'organization_surveyors',
5
+ version: 1,
6
+ table: 'surveyor.organization_surveyors',
7
+ key: 'org_id',
8
+ module: 'surveyor',
9
+ operations: ["read"],
10
+ fields: {
11
+ org_id: { type: 'text', read: true, },
12
+ surveyor_id: { type: 'text', read: true },
13
+ first_name: { type: 'text', read: true },
14
+ last_name: { type: 'text', read: true },
15
+ middle_name: { type: 'text', read: true },
16
+ enabled: { type: 'boolean', read: true },
17
+ created_by: { type: 'text', read: true },
18
+ created_at: { type: 'timestamp', read: true },
19
+ registered_at: { type: 'timestamp', read: true },
20
+ email: { type: 'text', read: true },
21
+ phone: { type: 'text', read: true },
22
+ certificate_id: {
23
+ type: 'text',
24
+ read: true,
25
+ lookup: { table: 'surveyor.certificates', value: 'certificate_id', text: 'number_certificate' },
26
+ },
27
+ },
28
+ joins: [{
29
+ sql: `LEFT JOIN LATERAL (select first_name, last_name, middle_name, registered_at, email, phone, certificate_id, enabled AS surveyor_enabled from surveyor.surveyors s where s.surveyor_id = t.surveyor_id) as s on true`
30
+ }]
31
+
32
32
  } satisfies ResourceContract;