@delmaredigital/payload-experiments 0.1.0-rc.6 → 0.1.0-rc.7

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.
@@ -6,20 +6,14 @@ export const flagControlParams = async ({ data, originalDoc, operation, req })=>
6
6
  const pointId = data.flagPoint ?? originalDoc?.flagPoint;
7
7
  const point = xpOptionsFromReq(req).flagPoints?.find((point)=>point.id === pointId);
8
8
  if (!point) return data;
9
- let params = point.defaultParams;
10
- try {
11
- const state = await req.payload.findGlobal({
12
- slug: 'xp-state',
13
- req,
14
- overrideAccess: false
15
- });
16
- const defaults = state.flagDefaults;
17
- params = defaults?.[point.id]?.params ?? params;
18
- } catch (cause) {
19
- const error = cause;
20
- if (error?.status !== 403 && error?.name !== 'Forbidden') throw cause;
21
- // A refused state read must not prevent using the registered point defaults.
22
- }
9
+ // the caller's write already passed experiments manage access; a second gate inside its hook would kill the caller's transaction on Forbidden (Payload killTransaction)
10
+ const state = await req.payload.findGlobal({
11
+ slug: 'xp-state',
12
+ req,
13
+ overrideAccess: true
14
+ });
15
+ const defaults = state.flagDefaults;
16
+ const params = defaults?.[point.id]?.params ?? point.defaultParams;
23
17
  const arms = data.arms ?? originalDoc?.arms;
24
18
  if (!arms) return data;
25
19
  return {
@@ -58,6 +58,7 @@ export function layersCollection(options) {
58
58
  hooks: {
59
59
  beforeDelete: [
60
60
  async ({ id, req })=>{
61
+ // The delete already passed layers access; a refused nested read would kill the caller's transaction (Payload killTransaction) and could hide a referencing experiment.
61
62
  const references = await req.payload.find({
62
63
  collection: 'xp-experiments',
63
64
  where: {
@@ -66,7 +67,7 @@ export function layersCollection(options) {
66
67
  }
67
68
  },
68
69
  limit: 1,
69
- overrideAccess: false,
70
+ overrideAccess: true,
70
71
  req
71
72
  });
72
73
  if (references.docs.length) throw new XpRefusal('invalid-status', 'This layer is still referenced by an experiment.', undefined, 409);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delmaredigital/payload-experiments",
3
- "version": "0.1.0-rc.6",
3
+ "version": "0.1.0-rc.7",
4
4
  "description": "No-code A/B testing for Payload CMS and Next.js: block, page and flag experiments with holdouts, layers, exposure logging and honest statistics inside the admin — no vendor",
5
5
  "type": "module",
6
6
  "license": "MIT",