@opengis/surveyor 0.0.18 → 0.0.20

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 (57) hide show
  1. package/dist/chunks/{AppIcon-CO70tpMX.js → AppIcon-Di5F4Bu_.js} +1 -1
  2. package/dist/chunks/{AppealDetailField-ByK9ZqR4.js → AppealDetailField-CWayoaII.js} +2 -2
  3. package/dist/chunks/AppealStatusBadge-DRWZst3M.js +430 -0
  4. package/dist/chunks/{AppealStatusBadge-BlAaNUSK.js → AppealStatusBadge-z77wwkFD.js} +2 -2
  5. package/dist/chunks/{ApplicationGeometryExportModal-DMPn9bkq.js → ApplicationGeometryExportModal-CH9VrqxO.js} +320 -339
  6. package/dist/chunks/{BaseModal-BJxKuONh.js → BaseModal-X-hzV_I2.js} +2 -2
  7. package/dist/chunks/{FormFilePicker-DxPQlxgy.js → FormFilePicker-D5fAUE0Z.js} +2 -2
  8. package/dist/chunks/{MapLayerMenu-B0TEoCJm.js → MapLayerMenu-CyVxRSNX.js} +1 -1
  9. package/dist/chunks/{RegistryForm-Dpis_ncj.js → RegistryForm-J7R4RWO3.js} +1 -1
  10. package/dist/chunks/{RegistryFormModal-CH4DbTvC.js → RegistryFormModal-B_EDwu9O.js} +3 -3
  11. package/dist/chunks/{RegistryToolbar-DisEejvi.js → RegistryToolbar-BDVaZ2Rf.js} +5 -5
  12. package/dist/chunks/{SurveyorTeleport-Cd6D92mo.js → SurveyorTeleport-Y-NJhfsb.js} +1 -1
  13. package/dist/chunks/{TablePagination-thQkE5iA.js → TablePagination-CZhRgCVr.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-n83dNORm.js → card-BMe6jQRR.js} +10 -10
  18. package/dist/chunks/{card-DVuqR0rL.js → card-Bw_EXY3D.js} +4 -4
  19. package/dist/chunks/{card-Cs8_8A8i.js → card-Cll0FQ0z.js} +6 -6
  20. package/dist/chunks/{card-u5I--_Gb.js → card-DMt5SAoD.js} +5 -5
  21. package/dist/chunks/{card-BP4nulPr.js → card-Dy333mEd.js} +9 -9
  22. package/dist/chunks/card-VMoiAe7V.js +1258 -0
  23. package/dist/chunks/{certificates-CDunSANR.js → certificates-URuwsRqg.js} +6 -6
  24. package/dist/chunks/{create-DQPxIZMW.js → create-CJXITPL0.js} +9 -9
  25. package/dist/chunks/downloadAttachmentFilename-B_4jZuOa.js +11 -0
  26. package/dist/chunks/{forgot-DfsFu-yY.js → forgot-JFlAKndO.js} +2 -2
  27. package/dist/chunks/{login-Dl0nTWs9.js → login-Bd6krLDP.js} +2 -2
  28. package/dist/chunks/{map-BoHEgBCw.js → map-CNPzf0wE.js} +44 -44
  29. package/dist/chunks/{map-layers-CRE8lZzH.js → map-layers-BgK6h6AD.js} +6 -6
  30. package/dist/chunks/{organizations-D6aazMAe.js → organizations-BLYhVQwf.js} +7 -7
  31. package/dist/chunks/{profile-CkwMFh82.js → profile-F7mr0poI.js} +3 -3
  32. package/dist/chunks/{registration-BSz1iLbO.js → registration-DIA4xV-t.js} +2 -2
  33. package/dist/chunks/{requests-D1ix8U5f.js → requests-CPVQ1Yy_.js} +5 -5
  34. package/dist/chunks/{requests-B9Ejt4av.js → requests-D-QPPUe4.js} +9 -9
  35. package/dist/chunks/{reset-D5G0x5Zi.js → reset-DR3GXwrH.js} +2 -2
  36. package/dist/chunks/{useEntityPath-C5Owtidc.js → useEntityPath-8s0Y1tjA.js} +1 -1
  37. package/dist/chunks/{users-DMe6JYI0.js → users-BsWV3iTt.js} +7 -7
  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 +80 -80
  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 +20 -0
  48. package/server/modules/surveyor/schema.ts +11 -0
  49. package/server/modules/surveyor/services/changeApplicationStatus.ts +100 -0
  50. package/server/modules/surveyor/services/mapLayers.ts +61 -61
  51. package/server/modules/surveyor/utils/templates/ds.surveyor_password_reset.pt.hbs +79 -79
  52. package/server/resources/helpers/settlement_lookup.ts +7 -7
  53. package/server/resources/surveyor-admin/applications.ts +126 -126
  54. package/server/resources/surveyor-admin/certificates.ts +113 -113
  55. package/server/resources/surveyor-admin/organization_surveyors.ts +31 -31
  56. package/dist/chunks/AppealStatusBadge-DzMn4RVy.js +0 -295
  57. package/dist/chunks/card-CBOQibhl.js +0 -1327
