@dappermountain/payload-plugin-achievements 1.0.0-beta.3 → 1.1.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 (240) hide show
  1. package/README.md +22 -8
  2. package/dist/admin/LucideIconField.d.ts +1 -0
  3. package/dist/admin/LucideIconField.d.ts.map +1 -1
  4. package/dist/admin/LucideIconField.js +54 -101
  5. package/dist/admin/ReconcileProgressionButton.d.ts +1 -1
  6. package/dist/admin/ReconcileProgressionButton.d.ts.map +1 -1
  7. package/dist/admin/ReconcileProgressionButton.js +21 -7
  8. package/dist/admin/useEventTypeFlags.d.ts.map +1 -1
  9. package/dist/admin/useEventTypeFlags.js +7 -4
  10. package/dist/admin/usePluginT.d.ts +6 -0
  11. package/dist/admin/usePluginT.d.ts.map +1 -0
  12. package/dist/admin/usePluginT.js +10 -0
  13. package/dist/adminLabel.d.ts +17 -0
  14. package/dist/adminLabel.d.ts.map +1 -0
  15. package/dist/adminLabel.js +28 -0
  16. package/dist/catalog.d.ts +10 -1
  17. package/dist/catalog.d.ts.map +1 -1
  18. package/dist/catalog.js +7 -1
  19. package/dist/collections/AchievementRequests/hooks/prepareAchievementRequest.d.ts.map +1 -1
  20. package/dist/collections/AchievementRequests/hooks/prepareAchievementRequest.js +8 -7
  21. package/dist/collections/AchievementRequests/index.d.ts.map +1 -1
  22. package/dist/collections/AchievementRequests/index.js +19 -5
  23. package/dist/collections/Achievements/index.d.ts.map +1 -1
  24. package/dist/collections/Achievements/index.js +30 -13
  25. package/dist/collections/EventTypes/index.d.ts.map +1 -1
  26. package/dist/collections/EventTypes/index.js +26 -12
  27. package/dist/collections/Grants/hooks/ensureUniqueGrant.js +2 -2
  28. package/dist/collections/Grants/index.d.ts.map +1 -1
  29. package/dist/collections/Grants/index.js +51 -11
  30. package/dist/collections/Logs/fields/validators.d.ts.map +1 -1
  31. package/dist/collections/Logs/fields/validators.js +8 -7
  32. package/dist/collections/Logs/hooks/ensureTypeRequirements.d.ts.map +1 -1
  33. package/dist/collections/Logs/hooks/ensureTypeRequirements.js +9 -7
  34. package/dist/collections/Logs/index.d.ts.map +1 -1
  35. package/dist/collections/Logs/index.js +33 -15
  36. package/dist/collections/MetricBalances/index.d.ts.map +1 -1
  37. package/dist/collections/MetricBalances/index.js +9 -3
  38. package/dist/collections/Metrics/index.d.ts.map +1 -1
  39. package/dist/collections/Metrics/index.js +35 -16
  40. package/dist/collections/Reactions/index.d.ts.map +1 -1
  41. package/dist/collections/Reactions/index.js +25 -13
  42. package/dist/collections/TierRequests/hooks/prepareTierRequest.d.ts.map +1 -1
  43. package/dist/collections/TierRequests/hooks/prepareTierRequest.js +8 -7
  44. package/dist/collections/TierRequests/index.d.ts.map +1 -1
  45. package/dist/collections/TierRequests/index.js +13 -7
  46. package/dist/collections/Tiers/index.d.ts.map +1 -1
  47. package/dist/collections/Tiers/index.js +18 -8
  48. package/dist/collections/fields/index.d.ts +1 -1
  49. package/dist/collections/fields/index.d.ts.map +1 -1
  50. package/dist/collections/fields/index.js +1 -1
  51. package/dist/collections/fields/localizedText.d.ts.map +1 -1
  52. package/dist/collections/fields/localizedText.js +3 -0
  53. package/dist/collections/fields/ruleFields.d.ts +27 -14
  54. package/dist/collections/fields/ruleFields.d.ts.map +1 -1
  55. package/dist/collections/fields/ruleFields.js +107 -34
  56. package/dist/collections/fields/scopeField.d.ts.map +1 -1
  57. package/dist/collections/fields/scopeField.js +3 -1
  58. package/dist/collections/fields/userField.d.ts.map +1 -1
  59. package/dist/collections/fields/userField.js +2 -0
  60. package/dist/collections/fields/usersAchievementsGroup.d.ts.map +1 -1
  61. package/dist/collections/fields/usersAchievementsGroup.js +2 -1
  62. package/dist/collections/helpers.d.ts.map +1 -1
  63. package/dist/collections/helpers.js +2 -1
  64. package/dist/collections/hooks/preventCatalogDelete.d.ts.map +1 -1
  65. package/dist/collections/hooks/preventCatalogDelete.js +6 -3
  66. package/dist/collections/slugs.d.ts +5 -2
  67. package/dist/collections/slugs.d.ts.map +1 -1
  68. package/dist/collections/slugs.js +7 -5
  69. package/dist/defaults.d.ts +1 -1
  70. package/dist/defaults.d.ts.map +1 -1
  71. package/dist/extensions/actions.d.ts.map +1 -1
  72. package/dist/extensions/actions.js +2 -1
  73. package/dist/extensions/elapsedSinceOptions.d.ts +1 -1
  74. package/dist/extensions/elapsedSinceOptions.d.ts.map +1 -1
  75. package/dist/extensions/elapsedSinceOptions.js +4 -3
  76. package/dist/index.d.ts +5 -2
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +4 -1
  79. package/dist/plugin.d.ts.map +1 -1
  80. package/dist/plugin.js +20 -0
  81. package/dist/seed/index.d.ts +2 -0
  82. package/dist/seed/index.d.ts.map +1 -1
  83. package/dist/seed/index.js +1 -0
  84. package/dist/services/achievement/builtInRules.d.ts.map +1 -1
  85. package/dist/services/achievement/builtInRules.js +10 -2
  86. package/dist/services/achievement/grantLifecycle.d.ts +31 -0
  87. package/dist/services/achievement/grantLifecycle.d.ts.map +1 -0
  88. package/dist/services/achievement/grantLifecycle.js +139 -0
  89. package/dist/services/achievement/grantSideEffects.d.ts +22 -0
  90. package/dist/services/achievement/grantSideEffects.d.ts.map +1 -1
  91. package/dist/services/achievement/grantSideEffects.js +89 -1
  92. package/dist/services/achievement/index.d.ts +1 -0
  93. package/dist/services/achievement/index.d.ts.map +1 -1
  94. package/dist/services/achievement/index.js +1 -0
  95. package/dist/services/achievement/logData.d.ts +3 -2
  96. package/dist/services/achievement/logData.d.ts.map +1 -1
  97. package/dist/translations/index.d.ts +8723 -0
  98. package/dist/translations/index.d.ts.map +1 -0
  99. package/dist/translations/index.js +96 -0
  100. package/dist/translations/keys.d.ts +4 -0
  101. package/dist/translations/keys.d.ts.map +1 -0
  102. package/dist/translations/keys.js +5 -0
  103. package/dist/translations/languages/ar.d.ts +199 -0
  104. package/dist/translations/languages/ar.d.ts.map +1 -0
  105. package/dist/translations/languages/ar.js +198 -0
  106. package/dist/translations/languages/az.d.ts +199 -0
  107. package/dist/translations/languages/az.d.ts.map +1 -0
  108. package/dist/translations/languages/az.js +198 -0
  109. package/dist/translations/languages/bg.d.ts +199 -0
  110. package/dist/translations/languages/bg.d.ts.map +1 -0
  111. package/dist/translations/languages/bg.js +198 -0
  112. package/dist/translations/languages/bnBd.d.ts +199 -0
  113. package/dist/translations/languages/bnBd.d.ts.map +1 -0
  114. package/dist/translations/languages/bnBd.js +198 -0
  115. package/dist/translations/languages/bnIn.d.ts +199 -0
  116. package/dist/translations/languages/bnIn.d.ts.map +1 -0
  117. package/dist/translations/languages/bnIn.js +198 -0
  118. package/dist/translations/languages/ca.d.ts +199 -0
  119. package/dist/translations/languages/ca.d.ts.map +1 -0
  120. package/dist/translations/languages/ca.js +198 -0
  121. package/dist/translations/languages/cs.d.ts +199 -0
  122. package/dist/translations/languages/cs.d.ts.map +1 -0
  123. package/dist/translations/languages/cs.js +198 -0
  124. package/dist/translations/languages/da.d.ts +199 -0
  125. package/dist/translations/languages/da.d.ts.map +1 -0
  126. package/dist/translations/languages/da.js +198 -0
  127. package/dist/translations/languages/de.d.ts +199 -0
  128. package/dist/translations/languages/de.d.ts.map +1 -0
  129. package/dist/translations/languages/de.js +198 -0
  130. package/dist/translations/languages/en.d.ts +199 -0
  131. package/dist/translations/languages/en.d.ts.map +1 -0
  132. package/dist/translations/languages/en.js +198 -0
  133. package/dist/translations/languages/es.d.ts +199 -0
  134. package/dist/translations/languages/es.d.ts.map +1 -0
  135. package/dist/translations/languages/es.js +198 -0
  136. package/dist/translations/languages/et.d.ts +199 -0
  137. package/dist/translations/languages/et.d.ts.map +1 -0
  138. package/dist/translations/languages/et.js +198 -0
  139. package/dist/translations/languages/fa.d.ts +199 -0
  140. package/dist/translations/languages/fa.d.ts.map +1 -0
  141. package/dist/translations/languages/fa.js +198 -0
  142. package/dist/translations/languages/fr.d.ts +199 -0
  143. package/dist/translations/languages/fr.d.ts.map +1 -0
  144. package/dist/translations/languages/fr.js +198 -0
  145. package/dist/translations/languages/he.d.ts +199 -0
  146. package/dist/translations/languages/he.d.ts.map +1 -0
  147. package/dist/translations/languages/he.js +198 -0
  148. package/dist/translations/languages/hr.d.ts +199 -0
  149. package/dist/translations/languages/hr.d.ts.map +1 -0
  150. package/dist/translations/languages/hr.js +198 -0
  151. package/dist/translations/languages/hu.d.ts +199 -0
  152. package/dist/translations/languages/hu.d.ts.map +1 -0
  153. package/dist/translations/languages/hu.js +198 -0
  154. package/dist/translations/languages/hy.d.ts +199 -0
  155. package/dist/translations/languages/hy.d.ts.map +1 -0
  156. package/dist/translations/languages/hy.js +198 -0
  157. package/dist/translations/languages/id.d.ts +199 -0
  158. package/dist/translations/languages/id.d.ts.map +1 -0
  159. package/dist/translations/languages/id.js +198 -0
  160. package/dist/translations/languages/is.d.ts +199 -0
  161. package/dist/translations/languages/is.d.ts.map +1 -0
  162. package/dist/translations/languages/is.js +198 -0
  163. package/dist/translations/languages/it.d.ts +199 -0
  164. package/dist/translations/languages/it.d.ts.map +1 -0
  165. package/dist/translations/languages/it.js +198 -0
  166. package/dist/translations/languages/ja.d.ts +199 -0
  167. package/dist/translations/languages/ja.d.ts.map +1 -0
  168. package/dist/translations/languages/ja.js +198 -0
  169. package/dist/translations/languages/ko.d.ts +199 -0
  170. package/dist/translations/languages/ko.d.ts.map +1 -0
  171. package/dist/translations/languages/ko.js +198 -0
  172. package/dist/translations/languages/lt.d.ts +199 -0
  173. package/dist/translations/languages/lt.d.ts.map +1 -0
  174. package/dist/translations/languages/lt.js +198 -0
  175. package/dist/translations/languages/lv.d.ts +199 -0
  176. package/dist/translations/languages/lv.d.ts.map +1 -0
  177. package/dist/translations/languages/lv.js +198 -0
  178. package/dist/translations/languages/my.d.ts +199 -0
  179. package/dist/translations/languages/my.d.ts.map +1 -0
  180. package/dist/translations/languages/my.js +198 -0
  181. package/dist/translations/languages/nb.d.ts +199 -0
  182. package/dist/translations/languages/nb.d.ts.map +1 -0
  183. package/dist/translations/languages/nb.js +198 -0
  184. package/dist/translations/languages/nl.d.ts +199 -0
  185. package/dist/translations/languages/nl.d.ts.map +1 -0
  186. package/dist/translations/languages/nl.js +198 -0
  187. package/dist/translations/languages/pl.d.ts +199 -0
  188. package/dist/translations/languages/pl.d.ts.map +1 -0
  189. package/dist/translations/languages/pl.js +198 -0
  190. package/dist/translations/languages/pt.d.ts +199 -0
  191. package/dist/translations/languages/pt.d.ts.map +1 -0
  192. package/dist/translations/languages/pt.js +198 -0
  193. package/dist/translations/languages/ro.d.ts +199 -0
  194. package/dist/translations/languages/ro.d.ts.map +1 -0
  195. package/dist/translations/languages/ro.js +198 -0
  196. package/dist/translations/languages/rs.d.ts +199 -0
  197. package/dist/translations/languages/rs.d.ts.map +1 -0
  198. package/dist/translations/languages/rs.js +198 -0
  199. package/dist/translations/languages/rsLatin.d.ts +199 -0
  200. package/dist/translations/languages/rsLatin.d.ts.map +1 -0
  201. package/dist/translations/languages/rsLatin.js +198 -0
  202. package/dist/translations/languages/ru.d.ts +199 -0
  203. package/dist/translations/languages/ru.d.ts.map +1 -0
  204. package/dist/translations/languages/ru.js +198 -0
  205. package/dist/translations/languages/sk.d.ts +199 -0
  206. package/dist/translations/languages/sk.d.ts.map +1 -0
  207. package/dist/translations/languages/sk.js +198 -0
  208. package/dist/translations/languages/sl.d.ts +199 -0
  209. package/dist/translations/languages/sl.d.ts.map +1 -0
  210. package/dist/translations/languages/sl.js +198 -0
  211. package/dist/translations/languages/sv.d.ts +199 -0
  212. package/dist/translations/languages/sv.d.ts.map +1 -0
  213. package/dist/translations/languages/sv.js +198 -0
  214. package/dist/translations/languages/ta.d.ts +199 -0
  215. package/dist/translations/languages/ta.d.ts.map +1 -0
  216. package/dist/translations/languages/ta.js +198 -0
  217. package/dist/translations/languages/th.d.ts +199 -0
  218. package/dist/translations/languages/th.d.ts.map +1 -0
  219. package/dist/translations/languages/th.js +198 -0
  220. package/dist/translations/languages/tr.d.ts +199 -0
  221. package/dist/translations/languages/tr.d.ts.map +1 -0
  222. package/dist/translations/languages/tr.js +198 -0
  223. package/dist/translations/languages/uk.d.ts +199 -0
  224. package/dist/translations/languages/uk.d.ts.map +1 -0
  225. package/dist/translations/languages/uk.js +198 -0
  226. package/dist/translations/languages/vi.d.ts +199 -0
  227. package/dist/translations/languages/vi.d.ts.map +1 -0
  228. package/dist/translations/languages/vi.js +198 -0
  229. package/dist/translations/languages/zh.d.ts +199 -0
  230. package/dist/translations/languages/zh.d.ts.map +1 -0
  231. package/dist/translations/languages/zh.js +198 -0
  232. package/dist/translations/languages/zhTw.d.ts +199 -0
  233. package/dist/translations/languages/zhTw.d.ts.map +1 -0
  234. package/dist/translations/languages/zhTw.js +198 -0
  235. package/dist/translations/reqT.d.ts +14 -0
  236. package/dist/translations/reqT.d.ts.map +1 -0
  237. package/dist/translations/reqT.js +26 -0
  238. package/dist/types.d.ts +8 -3
  239. package/dist/types.d.ts.map +1 -1
  240. package/package.json +3 -1
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { catalogFilterOptions, metricLogFilterOptions } from '../fields/catalogFilter.js';
2
3
  import { collectionAdmin, collectionOf, optionalFields, slugOf } from '../helpers.js';
