psytools 0.3.2 → 0.5.0

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 (227) hide show
  1. package/README.md +54 -17
  2. package/SOURCES.md +5 -1
  3. package/dist/cjs/assessment.d.ts +6 -4
  4. package/dist/cjs/assessment.js +10 -6
  5. package/dist/cjs/errors.d.ts +4 -2
  6. package/dist/cjs/evaluation.d.ts +10 -5
  7. package/dist/cjs/evaluation.js +68 -31
  8. package/dist/cjs/i18n.d.ts +22 -2
  9. package/dist/cjs/i18n.js +138 -2
  10. package/dist/cjs/index.d.ts +6 -2
  11. package/dist/cjs/index.js +20 -15
  12. package/dist/cjs/inventories/aq10.js +5 -35
  13. package/dist/cjs/inventories/asrs6.js +6 -28
  14. package/dist/cjs/inventories/audit.js +39 -56
  15. package/dist/cjs/inventories/common.js +0 -10
  16. package/dist/cjs/inventories/dass21.js +19 -75
  17. package/dist/cjs/inventories/gad7.js +5 -23
  18. package/dist/cjs/inventories/index.d.ts +11 -2
  19. package/dist/cjs/inventories/index.js +22 -3
  20. package/dist/cjs/inventories/mini-ipip.js +25 -59
  21. package/dist/cjs/inventories/phq9.js +6 -30
  22. package/dist/cjs/inventories/who5.js +5 -31
  23. package/dist/cjs/locales/de/aq10.d.ts +4 -0
  24. package/dist/cjs/locales/de/aq10.js +53 -0
  25. package/dist/cjs/locales/de/asrs6.d.ts +4 -0
  26. package/dist/cjs/locales/de/asrs6.js +42 -0
  27. package/dist/cjs/locales/de/audit.d.ts +4 -0
  28. package/dist/cjs/locales/de/audit.js +80 -0
  29. package/dist/cjs/locales/de/dass21.d.ts +4 -0
  30. package/dist/cjs/locales/de/dass21.js +114 -0
  31. package/dist/cjs/locales/de/gad7.d.ts +4 -0
  32. package/dist/cjs/locales/de/gad7.js +46 -0
  33. package/dist/cjs/locales/de/mini-ipip.d.ts +4 -0
  34. package/dist/cjs/locales/de/mini-ipip.js +97 -0
  35. package/dist/cjs/locales/de/phq9.d.ts +4 -0
  36. package/dist/cjs/locales/de/phq9.js +56 -0
  37. package/dist/cjs/locales/de/who5.d.ts +4 -0
  38. package/dist/cjs/locales/de/who5.js +41 -0
  39. package/dist/cjs/locales/es/aq10.d.ts +4 -0
  40. package/dist/cjs/locales/es/aq10.js +53 -0
  41. package/dist/cjs/locales/es/asrs6.d.ts +4 -0
  42. package/dist/cjs/locales/es/asrs6.js +42 -0
  43. package/dist/cjs/locales/es/audit.d.ts +4 -0
  44. package/dist/cjs/locales/es/audit.js +80 -0
  45. package/dist/cjs/locales/es/dass21.d.ts +4 -0
  46. package/dist/cjs/locales/es/dass21.js +114 -0
  47. package/dist/cjs/locales/es/gad7.d.ts +4 -0
  48. package/dist/cjs/locales/es/gad7.js +46 -0
  49. package/dist/cjs/locales/es/mini-ipip.d.ts +4 -0
  50. package/dist/cjs/locales/es/mini-ipip.js +97 -0
  51. package/dist/cjs/locales/es/phq9.d.ts +4 -0
  52. package/dist/cjs/locales/es/phq9.js +56 -0
  53. package/dist/cjs/locales/es/who5.d.ts +4 -0
  54. package/dist/cjs/locales/es/who5.js +41 -0
  55. package/dist/cjs/locales/index.d.ts +12 -0
  56. package/dist/cjs/locales/index.js +63 -0
  57. package/dist/cjs/locales/tr/aq10.d.ts +4 -0
  58. package/dist/cjs/locales/tr/aq10.js +53 -0
  59. package/dist/cjs/locales/tr/asrs6.d.ts +4 -0
  60. package/dist/cjs/locales/tr/asrs6.js +42 -0
  61. package/dist/cjs/locales/tr/audit.d.ts +4 -0
  62. package/dist/cjs/locales/tr/audit.js +80 -0
  63. package/dist/cjs/locales/tr/dass21.d.ts +4 -0
  64. package/dist/cjs/locales/tr/dass21.js +114 -0
  65. package/dist/cjs/locales/tr/gad7.d.ts +4 -0
  66. package/dist/cjs/locales/tr/gad7.js +46 -0
  67. package/dist/cjs/locales/tr/mini-ipip.d.ts +4 -0
  68. package/dist/cjs/locales/tr/mini-ipip.js +97 -0
  69. package/dist/cjs/locales/tr/phq9.d.ts +4 -0
  70. package/dist/cjs/locales/tr/phq9.js +56 -0
  71. package/dist/cjs/locales/tr/who5.d.ts +4 -0
  72. package/dist/cjs/locales/tr/who5.js +41 -0
  73. package/dist/cjs/locales/zh/aq10.d.ts +4 -0
  74. package/dist/cjs/locales/zh/aq10.js +53 -0
  75. package/dist/cjs/locales/zh/asrs6.d.ts +4 -0
  76. package/dist/cjs/locales/zh/asrs6.js +42 -0
  77. package/dist/cjs/locales/zh/audit.d.ts +4 -0
  78. package/dist/cjs/locales/zh/audit.js +80 -0
  79. package/dist/cjs/locales/zh/dass21.d.ts +4 -0
  80. package/dist/cjs/locales/zh/dass21.js +114 -0
  81. package/dist/cjs/locales/zh/gad7.d.ts +4 -0
  82. package/dist/cjs/locales/zh/gad7.js +46 -0
  83. package/dist/cjs/locales/zh/mini-ipip.d.ts +4 -0
  84. package/dist/cjs/locales/zh/mini-ipip.js +97 -0
  85. package/dist/cjs/locales/zh/phq9.d.ts +4 -0
  86. package/dist/cjs/locales/zh/phq9.js +56 -0
  87. package/dist/cjs/locales/zh/who5.d.ts +4 -0
  88. package/dist/cjs/locales/zh/who5.js +41 -0
  89. package/dist/cjs/types.d.ts +60 -1
  90. package/dist/esm/assessment.d.ts +6 -4
  91. package/dist/esm/assessment.js +11 -7
  92. package/dist/esm/errors.d.ts +4 -2
  93. package/dist/esm/evaluation.d.ts +10 -5
  94. package/dist/esm/evaluation.js +68 -31
  95. package/dist/esm/i18n.d.ts +22 -2
  96. package/dist/esm/i18n.js +135 -1
  97. package/dist/esm/index.d.ts +6 -2
  98. package/dist/esm/index.js +2 -1
  99. package/dist/esm/inventories/aq10.js +5 -35
  100. package/dist/esm/inventories/asrs6.js +6 -28
  101. package/dist/esm/inventories/audit.js +39 -56
  102. package/dist/esm/inventories/common.js +0 -10
  103. package/dist/esm/inventories/dass21.js +19 -75
  104. package/dist/esm/inventories/gad7.js +5 -23
  105. package/dist/esm/inventories/index.d.ts +11 -2
  106. package/dist/esm/inventories/index.js +22 -3
  107. package/dist/esm/inventories/mini-ipip.js +25 -59
  108. package/dist/esm/inventories/phq9.js +6 -30
  109. package/dist/esm/inventories/who5.js +5 -31
  110. package/dist/esm/locales/de/aq10.d.ts +4 -0
  111. package/dist/esm/locales/de/aq10.js +51 -0
  112. package/dist/esm/locales/de/asrs6.d.ts +4 -0
  113. package/dist/esm/locales/de/asrs6.js +40 -0
  114. package/dist/esm/locales/de/audit.d.ts +4 -0
  115. package/dist/esm/locales/de/audit.js +78 -0
  116. package/dist/esm/locales/de/dass21.d.ts +4 -0
  117. package/dist/esm/locales/de/dass21.js +112 -0
  118. package/dist/esm/locales/de/gad7.d.ts +4 -0
  119. package/dist/esm/locales/de/gad7.js +44 -0
  120. package/dist/esm/locales/de/mini-ipip.d.ts +4 -0
  121. package/dist/esm/locales/de/mini-ipip.js +95 -0
  122. package/dist/esm/locales/de/phq9.d.ts +4 -0
  123. package/dist/esm/locales/de/phq9.js +54 -0
  124. package/dist/esm/locales/de/who5.d.ts +4 -0
  125. package/dist/esm/locales/de/who5.js +39 -0
  126. package/dist/esm/locales/es/aq10.d.ts +4 -0
  127. package/dist/esm/locales/es/aq10.js +51 -0
  128. package/dist/esm/locales/es/asrs6.d.ts +4 -0
  129. package/dist/esm/locales/es/asrs6.js +40 -0
  130. package/dist/esm/locales/es/audit.d.ts +4 -0
  131. package/dist/esm/locales/es/audit.js +78 -0
  132. package/dist/esm/locales/es/dass21.d.ts +4 -0
  133. package/dist/esm/locales/es/dass21.js +112 -0
  134. package/dist/esm/locales/es/gad7.d.ts +4 -0
  135. package/dist/esm/locales/es/gad7.js +44 -0
  136. package/dist/esm/locales/es/mini-ipip.d.ts +4 -0
  137. package/dist/esm/locales/es/mini-ipip.js +95 -0
  138. package/dist/esm/locales/es/phq9.d.ts +4 -0
  139. package/dist/esm/locales/es/phq9.js +54 -0
  140. package/dist/esm/locales/es/who5.d.ts +4 -0
  141. package/dist/esm/locales/es/who5.js +39 -0
  142. package/dist/esm/locales/index.d.ts +12 -0
  143. package/dist/esm/locales/index.js +59 -0
  144. package/dist/esm/locales/tr/aq10.d.ts +4 -0
  145. package/dist/esm/locales/tr/aq10.js +51 -0
  146. package/dist/esm/locales/tr/asrs6.d.ts +4 -0
  147. package/dist/esm/locales/tr/asrs6.js +40 -0
  148. package/dist/esm/locales/tr/audit.d.ts +4 -0
  149. package/dist/esm/locales/tr/audit.js +78 -0
  150. package/dist/esm/locales/tr/dass21.d.ts +4 -0
  151. package/dist/esm/locales/tr/dass21.js +112 -0
  152. package/dist/esm/locales/tr/gad7.d.ts +4 -0
  153. package/dist/esm/locales/tr/gad7.js +44 -0
  154. package/dist/esm/locales/tr/mini-ipip.d.ts +4 -0
  155. package/dist/esm/locales/tr/mini-ipip.js +95 -0
  156. package/dist/esm/locales/tr/phq9.d.ts +4 -0
  157. package/dist/esm/locales/tr/phq9.js +54 -0
  158. package/dist/esm/locales/tr/who5.d.ts +4 -0
  159. package/dist/esm/locales/tr/who5.js +39 -0
  160. package/dist/esm/locales/zh/aq10.d.ts +4 -0
  161. package/dist/esm/locales/zh/aq10.js +51 -0
  162. package/dist/esm/locales/zh/asrs6.d.ts +4 -0
  163. package/dist/esm/locales/zh/asrs6.js +40 -0
  164. package/dist/esm/locales/zh/audit.d.ts +4 -0
  165. package/dist/esm/locales/zh/audit.js +78 -0
  166. package/dist/esm/locales/zh/dass21.d.ts +4 -0
  167. package/dist/esm/locales/zh/dass21.js +112 -0
  168. package/dist/esm/locales/zh/gad7.d.ts +4 -0
  169. package/dist/esm/locales/zh/gad7.js +44 -0
  170. package/dist/esm/locales/zh/mini-ipip.d.ts +4 -0
  171. package/dist/esm/locales/zh/mini-ipip.js +95 -0
  172. package/dist/esm/locales/zh/phq9.d.ts +4 -0
  173. package/dist/esm/locales/zh/phq9.js +54 -0
  174. package/dist/esm/locales/zh/who5.d.ts +4 -0
  175. package/dist/esm/locales/zh/who5.js +39 -0
  176. package/dist/esm/types.d.ts +60 -1
  177. package/package.json +21 -1
  178. package/schema/assessment-definition.schema.json +15 -3
  179. package/src/assessment.ts +15 -9
  180. package/src/errors.ts +26 -2
  181. package/src/evaluation.ts +103 -30
  182. package/src/i18n.ts +177 -2
  183. package/src/index.ts +9 -1
  184. package/src/inventories/aq10.ts +5 -35
  185. package/src/inventories/asrs6.ts +6 -28
  186. package/src/inventories/audit.ts +39 -56
  187. package/src/inventories/common.ts +0 -10
  188. package/src/inventories/dass21.ts +19 -75
  189. package/src/inventories/gad7.ts +5 -23
  190. package/src/inventories/index.ts +27 -3
  191. package/src/inventories/mini-ipip.ts +25 -59
  192. package/src/inventories/phq9.ts +6 -30
  193. package/src/inventories/who5.ts +5 -31
  194. package/src/locales/de/aq10.ts +54 -0
  195. package/src/locales/de/asrs6.ts +43 -0
  196. package/src/locales/de/audit.ts +81 -0
  197. package/src/locales/de/dass21.ts +115 -0
  198. package/src/locales/de/gad7.ts +47 -0
  199. package/src/locales/de/mini-ipip.ts +98 -0
  200. package/src/locales/de/phq9.ts +57 -0
  201. package/src/locales/de/who5.ts +42 -0
  202. package/src/locales/es/aq10.ts +54 -0
  203. package/src/locales/es/asrs6.ts +43 -0
  204. package/src/locales/es/audit.ts +81 -0
  205. package/src/locales/es/dass21.ts +115 -0
  206. package/src/locales/es/gad7.ts +47 -0
  207. package/src/locales/es/mini-ipip.ts +98 -0
  208. package/src/locales/es/phq9.ts +57 -0
  209. package/src/locales/es/who5.ts +42 -0
  210. package/src/locales/index.ts +64 -0
  211. package/src/locales/tr/aq10.ts +54 -0
  212. package/src/locales/tr/asrs6.ts +43 -0
  213. package/src/locales/tr/audit.ts +81 -0
  214. package/src/locales/tr/dass21.ts +115 -0
  215. package/src/locales/tr/gad7.ts +47 -0
  216. package/src/locales/tr/mini-ipip.ts +98 -0
  217. package/src/locales/tr/phq9.ts +57 -0
  218. package/src/locales/tr/who5.ts +42 -0
  219. package/src/locales/zh/aq10.ts +54 -0
  220. package/src/locales/zh/asrs6.ts +43 -0
  221. package/src/locales/zh/audit.ts +81 -0
  222. package/src/locales/zh/dass21.ts +115 -0
  223. package/src/locales/zh/gad7.ts +47 -0
  224. package/src/locales/zh/mini-ipip.ts +98 -0
  225. package/src/locales/zh/phq9.ts +57 -0
  226. package/src/locales/zh/who5.ts +42 -0
  227. package/src/types.ts +63 -6
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Simplified Chinese locale pack for dass21. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
4
+ const pack = {
5
+ "id": "dass21",
6
+ "locale": "zh",
7
+ "title": "抑郁-焦虑-压力量表(DASS-21)",
8
+ "description": "一份包含21个条目的自评问卷,用于测量过去一周的抑郁、焦虑和压力水平。",
9
+ "instructions": "请阅读每一条陈述,并选择最能表明过去一周该陈述在多大程度上适用于您的选项。答案没有对错之分。请不要在任何一条陈述上花费太多时间。",
10
+ "options": [
11
+ "完全不适用于我",
12
+ "在某种程度上适用于我,或有时适用",
13
+ "在相当程度上适用于我,或大部分时间适用",
14
+ "非常适用于我,或绝大部分时间适用"
15
+ ],
16
+ "questions": {
17
+ "dass21-1": {
18
+ "text": "我发现自己很难平静下来"
19
+ },
20
+ "dass21-2": {
21
+ "text": "我注意到自己口干"
22
+ },
23
+ "dass21-3": {
24
+ "text": "我似乎完全无法体验到任何积极的感受"
25
+ },
26
+ "dass21-4": {
27
+ "text": "我感到呼吸困难(例如呼吸过快,或没有体力活动时也感到喘不过气)"
28
+ },
29
+ "dass21-5": {
30
+ "text": "我发现自己很难主动去做事情"
31
+ },
32
+ "dass21-6": {
33
+ "text": "我容易对事情反应过度"
34
+ },
35
+ "dass21-7": {
36
+ "text": "我出现过颤抖(例如手抖)"
37
+ },
38
+ "dass21-8": {
39
+ "text": "我觉得自己消耗了很多精神能量"
40
+ },
41
+ "dass21-9": {
42
+ "text": "我担心自己会在某些场合惊慌失措、出丑"
43
+ },
44
+ "dass21-10": {
45
+ "text": "我觉得自己没有什么可期待的"
46
+ },
47
+ "dass21-11": {
48
+ "text": "我发现自己变得焦躁不安"
49
+ },
50
+ "dass21-12": {
51
+ "text": "我发现自己很难放松"
52
+ },
53
+ "dass21-13": {
54
+ "text": "我感到情绪低落、忧郁"
55
+ },
56
+ "dass21-14": {
57
+ "text": "我无法容忍任何妨碍我继续做事的事情"
58
+ },
59
+ "dass21-15": {
60
+ "text": "我感到自己快要惊慌失措了"
61
+ },
62
+ "dass21-16": {
63
+ "text": "我对任何事情都提不起热情"
64
+ },
65
+ "dass21-17": {
66
+ "text": "我觉得自己作为一个人没有多大价值"
67
+ },
68
+ "dass21-18": {
69
+ "text": "我觉得自己相当敏感、易被触怒"
70
+ },
71
+ "dass21-19": {
72
+ "text": "在没有体力活动的情况下,我能察觉到自己的心跳(例如感到心率加快或心跳漏跳)"
73
+ },
74
+ "dass21-20": {
75
+ "text": "我无缘无故地感到害怕"
76
+ },
77
+ "dass21-21": {
78
+ "text": "我觉得生活毫无意义"
79
+ }
80
+ },
81
+ "subscales": {
82
+ "depression": {
83
+ "label": "抑郁",
84
+ "bands": {
85
+ "normal": "正常",
86
+ "mild": "轻度",
87
+ "moderate": "中度",
88
+ "severe": "重度",
89
+ "extremely-severe": "极重度"
90
+ }
91
+ },
92
+ "anxiety": {
93
+ "label": "焦虑",
94
+ "bands": {
95
+ "normal": "正常",
96
+ "mild": "轻度",
97
+ "moderate": "中度",
98
+ "severe": "重度",
99
+ "extremely-severe": "极重度"
100
+ }
101
+ },
102
+ "stress": {
103
+ "label": "压力",
104
+ "bands": {
105
+ "normal": "正常",
106
+ "mild": "轻度",
107
+ "moderate": "中度",
108
+ "severe": "重度",
109
+ "extremely-severe": "极重度"
110
+ }
111
+ }
112
+ }
113
+ };
114
+ exports.default = pack;
@@ -0,0 +1,4 @@
1
+ import type { InventoryLocalePack } from "../../types.ts";
2
+ /** Simplified Chinese locale pack for gad7. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
3
+ declare const pack: InventoryLocalePack;
4
+ export default pack;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Simplified Chinese locale pack for gad7. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
4
+ const pack = {
5
+ "id": "gad7",
6
+ "locale": "zh",
7
+ "title": "广泛性焦虑障碍量表(GAD-7)",
8
+ "description": "一份包含7个条目的自评问卷,用于筛查广泛性焦虑并测量其严重程度。",
9
+ "instructions": "在过去的2周里,您被以下任何一个问题困扰的频率如何?",
10
+ "options": [
11
+ "完全没有",
12
+ "有几天",
13
+ "一半以上的天数",
14
+ "几乎每天"
15
+ ],
16
+ "questions": {
17
+ "gad7-1": {
18
+ "text": "感到紧张、焦虑或心情烦躁"
19
+ },
20
+ "gad7-2": {
21
+ "text": "无法停止或控制担忧"
22
+ },
23
+ "gad7-3": {
24
+ "text": "对各种各样的事情担忧过多"
25
+ },
26
+ "gad7-4": {
27
+ "text": "难以放松"
28
+ },
29
+ "gad7-5": {
30
+ "text": "坐立不安,难以安静地坐着"
31
+ },
32
+ "gad7-6": {
33
+ "text": "容易恼怒或易被激怒"
34
+ },
35
+ "gad7-7": {
36
+ "text": "感到害怕,好像会有可怕的事情发生"
37
+ }
38
+ },
39
+ "bands": {
40
+ "minimal": "极轻度焦虑",
41
+ "mild": "轻度焦虑",
42
+ "moderate": "中度焦虑",
43
+ "severe": "重度焦虑"
44
+ }
45
+ };
46
+ exports.default = pack;
@@ -0,0 +1,4 @@
1
+ import type { InventoryLocalePack } from "../../types.ts";
2
+ /** Simplified Chinese locale pack for mini-ipip. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
3
+ declare const pack: InventoryLocalePack;
4
+ export default pack;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Simplified Chinese locale pack for mini-ipip. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
4
+ const pack = {
5
+ "id": "mini-ipip",
6
+ "locale": "zh",
7
+ "title": "Mini-IPIP 大五人格量表",
8
+ "description": "一个源自国际人格条目库(IPIP)的20项公共领域量表,用于测量大五人格特质(外向性、宜人性、尽责性、神经质、开放性)。",
9
+ "instructions": "请按照您现在通常的样子来描述自己,而不是您希望将来成为的样子。请指出每个陈述对您的描述有多准确。",
10
+ "options": [
11
+ "非常不符合",
12
+ "比较不符合",
13
+ "既非符合也非不符合",
14
+ "比较符合",
15
+ "非常符合"
16
+ ],
17
+ "questions": {
18
+ "mini-ipip-1": {
19
+ "text": "我是聚会中的活跃人物"
20
+ },
21
+ "mini-ipip-2": {
22
+ "text": "我能体会别人的感受"
23
+ },
24
+ "mini-ipip-3": {
25
+ "text": "我会立刻把日常事务做完"
26
+ },
27
+ "mini-ipip-4": {
28
+ "text": "我的情绪经常波动"
29
+ },
30
+ "mini-ipip-5": {
31
+ "text": "我有丰富的想象力"
32
+ },
33
+ "mini-ipip-6": {
34
+ "text": "我话不多"
35
+ },
36
+ "mini-ipip-7": {
37
+ "text": "我对别人的问题不感兴趣"
38
+ },
39
+ "mini-ipip-8": {
40
+ "text": "我经常忘记把东西放回原处"
41
+ },
42
+ "mini-ipip-9": {
43
+ "text": "我大部分时间都很放松"
44
+ },
45
+ "mini-ipip-10": {
46
+ "text": "我对抽象的观念不感兴趣"
47
+ },
48
+ "mini-ipip-11": {
49
+ "text": "在聚会上我会和很多不同的人交谈"
50
+ },
51
+ "mini-ipip-12": {
52
+ "text": "我能感受到别人的情绪"
53
+ },
54
+ "mini-ipip-13": {
55
+ "text": "我喜欢井井有条"
56
+ },
57
+ "mini-ipip-14": {
58
+ "text": "我容易心烦意乱"
59
+ },
60
+ "mini-ipip-15": {
61
+ "text": "我难以理解抽象的观念"
62
+ },
63
+ "mini-ipip-16": {
64
+ "text": "我习惯待在幕后"
65
+ },
66
+ "mini-ipip-17": {
67
+ "text": "我对别人并不真正感兴趣"
68
+ },
69
+ "mini-ipip-18": {
70
+ "text": "我常把事情弄得一团糟"
71
+ },
72
+ "mini-ipip-19": {
73
+ "text": "我很少感到忧郁"
74
+ },
75
+ "mini-ipip-20": {
76
+ "text": "我的想象力不佳"
77
+ }
78
+ },
79
+ "subscales": {
80
+ "extraversion": {
81
+ "label": "外向性"
82
+ },
83
+ "agreeableness": {
84
+ "label": "宜人性"
85
+ },
86
+ "conscientiousness": {
87
+ "label": "尽责性"
88
+ },
89
+ "neuroticism": {
90
+ "label": "神经质"
91
+ },
92
+ "openness": {
93
+ "label": "开放性(智力/想象力)"
94
+ }
95
+ }
96
+ };
97
+ exports.default = pack;
@@ -0,0 +1,4 @@
1
+ import type { InventoryLocalePack } from "../../types.ts";
2
+ /** Simplified Chinese locale pack for phq9. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
3
+ declare const pack: InventoryLocalePack;
4
+ export default pack;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Simplified Chinese locale pack for phq9. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
4
+ const pack = {
5
+ "id": "phq9",
6
+ "locale": "zh",
7
+ "title": "患者健康问卷(PHQ-9)",
8
+ "description": "一份包含9个条目的自评问卷,用于筛查抑郁并测量其严重程度。",
9
+ "instructions": "在过去的2周里,您被以下任何一个问题困扰的频率如何?",
10
+ "options": [
11
+ "完全没有",
12
+ "有几天",
13
+ "一半以上的天数",
14
+ "几乎每天"
15
+ ],
16
+ "questions": {
17
+ "phq9-1": {
18
+ "text": "做事时提不起兴趣或没有乐趣"
19
+ },
20
+ "phq9-2": {
21
+ "text": "感到心情低落、沮丧或绝望"
22
+ },
23
+ "phq9-3": {
24
+ "text": "入睡困难、睡不安稳或睡眠过多"
25
+ },
26
+ "phq9-4": {
27
+ "text": "感觉疲倦或没有活力"
28
+ },
29
+ "phq9-5": {
30
+ "text": "食欲不振或吃得过多"
31
+ },
32
+ "phq9-6": {
33
+ "text": "觉得自己很糟糕——或觉得自己很失败,或让自己或家人失望"
34
+ },
35
+ "phq9-7": {
36
+ "text": "难以集中注意力做事,例如看报纸或看电视"
37
+ },
38
+ "phq9-8": {
39
+ "text": "动作或说话缓慢到别人可能已经察觉?或者正好相反——烦躁或坐立不安,动来动去的情况比平时多得多"
40
+ },
41
+ "phq9-9": {
42
+ "text": "有不如死掉或以某种方式伤害自己的念头"
43
+ }
44
+ },
45
+ "bands": {
46
+ "minimal": "极轻度抑郁",
47
+ "mild": "轻度抑郁",
48
+ "moderate": "中度抑郁",
49
+ "moderately-severe": "中重度抑郁",
50
+ "severe": "重度抑郁"
51
+ },
52
+ "flags": {
53
+ "suicidality": "报告了自我伤害或自杀意念(第9项)——需要临床关注"
54
+ }
55
+ };
56
+ exports.default = pack;
@@ -0,0 +1,4 @@
1
+ import type { InventoryLocalePack } from "../../types.ts";
2
+ /** Simplified Chinese locale pack for who5. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
3
+ declare const pack: InventoryLocalePack;
4
+ export default pack;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Simplified Chinese locale pack for who5. AI translation (Anthropic Claude, claude-fable-5), unverified — see SOURCES.md. */
4
+ const pack = {
5
+ "id": "who5",
6
+ "locale": "zh",
7
+ "title": "世界卫生组织五项身心健康指标(WHO-5)",
8
+ "description": "一份包含5个条目的自评量表,用于测量过去两周的主观心理幸福感。得分越高,表示身心健康状况越好。",
9
+ "instructions": "请针对以下五条陈述,逐条选出最接近您在过去两周内感受的选项。",
10
+ "options": [
11
+ "任何时候都没有",
12
+ "有些时候",
13
+ "少于一半的时间",
14
+ "多于一半的时间",
15
+ "大部分时间",
16
+ "所有时间"
17
+ ],
18
+ "questions": {
19
+ "who5-1": {
20
+ "text": "我感到愉快、心情舒畅"
21
+ },
22
+ "who5-2": {
23
+ "text": "我感到平静和放松"
24
+ },
25
+ "who5-3": {
26
+ "text": "我感到精力充沛、充满活力"
27
+ },
28
+ "who5-4": {
29
+ "text": "我醒来时感到清爽、休息充分"
30
+ },
31
+ "who5-5": {
32
+ "text": "我的日常生活充满了让我感兴趣的事物"
33
+ }
34
+ },
35
+ "bands": {
36
+ "low": "幸福感低——提示可能存在抑郁,建议进行评估",
37
+ "reduced": "幸福感降低——建议进行抑郁筛查",
38
+ "good": "幸福感良好"
39
+ }
40
+ };
41
+ exports.default = pack;
@@ -57,6 +57,28 @@ export interface ScoreFlag {
57
57
  minValue: number;
58
58
  label: LocalizedText;
59
59
  }