@@ -1,126 +1,126 @@
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 covers descriptive fields and replacing issued source data (file_output);
14
- // workflow fields (status, files, signature, area/geom, dates) stay read-only.
15
- export default {
16
- version: 1,
17
- name: "applications",
18
- module: "surveyor",
19
- title: "Заявки на геодезичні роботи",
20
- table: "surveyor.applications",
21
- key: "app_id",
22
- access: "user",
23
- operations: ["read", "update"],
24
- searchable: ["number", "location", "description"],
25
- capabilities: ["notes", "files"],
26
- summary: {
27
- awaitingData: { aggregate: "count", where: "t.status = 'awaitingData'" },
28
- dataIssued: { aggregate: "count", where: "t.status = 'dataIssued'" },
29
- reserve: { aggregate: "count", where: "t.status = 'reserve'" },
30
- underReview: { aggregate: "count", where: "t.status = 'underReview'" },
31
- verified: { aggregate: "count", where: "t.status = 'verified'" },
32
- completed: { aggregate: "count", where: "t.status = 'completed'" },
33
- cancelled: { aggregate: "count", where: "t.status = 'cancelled'" },
34
- },
35
- fields: {
36
- app_id: { type: "text", write: false, filterable: true, sortable: true },
37
- number: { type: "string", write: false, searchable: true, sortable: true },
38
- org_id: {
39
- type: "text",
40
- write: false,
41
- filterable: true,
42
- lookup: { table: "surveyor.organizations", value: "org_id", text: "name" },
43
- },
44
- surveyor_id: {
45
- type: "text",
46
- write: false,
47
- filterable: true,
48
- lookup: { table: "surveyor.surveyors", value: "surveyor_id", text: "email" },
49
- },
50
- status: {
51
- type: "string",
52
- write: false,
53
- filterable: true,
54
- dictionary: applicationStatus.code,
55
- enum: applicationStatusCodes,
56
- },
57
- work_type: {
58
- type: "string",
59
- write: true,
60
- filterable: true,
61
- dictionary: workTypes.code,
62
- enum: workTypeCodes,
63
- },
64
- description: { type: "text", write: true, searchable: true },
65
- execution_basis: { type: "text", write: true },
66
- settlement_id: {
67
- type: "string",
68
- write: true,
69
- filterable: true,
70
- lookup: settlementLookup,
71
- },
72
- is_found_address_id: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
73
- address_id: { type: "string", write: true, filterable: true, lookup: addressLookup },
74
- location: { type: "text", write: true, searchable: true },
75
- area: { type: "number", write: false, sortable: true },
76
- geom: { type: "geometry", write: false },
77
- file_output: { type: "file", write: true },
78
- file_geodetic_survey: { type: "file", write: false },
79
- file_corrected_geodetic_survey: { type: "file", write: false },
80
- note_4_file_corrected_geodetic_survey: { type: "text", write: false },
81
- notes: { type: "text", write: true },
82
- signature: { type: "text", write: true },
83
- cancel_reason: { type: "text", write: false },
84
- source_data_issued_at: { type: "timestamp", write: false, sortable: true },
85
- survey_uploaded_at: { type: "timestamp", write: false, sortable: true },
86
- verified_at: { type: "timestamp", write: false, sortable: true },
87
- integrated_at: { type: "timestamp", write: false, sortable: true },
88
- cancelled_at: { type: "timestamp", write: false, sortable: true },
89
- verified_by: { type: "string", write: false, lookup: userLookup },
90
- integrated_by: { type: "string", write: false, lookup: userLookup },
91
- cancelled_by: { type: "string", write: false, lookup: userLookup },
92
- created_by: { type: "string", write: false, lookup: actorLookup },
93
- updated_by: { type: "string", write: false, lookup: actorLookup },
94
- created_at: { type: "timestamp", write: false, filterable: true, sortable: true },
95
- updated_at: { type: "timestamp", write: false, sortable: true },
96
- },
97
- relations: {
98
- comments: {
99
- type: "many",
100
- resource: "application_comments",
101
- localKey: "app_id",
102
- foreignKey: "resource_id",
103
- where: "t.resource IN ('applications', 'public_applications')",
104
- },
105
- organization: { resource: "organizations", localKey: "org_id" },
106
- surveyor: {
107
- resource: "surveyors",
108
- localKey: "surveyor_id",
109
- fields: [
110
- 't."surveyor_id"',
111
- 't."certificate_id"',
112
- 't."first_name"',
113
- 't."last_name"',
114
- 't."middle_name"',
115
- 't."email"',
116
- 't."phone"',
117
- 't."enabled"',
118
- ],
119
- },
120
- status_history: {
121
- resource: "application_status_history",
122
- localKey: "app_id",
123
- foreignKey: "application_id",
124
- },
125
- },
126
- } satisfies ResourceContract;
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 covers descriptive fields and replacing issued source data (file_output);
14
+ // workflow fields (status, files, signature, area/geom, dates) stay read-only.
15
+ export default {
16
+ version: 1,
17
+ name: "applications",
18
+ module: "surveyor",
19
+ title: "Заявки на геодезичні роботи",
20
+ table: "surveyor.applications",
21
+ key: "app_id",
22
+ access: "user",
23
+ operations: ["read", "update"],
24
+ searchable: ["number", "location", "description"],
25
+ capabilities: ["notes", "files"],
26
+ summary: {
27
+ awaitingData: { aggregate: "count", where: "t.status = 'awaitingData'" },
28
+ dataIssued: { aggregate: "count", where: "t.status = 'dataIssued'" },
29
+ reserve: { aggregate: "count", where: "t.status = 'reserve'" },
30
+ underReview: { aggregate: "count", where: "t.status = 'underReview'" },
31
+ verified: { aggregate: "count", where: "t.status = 'verified'" },
32
+ completed: { aggregate: "count", where: "t.status = 'completed'" },
33
+ cancelled: { aggregate: "count", where: "t.status = 'cancelled'" },
34
+ },
35
+ fields: {
36
+ app_id: { type: "text", write: false, filterable: true, sortable: true },
37
+ number: { type: "string", write: false, searchable: true, sortable: true },
38
+ org_id: {
39
+ type: "text",
40
+ write: false,
41
+ filterable: true,
42
+ lookup: { table: "surveyor.organizations", value: "org_id", text: "name" },
43
+ },
44
+ surveyor_id: {
45
+ type: "text",
46
+ write: false,
47
+ filterable: true,
48
+ lookup: { table: "surveyor.surveyors", value: "surveyor_id", text: "email" },
49
+ },
50
+ status: {
51
+ type: "string",
52
+ write: false,
53
+ filterable: true,
54
+ dictionary: applicationStatus.code,
55
+ enum: applicationStatusCodes,
56
+ },
57
+ work_type: {
58
+ type: "string",
59
+ write: true,
60
+ filterable: true,
61
+ dictionary: workTypes.code,
62
+ enum: workTypeCodes,
63
+ },
64
+ description: { type: "text", write: true, searchable: true },
65
+ execution_basis: { type: "text", write: true },
66
+ settlement_id: {
67
+ type: "string",
68
+ write: true,
69
+ filterable: true,
70
+ lookup: settlementLookup,
71
+ },
72
+ is_found_address_id: { type: "boolean", write: true, filterable: true, dictionary: "yes-no" },
73
+ address_id: { type: "string", write: true, filterable: true, lookup: addressLookup },
74
+ location: { type: "text", write: true, searchable: true },
75
+ area: { type: "number", write: false, sortable: true },
76
+ geom: { type: "geometry", write: false },
77
+ file_output: { type: "file", write: true },
78
+ file_geodetic_survey: { type: "file", write: false },
79
+ file_corrected_geodetic_survey: { type: "file", write: false },
80
+ note_4_file_corrected_geodetic_survey: { type: "text", write: false },
81
+ notes: { type: "text", write: true },
82
+ signature: { type: "text", write: true },
83
+ cancel_reason: { type: "text", write: false },
84
+ source_data_issued_at: { type: "timestamp", write: false, sortable: true },
85
+ survey_uploaded_at: { type: "timestamp", write: false, sortable: true },
86
+ verified_at: { type: "timestamp", write: false, sortable: true },
87
+ integrated_at: { type: "timestamp", write: false, sortable: true },
88
+ cancelled_at: { type: "timestamp", write: false, sortable: true },
89
+ verified_by: { type: "string", write: false, lookup: userLookup },
90
+ integrated_by: { type: "string", write: false, lookup: userLookup },
91
+ cancelled_by: { type: "string", write: false, lookup: userLookup },
92
+ created_by: { type: "string", write: false, lookup: actorLookup },
93
+ updated_by: { type: "string", write: false, lookup: actorLookup },
94
+ created_at: { type: "timestamp", write: false, filterable: true, sortable: true },
95
+ updated_at: { type: "timestamp", write: false, sortable: true },
96
+ },
97
+ relations: {
98
+ comments: {
99
+ type: "many",
100
+ resource: "application_comments",
101
+ localKey: "app_id",
102
+ foreignKey: "resource_id",
103
+ where: "t.resource IN ('applications', 'public_applications')",
104
+ },
105
+ organization: { resource: "organizations", localKey: "org_id" },
106
+ surveyor: {
107
+ resource: "surveyors",
108
+ localKey: "surveyor_id",
109
+ fields: [
110
+ 't."surveyor_id"',
111
+ 't."certificate_id"',
112
+ 't."first_name"',
113
+ 't."last_name"',
114
+ 't."middle_name"',
115
+ 't."email"',
116
+ 't."phone"',
117
+ 't."enabled"',
118
+ ],
119
+ },
120
+ status_history: {
121
+ resource: "application_status_history",
122
+ localKey: "app_id",
123
+ foreignKey: "application_id",
124
+ },
125
+ },
126
+ } satisfies ResourceContract;
@@ -1,113 +1,113 @@
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
- import { certificateStatusSql } from "../../modules/surveyor/utils/certificateStatus.js";
5
-
6
- const accountTypeCodes = accountTypes.items.map(({ code }) => code);
7
-
8
- // Сертифікати імпортуються із зовнішнього реєстру, але адміністратор може додавати та редагувати їх вручну.
9
- export default {
10
- version: 1,
11
- name: "certificates",
12
- module: "surveyor",
13
- title: "Сертифікати",
14
- table: "surveyor.certificates",
15
- key: "certificate_id",
16
- display: ["surveyor_name", "number_certificate"],
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
- ],
29
- access: "user",
30
- operations: ["read", "create", "update"],
31
- searchable: ["surveyor_name", "last_name", "first_name", "number_certificate"],
32
- fields: {
33
- certificate_id: {
34
- type: "text",
35
- write: false,
36
- filterable: true,
37
- lookup: {
38
- table: "surveyor.certificates",
39
- value: "certificate_id",
40
- text: "surveyor_name",
41
- fields: ["surveyor_email", "surveyor_phone", "number_certificate"],
42
- },
43
- },
44
- certificate_type: {
45
- type: "string",
46
- write: true,
47
- filterable: true,
48
- dictionary: accountTypes.code,
49
- enum: accountTypeCodes,
50
- },
51
- surveyor_name: {
52
- type: "string",
53
- write: true,
54
- searchable: true,
55
- },
56
- last_name: { type: "string", write: true, searchable: true },
57
- first_name: { type: "string", write: true, searchable: true },
58
- middle_name: { type: "string", write: true },
59
- surveyor_phone: { type: "string", write: true },
60
- surveyor_email: { type: "string", write: true },
61
- date_certificate: {
62
- type: "date",
63
- write: true,
64
- filterable: true,
65
- sortable: true,
66
- },
67
- number_certificate: { type: "string", write: true, searchable: true },
68
- name_school: { type: "text", write: true },
69
- date_protocol: { type: "date", write: true },
70
- number_protocol: { type: "string", write: true },
71
- certificate_increase: { type: "text", write: true },
72
- certificate_stopping: { type: "text", write: true },
73
- certificate_suspension: { type: "date", write: true },
74
- certificate_renewal: { type: "text", write: true },
75
- work_place: { type: "text", write: true },
76
- economic_activity: { type: "text", write: true },
77
- created_by: { type: "string", write: false, lookup: userLookup },
78
- created_at: { type: "timestamp", write: false, sortable: true },
79
- updated_by: { type: "string", write: false, lookup: userLookup },
80
- updated_at: { type: "timestamp", write: false, sortable: true },
81
- is_membership: {
82
- type: "boolean",
83
- write: true,
84
- filterable: true,
85
- dictionary: "yes-no",
86
- },
87
- membership: { type: "text", write: true },
88
- last_qualification_date: { type: "date", write: true },
89
- isvalid: { type: "boolean", write: true, filterable: true },
90
- qualification_level: { type: "string", write: true },
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
- }],
106
- relations: {
107
- surveyors: {
108
- resource: "surveyors",
109
- localKey: "certificate_id"
110
-
111
- },
112
- },
113
- } satisfies ResourceContract;
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
+ import { certificateStatusSql } from "../../modules/surveyor/utils/certificateStatus.js";
5
+
6
+ const accountTypeCodes = accountTypes.items.map(({ code }) => code);
7
+
8
+ // Сертифікати імпортуються із зовнішнього реєстру, але адміністратор може додавати та редагувати їх вручну.
9
+ export default {
10
+ version: 1,
11
+ name: "certificates",
12
+ module: "surveyor",
13
+ title: "Сертифікати",
14
+ table: "surveyor.certificates",
15
+ key: "certificate_id",
16
+ display: ["surveyor_name", "number_certificate"],
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
+ ],
29
+ access: "user",
30
+ operations: ["read", "create", "update"],
31
+ searchable: ["surveyor_name", "last_name", "first_name", "number_certificate"],
32
+ fields: {
33
+ certificate_id: {
34
+ type: "text",
35
+ write: false,
36
+ filterable: true,
37
+ lookup: {
38
+ table: "surveyor.certificates",
39
+ value: "certificate_id",
40
+ text: "surveyor_name",
41
+ fields: ["surveyor_email", "surveyor_phone", "number_certificate"],
42
+ },
43
+ },
44
+ certificate_type: {
45
+ type: "string",
46
+ write: true,
47
+ filterable: true,
48
+ dictionary: accountTypes.code,
49
+ enum: accountTypeCodes,
50
+ },
51
+ surveyor_name: {
52
+ type: "string",
53
+ write: true,
54
+ searchable: true,
55
+ },
56
+ last_name: { type: "string", write: true, searchable: true },
57
+ first_name: { type: "string", write: true, searchable: true },
58
+ middle_name: { type: "string", write: true },
59
+ surveyor_phone: { type: "string", write: true },
60
+ surveyor_email: { type: "string", write: true },
61
+ date_certificate: {
62
+ type: "date",
63
+ write: true,
64
+ filterable: true,
65
+ sortable: true,
66
+ },
67
+ number_certificate: { type: "string", write: true, searchable: true },
68
+ name_school: { type: "text", write: true },
69
+ date_protocol: { type: "date", write: true },
70
+ number_protocol: { type: "string", write: true },
71
+ certificate_increase: { type: "text", write: true },
72
+ certificate_stopping: { type: "text", write: true },
73
+ certificate_suspension: { type: "date", write: true },
74
+ certificate_renewal: { type: "text", write: true },
75
+ work_place: { type: "text", write: true },
76
+ economic_activity: { type: "text", write: true },
77
+ created_by: { type: "string", write: false, lookup: userLookup },
78
+ created_at: { type: "timestamp", write: false, sortable: true },
79
+ updated_by: { type: "string", write: false, lookup: userLookup },
80
+ updated_at: { type: "timestamp", write: false, sortable: true },
81
+ is_membership: {
82
+ type: "boolean",
83
+ write: true,
84
+ filterable: true,
85
+ dictionary: "yes-no",
86
+ },
87
+ membership: { type: "text", write: true },
88
+ last_qualification_date: { type: "date", write: true },
89
+ isvalid: { type: "boolean", write: true, filterable: true },
90
+ qualification_level: { type: "string", write: true },
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
+ }],
106
+ relations: {
107
+ surveyors: {
108
+ resource: "surveyors",
109
+ localKey: "certificate_id"
110
+
111
+ },
112
+ },
113
+ } 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;