@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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/AchievementRequests/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAOtD,wBAAgB,kCAAkC,IAAI,gBAAgB,CAmCrE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/AchievementRequests/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAQtD,wBAAgB,kCAAkC,IAAI,gBAAgB,CA+CrE"}
@@ -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';
@@ -5,12 +6,16 @@ import { hooks } from './hooks/index.js';
5
6
  export function buildAchievementRequestsCollection() {
6
7
  return {
7
8
  slug: slugOf('achievementRequests'),
9
+ labels: {
10
+ singular: tLabel('achievementRequest'),
11
+ plural: tLabel('achievementRequests'),
12
+ },
8
13
  access: { ...access },
9
14
  hooks,
10
15
  admin: collectionAdmin({
11
16
  useAsTitle: 'id',
12
17
  defaultColumns: ['user', 'achievement', 'status', 'createdAt'],
13
- description: 'When someone asks to earn an achievement. We check eligibility, then either grant it right away or wait for a review.',
18
+ description: tEntityDescription('whenSomeoneAsksToEarnAnAchievementWe'),
14
19
  }),
15
20
  fields: [
16
21
  ...optionalFields(scopeField()),
@@ -21,19 +26,28 @@ export function buildAchievementRequestsCollection() {
21
26
  relationTo: collectionOf('achievements'),
22
27
  required: true,
23
28
  index: true,
29
+ label: tLabel('achievement'),
24
30
  },
25
31
  {
26
32
  name: 'status',
27
33
  type: 'select',
28
34
  required: true,
29
35
  defaultValue: 'pending',
36
+ label: tLabel('status'),
30
37
  options: [
31
- { label: 'Pending', value: 'pending' },
32
- { label: 'Approved', value: 'approved' },
33
- { label: 'Rejected', value: 'rejected' },
38
+ { label: tLabel('pending'), value: 'pending' },
39
+ { label: tLabel('approved'), value: 'approved' },
40
+ { label: tLabel('rejected'), value: 'rejected' },
34
41
  ],
35
42
  },
36
- { name: 'note', type: 'textarea', admin: { description: 'Optional note from the requester or reviewer.' } },
43
+ {
44
+ name: 'note',
45
+ type: 'textarea',
46
+ label: tLabel('note'),
47
+ admin: {
48
+ description: tLabel('optionalNoteFromTheRequesterOrReviewer'),
49
+ },
50
+ },
37
51
  ],
38
52
  };
39
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Achievements/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,wBAAgB,2BAA2B,IAAI,gBAAgB,CAsE9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Achievements/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAQ/C,wBAAgB,2BAA2B,IAAI,gBAAgB,CAmF9D"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { buildRuleTreeFields, localizedDescriptionField, localizedNameField, scopeField } from '../fields/index.js';
2
3
  import { collectionAdmin, columnsWithOptionalScope, optionalFields, slugOf } from '../helpers.js';
3
4
  import { access } from './access/index.js';
@@ -6,15 +7,15 @@ export function buildAchievementsCollection() {
6
7
  return {
7
8
  slug: slugOf('achievements'),
8
9
  labels: {
9
- singular: 'Achievement Definition',
10
- plural: 'Achievement Definitions',
10
+ singular: tLabel('achievementDefinition'),
11
+ plural: tLabel('achievementDefinitions'),
11
12
  },
12
13
  access: { ...access },
13
14
  hooks,
14
15
  admin: collectionAdmin({
15
16
  useAsTitle: 'name',
16
- defaultColumns: columnsWithOptionalScope(['name', 'slug', 'requiresReview', 'scope']),
17
- description: 'What someone can earn. Set who’s eligible and whether a person on your team needs to approve it.',
17
+ defaultColumns: columnsWithOptionalScope(['name', 'slug', 'lifecycle', 'requiresReview', 'scope']),
18
+ description: tEntityDescription('whatSomeoneCanEarnSetWhoSEligible'),
18
19
  }),
19
20
  fields: [
20
21
  ...optionalFields(scopeField()),
@@ -28,6 +29,7 @@ export function buildAchievementsCollection() {
28
29
  required: true,
29
30
  unique: true,
30
31
  index: true,
32
+ label: tLabel('slug'),
31
33
  admin: { width: '50%' },
32
34
  },
33
35
  ],
@@ -36,36 +38,51 @@ export function buildAchievementsCollection() {
36
38
  {
37
39
  name: 'metadata',
38
40
  type: 'json',
41
+ label: tLabel('metadata'),
39
42
  admin: {
40
- description: 'Optional host/product payload (structure only). Shape is owned by the host — validate with Zod or similar at read/seed time. Do not store localized copy here; use name, description, and host i18n.',
43
+ description: tLabel('optionalHostProductPayloadStructureOnlyShapeIs'),
44
+ },
45
+ },
46
+ {
47
+ name: 'lifecycle',
48
+ type: 'select',
49
+ required: true,
50
+ defaultValue: 'once',
51
+ label: tLabel('lifecycle'),
52
+ options: [
53
+ { label: tLabel('once'), value: 'once' },
54
+ { label: tLabel('ongoing'), value: 'ongoing' },
55
+ ],
56
+ admin: {
57
+ description: tLabel('onceBinaryGrantCreateDeleteOngoingOneGrant'),
41
58
  },
42
59
  },
43
60
  {
44
61
  name: 'requiresReview',
45
62
  type: 'checkbox',
46
63
  defaultValue: true,
47
- label: 'Requires review',
64
+ label: tLabel('requiresReview'),
48
65
  admin: {
49
- description: 'When turned off, any pending requests for this achievement are approved automatically (one user at a time via existing grant hooks).',
66
+ description: tLabel('whenTurnedOffAnyPendingRequestsForThis'),
50
67
  },
51
68
  },
52
69
  {
53
70
  name: 'eligibilityRules',
54
71
  type: 'group',
55
- label: 'Eligibility rules',
72
+ label: tLabel('eligibilityRules'),
56
73
  admin: {
57
- description: 'Who may request this achievement. Composed parents that auto-grant should leave this empty.',
74
+ description: tLabel('whoMayRequestThisAchievementComposedParentsThat'),
58
75
  },
59
- fields: buildRuleTreeFields({ dbName: 'ach_elig_r' }),
76
+ fields: buildRuleTreeFields({ site: 'eligibility' }),
60
77
  },
61
78
  {
62
79
  name: 'completionRules',
63
80
  type: 'group',
64
- label: 'Completion rules',
81
+ label: tLabel('completionRules'),
65
82
  admin: {
66
- description: 'What this achievement is made of. When every rule passes, it is granted automatically (do not require review on composed parents). Nested achievements appear in this order in your app UI.',
83
+ description: tLabel('whatThisAchievementIsMadeOfWhenEvery'),
67
84
  },
68
- fields: buildRuleTreeFields({ dbName: 'ach_comp_r' }),
85
+ fields: buildRuleTreeFields({ site: 'completion' }),
69
86
  },
70
87
  ],
71
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/EventTypes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAqCtD,wBAAgB,yBAAyB,IAAI,gBAAgB,CA+E5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/EventTypes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAoCtD,wBAAgB,yBAAyB,IAAI,gBAAgB,CAyF5D"}
@@ -1,3 +1,4 @@
1
+ import { tEntityDescription, tLabel } from '../../adminLabel.js';
1
2
  import { getAchievementOptions } from '../../options-store.js';
2
3
  import { collectionAdmin, collectionOf, columnsWithOptionalScope, optionalFields, slugOf } from '../helpers.js';
3
4
  import { localizedNameField, scopeField } from '../fields/index.js';
@@ -12,9 +13,9 @@ function subjectCatalogFields() {
12
13
  name: 'requiresSubject',
13
14
  type: 'checkbox',
14
15
  defaultValue: false,
15
- label: 'Requires a subject',
16
+ label: tLabel('requiresASubject'),
16
17
  admin: {
17
- description: 'Turn this on when the log points at a host document (for example a post or comment). We’ll ask for that document when it’s logged.',
18
+ description: tLabel('turnThisOnWhenTheLogPointsAt'),
18
19
  },
19
20
  },
20
21
  {
@@ -24,7 +25,7 @@ function subjectCatalogFields() {
24
25
  options: collections.map((slug) => ({ label: slug, value: slug })),
25
26
  admin: {
26
27
  condition: (_, siblingData) => Boolean(siblingData?.requiresSubject),
27
- description: 'Which host collections this type may reference. Leave empty to allow any collection from the plugin subjects allowlist.',
28
+ description: tLabel('whichHostCollectionsThisTypeMayReferenceLeave'),
28
29
  },
29
30
  },
30
31
  ];
@@ -33,6 +34,10 @@ export function buildEventTypesCollection() {
33
34
  const subjectFields = subjectCatalogFields();
34
35
  return {
35
36
  slug: slugOf('eventTypes'),
37
+ labels: {
38
+ singular: tLabel('eventType2'),
39
+ plural: tLabel('eventTypes'),
40
+ },
36
41
  access: { ...access },
37
42
  hooks,
38
43
  admin: collectionAdmin({
@@ -47,7 +52,7 @@ export function buildEventTypesCollection() {
47
52
  'system',
48
53
  'scope',
49
54
  ]),
50
- description: 'Names for things that can happen and show up in the achievement logs.',
55
+ description: tEntityDescription('namesForThingsThatCanHappenAndShow'),
51
56
  }),
52
57
  fields: [
53
58
  ...optionalFields(scopeField()),
@@ -55,34 +60,42 @@ export function buildEventTypesCollection() {
55
60
  type: 'row',
56
61
  fields: [
57
62
  localizedNameField({ width: '50%' }),
58
- { name: 'slug', type: 'text', required: true, unique: true, index: true, admin: { width: '50%' } },
63
+ {
64
+ name: 'slug',
65
+ type: 'text',
66
+ required: true,
67
+ unique: true,
68
+ index: true,
69
+ label: tLabel('slug'),
70
+ admin: { width: '50%' },
71
+ },
59
72
  ],
60
73
  },
61
74
  {
62
75
  name: 'requiresActor',
63
76
  type: 'checkbox',
64
77
  defaultValue: false,
65
- label: 'Requires an actor',
78
+ label: tLabel('requiresAnActor'),
66
79
  admin: {
67
- description: 'Turn this on when someone else caused the entry (for example a peer nomination). We’ll ask for that person when it’s logged.',
80
+ description: tLabel('turnThisOnWhenSomeoneElseCausedThe'),
68
81
  },
69
82
  },
70
83
  {
71
84
  name: 'snapshotActorTiers',
72
85
  type: 'checkbox',
73
86
  defaultValue: false,
74
- label: 'Snapshot actor tiers',
87
+ label: tLabel('snapshotActorTiers'),
75
88
  admin: {
76
- description: 'When this entry is logged, store the actor’s derived ladder rank at write time. Unscoped logs stamp every ladder; scoped logs stamp that tenant plus unscoped ranks. Event count can then require “actor was at least this tier” in the rule’s scope. Does not grant or open requests.',
89
+ description: tLabel('whenThisEntryIsLoggedStoreTheActor'),
77
90
  },
78
91
  },
79
92
  {
80
93
  name: 'requiresMetric',
81
94
  type: 'checkbox',
82
95
  defaultValue: false,
83
- label: 'Adjusts a metric',
96
+ label: tLabel('adjustsAMetric'),
84
97
  admin: {
85
- description: 'Turn this on when the entry changes a score (like points). We’ll ask which metric and by how much.',
98
+ description: tLabel('turnThisOnWhenTheEntryChangesA'),
86
99
  },
87
100
  },
88
101
  ...subjectFields,
@@ -90,9 +103,10 @@ export function buildEventTypesCollection() {
90
103
  name: 'system',
91
104
  type: 'checkbox',
92
105
  defaultValue: false,
106
+ label: tLabel('system'),
93
107
  admin: {
94
108
  readOnly: true,
95
- description: 'Built-in type. It can’t be deleted.',
109
+ description: tLabel('builtInTypeItCanTBeDeleted'),
96
110
  },
97
111
  },
98
112
  {
@@ -1,6 +1,6 @@
1
- import { APIError } from 'payload';
2
1
  import { collectionOf } from '../../helpers.js';
3
2
  import { relationId } from '../../../services/achievement/relationId.js';
3
+ import { throwApiError } from '../../../translations/reqT.js';
4
4
  /** Reject a second grant of the same achievement for the same user (+ scope). */
5
5
  export const ensureUniqueGrant = async ({ data, originalDoc, operation, req, }) => {
6
6
  if (!req?.payload || !data)
@@ -28,7 +28,7 @@ export const ensureUniqueGrant = async ({ data, originalDoc, operation, req, })
28
28
  });
29
29
  const other = existing.docs[0];
30
30
  if (other && (operation === 'create' || relationId(other.id) !== relationId(originalDoc?.id))) {
31
- throw new APIError('This achievement is already granted to that user for this scope.', 400);
31
+ throwApiError(req, 'errorAlreadyGranted', 400);
32
32
  }
33
33
  return data;
34
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Grants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAQtD,wBAAgB,qBAAqB,IAAI,gBAAgB,CA4ExD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Grants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAStD,wBAAgB,qBAAqB,IAAI,gBAAgB,CAkHxD"}
@@ -1,33 +1,36 @@
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 { getAchievementOptions } from '../../options-store.js';
4
5
  import { access } from './access/index.js';
5
6
  import { hooks } from './hooks/index.js';
6
7
  export function buildGrantsCollection() {
7
- const reconcilePath = getAchievementOptions().endpoints?.reconcile;
8
- const apiPath = typeof reconcilePath === 'string' && reconcilePath.length > 0
9
- ? `/api${reconcilePath.startsWith('/') ? reconcilePath : `/${reconcilePath}`}`
8
+ const reconcileEndpoint = getAchievementOptions().endpoints?.reconcile;
9
+ const reconcilePath = typeof reconcileEndpoint === 'string' && reconcileEndpoint.length > 0
10
+ ? reconcileEndpoint.startsWith('/')
11
+ ? reconcileEndpoint
12
+ : `/${reconcileEndpoint}`
10
13
  : null;
11
14
  return {
12
15
  slug: slugOf('grants'),
13
16
  labels: {
14
- singular: 'Achievement Grant',
15
- plural: 'Achievement Grants',
17
+ singular: tLabel('achievementGrant'),
18
+ plural: tLabel('achievementGrants'),
16
19
  },
17
20
  access: { ...access },
18
21
  hooks,
19
22
  admin: collectionAdmin({
20
23
  useAsTitle: 'title',
21
- defaultColumns: columnsWithOptionalScope(['title', 'user', 'completedAt', 'scope']),
24
+ defaultColumns: columnsWithOptionalScope(['title', 'user', 'status', 'completedAt', 'scope']),
22
25
  listSearchableFields: ['title'],
23
- description: 'What someone has earned — one row per grant. Creating or deleting a grant updates logs and composed progression automatically.',
24
- ...(apiPath
26
+ description: tEntityDescription('whatSomeoneHasEarnedOneRowPerUser'),
27
+ ...(reconcilePath
25
28
  ? {
26
29
  components: {
27
30
  beforeListTable: [
28
31
  {
29
32
  path: '@dappermountain/payload-plugin-achievements/client#ReconcileProgressionButton',
30
- clientProps: { reconcilePath: apiPath },
33
+ clientProps: { reconcilePath },
31
34
  },
32
35
  ],
33
36
  },
@@ -39,9 +42,10 @@ export function buildGrantsCollection() {
39
42
  name: 'title',
40
43
  type: 'text',
41
44
  index: true,
45
+ label: tLabel('title'),
42
46
  admin: {
43
47
  readOnly: true,
44
- description: 'Copied from the achievement name for lists and search.',
48
+ description: tLabel('copiedFromTheAchievementNameForListsAnd'),
45
49
  },
46
50
  },
47
51
  ...optionalFields(scopeField()),
@@ -55,6 +59,7 @@ export function buildGrantsCollection() {
55
59
  relationTo: collectionOf('achievements'),
56
60
  required: true,
57
61
  index: true,
62
+ label: tLabel('achievement'),
58
63
  admin: { width: '60%' },
59
64
  },
60
65
  {
@@ -69,10 +74,45 @@ export function buildGrantsCollection() {
69
74
  },
70
75
  ],
71
76
  },
77
+ {
78
+ name: 'status',
79
+ type: 'select',
80
+ required: true,
81
+ defaultValue: 'active',
82
+ index: true,
83
+ label: tLabel('status'),
84
+ options: [
85
+ { label: tLabel('active'), value: 'active' },
86
+ { label: tLabel('expired'), value: 'expired' },
87
+ { label: tLabel('superseded'), value: 'superseded' },
88
+ ],
89
+ admin: {
90
+ description: tLabel('standingForOngoingAchievementsOnceAchievementsStayActive'),
91
+ },
92
+ },
93
+ {
94
+ name: 'renewedAt',
95
+ type: 'date',
96
+ admin: {
97
+ date: { pickerAppearance: 'dayAndTime' },
98
+ description: tLabel('lastRenewTimeForAnOngoingGrant'),
99
+ },
100
+ },
101
+ {
102
+ name: 'supersededBy',
103
+ type: 'relationship',
104
+ relationTo: collectionOf('grants'),
105
+ admin: {
106
+ description: tLabel('grantThatReplacedThisOneWhenStatusIs'),
107
+ },
108
+ },
72
109
  {
73
110
  name: 'note',
74
111
  type: 'textarea',
75
- admin: { description: 'Optional note about why this was granted.' },
112
+ label: tLabel('note'),
113
+ admin: {
114
+ description: tLabel('optionalNoteAboutWhyThisWasGranted'),
115
+ },
76
116
  },
77
117
  ],
78
118
  };
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../src/collections/Logs/fields/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAavC,eAAO,MAAM,aAAa,EAAE,QAW3B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QA0B5B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QAW5B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,QAqC7B,CAAA"}
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../src/collections/Logs/fields/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAcvC,eAAO,MAAM,aAAa,EAAE,QAW3B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QA0B5B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QAW5B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,QAqC7B,CAAA"}
@@ -3,6 +3,7 @@ import { collectionOf } from '../../../collections/helpers.js';
3
3
  import { eventTypeRequiresActor, eventTypeRequiresMetric, eventTypeSubjectRelationTo, getEventTypeFlags, } from '../../../services/achievement/eventTypeRequiresActor.js';
4
4
  import { readLogSubject } from '../../../services/achievement/logSubject.js';
5
5
  import { relationId } from '../../../services/achievement/relationId.js';
6
+ import { reqT } from '../../../translations/reqT.js';
6
7
  export const validateActor = async (value, { data, req }) => {
7
8
  if (!req?.payload)
8
9
  return true;
@@ -13,7 +14,7 @@ export const validateActor = async (value, { data, req }) => {
13
14
  return true;
14
15
  }
15
16
  if (!relationId(value)) {
16
- return 'This log type needs an actor (who caused it).';
17
+ return reqT(req, 'validationNeedsActor');
17
18
  }
18
19
  return true;
19
20
  };
@@ -28,7 +29,7 @@ export const validateMetric = async (value, { data, req }) => {
28
29
  }
29
30
  const metricId = relationId(value);
30
31
  if (!metricId) {
31
- return 'This log type needs a metric.';
32
+ return reqT(req, 'validationNeedsMetric');
32
33
  }
33
34
  const metric = (await req.payload.findByID({
34
35
  collection: collectionOf('metrics'),
@@ -39,7 +40,7 @@ export const validateMetric = async (value, { data, req }) => {
39
40
  select: { kind: true, name: true, slug: true },
40
41
  }));
41
42
  if (metric && (metric.kind ?? 'stored') === 'computed') {
42
- return 'Computed metrics (for example Days) cannot be changed with a metric delta. Use a stored metric such as Points.';
43
+ return reqT(req, 'validationComputedMetricDelta');
43
44
  }
44
45
  return true;
45
46
  };
@@ -53,7 +54,7 @@ export const validateChange = async (value, { data, req }) => {
53
54
  return true;
54
55
  }
55
56
  if (typeof value !== 'number' || Number.isNaN(value)) {
56
- return 'This log type needs a change amount.';
57
+ return reqT(req, 'validationNeedsChange');
57
58
  }
58
59
  return true;
59
60
  };
@@ -76,10 +77,10 @@ export const validateSubject = async (value, { data, req }) => {
76
77
  return true;
77
78
  }
78
79
  if (!subject) {
79
- return 'This log type needs a subject (the host document it is about).';
80
+ return reqT(req, 'validationNeedsSubject');
80
81
  }
81
82
  if (!allowlist.includes(subject.relationTo)) {
82
- return `Subject collection "${subject.relationTo}" is not in the plugin subjects allowlist.`;
83
+ return reqT(req, 'validationSubjectNotAllowlisted', { collection: subject.relationTo });
83
84
  }
84
85
  const allowed = await eventTypeSubjectRelationTo({
85
86
  payload: req.payload,
@@ -87,7 +88,7 @@ export const validateSubject = async (value, { data, req }) => {
87
88
  typeIdOrDoc: typeId,
88
89
  });
89
90
  if (allowed.length > 0 && !allowed.includes(subject.relationTo)) {
90
- return `This log type only allows subjects from: ${allowed.join(', ')}.`;
91
+ return reqT(req, 'validationSubjectNotAllowed', { collections: allowed.join(', ') });
91
92
  }
92
93
  return true;
93
94
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ensureTypeRequirements.d.ts","sourceRoot":"","sources":["../../../../src/collections/Logs/hooks/ensureTypeRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAc3D,eAAO,MAAM,sBAAsB,EAAE,4BA+DpC,CAAA"}
1
+ {"version":3,"file":"ensureTypeRequirements.d.ts","sourceRoot":"","sources":["../../../../src/collections/Logs/hooks/ensureTypeRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAY3D,eAAO,MAAM,sBAAsB,EAAE,4BA2DpC,CAAA"}
@@ -1,9 +1,9 @@
1
- import { APIError } from 'payload';
2
1
  import { getAchievementOptions } from '../../../options-store.js';
3
2
  import { collectionOf } from '../../../collections/helpers.js';
4
3
  import { eventTypeSubjectRelationTo, getEventTypeFlags, } from '../../../services/achievement/eventTypeRequiresActor.js';
5
4
  import { readLogSubject } from '../../../services/achievement/logSubject.js';
6
5
  import { relationId } from '../../../services/achievement/relationId.js';
6
+ import { throwApiError } from '../../../translations/reqT.js';
7
7
  export const ensureTypeRequirements = async ({ data, req }) => {
8
8
  if (!data)
9
9
  return data;
@@ -16,16 +16,16 @@ export const ensureTypeRequirements = async ({ data, req }) => {
16
16
  typeIdOrDoc: typeId,
17
17
  });
18
18
  if (flags.requiresActor && !relationId(data.actor)) {
19
- throw new APIError('This log type needs an actor (who caused it).', 400);
19
+ throwApiError(req, 'validationNeedsActor', 400);
20
20
  }
21
21
  if (flags.requiresMetric) {
22
22
  const metricId = relationId(data.metric);
23
23
  if (!metricId) {
24
- throw new APIError('This log type needs a metric.', 400);
24
+ throwApiError(req, 'validationNeedsMetric', 400);
25
25
  }
26
26
  const change = data.change;
27
27
  if (typeof change !== 'number' || Number.isNaN(change)) {
28
- throw new APIError('This log type needs a change amount.', 400);
28
+ throwApiError(req, 'validationNeedsChange', 400);
29
29
  }
30
30
  const metric = (await req.payload.findByID({
31
31
  collection: collectionOf('metrics'),
@@ -36,13 +36,13 @@ export const ensureTypeRequirements = async ({ data, req }) => {
36
36
  select: { kind: true },
37
37
  }));
38
38
  if (metric && (metric.kind ?? 'stored') === 'computed') {
39
- throw new APIError('Computed metrics cannot be changed with a metric delta. Use a stored metric such as Points.', 400);
39
+ throwApiError(req, 'validationComputedMetricDelta', 400);
40
40
  }
41
41
  }
42
42
  if (flags.requiresSubject && getAchievementOptions().subjectCollections.length > 0) {
43
43
  const subject = readLogSubject(data.subject);
44
44
  if (!subject) {
45
- throw new APIError('This log type needs a subject (the host document it is about).', 400);
45
+ throwApiError(req, 'validationNeedsSubject', 400);
46
46
  }
47
47
  const allowed = await eventTypeSubjectRelationTo({
48
48
  payload: req.payload,
@@ -50,7 +50,9 @@ export const ensureTypeRequirements = async ({ data, req }) => {
50
50
  typeIdOrDoc: typeId,
51
51
  });
52
52
  if (allowed.length > 0 && !allowed.includes(subject.relationTo)) {
53
- throw new APIError(`This log type only allows subjects from: ${allowed.join(', ')}.`, 400);
53
+ throwApiError(req, 'validationSubjectNotAllowed', 400, {
54
+ collections: allowed.join(', '),
55
+ });
54
56
  }
55
57
  }
56
58
  return data;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Logs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAqCtD,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,gBAAgB,CAgJtD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Logs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAuCtD,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,gBAAgB,CA6JtD"}