60
+ /** How a scorer treats unanswered items among the ones it uses. */
61
+ export type MissingDataStrategy = "ignore" | "prorate" | "require-complete";
62
+ /**
63
+ * Missing-data policy for declarative scoring. Applies when incomplete
64
+ * answers reach the scorer (raw answer maps, or `allowIncomplete`).
65
+ *
66
+ * - `ignore` (default): unanswered items contribute nothing — partial
67
+ * totals understate severity, so use deliberately.
68
+ * - `prorate`: the raw score is scaled up by totalItems / answeredItems
69
+ * and rounded before any multiplier, per scale/subscale.
70
+ * - `require-complete`: evaluation throws `incomplete_response` when any
71
+ * contributing item is unanswered.
72
+ */
73
+ export interface MissingDataPolicy {
74
+ strategy: MissingDataStrategy;
75
+ /**
76
+ * Minimum answered contributing items (per scale/subscale) needed to
77
+ * produce a score; below it evaluation throws `incomplete_response`.
78
+ * Defaults to 1 for `prorate`, 0 otherwise.
79
+ */
80
+ minAnswered?: number;
81
+ }
60
82
  /** Sums all answers into a single total score (PHQ-9, GAD-7, ...). */
61
83
  export interface SumScoring {
62
84
  kind: "sum";
@@ -65,6 +87,7 @@ export interface SumScoring {
65
87
  /** Severity bands the (multiplied) total is matched against. */
66
88
  bands?: ScoreBand[];
67
89
  flags?: ScoreFlag[];
90
+ missing?: MissingDataPolicy;
68
91
  }
69
92
  /** One subscale of a multi-scale scoring definition. */
70
93
  export interface SubscaleDefinition {
@@ -82,6 +105,8 @@ export interface SubscaleScoring {
82
105
  kind: "subscales";
83
106
  subscales: SubscaleDefinition[];
84
107
  flags?: ScoreFlag[];
108
+ /** Applied to each subscale independently. */
109
+ missing?: MissingDataPolicy;
85
110
  }
86
111
  /** One item of a `count` scoring: when it counts as screen-positive. */
87
112
  export interface CountScoringItem {
@@ -102,6 +127,8 @@ export interface CountScoring {
102
127
  /** Bands the positive-item count is matched against. */
103
128
  bands?: ScoreBand[];
104
129
  flags?: ScoreFlag[];
130
+ /** `prorate` scales the positive count by totalItems / answeredItems. */
131
+ missing?: MissingDataPolicy;
105
132
  }
106
133
  /** Declarative, serializable scoring rules built into psytools. */
107
134
  export type ScoringDefinition = SumScoring | SubscaleScoring | CountScoring;
@@ -130,6 +157,36 @@ export interface AssessmentDefinition {
130
157
  /** Free-form metadata (source, license, citation, timeframe, ...). */
131
158
  meta?: Record<string, unknown>;
132
159
  }
160
+ /**
161
+ * One language for one inventory, shipped as a separate lazily-loadable
162
+ * module so that only requested locales are bundled and held in memory.
163
+ * Merge into a base definition with `applyLocale`.
164
+ */
165
+ export interface InventoryLocalePack {
166
+ /** Id of the inventory this pack translates. */
167
+ id: string;
168
+ /** BCP-47 language tag of the pack, e.g. `"tr"`. */
169
+ locale: string;
170
+ title: string;
171
+ description?: string;
172
+ instructions?: string;
173
+ /** Labels of the assessment-level option scale, by option index. */
174
+ options: string[];
175
+ /** Per-question texts (and option labels for question-level scales), by question id. */
176
+ questions: Record<string, {
177
+ text: string;
178
+ options?: string[];
179
+ }>;
180
+ /** Band labels by band id (sum and count scoring). */
181
+ bands?: Record<string, string>;
182
+ /** Flag labels by flag id. */
183
+ flags?: Record<string, string>;
184
+ /** Subscale labels and band labels, by subscale id. */
185
+ subscales?: Record<string, {
186
+ label: string;
187
+ bands?: Record<string, string>;
188
+ }>;
189
+ }
133
190
  /** Answers keyed by question id. */
134
191
  export type AnswerMap = Record<string, number>;
135
192
  /**
@@ -156,9 +213,11 @@ export interface ResponseData {
156
213
  submittedAt?: string;
157
214
  meta?: Record<string, unknown>;
158
215
  }
216
+ /** Codes a validation issue can carry (a subset of `PsytoolsErrorCode`). */
217
+ export type ValidationIssueCode = "unknown_question" | "invalid_value" | "missing_answer" | "duplicate_question" | "malformed";
159
218
  /** A single validation problem. */
160
219
  export interface ValidationIssue {
161
- code: "unknown_question" | "invalid_value" | "missing_answer" | "duplicate_question" | "malformed";
220
+ code: ValidationIssueCode;
162
221
  message: string;
163
222
  questionId?: string;
164
223
  }
@@ -1,5 +1,6 @@
1
- import type { AssessmentDefinition, AssessmentOption, AssessmentQuestion, EvaluationResult, Evaluator, LocalizedAssessmentView, ValidationResult } from "./types.ts";
1
+ import type { AssessmentDefinition, AssessmentOption, AssessmentQuestion, EvaluationResult, LocalizedAssessmentView, ValidationResult } from "./types.ts";
2
2
  import { AssessmentResponse } from "./response.ts";
3
+ import { type EvaluateOptions } from "./evaluation.ts";
3
4
  /**
4
5
  * Structurally validates an assessment definition (useful before persisting
5
6
  * user-created assessments). Returns issues instead of throwing.
@@ -34,16 +35,17 @@ export declare class Assessment {
34
35
  }): AssessmentResponse;
35
36
  /**
36
37
  * Evaluates a response (or raw answers) with the definition's declarative
37
- * scoring, or with `evaluator` when provided.
38
+ * scoring, or with `options.evaluator` when provided.
38
39
  *
39
40
  * When given an `AssessmentResponse`, its status must be `complete` or
40
41
  * `submitted` — pass `allowIncomplete` to score partial responses anyway.
41
42
  * Raw answer maps skip the completeness check, but their values are
42
- * still validated against the option scales.
43
+ * still validated against the option scales, and the scoring definition's
44
+ * missing-data policy still applies.
43
45
  *
44
46
  * @throws PsytoolsError `incomplete_response` | `unknown_question` | `invalid_value` | `no_scoring`
45
47
  */
46
- evaluate(response: AssessmentResponse | Record<string, number>, evaluator?: Evaluator, options?: {
48
+ evaluate(response: AssessmentResponse | Record<string, number>, options?: EvaluateOptions & {
47
49
  allowIncomplete?: boolean;
48
50
  }): EvaluationResult;
49
51
  /** The plain serializable definition (used by `JSON.stringify`). */
@@ -1,5 +1,5 @@
1
1
  import { PsytoolsError } from "./errors.js";
2
- import { collectLocales, localize } from "./i18n.js";
2
+ import { collectLocales, localizeText } from "./i18n.js";
3
3
  import { AssessmentResponse } from "./response.js";
4
4
  import { evaluate } from "./evaluation.js";
5
5
  /**
@@ -187,16 +187,20 @@ export class Assessment {
187
187
  }
188
188
  /**
189
189
  * Evaluates a response (or raw answers) with the definition's declarative
190
- * scoring, or with `evaluator` when provided.
190
+ * scoring, or with `options.evaluator` when provided.
191
191
  *
192
192
  * When given an `AssessmentResponse`, its status must be `complete` or
193
193
  * `submitted` — pass `allowIncomplete` to score partial responses anyway.
194
194
  * Raw answer maps skip the completeness check, but their values are
195
- * still validated against the option scales.
195
+ * still validated against the option scales, and the scoring definition's
196
+ * missing-data policy still applies.
196
197
  *
197
198
  * @throws PsytoolsError `incomplete_response` | `unknown_question` | `invalid_value` | `no_scoring`
198
199
  */
199
- evaluate(response, evaluator, options) {
200
+ evaluate(response, options) {
201
+ if (typeof options === "function") {
202
+ throw new PsytoolsError("invalid_argument", "Pass the evaluator as an option: assessment.evaluate(response, { evaluator })");
203
+ }
200
204
  if (response instanceof AssessmentResponse) {
201
205
  const scorable = response.status === "complete" || response.status === "submitted";
202
206
  if (!scorable && !options?.allowIncomplete) {
@@ -204,9 +208,9 @@ export class Assessment {
204
208
  throw new PsytoolsError("incomplete_response", `Cannot evaluate a response with status "${response.status}" (unanswered: ${missing}); ` +
205
209
  "pass { allowIncomplete: true } to score it anyway");
206
210
  }
207
- return evaluate(this.definition, response.answers, evaluator);
211
+ return evaluate(this.definition, response.answers, { evaluator: options?.evaluator });
208
212
  }
209
- return evaluate(this.definition, response, evaluator);
213
+ return evaluate(this.definition, response, { evaluator: options?.evaluator });
210
214
  }
211
215
  /** The plain serializable definition (used by `JSON.stringify`). */
212
216
  toJSON() {
@@ -233,6 +237,6 @@ export class Assessment {
233
237
  return new Assessment(raw);
234
238
  }
235
239
  text(text, locale) {
236
- return localize(text, locale ?? this.definition.defaultLocale, this.definition.defaultLocale);
240
+ return localizeText(text, locale ?? this.definition.defaultLocale, this.definition.defaultLocale);
237
241
  }
238
242
  }
@@ -1,5 +1,7 @@
1
+ /** Every error code psytools can throw, for exhaustive handling. */
2
+ export type PsytoolsErrorCode = "malformed" | "duplicate_question" | "invalid_definition" | "unknown_question" | "invalid_value" | "missing_answer" | "already_submitted" | "invalid_response" | "incomplete_response" | "assessment_mismatch" | "no_scoring" | "invalid_json" | "unknown_inventory" | "unknown_locale" | "invalid_argument";
1
3
  /** Error thrown by psytools, carrying a stable machine-readable code. */
2
4
  export declare class PsytoolsError extends Error {
3
- readonly code: string;
4
- constructor(code: string, message: string);
5
+ readonly code: PsytoolsErrorCode;
6
+ constructor(code: PsytoolsErrorCode, message: string);
5
7
  }
@@ -1,12 +1,17 @@
1
1
  import type { AnswerMap, AssessmentDefinition, EvaluationResult, Evaluator } from "./types.ts";
2
+ export interface EvaluateOptions {
3
+ /** Custom evaluator used instead of the definition's declarative scoring. */
4
+ evaluator?: Evaluator;
5
+ }
2
6
  /**
3
7
  * Evaluates answers against an assessment definition.
4
8
  *
5
9
  * Every answer is first validated against the assessment: the question must
6
- * exist and the value must belong to its option scale. Then `evaluator` is
7
- * used when given; otherwise the definition's declarative `scoring`
8
- * (`sum` or `subscales`) applies.
10
+ * exist and the value must belong to its option scale. Then
11
+ * `options.evaluator` is used when given; otherwise the definition's
12
+ * declarative `scoring` (`sum`, `subscales`, or `count`) applies, honoring
13
+ * its missing-data policy.
9
14
  *
10
- * @throws PsytoolsError `unknown_question` | `invalid_value` | `no_scoring`
15
+ * @throws PsytoolsError `unknown_question` | `invalid_value` | `incomplete_response` | `no_scoring`
11
16
  */
12
- export declare function evaluate(definition: AssessmentDefinition, answers: AnswerMap, evaluator?: Evaluator): EvaluationResult;
17
+ export declare function evaluate(definition: AssessmentDefinition, answers: AnswerMap, options?: EvaluateOptions): EvaluationResult;