@dappermountain/payload-plugin-achievements 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ Slugs are prefixed with `achievement-` by default so they don’t collide with y
|
|
|
97
97
|
| `metric.delta` | Metric change log type (requires metric + change amount) |
|
|
98
98
|
| `achievement.granted` | Written when a grant is created |
|
|
99
99
|
| `achievement.revoked` | Written when a grant is deleted |
|
|
100
|
-
| `tier.changed` | Written when derived tier moves |
|
|
100
|
+
| `tier.changed` | Written when derived tier moves (including demotions when a tier request leaves `approved`) |
|
|
101
101
|
|
|
102
102
|
Event types can require an **actor** and/or a **metric + change**. Admin only prompts for those fields when the type needs them.
|
|
103
103
|
|
|
@@ -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;AAYhB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,4BAyChC,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,
|
|
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;AAYhB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,4BAyChC,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,yBAoBpC,CAAA"}
|
|
@@ -46,17 +46,14 @@ export const prepareTierRequest = async ({ data, operation, req, originalDoc, })
|
|
|
46
46
|
}
|
|
47
47
|
return data;
|
|
48
48
|
};
|
|
49
|
-
export const afterTierRequestChange = async ({ doc,
|
|
50
|
-
const status = doc.status;
|
|
51
|
-
if (status !== 'approved')
|
|
52
|
-
return doc;
|
|
53
|
-
const previousStatus = operation === 'update' ? previousDoc?.status : undefined;
|
|
54
|
-
if (previousStatus === 'approved')
|
|
55
|
-
return doc;
|
|
49
|
+
export const afterTierRequestChange = async ({ doc, req, }) => {
|
|
56
50
|
const userId = relationId(doc.user);
|
|
57
51
|
if (!userId)
|
|
58
52
|
return doc;
|
|
59
53
|
const scopeId = scopeIdOf(doc);
|
|
54
|
+
// Any status transition (or create as pending/rejected/approved) can change the
|
|
55
|
+
// live ladder — including demotions when approved → pending/rejected. Sync is
|
|
56
|
+
// idempotent when the latest audit already matches resolveCurrentTier.
|
|
60
57
|
await syncTierChangedLog({
|
|
61
58
|
payload: req.payload,
|
|
62
59
|
req: req,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dappermountain/payload-plugin-achievements",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "A robust, Admin-configured achievements engine for Payload: composable unlock rules, derived rank progress, request/review grants, metrics, and scoped multi-tenant support.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|