3
4
  import { getAchievementOptions } from '../../options-store.js';
@@ -15,8 +16,9 @@ function subjectLogField(eventTypesSlug) {
15
16
  relationTo: collections,
16
17
  index: true,
17
18
  validate: validateSubject,
19
+ label: tLabel('subject'),
18
20
  admin: {
19
- description: 'Host document this entry is about (post, comment, …).',
21
+ description: tLabel('hostDocumentThisEntryIsAboutPostComment'),
20
22
  components: {
21
23
  Field: {
22
24
  path: '@dappermountain/payload-plugin-achievements/client#SubjectField',
@@ -34,8 +36,8 @@ export function buildLogsCollection() {
34
36
  return {
35
37
  slug: slugOf('logs'),
36
38
  labels: {
37
- singular: 'Achievement Log',
38
- plural: 'Achievement Logs',
39
+ singular: tLabel('achievementLog'),
40
+ plural: tLabel('achievementLogs'),
39
41
  },
40
42
  access: { ...access },
41
43
  hooks,
@@ -50,7 +52,7 @@ export function buildLogsCollection() {
50
52
  'change',
51
53
  'createdAt',
52
54
  ],
53
- description: 'Member activity history — grants, revokes, score changes, tier moves, and host custom events. Creating or deleting a host (or metric) log re-evaluates composed achievements and derived tiers.',
55
+ description: tEntityDescription('memberActivityHistoryGrantsRevokesScoreChangesTier'),
54
56
  }),
55
57
  fields: [
56
58
  ...optionalFields(scopeField()),
@@ -65,7 +67,11 @@ export function buildLogsCollection() {
65
67
  required: true,
66
68
  index: true,
67
69
  filterOptions: catalogFilterOptions,
68
- admin: { width: '50%', description: 'What kind of thing happened.' },
70
+ label: tLabel('eventType'),
71
+ admin: {
72
+ width: '50%',
73
+ description: tLabel('whatKindOfThingHappened'),
74
+ },
69
75
  },
70
76
  {
71
77
  name: 'actor',
@@ -73,9 +79,10 @@ export function buildLogsCollection() {
73
79
  relationTo: users,
74
80
  index: true,
75
81
  validate: validateActor,
82
+ label: tLabel('actor'),
76
83
  admin: {
77
84
  width: '50%',
78
- description: 'Who caused it.',
85
+ description: tLabel('whoCausedIt'),
79
86
  components: {
80
87
  Field: {
81
88
  path: '@dappermountain/payload-plugin-achievements/client#ActorField',
@@ -90,9 +97,10 @@ export function buildLogsCollection() {
90
97
  relationTo: collectionOf('metrics'),
91
98
  filterOptions: metricLogFilterOptions,
92
99
  validate: validateMetric,
100
+ label: tLabel('metric'),
93
101
  admin: {
94
102
  width: '50%',
95
- description: 'Which stored score moved (computed metrics like Days cannot be chosen here).',
103
+ description: tLabel('whichStoredScoreMovedComputedMetricsLikeDays'),
96
104
  components: {
97
105
  Field: {
98
106
  path: '@dappermountain/payload-plugin-achievements/client#MetricField',
@@ -105,9 +113,10 @@ export function buildLogsCollection() {
105
113
  name: 'change',
106
114
  type: 'number',
107
115
  validate: validateChange,
116
+ label: tLabel('change'),
108
117
  admin: {
109
118
  width: '50%',
110
- description: 'How much it changed (for example 10 or −3).',
119
+ description: tLabel('howMuchItChangedForExample10Or'),
111
120
  components: {
112
121
  Field: {
113
122
  path: '@dappermountain/payload-plugin-achievements/client#MetricChangeField',
@@ -124,7 +133,7 @@ export function buildLogsCollection() {
124
133
  type: 'array',
125
134
  admin: {
126
135
  readOnly: true,
127
- description: 'Derived ladder rank of the actor when this entry was written. Filled only when the event type snapshots actor tiers.',
136
+ description: tLabel('derivedLadderRankOfTheActorWhenThis'),
128
137
  },
129
138
  fields: [
130
139
  ...optionalFields(scopeField()),
@@ -133,34 +142,43 @@ export function buildLogsCollection() {
133
142
  type: 'relationship',
134
143
  relationTo: collectionOf('tiers'),
135
144
  required: true,
136
- admin: { description: 'Which ladder step they held.' },
145
+ label: tLabel('tier'),
146
+ admin: {
147
+ description: tLabel('whichLadderStepTheyHeld'),
148
+ },
137
149
  },
138
150
  {
139
151
  name: 'rank',
140
152
  type: 'number',
141
153
  required: true,
142
- admin: { description: 'Ladder rank at write time (higher is further along).' },
154
+ label: tLabel('rank'),
155
+ admin: {
156
+ description: tLabel('ladderRankAtWriteTimeHigherIsFurther'),
157
+ },
143
158
  },
144
159
  ],
145
160
  },
146
161
  {
147
162
  type: 'collapsible',
148
- label: 'Details',
163
+ label: tLabel('details'),
149
164
  admin: {
150
165
  initCollapsed: true,
151
- description: 'Extra detail if you need it.',
166
+ description: tLabel('extraDetailIfYouNeedIt'),
152
167
  },
153
168
  fields: [
154
169
  {
155
170
  name: 'reason',
156
171
  type: 'text',
157
- admin: { description: 'A short note about why this was recorded.' },
172
+ admin: {
173
+ description: tLabel('aShortNoteAboutWhyThisWasRecorded'),
174
+ },
158
175
  },
159
176
  {
160
177
  name: 'data',
161
178
  type: 'json',
179
+ label: tLabel('data'),
162
180
  admin: {
163
- description: 'Engine transition envelope: `{ from, to }` each `{ id, slug? }` or null (tier.changed, achievement.granted/revoked). Prefer `subject` for host document links.',
181
+ description: tLabel('engineTransitionEnvelopeFromToEachIdSlug'),
164
182
  },
165
183
  },
166
184
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/MetricBalances/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAa/C,wBAAgB,6BAA6B,IAAI,gBAAgB,CA4ChE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/MetricBalances/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAc/C,wBAAgB,6BAA6B,IAAI,gBAAgB,CAgDhE"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { collectionAdmin, collectionOf, columnsWithOptionalScope, optionalFields, slugOf, } from '../helpers.js';
2
3
  import { scopeField, userField } from '../fields/index.js';
3
4
  import { access } from './access/index.js';
@@ -5,12 +6,16 @@ import { hooks } from './hooks/index.js';
5
6
  export function buildMetricBalancesCollection() {
6
7
  return {
7
8
  slug: slugOf('metricBalances'),
9
+ labels: {
10
+ singular: tLabel('metricBalance'),
11
+ plural: tLabel('metricBalances'),
12
+ },
8
13
  access: { ...access },
9
14
  hooks,
10
15
  admin: collectionAdmin({
11
16
  useAsTitle: 'key',
12
17
  defaultColumns: columnsWithOptionalScope(['metric', 'user', 'value', 'scope', 'updatedAt']),
13
- description: 'Stored metric totals per user (and scope). Updated by recordMetricChange; repair with reconcile. Not for computed metrics.',
18
+ description: tEntityDescription('storedMetricTotalsPerUserAndScopeUpdated'),
14
19
  }),
15
20
  fields: [
16
21
  userField(),
@@ -21,6 +26,7 @@ export function buildMetricBalancesCollection() {
21
26
  relationTo: collectionOf('metrics'),
22
27
  required: true,
23
28
  index: true,
29
+ label: tLabel('metric'),
24
30
  },
25
31
  {
26
32
  name: 'value',
@@ -29,7 +35,7 @@ export function buildMetricBalancesCollection() {
29
35
  defaultValue: 0,
30
36
  index: true,
31
37
  admin: {
32
- description: 'Current total (sum of metric.delta changes).',
38
+ description: tLabel('currentTotalSumOfMetricDeltaChanges'),
33
39
  },
34
40
  },
35
41
  {
@@ -40,7 +46,7 @@ export function buildMetricBalancesCollection() {
40
46
  index: true,
41
47
  admin: {
42
48
  readOnly: true,
43
- description: 'Stable unique key: user:scope:metric.',
49
+ description: tLabel('stableUniqueKeyUserScopeMetric'),
44
50
  },
45
51
  },
46
52
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAS/C,wBAAgB,sBAAsB,IAAI,gBAAgB,CAkGzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAU/C,wBAAgB,sBAAsB,IAAI,gBAAgB,CAkHzD"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { collectionAdmin, collectionOf, columnsWithOptionalScope, optionalFields, slugOf } from '../helpers.js';
2
3
  import { localizedNameField, scopeField } from '../fields/index.js';
3
4
  import { catalogFilterOptions } from '../fields/catalogFilter.js';
@@ -7,12 +8,16 @@ import { hooks } from './hooks/index.js';
7
8
  export function buildMetricsCollection() {
8
9
  return {
9
10
  slug: slugOf('metrics'),
11
+ labels: {
12
+ singular: tLabel('metric'),
13
+ plural: tLabel('metrics'),
14
+ },
10
15
  access: { ...access },
11
16
  hooks,
12
17
  admin: collectionAdmin({
13
18
  useAsTitle: 'name',
14
19
  defaultColumns: columnsWithOptionalScope(['name', 'slug', 'kind', 'system', 'scope']),
15
- description: 'Named numbers. Stored metrics are score totals from log deltas; computed metrics are derived at evaluation time.',
20
+ description: tEntityDescription('namedNumbersStoredMetricsAreScoreTotalsFrom'),
16
21
  }),
17
22
  fields: [
18
23
  ...optionalFields(scopeField()),
@@ -20,7 +25,15 @@ export function buildMetricsCollection() {
20
25
  type: 'row',
21
26
  fields: [
22
27
  localizedNameField({ width: '50%' }),
23
- { name: 'slug', type: 'text', required: true, unique: true, index: true, admin: { width: '50%' } },
28
+ {
29
+ name: 'slug',
30
+ type: 'text',
31
+ required: true,
32
+ unique: true,
33
+ index: true,
34
+ label: tLabel('slug'),
35
+ admin: { width: '50%' },
36
+ },
24
37
  ],
25
38
  },
26
39
  {
@@ -28,52 +41,56 @@ export function buildMetricsCollection() {
28
41
  type: 'select',
29
42
  required: true,
30
43
  defaultValue: 'stored',
44
+ label: tLabel('kind'),
31
45
  enumName: 'ach_metric_kind',
32
46
  options: [
33
- { label: 'Stored (log deltas)', value: 'stored' },
34
- { label: 'Computed', value: 'computed' },
47
+ { label: tLabel('storedLogDeltas'), value: 'stored' },
48
+ { label: tLabel('computed'), value: 'computed' },
35
49
  ],
36
50
  admin: {
37
- description: 'Stored = sum of metric.delta logs (via balances). Computed = derived value.',
51
+ description: tLabel('storedSumOfMetricDeltaLogsViaBalances'),
38
52
  },
39
53
  },
40
54
  {
41
55
  name: 'compute',
42
56
  type: 'select',
43
57
  defaultValue: 'elapsed',
58
+ label: tLabel('compute'),
44
59
  enumName: 'ach_metric_compute',
45
- options: [{ label: 'Elapsed time', value: 'elapsed' }],
60
+ options: [{ label: tLabel('elapsedTime'), value: 'elapsed' }],
46
61
  admin: {
47
62
  condition: (_, sibling) => sibling?.kind === 'computed',
48
- description: 'How this number is derived.',
63
+ description: tLabel('howThisNumberIsDerived'),
49
64
  },
50
65
  },
51
66
  {
52
67
  name: 'unit',
53
68
  type: 'select',
54
69
  defaultValue: 'days',
70
+ label: tLabel('unit'),
55
71
  enumName: 'ach_metric_unit',
56
72
  options: [
57
- { label: 'Seconds', value: 'seconds' },
58
- { label: 'Minutes', value: 'minutes' },
59
- { label: 'Hours', value: 'hours' },
60
- { label: 'Days', value: 'days' },
61
- { label: 'Years', value: 'years' },
73
+ { label: tLabel('seconds'), value: 'seconds' },
74
+ { label: tLabel('minutes'), value: 'minutes' },
75
+ { label: tLabel('hours'), value: 'hours' },
76
+ { label: tLabel('days'), value: 'days' },
77
+ { label: tLabel('years'), value: 'years' },
62
78
  ],
63
79
  admin: {
64
80
  condition: (_, sibling) => sibling?.kind === 'computed' && sibling?.compute === 'elapsed',
65
- description: 'Unit of the exposed number (whole units since the anchor). Years use a fixed 365-day length.',
81
+ description: tLabel('unitOfTheExposedNumberWholeUnitsSince'),
66
82
  },
67
83
  },
68
84
  {
69
85
  name: 'since',
70
86
  type: 'select',
71
87
  defaultValue: 'user-created-at',
88
+ label: tLabel('since'),
72
89
  enumName: 'ach_metric_since',
73
90
  options: elapsedSinceSelectOptions(),
74
91
  admin: {
75
92
  condition: (_, sibling) => sibling?.kind === 'computed' && sibling?.compute === 'elapsed',
76
- description: 'Which timestamp starts the clock.',
93
+ description: tLabel('whichTimestampStartsTheClock'),
77
94
  },
78
95
  },
79
96
  {
@@ -81,20 +98,22 @@ export function buildMetricsCollection() {
81
98
  type: 'relationship',
82
99
  relationTo: collectionOf('eventTypes'),
83
100
  filterOptions: catalogFilterOptions,
101
+ label: tLabel('firstEventType'),
84
102
  admin: {
85
103
  condition: (_, sibling) => sibling?.kind === 'computed' &&
86
104
  sibling?.compute === 'elapsed' &&
87
105
  sibling?.since === 'first-event',
88
- description: 'Event type whose first log starts the clock.',
106
+ description: tLabel('eventTypeWhoseFirstLogStartsTheClock'),
89
107
  },
90
108
  },
91
109
  {
92
110
  name: 'system',
93
111
  type: 'checkbox',
94
112
  defaultValue: false,
113
+ label: tLabel('system'),
95
114
  admin: {
96
115
  readOnly: true,
97
- description: 'Built-in metric. It can’t be deleted.',
116
+ description: tLabel('builtInMetricItCanTBeDeleted'),
98
117
  },
99
118
  },
100
119
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Reactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAmBtD,wBAAgB,wBAAwB,IAAI,gBAAgB,CAoF3D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Reactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAoBtD,wBAAgB,wBAAwB,IAAI,gBAAgB,CA6F3D"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { actionSelectOptions, BUILTIN_GRANT_ACTION, getHostActions } from '../../extensions/actions.js';
2
3
  import { catalogFilterOptions } from '../fields/catalogFilter.js';
3
4
  import { whenSiblingEquals } from '../fields/whenSibling.js';
@@ -17,14 +18,14 @@ export function buildReactionsCollection() {
17
18
  return {
18
19
  slug: slugOf('reactions'),
19
20
  labels: {
20
- singular: 'Achievement Reaction',
21
- plural: 'Achievement Reactions',
21
+ singular: tLabel('achievementReaction'),
22
+ plural: tLabel('achievementReactions'),
22
23
  },
23
24
  access: { ...access },
24
25
  admin: collectionAdmin({
25
26
  useAsTitle: 'name',
26
27
  defaultColumns: columnsWithOptionalScope(['name', 'trigger', 'action', 'enabled', 'scope']),
27
- description: 'When an event is logged or an achievement is granted/revoked, run a set-based action. Re-running is safe — there is no run-history table.',
28
+ description: tEntityDescription('whenAnEventIsLoggedOrAnAchievement'),
28
29
  }),
29
30
  fields: [
30
31
  ...optionalFields(scopeField()),
@@ -33,25 +34,31 @@ export function buildReactionsCollection() {
33
34
  type: 'text',
34
35
  required: true,
35
36
  index: true,
36
- admin: { description: 'Admin label for this reaction.' },
37
+ admin: {
38
+ description: tLabel('adminLabelForThisReaction'),
39
+ },
37
40
  },
38
41
  {
39
42
  name: 'enabled',
40
43
  type: 'checkbox',
41
44
  defaultValue: true,
42
- admin: { description: 'Turn off to keep the row without running it.' },
45
+ label: tLabel('enabled'),
46
+ admin: {
47
+ description: tLabel('turnOffToKeepTheRowWithoutRunning'),
48
+ },
43
49
  },
44
50
  {
45
51
  name: 'trigger',
46
52
  type: 'select',
47
53
  required: true,
54
+ label: tLabel('trigger'),
48
55
  options: [
49
- { label: 'Event logged', value: 'event' },
50
- { label: 'Achievement granted', value: 'achievement.granted' },
51
- { label: 'Achievement revoked', value: 'achievement.revoked' },
56
+ { label: tLabel('eventLogged'), value: 'event' },
57
+ { label: tLabel('achievementGranted'), value: 'achievement.granted' },
58
+ { label: tLabel('achievementRevoked'), value: 'achievement.revoked' },
52
59
  ],
53
60
  admin: {
54
- description: 'Grant/revoke triggers fire from the grant row. Use “Event logged” for host event types (not achievement.granted / achievement.revoked — those already cascade from grants).',
61
+ description: tLabel('grantRevokeTriggersFireFromTheGrantRow'),
55
62
  },
56
63
  },
57
64
  {
@@ -59,9 +66,10 @@ export function buildReactionsCollection() {
59
66
  type: 'relationship',
60
67
  relationTo: collectionOf('eventTypes'),
61
68
  filterOptions: catalogFilterOptions,
69
+ label: tLabel('eventType'),
62
70
  admin: {
63
71
  condition: (_, sibling) => sibling?.trigger === 'event',
64
- description: 'Which log type starts this reaction.',
72
+ description: tLabel('whichLogTypeStartsThisReaction'),
65
73
  },
66
74
  },
67
75
  {
@@ -69,17 +77,21 @@ export function buildReactionsCollection() {
69
77
  type: 'relationship',
70
78
  relationTo: collectionOf('achievements'),
71
79
  filterOptions: catalogFilterOptions,
80
+ label: tLabel('achievement'),
72
81
  admin: {
73
82
  condition: (_, sibling) => sibling?.trigger === 'achievement.granted' || sibling?.trigger === 'achievement.revoked',
74
- description: 'Which achievement grant/revoke starts this reaction.',
83
+ description: tLabel('whichAchievementGrantRevokeStartsThisReaction'),
75
84
  },
76
85
  },
77
86
  {
78
87
  name: 'action',
79
88
  type: 'select',
80
89
  required: true,
90
+ label: tLabel('action'),
81
91
  options: actionSelectOptions(),
82
- admin: { description: 'Set-based command to run. Hosts register extra actions in plugin options.' },
92
+ admin: {
93
+ description: tLabel('setBasedCommandToRunHostsRegisterExtra'),
94
+ },
83
95
  },
84
96
  {
85
97
  name: 'targetAchievement',
@@ -88,7 +100,7 @@ export function buildReactionsCollection() {
88
100
  filterOptions: catalogFilterOptions,
89
101
  admin: {
90
102
  condition: (_, sibling) => sibling?.action === BUILTIN_GRANT_ACTION,
91
- description: 'Achievement to grant (no-ops if they already have it).',
103
+ description: tLabel('achievementToGrantNoOpsIfTheyAlready'),
92
104
  },
93
105
  },
94
106
  ...hostActionParamFields(),
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTierRequest.d.ts","sourceRoot":"","sources":["../../../../src/collections/TierRequests/hooks/prepareTierRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAE7B,MAAM,SAAS,CAAA;AA2BhB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,4BAiGhC,CAAA;AA8CD,eAAO,MAAM,sBAAsB,EAAE,yBAkCpC,CAAA"}
1
+ {"version":3,"file":"prepareTierRequest.d.ts","sourceRoot":"","sources":["../../../../src/collections/TierRequests/hooks/prepareTierRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAE7B,MAAM,SAAS,CAAA;AA4BhB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,4BAiGhC,CAAA;AA8CD,eAAO,MAAM,sBAAsB,EAAE,yBAkCpC,CAAA"}
@@ -5,6 +5,7 @@ import { evaluateRules } from '../../../services/achievement/evaluateRules.js';
5
5
  import { catalogRef } from '../../../services/achievement/logData.js';
6
6
  import { recordLog, syncTierChangedLog } from '../../../services/achievement/recordEvent.js';
7
7
  import { relationId } from '../../../services/achievement/relationId.js';
8
+ import { throwApiError } from '../../../translations/reqT.js';
8
9
  function scopeIdOf(data) {
9
10
  return relationId(data?.scope);
10
11
  }
@@ -31,15 +32,15 @@ export const prepareTierRequest = async ({ data, operation, req, originalDoc, })
31
32
  else {
32
33
  const bound = relationId(data.user);
33
34
  if (!bound)
34
- throw new APIError('user required', 400);
35
+ throwApiError(req, 'errorUserRequired', 400);
35
36
  data.user = bound;
36
37
  }
37
38
  const userId = relationId(data.user);
38
39
  if (!userId)
39
- throw new APIError('user required', 400);
40
+ throwApiError(req, 'errorUserRequired', 400);
40
41
  const tierId = relationId(data.tier);
41
42
  if (!tierId)
42
- throw new APIError('tier required', 400);
43
+ throwApiError(req, 'errorTierRequired', 400);
43
44
  const tier = (await req.payload.findByID({
44
45
  collection: collectionOf('tiers'),
45
46
  id: tierId,
@@ -48,9 +49,9 @@ export const prepareTierRequest = async ({ data, operation, req, originalDoc, })
48
49
  req,
49
50
  }));
50
51
  if (!tier)
51
- throw new APIError(`Unknown tier: ${tierId}`, 400);
52
+ throwApiError(req, 'errorUnknownTier', 400, { id: tierId });
52
53
  if (tier.requiresReview !== true) {
53
- throw new APIError('This tier does not require review.', 400);
54
+ throwApiError(req, 'errorTierDoesNotRequireReview', 400);
54
55
  }
55
56
  data.tier = tierId;
56
57
  if (!system) {
@@ -63,7 +64,7 @@ export const prepareTierRequest = async ({ data, operation, req, originalDoc, })
63
64
  scopeId,
64
65
  });
65
66
  if (!unlocked) {
66
- throw new APIError('Unlock rules not met for this tier.', 400);
67
+ throwApiError(req, 'errorUnlockRulesNotMet', 400);
67
68
  }
68
69
  // Members cannot self-approve; only reviewers / system may set approved|rejected.
69
70
  data.status = 'pending';
@@ -100,7 +101,7 @@ export const prepareTierRequest = async ({ data, operation, req, originalDoc, })
100
101
  scopeId,
101
102
  });
102
103
  if (!unlocked) {
103
- throw new APIError('Unlock rules not met for this tier.', 400);
104
+ throwApiError(req, 'errorUnlockRulesNotMet', 400);
104
105
  }
105
106
  }
106
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/TierRequests/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAOtD,wBAAgB,2BAA2B,IAAI,gBAAgB,CA2C9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/TierRequests/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAQtD,wBAAgB,2BAA2B,IAAI,gBAAgB,CA+C9D"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { collectionAdmin, collectionOf, optionalFields, slugOf } from '../helpers.js';
2
3
  import { scopeField, userField } from '../fields/index.js';
3
4
  import { access } from './access/index.js';
@@ -6,15 +7,15 @@ export function buildTierRequestsCollection() {
6
7
  return {
7
8
  slug: slugOf('tierRequests'),
8
9
  labels: {
9
- singular: 'Tier Request',
10
- plural: 'Tier Requests',
10
+ singular: tLabel('tierRequest'),
11
+ plural: tLabel('tierRequests'),
11
12
  },
12
13
  access: { ...access },
13
14
  hooks,
14
15
  admin: collectionAdmin({
15
16
  useAsTitle: 'id',
16
17
  defaultColumns: ['user', 'tier', 'status', 'createdAt'],
17
- description: 'When a member has met a tier’s unlock rules but that tier requires review before it becomes their current tier.',
18
+ description: tEntityDescription('whenAMemberHasMetATierS'),
18
19
  }),
19
20
  fields: [
20
21
  ...optionalFields(scopeField()),
@@ -25,22 +26,27 @@ export function buildTierRequestsCollection() {
25
26
  relationTo: collectionOf('tiers'),
26
27
  required: true,
27
28
  index: true,
29
+ label: tLabel('tier'),
28
30
  },
29
31
  {
30
32
  name: 'status',
31
33
  type: 'select',
32
34
  required: true,
33
35
  defaultValue: 'pending',
36
+ label: tLabel('status'),
34
37
  options: [
35
- { label: 'Pending', value: 'pending' },
36
- { label: 'Approved', value: 'approved' },
37
- { label: 'Rejected', value: 'rejected' },
38
+ { label: tLabel('pending'), value: 'pending' },
39
+ { label: tLabel('approved'), value: 'approved' },
40
+ { label: tLabel('rejected'), value: 'rejected' },
38
41
  ],
39
42
  },
40
43
  {
41
44
  name: 'note',
42
45
  type: 'textarea',
43
- admin: { description: 'Optional note from the requester or reviewer.' },
46
+ label: tLabel('note'),
47
+ admin: {
48
+ description: tLabel('optionalNoteFromTheRequesterOrReviewer'),
49
+ },
44
50
  },
45
51
  ],
46
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Tiers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAQ/C,wBAAgB,oBAAoB,IAAI,gBAAgB,CA2FvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Tiers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAS/C,wBAAgB,oBAAoB,IAAI,gBAAgB,CAgGvD"}