odant-work 1.0.62 → 1.0.63
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/#system/package-manifest.json +138 -105
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/class.js +27 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/gantt.js +293 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/class.js +27 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/scheduler.js +234 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/staff/$handler/staff.js +119 -0
- package/$server/$folder/lib/explorer/explorer.js +29 -0
- package/MODULES/Geo/$module/readme.md +6 -4
- package/MODULES/Geo//320/223/320/265/320/276/321/202/320/276/321/207/320/272/320/270/$catalog/class.js +9 -3
- package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/class.js +10 -0
- package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +21 -0
- package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +623 -0
- package/MODULES/Geo//320/232/320/276/320/276/321/200/320/264/320/270/320/275/320/260/321/202/321/213/$struct/class.js +1 -0
- package/MODULES/Geo//320/250/320/265/320/271/320/277/$struct/class.js +17 -0
- package/MODULES/KLADR/$module/$folder/$class/$catalog/class.js +9 -0
- package/MODULES/KLADR/$module/class.js +4 -0
- package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +7 -0
- package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +134 -0
- package/MODULES/KLADR/$module/readme.md +10 -0
- package/MODULES/KLADR//320/235/320/260/321/201/320/265/320/273/321/221/320/275/320/275/321/213/320/265 /320/277/321/203/320/275/320/272/321/202/321/213/$catalog/class.js" +14 -0
- package/MODULES/KLADR//320/237/320/276/320/264/321/200/320/260/320/267/320/264/320/265/320/273/320/265/320/275/320/270/321/217 /320/234/320/222/320/224/$catalog/class.js" +13 -0
- package/MODULES/KLADR//320/240/320/265/320/263/320/270/320/276/320/275/321/213/$catalog/class.js +14 -0
- package/MODULES/KLADR//320/243/320/273/320/270/321/206/321/213/$catalog/class.js +13 -0
- package/MODULES/Process/$module/$folder/$class/$catalog/class.js +4 -0
- package/MODULES/Process/$module/class.js +4 -0
- package/MODULES/Process/$module/readme.md +7 -0
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/class.js" +29 -0
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +7 -0
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +1 -0
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +7 -0
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +1 -0
- package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/class.js" +18 -0
- package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +406 -0
- package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +19 -0
- package/MODULES/Register/$module/readme.md +3 -3
- package/MODULES/Register/CATALOGS/$catalog/class.js +1 -6
- package/MODULES/Register/CATALOGS/$catalog/readme.md +1 -1
- package/MODULES/Register/CATALOGS//320/222/320/270/320/264/321/213 /320/275/320/276/321/200/320/274/320/260/321/202/320/270/320/262/320/276/320/262/$catalog/class.js" +11 -4
- package/MODULES/Register/CATALOGS//320/224/320/276/320/263/320/276/320/262/320/276/321/200/321/213/$catalog/class.js +21 -19
- package/MODULES/Register/CATALOGS//320/224/320/276/320/273/320/266/320/275/320/276/321/201/321/202/320/270/$catalog/class.js +1 -1
- package/MODULES/Register/CATALOGS//320/232/320/273/320/270/320/265/320/275/321/202/321/213/$virtual/class.js +11 -10
- package/MODULES/Register/CATALOGS//320/235/320/276/320/274/320/265/320/275/320/272/320/273/320/260/321/202/321/203/321/200/320/260/$catalog/class.js +24 -13
- package/MODULES/Register/CATALOGS//320/237/320/260/321/200/321/202/320/270/320/270/$catalog/class.js +13 -13
- package/MODULES/Register/CATALOGS//320/237/320/276/321/201/321/202/320/260/320/262/321/211/320/270/320/272/320/270/$virtual/class.js +9 -8
- package/MODULES/Register/CATALOGS//320/241/320/272/320/273/320/260/320/264/321/213/$catalog/class.js +17 -0
- package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +11 -9
- package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270//320/222 /320/276/321/202/320/277/321/203/321/201/320/272/320/265/$virtual/class.js" +1 -1
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +13 -11
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213//320/230/320/237/$catalog/class.js +4 -6
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213//320/244/320/270/320/267. /320/273/320/270/321/206/320/260/$catalog/class.js" +12 -11
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213//320/256/321/200. /320/273/320/270/321/206/320/260/$catalog/class.js" +15 -14
- package/MODULES/Register/CATALOGS//320/242/321/200/320/260/320/275/321/201/320/277/320/276/321/200/321/202/$catalog/class.js +19 -18
- package/MODULES/Register/OPERATIONS/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS/$operation/readme.md +1 -1
- package/MODULES/Register/OPERATIONS//320/224/320/276/321/201/321/202/320/260/320/262/320/272/320/260/$operation/class.js +22 -21
- package/MODULES/Register/OPERATIONS//320/227/320/260/321/200/320/277/320/273/320/260/321/202/320/260/$operation/class.js +48 -47
- package/MODULES/Register/OPERATIONS//320/230/320/275/320/262/320/265/320/275/321/202/320/260/321/200/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +46 -45
- package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213//320/236/321/202/320/277/321/200/320/260/320/262/320/270/321/202/321/214 /320/262 /320/276/321/202/320/277/321/203/321/201/320/272/$operation/class.js" +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213//320/237/321/200/320/270/321/221/320/274 /320/275/320/260 /321/200/320/260/320/261/320/276/321/202/321/203/$operation/class.js" +18 -14
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260//320/220/320/262/320/260/320/275/321/201/320/276/320/262/321/213/320/271 /320/276/321/202/321/207/321/221/321/202/$operation/class.js" +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260//320/237/320/232/320/236/$operation/class.js +3 -3
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260//320/240/320/232/320/236/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270//320/227/320/262/320/276/320/275/320/276/320/272/$operation/class.js +2 -2
- package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270//320/237/320/270/321/201/321/214/320/274/320/276/$operation/class.js +1 -1
- package/MODULES/Register/OPERATIONS//320/{244/320/260/321/201/320/276/320/262/320/272/320/260 → 232/320/276/320/274/320/277/320/273/320/265/320/272/321/202/320/260/321/206/320/270/321/217}/$operation/class.js +52 -57
- package/MODULES/Register/OPERATIONS//320/236/321/201/320/275/320/276/320/262/320/275/321/213/320/265 /321/201/321/200/320/265/320/264/321/201/321/202/320/262/320/260//320/235/320/260/321/207/320/270/321/201/320/273/320/265/320/275/320/270/320/265 /320/260/320/274/320/276/321/200/321/202/320/270/320/267/320/260/321/206/320/270/320/270/$operation/class.js" +2 -2
- package/MODULES/Register/OPERATIONS//320/236/321/201/320/275/320/276/320/262/320/275/321/213/320/265 /321/201/321/200/320/265/320/264/321/201/321/202/320/262/320/260//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/320/265 /320/236/320/241/$operation/class.js" +7 -6
- package/MODULES/Register/OPERATIONS//320/236/321/201/320/275/320/276/320/262/320/275/321/213/320/265 /321/201/321/200/320/265/320/264/321/201/321/202/320/262/320/260//320/237/321/200/320/270/320/275/321/217/321/202/320/270/320/265 /320/272 /321/203/321/207/321/221/321/202/321/203 /320/236/320/241/$operation/class.js" +2 -2
- package/MODULES/Register/OPERATIONS//320/237/320/265/321/200/320/265/320/274/320/265/321/211/320/265/320/275/320/270/320/265/$operation/class.js +41 -40
- package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +1 -1
- package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260//320/227/320/260/321/200/320/277/320/273/320/260/321/202/320/260/$operation/class.js" +1 -1
- package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260//320/237/320/276/321/201/321/202/320/260/320/262/321/211/320/270/320/272/321/203/$operation/class.js" +11 -10
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/320/265 /321/202/320/276/320/262/320/260/321/200/320/260/$operation/class.js" +45 -46
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +1 -1
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202//320/222/320/276/320/267/320/262/321/200/320/260/321/202 /320/276/321/202 /320/277/320/276/321/201/321/202/320/260/320/262/321/211/320/270/320/272/320/260/$operation/class.js" +11 -10
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202//320/236/321/202 /320/277/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/217/$operation/class.js" +11 -10
- package/MODULES/Register/OPERATIONS//320/237/321/200/320/276/320/270/320/267/320/262/320/276/320/264/321/201/321/202/320/262/320/276//320/222/321/213/320/277/321/203/321/201/320/272 /320/263/320/276/321/202/320/276/320/262/320/276/320/271 /320/277/321/200/320/276/320/264/321/203/320/272/321/206/320/270/320/270/$operation/class.js" +4 -4
- package/MODULES/Register/OPERATIONS//320/237/321/200/320/276/320/270/320/267/320/262/320/276/320/264/321/201/321/202/320/262/320/276//320/237/320/265/321/200/320/265/320/264/320/260/321/207/320/260 /320/274/320/260/321/202/320/265/321/200/320/270/320/260/320/273/320/276/320/262 /320/262 /320/277/321/200/320/276/320/270/320/267/320/262/320/276/320/264/321/201/321/202/320/262/320/276/$operation/class.js" +5 -4
- package/MODULES/Register/OPERATIONS//320/237/321/200/320/276/320/270/320/267/320/262/320/276/320/264/321/201/321/202/320/262/320/276//320/241/320/277/320/270/321/201/320/260/320/275/320/270/320/265 /320/276/320/261/321/211/320/265/321/205/320/276/320/267/321/217/320/271/321/201/321/202/320/262/320/265/320/275/320/275/321/213/321/205 /320/267/320/260/321/202/321/200/320/260/321/202/$operation/class.js" +6 -6
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +26 -25
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/222/320/276/320/267/320/262/321/200/320/260/321/202 /320/276/321/202 /320/277/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/217/$operation/class.js" +32 -31
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/class.js +32 -31
- package/MODULES/Register/OPERATIONS//320/241/320/277/320/270/321/201/320/260/320/275/320/270/320/265 /320/242/320/234/320/246/$operation/class.js" +28 -0
- package/MODULES/Register/OPERATIONS//320/243/321/201/321/202/320/260/320/275/320/276/320/262/320/272/320/260 /320/275/320/276/321/200/320/274/320/260/321/202/320/270/320/262/320/260/$operation/class.js" +3 -3
- package/MODULES/Register/OPERATIONS//320/244/320/270/320/275/320/260/320/275/321/201/320/276/320/262/321/213/320/271 /321/200/320/265/320/267/321/203/320/273/321/214/321/202/320/260/321/202//320/227/320/260/320/272/321/200/321/213/321/202/320/270/320/265 /320/274/320/265/321/201/321/217/321/206/320/260/$operation/class.js" +1 -1
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/readme.md +1 -1
- package/MODULES/Register/REGISTER/$register/readme.md +1 -1
- package/MODULES/Register/REGISTER/01/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/02/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/04/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/08/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/10/$account/class.js +23 -1
- package/MODULES/Register/REGISTER/10/01/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/10/05/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/41/$account/class.js +25 -24
- package/MODULES/Register/REGISTER/43/$account/class.js +2 -2
- package/MODULES/Register/REGISTER/44/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/60/$account/class.js +24 -15
- package/MODULES/Register/REGISTER/62/$account/class.js +24 -15
- package/MODULES/Register/REGISTER/67/$account/class.js +1 -0
- package/MODULES/Register/REGISTER/70/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/71/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/73/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/76/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/90/01/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/90/02/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/90/03/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/91/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/94/$account/class.js +24 -23
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/235/320/276/321/200/320/274/320/260/321/202/320/270/320/262/321/213/$account/class.js +2 -2
- package/MODULES/Register/STRUCTS//320/220/320/264/321/200/320/265/321/201/$struct/class.js +14 -11
- package/MODULES/Register/STRUCTS//320/225/320/264/320/270/320/275/320/270/321/206/320/260 /320/270/320/267/320/274/320/265/321/200/320/265/320/275/320/270/321/217/$struct/class.js" +11 -11
- package/MODULES/Register/STRUCTS//320/237/320/260/321/201/320/277/320/276/321/200/321/202/$struct/class.js +14 -11
- package/MODULES/Register/STRUCTS//320/244/320/230/320/236/$struct/class.js +16 -0
- package/package.json +1 -1
- package/scripts/check-ignored-code.mjs +1 -1
- package/scripts/demo-seed.mjs +7 -5
- package/sources/client.js +6 -1
- package/sources/data/fio.js +355 -0
- package/sources/data/objects.js +11 -1
- package/sources/data/print.js +29 -3
- package/sources/data/schema.js +15 -4
- package/sources/host/auth-methods.js +34 -2
- package/sources/modules/kladr/index.js +336 -0
- package/sources/modules/user-profile/user-profile.js +40 -2
- package/sources/server/access/gateway.js +6 -0
- package/sources/server/access/invites.js +416 -0
- package/sources/server/class/base-template.js +94 -61
- package/sources/server/class.js +22 -0
- package/sources/server/folder.js +72 -6
- package/$server/$folder/$class/ai/progress.md +0 -33
- package/$server/$folder/$file/$task/progress.md +0 -20
- package/$server/$folder/handlers/methods/create/progress.md +0 -15
- package/$server/$folder/lib/dot/progress.md +0 -15
- package/$server/$folder/lib/menu/progress.md +0 -13
- package/$server/$folder/lib/node/progress.md +0 -13
- package/$server/$folder/lib/prompt-bar/progress.md +0 -13
- package/$server/$folder/lib/tree/progress.md +0 -16
- package/.cursor/rules/work.mdc +0 -8
- package/.cursorrules +0 -2
- package/MODULES/Register/CATALOGS//320/241/320/272/320/273/320/260/320/264/321/213 /320/270 /321/200/320/265/320/267/320/265/321/200/320/262/321/203/320/260/321/200/321/213/$catalog/class.js" +0 -17
- package/MODULES/Register/OPERATIONS//320/225/321/201/321/202/320/265/321/201/321/202/320/262/320/265/320/275/320/275/320/260/321/217 /321/203/320/261/321/213/320/273/321/214/$operation/class.js" +0 -21
- package/NODES/teewtew/$node/class.js +0 -3
- package/NODES/work.odant.org/$node/class.js +0 -4
- package/config.json +0 -1
- package/eslint.config.js +0 -51
- package/jsconfig.json +0 -37
- package/oda/components/packets/progress.md +0 -29
- package/oda/progress.md +0 -29
- package/opencode.json +0 -9
- package/progress.md +0 -13
- package/publish.cmd +0 -2
- package/sources/data/progress.md +0 -792
- package/sources/host/progress.md +0 -14
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Одноразовые приглашения пользователей на рабочие места (`$base`, `$structure`, `$project`).
|
|
3
|
+
* Каналы доставки: копируемая ссылка, Email (`getMailer`), Telegram / MAX (`sources/modules/notify`).
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import crypto from 'node:crypto';
|
|
8
|
+
import { getMailer } from '../../host/mail.js';
|
|
9
|
+
import { LOCAL_ORIGIN } from '../../host/config.js';
|
|
10
|
+
import { buildPointChain, readPointConfig, getAdapter } from '../../modules/notify/index.js';
|
|
11
|
+
import { audit } from './audit.js';
|
|
12
|
+
|
|
13
|
+
let customInvitesFile = '';
|
|
14
|
+
|
|
15
|
+
export function _setInvitesFileForTests(filePath = '') {
|
|
16
|
+
customInvitesFile = String(filePath || '').trim();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getInvitesFile() {
|
|
20
|
+
if (customInvitesFile)
|
|
21
|
+
return customInvitesFile;
|
|
22
|
+
if (process.env.WORK_INVITES_FILE)
|
|
23
|
+
return path.resolve(process.env.WORK_INVITES_FILE);
|
|
24
|
+
return path.resolve('.data/invites.json');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readStore() {
|
|
28
|
+
const file = getInvitesFile();
|
|
29
|
+
try {
|
|
30
|
+
if (!fs.existsSync(file))
|
|
31
|
+
return { invites: [] };
|
|
32
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
33
|
+
return Array.isArray(parsed?.invites) ? { invites: parsed.invites } : { invites: [] };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { invites: [] };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function writeStore(store) {
|
|
41
|
+
const file = getInvitesFile();
|
|
42
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
43
|
+
fs.writeFileSync(file, JSON.stringify({ invites: store.invites || [] }, null, 2), 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function findRoleByTrail(roles, trail = '') {
|
|
47
|
+
const parts = String(trail || '').split('/').filter(Boolean);
|
|
48
|
+
if (!parts.length)
|
|
49
|
+
return null;
|
|
50
|
+
let cur = Array.isArray(roles) ? roles : [];
|
|
51
|
+
let found = null;
|
|
52
|
+
for (const part of parts) {
|
|
53
|
+
found = cur.find(r => r && r.id === part) || null;
|
|
54
|
+
if (!found)
|
|
55
|
+
return null;
|
|
56
|
+
cur = Array.isArray(found.ROLES) ? found.ROLES : [];
|
|
57
|
+
}
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function normalizeChannel(ch = 'link') {
|
|
62
|
+
const v = String(ch || 'link').trim().toLowerCase();
|
|
63
|
+
return ['link', 'email', 'telegram', 'max'].includes(v) ? v : 'link';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function computeStatus(inv, now = Date.now()) {
|
|
67
|
+
if (!inv)
|
|
68
|
+
return 'missing';
|
|
69
|
+
if (inv.status === 'used')
|
|
70
|
+
return 'used';
|
|
71
|
+
if (inv.status === 'revoked')
|
|
72
|
+
return 'revoked';
|
|
73
|
+
if (inv.expiresAt && now > inv.expiresAt)
|
|
74
|
+
return 'expired';
|
|
75
|
+
return 'active';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createInvite({
|
|
79
|
+
pointPath,
|
|
80
|
+
pointLabel = '',
|
|
81
|
+
trail = '',
|
|
82
|
+
placeLabel = '',
|
|
83
|
+
channel = 'link',
|
|
84
|
+
recipient = '',
|
|
85
|
+
note = '',
|
|
86
|
+
createdBy = '',
|
|
87
|
+
ttlHours = 168,
|
|
88
|
+
} = {}) {
|
|
89
|
+
if (!pointPath || typeof pointPath !== 'string')
|
|
90
|
+
throw new Error('Не указана точка приглашения');
|
|
91
|
+
if (!trail || typeof trail !== 'string')
|
|
92
|
+
throw new Error('Не выбрано рабочее место для приглашения');
|
|
93
|
+
|
|
94
|
+
const store = readStore();
|
|
95
|
+
const now = Date.now();
|
|
96
|
+
const ttlMs = Math.max(1, Math.min(24 * 90, Number(ttlHours) || 168)) * 3600_000;
|
|
97
|
+
const inv = {
|
|
98
|
+
id: 'inv_' + crypto.randomBytes(6).toString('hex'),
|
|
99
|
+
token: crypto.randomBytes(18).toString('base64url'),
|
|
100
|
+
pointPath: String(pointPath).trim(),
|
|
101
|
+
pointLabel: String(pointLabel || pointPath).trim(),
|
|
102
|
+
trail: String(trail).trim(),
|
|
103
|
+
placeLabel: String(placeLabel || trail).trim(),
|
|
104
|
+
channel: normalizeChannel(channel),
|
|
105
|
+
recipient: String(recipient || '').trim().slice(0, 200),
|
|
106
|
+
note: String(note || '').trim().slice(0, 300),
|
|
107
|
+
createdBy: String(createdBy || '').trim(),
|
|
108
|
+
createdAt: now,
|
|
109
|
+
expiresAt: now + ttlMs,
|
|
110
|
+
status: 'active',
|
|
111
|
+
usedBy: '',
|
|
112
|
+
usedAt: 0,
|
|
113
|
+
};
|
|
114
|
+
store.invites.unshift(inv);
|
|
115
|
+
if (store.invites.length > 1000)
|
|
116
|
+
store.invites.length = 1000;
|
|
117
|
+
writeStore(store);
|
|
118
|
+
return inv;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function inspectInvite(token = '') {
|
|
122
|
+
const clean = String(token || '').trim();
|
|
123
|
+
if (!clean)
|
|
124
|
+
return { valid: false, status: 'missing' };
|
|
125
|
+
const store = readStore();
|
|
126
|
+
const inv = store.invites.find(x => x.token === clean);
|
|
127
|
+
const status = computeStatus(inv);
|
|
128
|
+
if (!inv)
|
|
129
|
+
return { valid: false, status: 'missing' };
|
|
130
|
+
return {
|
|
131
|
+
valid: status === 'active',
|
|
132
|
+
status,
|
|
133
|
+
id: inv.id,
|
|
134
|
+
pointPath: inv.pointPath,
|
|
135
|
+
pointLabel: inv.pointLabel,
|
|
136
|
+
trail: inv.trail,
|
|
137
|
+
placeLabel: inv.placeLabel,
|
|
138
|
+
channel: inv.channel,
|
|
139
|
+
recipient: inv.recipient,
|
|
140
|
+
expiresAt: inv.expiresAt,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function listPointInvites(pointPath = '') {
|
|
145
|
+
const clean = String(pointPath || '').trim();
|
|
146
|
+
const store = readStore();
|
|
147
|
+
const now = Date.now();
|
|
148
|
+
return store.invites
|
|
149
|
+
.filter(x => !clean || x.pointPath === clean)
|
|
150
|
+
.slice(0, 100)
|
|
151
|
+
.map(inv => ({
|
|
152
|
+
...inv,
|
|
153
|
+
effectiveStatus: computeStatus(inv, now),
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function revokeInvite({ pointPath = '', token = '', id = '' } = {}) {
|
|
158
|
+
const store = readStore();
|
|
159
|
+
const inv = store.invites.find(x =>
|
|
160
|
+
(!pointPath || x.pointPath === pointPath)
|
|
161
|
+
&& ((token && x.token === token) || (id && x.id === id))
|
|
162
|
+
);
|
|
163
|
+
if (!inv)
|
|
164
|
+
throw new Error('Приглашение не найдено');
|
|
165
|
+
if (inv.status === 'used')
|
|
166
|
+
throw new Error('Приглашение уже использовано');
|
|
167
|
+
inv.status = 'revoked';
|
|
168
|
+
writeStore(store);
|
|
169
|
+
return inv;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function consumeInvite({ token = '', uid = '', resolver = null, sockets = null } = {}) {
|
|
173
|
+
const clean = String(token || '').trim();
|
|
174
|
+
const cleanUid = String(uid || '').trim().toUpperCase();
|
|
175
|
+
if (!clean || !cleanUid)
|
|
176
|
+
return { consumed: false, reason: 'missing_params' };
|
|
177
|
+
|
|
178
|
+
const store = readStore();
|
|
179
|
+
const inv = store.invites.find(x => x.token === clean);
|
|
180
|
+
const st = computeStatus(inv);
|
|
181
|
+
if (st !== 'active')
|
|
182
|
+
return { consumed: false, reason: st };
|
|
183
|
+
|
|
184
|
+
const getPoint = typeof resolver === 'function'
|
|
185
|
+
? resolver
|
|
186
|
+
: (p => globalThis.WORK?.get_item?.(p));
|
|
187
|
+
const item = await getPoint(inv.pointPath);
|
|
188
|
+
if (!item)
|
|
189
|
+
throw new Error(`Точка приглашения ${inv.pointPath} не найдена`);
|
|
190
|
+
|
|
191
|
+
await item.init;
|
|
192
|
+
const data = structuredClone(item.DATA || {});
|
|
193
|
+
data['#security'] ??= {};
|
|
194
|
+
|
|
195
|
+
if (inv.trail === 'BOSS') {
|
|
196
|
+
data['#security'].BOSS ??= [];
|
|
197
|
+
if (!data['#security'].BOSS.includes(cleanUid))
|
|
198
|
+
data['#security'].BOSS.push(cleanUid);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
data['#security'].ROLES ??= [];
|
|
202
|
+
const roleNode = findRoleByTrail(data['#security'].ROLES, inv.trail);
|
|
203
|
+
if (!roleNode)
|
|
204
|
+
throw new Error(`Рабочее место «${inv.placeLabel || inv.trail}» больше не существует`);
|
|
205
|
+
roleNode.USERS ??= [];
|
|
206
|
+
if (!roleNode.USERS.includes(cleanUid))
|
|
207
|
+
roleNode.USERS.push(cleanUid);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
await item.save({
|
|
211
|
+
post: item.constructor.toScript(data),
|
|
212
|
+
session: { $user: globalThis.WORK },
|
|
213
|
+
sockets,
|
|
214
|
+
});
|
|
215
|
+
item.reset?.();
|
|
216
|
+
item.fire?.('changed', { value: null });
|
|
217
|
+
|
|
218
|
+
inv.status = 'used';
|
|
219
|
+
inv.usedBy = cleanUid;
|
|
220
|
+
inv.usedAt = Date.now();
|
|
221
|
+
writeStore(store);
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
consumed: true,
|
|
225
|
+
pointPath: inv.pointPath,
|
|
226
|
+
pointLabel: inv.pointLabel,
|
|
227
|
+
trail: inv.trail,
|
|
228
|
+
placeLabel: inv.placeLabel,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function resolveChannelBotForPoint(point, channel) {
|
|
233
|
+
const chain = await buildPointChain(point);
|
|
234
|
+
for (const p of chain) {
|
|
235
|
+
const cfg = await readPointConfig(p);
|
|
236
|
+
const candidates = [];
|
|
237
|
+
if (cfg.bot)
|
|
238
|
+
candidates.push(cfg.bot);
|
|
239
|
+
if (Array.isArray(cfg.bots))
|
|
240
|
+
candidates.push(...cfg.bots);
|
|
241
|
+
const match = candidates.find(b => b && b.enabled !== false && b.kind === channel && b.token);
|
|
242
|
+
if (match)
|
|
243
|
+
return match;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function escapeHtml(s = '') {
|
|
249
|
+
return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function buildInviteUrl(origin, token) {
|
|
253
|
+
const base = String(origin || LOCAL_ORIGIN || 'http://localhost:8010').replace(/\/+$/, '');
|
|
254
|
+
return `${base}/?invite=${encodeURIComponent(token)}`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export const INVITE_METHODS = Object.freeze({
|
|
258
|
+
invite_info: {
|
|
259
|
+
level: 'public',
|
|
260
|
+
fn: async function (params = {}) {
|
|
261
|
+
const token = params.post?.token ?? params.token ?? '';
|
|
262
|
+
return inspectInvite(token);
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
invite_accept: {
|
|
267
|
+
level: 'user',
|
|
268
|
+
fn: async function (params = {}) {
|
|
269
|
+
const uid = params.session?.uid;
|
|
270
|
+
if (!uid)
|
|
271
|
+
throw new Error('Требуется вход в систему');
|
|
272
|
+
const token = params.post?.token ?? params.token ?? '';
|
|
273
|
+
const res = await consumeInvite({ token, uid, sockets: params.sockets });
|
|
274
|
+
if (!res.consumed)
|
|
275
|
+
throw new Error(res.reason === 'used' ? 'Приглашение уже использовано' : res.reason === 'expired' ? 'Срок приглашения истёк' : 'Приглашение недействительно');
|
|
276
|
+
audit('invite_accept', { uid, pointPath: res.pointPath, trail: res.trail, params });
|
|
277
|
+
return res;
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
invite_list: {
|
|
282
|
+
level: 'read',
|
|
283
|
+
fn: async function (params = {}) {
|
|
284
|
+
if (!(await this.isAdmin))
|
|
285
|
+
throw new Error('Только руководитель (BOSS) может просматривать приглашения');
|
|
286
|
+
return listPointInvites(this.path);
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
invite_revoke: {
|
|
291
|
+
level: 'write',
|
|
292
|
+
fn: async function (params = {}) {
|
|
293
|
+
await this.assertAccess(params, this.constructor.ACCESS_LEVEL.ADMIN);
|
|
294
|
+
const token = params.post?.token ?? params.token ?? '';
|
|
295
|
+
const id = params.post?.id ?? params.id ?? '';
|
|
296
|
+
const rev = revokeInvite({ pointPath: this.path, token, id });
|
|
297
|
+
audit('invite_revoke', { pointPath: this.path, id: rev.id, params });
|
|
298
|
+
return { ok: true, invite: rev };
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
invite_create: {
|
|
303
|
+
level: 'write',
|
|
304
|
+
fn: async function (params = {}) {
|
|
305
|
+
await this.assertAccess(params, this.constructor.ACCESS_LEVEL.ADMIN);
|
|
306
|
+
const post = (params.post && typeof params.post === 'object') ? params.post : params;
|
|
307
|
+
const trail = String(post.trail || '').trim();
|
|
308
|
+
const channel = normalizeChannel(post.channel || 'link');
|
|
309
|
+
const recipient = String(post.recipient || '').trim();
|
|
310
|
+
const note = String(post.note || '').trim();
|
|
311
|
+
const ttlHours = Number(post.ttlHours) || 168;
|
|
312
|
+
|
|
313
|
+
await this.init;
|
|
314
|
+
const sec = this.DATA?.['#security'] || {};
|
|
315
|
+
let placeLabel = '';
|
|
316
|
+
if (trail === 'BOSS') {
|
|
317
|
+
placeLabel = 'Руководитель (BOSS)';
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
const roleNode = findRoleByTrail(sec.ROLES, trail);
|
|
321
|
+
if (!roleNode)
|
|
322
|
+
throw new Error(`Рабочее место «${trail}» не найдено`);
|
|
323
|
+
placeLabel = roleNode.label || roleNode.id;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const inv = createInvite({
|
|
327
|
+
pointPath: this.path,
|
|
328
|
+
pointLabel: this.label || this.DATA?.label || this.id || this.path,
|
|
329
|
+
trail,
|
|
330
|
+
placeLabel,
|
|
331
|
+
channel,
|
|
332
|
+
recipient,
|
|
333
|
+
note,
|
|
334
|
+
createdBy: params.session?.uid || '',
|
|
335
|
+
ttlHours,
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
const reqOrigin = post.origin
|
|
339
|
+
|| (params.request?.headers?.host ? `${params.request.socket?.encrypted ? 'https' : 'http'}://${params.request.headers.host}` : '')
|
|
340
|
+
|| LOCAL_ORIGIN;
|
|
341
|
+
const url = buildInviteUrl(reqOrigin, inv.token);
|
|
342
|
+
const text = `Приглашение в ODANT-WORK (${inv.pointLabel} → ${inv.placeLabel}). Перейдите по одноразовой ссылке для входа и подключения к рабочему месту:\n${url}`;
|
|
343
|
+
const shareUrl = `https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(`Приглашение в ${inv.pointLabel} (${inv.placeLabel})`)}`;
|
|
344
|
+
|
|
345
|
+
let sent = false;
|
|
346
|
+
let sentVia = '';
|
|
347
|
+
let warning = '';
|
|
348
|
+
|
|
349
|
+
if (channel === 'email' && recipient) {
|
|
350
|
+
const mailer = getMailer();
|
|
351
|
+
if (mailer?.transport) {
|
|
352
|
+
const fromUser = mailer.fromUser || mailer.transport?.options?.auth?.user || 'noreply@localhost';
|
|
353
|
+
await mailer.transport.sendMail({
|
|
354
|
+
from: `"ODANT-WORK" <${fromUser}>`,
|
|
355
|
+
to: recipient,
|
|
356
|
+
subject: `Приглашение в ${inv.pointLabel} — ODANT-WORK`,
|
|
357
|
+
text,
|
|
358
|
+
html: `
|
|
359
|
+
<div style="font-family:Segoe UI,Arial,sans-serif;max-width:560px;margin:0 auto;padding:20px;border:1px solid #e5e7eb;border-radius:10px">
|
|
360
|
+
<h2 style="margin:0 0 12px;color:#0f172a">Приглашение в ODANT-WORK</h2>
|
|
361
|
+
<p>Вас пригласили присоединиться к разделу <b>${escapeHtml(inv.pointLabel)}</b> на рабочее место <b>${escapeHtml(inv.placeLabel)}</b>.</p>
|
|
362
|
+
${note ? `<p style="color:#475569">${escapeHtml(note)}</p>` : ''}
|
|
363
|
+
<p style="margin:20px 0">
|
|
364
|
+
<a href="${escapeHtml(url)}" style="display:inline-block;padding:12px 20px;background:#2563eb;color:#fff;text-decoration:none;border-radius:8px;font-weight:600">Принять приглашение и войти</a>
|
|
365
|
+
</p>
|
|
366
|
+
<p style="font-size:12px;color:#64748b">Ссылка одноразовая. Если кнопка не открывается, скопируйте адрес:<br>${escapeHtml(url)}</p>
|
|
367
|
+
</div>
|
|
368
|
+
`,
|
|
369
|
+
});
|
|
370
|
+
sent = true;
|
|
371
|
+
sentVia = 'email';
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
warning = 'SMTP-сервер не настроен — скопируйте ссылку вручную и отправьте получателю.';
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else if ((channel === 'telegram' || channel === 'max') && recipient) {
|
|
378
|
+
const bot = await resolveChannelBotForPoint(this, channel);
|
|
379
|
+
const looksLikeId = /^-?\d{4,}$/.test(recipient) || (channel === 'max' && /^[a-z0-9_-]{4,}$/i.test(recipient) && !recipient.startsWith('@'));
|
|
380
|
+
if (bot?.token && looksLikeId) {
|
|
381
|
+
try {
|
|
382
|
+
const adapter = getAdapter(channel);
|
|
383
|
+
await adapter.sendMessage(bot.token, {
|
|
384
|
+
chatId: recipient,
|
|
385
|
+
text,
|
|
386
|
+
apiUrl: bot.apiUrl,
|
|
387
|
+
});
|
|
388
|
+
sent = true;
|
|
389
|
+
sentVia = channel;
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
warning = `Не удалось отправить через бота ${channel.toUpperCase()} (${err?.message || err}). Перешлите ссылку вручную.`;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else if (!bot?.token) {
|
|
396
|
+
warning = `Бот ${channel.toUpperCase()} не настроен на точке — скопируйте ссылку или нажмите «Отправить в ${channel === 'telegram' ? 'Telegram' : 'MAX'}».`;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
warning = `Для автоматической отправки ботом нужен числовой Chat ID; используйте кнопку пересылки или скопируйте ссылку.`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
audit('invite_create', { pointPath: this.path, trail, channel, sent, params });
|
|
404
|
+
return {
|
|
405
|
+
ok: true,
|
|
406
|
+
invite: inv,
|
|
407
|
+
url,
|
|
408
|
+
shareUrl,
|
|
409
|
+
text,
|
|
410
|
+
sent,
|
|
411
|
+
sentVia,
|
|
412
|
+
warning,
|
|
413
|
+
};
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
});
|