@strapi/core 5.60.0 → 5.61.1

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 (43) hide show
  1. package/dist/package.json.js +16 -20
  2. package/dist/package.json.js.map +1 -1
  3. package/dist/package.json.mjs +16 -20
  4. package/dist/package.json.mjs.map +1 -1
  5. package/dist/providers/webhooks.d.ts.map +1 -1
  6. package/dist/providers/webhooks.js +1 -0
  7. package/dist/providers/webhooks.js.map +1 -1
  8. package/dist/providers/webhooks.mjs +1 -0
  9. package/dist/providers/webhooks.mjs.map +1 -1
  10. package/dist/services/document-service/events.d.ts.map +1 -1
  11. package/dist/services/document-service/events.js +2 -1
  12. package/dist/services/document-service/events.js.map +1 -1
  13. package/dist/services/document-service/events.mjs +2 -1
  14. package/dist/services/document-service/events.mjs.map +1 -1
  15. package/dist/services/entity-validator/index.d.ts.map +1 -1
  16. package/dist/services/entity-validator/index.js +35 -4
  17. package/dist/services/entity-validator/index.js.map +1 -1
  18. package/dist/services/entity-validator/index.mjs +35 -4
  19. package/dist/services/entity-validator/index.mjs.map +1 -1
  20. package/dist/services/mcp/handlers/handlePost.d.ts.map +1 -1
  21. package/dist/services/mcp/handlers/handlePost.js +2 -1
  22. package/dist/services/mcp/handlers/handlePost.js.map +1 -1
  23. package/dist/services/mcp/handlers/handlePost.mjs +2 -1
  24. package/dist/services/mcp/handlers/handlePost.mjs.map +1 -1
  25. package/dist/services/mcp/internal/McpConfiguration.d.ts +2 -0
  26. package/dist/services/mcp/internal/McpConfiguration.d.ts.map +1 -1
  27. package/dist/services/mcp/internal/McpConfiguration.js +17 -0
  28. package/dist/services/mcp/internal/McpConfiguration.js.map +1 -1
  29. package/dist/services/mcp/internal/McpConfiguration.mjs +17 -1
  30. package/dist/services/mcp/internal/McpConfiguration.mjs.map +1 -1
  31. package/dist/services/mcp/internal/McpServerFactory.d.ts +3 -1
  32. package/dist/services/mcp/internal/McpServerFactory.d.ts.map +1 -1
  33. package/dist/services/mcp/internal/McpServerFactory.js +4 -2
  34. package/dist/services/mcp/internal/McpServerFactory.js.map +1 -1
  35. package/dist/services/mcp/internal/McpServerFactory.mjs +4 -2
  36. package/dist/services/mcp/internal/McpServerFactory.mjs.map +1 -1
  37. package/dist/services/webhook-runner.d.ts +5 -6
  38. package/dist/services/webhook-runner.d.ts.map +1 -1
  39. package/dist/services/webhook-runner.js +23 -6
  40. package/dist/services/webhook-runner.js.map +1 -1
  41. package/dist/services/webhook-runner.mjs +23 -6
  42. package/dist/services/webhook-runner.mjs.map +1 -1
  43. package/package.json +16 -20
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@strapi/core";
6
- var version = "5.60.0";
6
+ var version = "5.61.1";
7
7
  var description = "Core of Strapi";
8
8
  var homepage = "https://strapi.io";
9
9
  var bugs = {
@@ -54,8 +54,6 @@ var scripts = {
54
54
  lint: "run -T eslint . --max-warnings=0",
55
55
  prepublishOnly: "yarn clean && yarn build",
56
56
  "test:ts": "run -T tsc -p tsconfig.json",
57
- "test:unit": "run -T jest",
58
- "test:unit:watch": "run -T jest --watch",
59
57
  "test:unit:vitest": "vitest run",
60
58
  "test:unit:vitest:watch": "vitest --watch"
61
59
  };
@@ -66,15 +64,15 @@ var dependencies = {
66
64
  "@modelcontextprotocol/node": "2.1.1",
67
65
  "@modelcontextprotocol/server": "2.3.1",
68
66
  "@paralleldrive/cuid2": "2.2.2",
69
- "@strapi/admin": "5.60.0",
70
- "@strapi/database": "5.60.0",
71
- "@strapi/generators": "5.60.0",
72
- "@strapi/logger": "5.60.0",
73
- "@strapi/openapi": "5.60.0",
74
- "@strapi/permissions": "5.60.0",
75
- "@strapi/types": "5.60.0",
76
- "@strapi/typescript-utils": "5.60.0",
77
- "@strapi/utils": "5.60.0",
67
+ "@strapi/admin": "5.61.1",
68
+ "@strapi/database": "5.61.1",
69
+ "@strapi/generators": "5.61.1",
70
+ "@strapi/logger": "5.61.1",
71
+ "@strapi/openapi": "5.61.1",
72
+ "@strapi/permissions": "5.61.1",
73
+ "@strapi/types": "5.61.1",
74
+ "@strapi/typescript-utils": "5.61.1",
75
+ "@strapi/utils": "5.61.1",
78
76
  "@vercel/stega": "0.1.2",
79
77
  bcryptjs: "2.4.3",
80
78
  boxen: "5.1.2",
@@ -112,7 +110,7 @@ var dependencies = {
112
110
  ora: "5.4.1",
113
111
  "package-json": "10.0.1",
114
112
  "pkg-up": "3.1.0",
115
- qs: "6.16.0",
113
+ qs: "6.16.1",
116
114
  "resolve.exports": "2.0.2",
117
115
  semver: "7.7.4",
118
116
  typescript: "5.9.3",
@@ -129,7 +127,6 @@ var devDependencies = {
129
127
  "@types/fs-extra": "11.0.4",
130
128
  "@types/global-agent": "3.0.0",
131
129
  "@types/http-errors": "2.0.4",
132
- "@types/jest": "29.5.2",
133
130
  "@types/json-logic-js": "2.0.8",
134
131
  "@types/koa": "2.15.2",
135
132
  "@types/koa-compress": "4.0.3",
@@ -138,18 +135,17 @@ var devDependencies = {
138
135
  "@types/koa__router": "12.0.0",
139
136
  "@types/lodash": "^4.14.191",
140
137
  "@types/mime-types": "2.1.1",
141
- "@types/node": "20.19.41",
138
+ "@types/node": "22.20.0",
142
139
  ajv: "8.20.0",
143
140
  "ajv-formats": "3.0.1",
144
- "eslint-config-custom": "5.60.0",
145
- jest: "29.6.0",
141
+ "eslint-config-custom": "5.61.1",
146
142
  supertest: "7.2.2",
147
- tsconfig: "5.60.0",
143
+ tsconfig: "5.61.1",
148
144
  vitest: "catalog:",
149
- "vitest-config": "5.60.0"
145
+ "vitest-config": "5.61.1"
150
146
  };
151
147
  var engines = {
152
- node: ">=20.0.0 <=26.x.x",
148
+ node: ">=22.0.0 <=26.x.x",
153
149
  npm: ">=6.0.0"
154
150
  };
155
151
  var pkg = {
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  var name = "@strapi/core";
2
- var version = "5.60.0";
2
+ var version = "5.61.1";
3
3
  var description = "Core of Strapi";
4
4
  var homepage = "https://strapi.io";
5
5
  var bugs = {
@@ -50,8 +50,6 @@ var scripts = {
50
50
  lint: "run -T eslint . --max-warnings=0",
51
51
  prepublishOnly: "yarn clean && yarn build",
52
52
  "test:ts": "run -T tsc -p tsconfig.json",
53
- "test:unit": "run -T jest",
54
- "test:unit:watch": "run -T jest --watch",
55
53
  "test:unit:vitest": "vitest run",
56
54
  "test:unit:vitest:watch": "vitest --watch"
57
55
  };
@@ -62,15 +60,15 @@ var dependencies = {
62
60
  "@modelcontextprotocol/node": "2.1.1",
63
61
  "@modelcontextprotocol/server": "2.3.1",
64
62
  "@paralleldrive/cuid2": "2.2.2",
65
- "@strapi/admin": "5.60.0",
66
- "@strapi/database": "5.60.0",
67
- "@strapi/generators": "5.60.0",
68
- "@strapi/logger": "5.60.0",
69
- "@strapi/openapi": "5.60.0",
70
- "@strapi/permissions": "5.60.0",
71
- "@strapi/types": "5.60.0",
72
- "@strapi/typescript-utils": "5.60.0",
73
- "@strapi/utils": "5.60.0",
63
+ "@strapi/admin": "5.61.1",
64
+ "@strapi/database": "5.61.1",
65
+ "@strapi/generators": "5.61.1",
66
+ "@strapi/logger": "5.61.1",
67
+ "@strapi/openapi": "5.61.1",
68
+ "@strapi/permissions": "5.61.1",
69
+ "@strapi/types": "5.61.1",
70
+ "@strapi/typescript-utils": "5.61.1",
71
+ "@strapi/utils": "5.61.1",
74
72
  "@vercel/stega": "0.1.2",
75
73
  bcryptjs: "2.4.3",
76
74
  boxen: "5.1.2",
@@ -108,7 +106,7 @@ var dependencies = {
108
106
  ora: "5.4.1",
109
107
  "package-json": "10.0.1",
110
108
  "pkg-up": "3.1.0",
111
- qs: "6.16.0",
109
+ qs: "6.16.1",
112
110
  "resolve.exports": "2.0.2",
113
111
  semver: "7.7.4",
114
112
  typescript: "5.9.3",
@@ -125,7 +123,6 @@ var devDependencies = {
125
123
  "@types/fs-extra": "11.0.4",
126
124
  "@types/global-agent": "3.0.0",
127
125
  "@types/http-errors": "2.0.4",
128
- "@types/jest": "29.5.2",
129
126
  "@types/json-logic-js": "2.0.8",
130
127
  "@types/koa": "2.15.2",
131
128
  "@types/koa-compress": "4.0.3",
@@ -134,18 +131,17 @@ var devDependencies = {
134
131
  "@types/koa__router": "12.0.0",
135
132
  "@types/lodash": "^4.14.191",
136
133
  "@types/mime-types": "2.1.1",
137
- "@types/node": "20.19.41",
134
+ "@types/node": "22.20.0",
138
135
  ajv: "8.20.0",
139
136
  "ajv-formats": "3.0.1",
140
- "eslint-config-custom": "5.60.0",
141
- jest: "29.6.0",
137
+ "eslint-config-custom": "5.61.1",
142
138
  supertest: "7.2.2",
143
- tsconfig: "5.60.0",
139
+ tsconfig: "5.61.1",
144
140
  vitest: "catalog:",
145
- "vitest-config": "5.60.0"
141
+ "vitest-config": "5.61.1"
146
142
  };
147
143
  var engines = {
148
- node: ">=20.0.0 <=26.x.x",
144
+ node: ">=22.0.0 <=26.x.x",
149
145
  npm: ">=6.0.0"
150
146
  };
151
147
  var pkg = {
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/providers/webhooks.ts"],"names":[],"mappings":";AAIA,wBAwBG"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/providers/webhooks.ts"],"names":[],"mappings":";AAIA,wBAyBG"}
@@ -12,6 +12,7 @@ var webhooks = provider.defineProvider({
12
12
  }));
13
13
  strapi.add('webhookRunner', ()=>webhookRunner({
14
14
  eventHub: strapi.eventHub,
15
+ requestContext: strapi.requestContext,
15
16
  logger: strapi.log,
16
17
  configuration: strapi.config.get('server.webhooks', {}),
17
18
  fetch: strapi.fetch
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.js","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","init","strapi","get","add","webhookModel","createWebhookStore","db","createWebhookRunner","eventHub","logger","log","configuration","config","fetch","bootstrap","webhooks","findWebhooks","webhook"],"mappings":";;;;;;AAIA,eAAeA,uBAAAA,CAAe;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,yBAAAA,CAAAA;AAEzBH,QAAAA,MAAAA,CAAOE,GAAG,CAAC,cAAA,EAAgB,IAAME,+BAAAA,CAAmB;AAAEC,gBAAAA,EAAAA,EAAIL,OAAOK;AAAG,aAAA,CAAA,CAAA;AACpEL,QAAAA,MAAAA,CAAOE,GAAG,CAAC,eAAA,EAAiB,IAC1BI,aAAAA,CAAoB;AAClBC,gBAAAA,QAAAA,EAAUP,OAAOO,QAAQ;AACzBC,gBAAAA,MAAAA,EAAQR,OAAOS,GAAG;AAClBC,gBAAAA,aAAAA,EAAeV,OAAOW,MAAM,CAACV,GAAG,CAAC,mBAAmB,EAAC,CAAA;AACrDW,gBAAAA,KAAAA,EAAOZ,OAAOY;AAChB,aAAA,CAAA,CAAA;AAEJ,IAAA,CAAA;AACA,IAAA,MAAMC,WAAUb,MAAM,EAAA;AACpB,QAAA,MAAMc,WAAW,MAAMd,MAAAA,CAAOC,GAAG,CAAC,gBAAgBc,YAAY,EAAA;AAC9D,QAAA,IAAI,CAACD,QAAAA,EAAU;AACb,YAAA;AACF,QAAA;QAEA,KAAK,MAAME,WAAWF,QAAAA,CAAU;AAC9Bd,YAAAA,MAAAA,CAAOC,GAAG,CAAC,eAAA,CAAA,CAAiBC,GAAG,CAACc,OAAAA,CAAAA;AAClC,QAAA;AACF,IAAA;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"webhooks.js","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n requestContext: strapi.requestContext,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","init","strapi","get","add","webhookModel","createWebhookStore","db","createWebhookRunner","eventHub","requestContext","logger","log","configuration","config","fetch","bootstrap","webhooks","findWebhooks","webhook"],"mappings":";;;;;;AAIA,eAAeA,uBAAAA,CAAe;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,yBAAAA,CAAAA;AAEzBH,QAAAA,MAAAA,CAAOE,GAAG,CAAC,cAAA,EAAgB,IAAME,+BAAAA,CAAmB;AAAEC,gBAAAA,EAAAA,EAAIL,OAAOK;AAAG,aAAA,CAAA,CAAA;AACpEL,QAAAA,MAAAA,CAAOE,GAAG,CAAC,eAAA,EAAiB,IAC1BI,aAAAA,CAAoB;AAClBC,gBAAAA,QAAAA,EAAUP,OAAOO,QAAQ;AACzBC,gBAAAA,cAAAA,EAAgBR,OAAOQ,cAAc;AACrCC,gBAAAA,MAAAA,EAAQT,OAAOU,GAAG;AAClBC,gBAAAA,aAAAA,EAAeX,OAAOY,MAAM,CAACX,GAAG,CAAC,mBAAmB,EAAC,CAAA;AACrDY,gBAAAA,KAAAA,EAAOb,OAAOa;AAChB,aAAA,CAAA,CAAA;AAEJ,IAAA,CAAA;AACA,IAAA,MAAMC,WAAUd,MAAM,EAAA;AACpB,QAAA,MAAMe,WAAW,MAAMf,MAAAA,CAAOC,GAAG,CAAC,gBAAgBe,YAAY,EAAA;AAC9D,QAAA,IAAI,CAACD,QAAAA,EAAU;AACb,YAAA;AACF,QAAA;QAEA,KAAK,MAAME,WAAWF,QAAAA,CAAU;AAC9Bf,YAAAA,MAAAA,CAAOC,GAAG,CAAC,eAAA,CAAA,CAAiBC,GAAG,CAACe,OAAAA,CAAAA;AAClC,QAAA;AACF,IAAA;AACF,CAAA,CAAA;;;;"}
@@ -10,6 +10,7 @@ var webhooks = defineProvider({
10
10
  }));
11
11
  strapi.add('webhookRunner', ()=>createWebhookRunner({
12
12
  eventHub: strapi.eventHub,
13
+ requestContext: strapi.requestContext,
13
14
  logger: strapi.log,
14
15
  configuration: strapi.config.get('server.webhooks', {}),
15
16
  fetch: strapi.fetch
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.mjs","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","init","strapi","get","add","webhookModel","createWebhookStore","db","createWebhookRunner","eventHub","logger","log","configuration","config","fetch","bootstrap","webhooks","findWebhooks","webhook"],"mappings":";;;;AAIA,eAAeA,cAAAA,CAAe;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,YAAAA,CAAAA;AAEzBH,QAAAA,MAAAA,CAAOE,GAAG,CAAC,cAAA,EAAgB,IAAME,kBAAAA,CAAmB;AAAEC,gBAAAA,EAAAA,EAAIL,OAAOK;AAAG,aAAA,CAAA,CAAA;AACpEL,QAAAA,MAAAA,CAAOE,GAAG,CAAC,eAAA,EAAiB,IAC1BI,mBAAAA,CAAoB;AAClBC,gBAAAA,QAAAA,EAAUP,OAAOO,QAAQ;AACzBC,gBAAAA,MAAAA,EAAQR,OAAOS,GAAG;AAClBC,gBAAAA,aAAAA,EAAeV,OAAOW,MAAM,CAACV,GAAG,CAAC,mBAAmB,EAAC,CAAA;AACrDW,gBAAAA,KAAAA,EAAOZ,OAAOY;AAChB,aAAA,CAAA,CAAA;AAEJ,IAAA,CAAA;AACA,IAAA,MAAMC,WAAUb,MAAM,EAAA;AACpB,QAAA,MAAMc,WAAW,MAAMd,MAAAA,CAAOC,GAAG,CAAC,gBAAgBc,YAAY,EAAA;AAC9D,QAAA,IAAI,CAACD,QAAAA,EAAU;AACb,YAAA;AACF,QAAA;QAEA,KAAK,MAAME,WAAWF,QAAAA,CAAU;AAC9Bd,YAAAA,MAAAA,CAAOC,GAAG,CAAC,eAAA,CAAA,CAAiBC,GAAG,CAACc,OAAAA,CAAAA;AAClC,QAAA;AACF,IAAA;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"webhooks.mjs","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n requestContext: strapi.requestContext,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","init","strapi","get","add","webhookModel","createWebhookStore","db","createWebhookRunner","eventHub","requestContext","logger","log","configuration","config","fetch","bootstrap","webhooks","findWebhooks","webhook"],"mappings":";;;;AAIA,eAAeA,cAAAA,CAAe;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,YAAAA,CAAAA;AAEzBH,QAAAA,MAAAA,CAAOE,GAAG,CAAC,cAAA,EAAgB,IAAME,kBAAAA,CAAmB;AAAEC,gBAAAA,EAAAA,EAAIL,OAAOK;AAAG,aAAA,CAAA,CAAA;AACpEL,QAAAA,MAAAA,CAAOE,GAAG,CAAC,eAAA,EAAiB,IAC1BI,mBAAAA,CAAoB;AAClBC,gBAAAA,QAAAA,EAAUP,OAAOO,QAAQ;AACzBC,gBAAAA,cAAAA,EAAgBR,OAAOQ,cAAc;AACrCC,gBAAAA,MAAAA,EAAQT,OAAOU,GAAG;AAClBC,gBAAAA,aAAAA,EAAeX,OAAOY,MAAM,CAACX,GAAG,CAAC,mBAAmB,EAAC,CAAA;AACrDY,gBAAAA,KAAAA,EAAOb,OAAOa;AAChB,aAAA,CAAA,CAAA;AAEJ,IAAA,CAAA;AACA,IAAA,MAAMC,WAAUd,MAAM,EAAA;AACpB,QAAA,MAAMe,WAAW,MAAMf,MAAAA,CAAOC,GAAG,CAAC,gBAAgBe,YAAY,EAAA;AAC9D,QAAA,IAAI,CAACD,QAAAA,EAAU;AACb,YAAA;AACF,QAAA;QAEA,KAAK,MAAME,WAAWF,QAAAA,CAAU;AAC9Bf,YAAAA,MAAAA,CAAOC,GAAG,CAAC,eAAA,CAAA,CAAiBC,GAAG,CAACe,OAAAA,CAAAA;AAClC,QAAA;AACF,IAAA;AACF,CAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK/D,QAAA,MAAM,MAAM;;;;;;;CAOX,CAAC;AAEF,KAAK,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,GAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,MAAM;IAkC5D;;;OAGG;yBACkB,SAAS,SAAS,OAAO,CAAC,SAAS,CAAC,WAAW;CAYvE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK/D,QAAA,MAAM,MAAM;;;;;;;CAOX,CAAC;AAEF,KAAK,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,GAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,MAAM;IAkC5D;;;OAGG;yBACkB,SAAS,SAAS,OAAO,CAAC,SAAS,CAAC,WAAW;CAmBvE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -48,10 +48,11 @@ const EVENTS = {
48
48
  * strapi.db.query might reuse the transaction used in the doc service request,
49
49
  * so this is executed after that transaction is committed.
50
50
  */ emitEvent (eventName, entry) {
51
+ const context = strapi.config.get('server.webhooks.deduplicateReleaseWebhooks', false) === true ? strapi.requestContext.get() : undefined;
51
52
  strapi.db.transaction(({ onCommit })=>{
52
53
  // The transaction runner discards the callback result, so a failure here
53
54
  // (e.g. the re-read of the entry) would be an unhandled rejection.
54
- onCommit(()=>emitEvent(eventName, entry).catch((error)=>{
55
+ onCommit(()=>(context ? strapi.requestContext.run(context, ()=>emitEvent(eventName, entry)) : emitEvent(eventName, entry)).catch((error)=>{
55
56
  strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);
56
57
  }));
57
58
  });
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sources":["../../../src/services/document-service/events.ts"],"sourcesContent":["import type { UID, Utils, Modules, Core } from '@strapi/types';\nimport { sanitize } from '@strapi/utils';\n\nimport { getDeepPopulate } from './utils/populate';\n\nconst EVENTS = {\n ENTRY_CREATE: 'entry.create',\n ENTRY_UPDATE: 'entry.update',\n ENTRY_DELETE: 'entry.delete',\n ENTRY_PUBLISH: 'entry.publish',\n ENTRY_UNPUBLISH: 'entry.unpublish',\n ENTRY_DRAFT_DISCARD: 'entry.draft-discard',\n};\n\ntype EventName = Utils.Object.Values<typeof EVENTS>;\n\n/**\n * Manager to trigger entry related events\n *\n * It will populate the entry if it is not a delete event.\n * So the event payload will contain the full entry.\n */\nconst createEventManager = (strapi: Core.Strapi, uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n\n const populate = getDeepPopulate(uid, {});\n\n const emitEvent = async (eventName: EventName, entry: Modules.Documents.AnyDocument) => {\n // Reading the entry again with a deep populate is the expensive part of an event: skip it,\n // along with the sanitization, when nothing would receive the event.\n if (!strapi.eventHub.hasListeners(eventName)) {\n return;\n }\n\n // There is no need to populate the entry if it has been deleted\n let populatedEntry = entry;\n if (![EVENTS.ENTRY_DELETE, EVENTS.ENTRY_UNPUBLISH].includes(eventName)) {\n populatedEntry = await strapi.db.query(uid).findOne({ where: { id: entry.id }, populate });\n }\n\n const sanitizedEntry = await sanitize.sanitizers.defaultSanitizeOutput(\n {\n schema: model,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n populatedEntry\n );\n\n await strapi.eventHub.emit(eventName, {\n model: model.modelName,\n uid: model.uid,\n entry: sanitizedEntry,\n });\n };\n\n return {\n /**\n * strapi.db.query might reuse the transaction used in the doc service request,\n * so this is executed after that transaction is committed.\n */\n emitEvent(eventName: EventName, entry: Modules.Documents.AnyDocument) {\n strapi.db.transaction(({ onCommit }) => {\n // The transaction runner discards the callback result, so a failure here\n // (e.g. the re-read of the entry) would be an unhandled rejection.\n onCommit(() =>\n emitEvent(eventName, entry).catch((error) => {\n strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);\n })\n );\n });\n },\n };\n};\n\nexport { createEventManager };\n"],"names":["EVENTS","ENTRY_DELETE","ENTRY_UNPUBLISH","createEventManager","strapi","uid","model","getModel","populate","getDeepPopulate","emitEvent","eventName","entry","eventHub","hasListeners","populatedEntry","includes","db","query","findOne","where","id","sanitizedEntry","sanitize","sanitizers","defaultSanitizeOutput","schema","emit","modelName","transaction","onCommit","catch","error","log","message"],"mappings":";;;;;AAKA,MAAMA,MAAAA,GAAS;IAGbC,YAAAA,EAAc,cAAA;IAEdC,eAAAA,EAAiB,iBAEnB,CAAA;AAIA;;;;;IAMA,MAAMC,kBAAAA,GAAqB,CAACC,MAAAA,EAAqBC,GAAAA,GAAAA;IAC/C,MAAMC,KAAAA,GAAQF,MAAAA,CAAOG,QAAQ,CAACF,GAAAA,CAAAA;IAE9B,MAAMG,UAAAA,GAAWC,wBAAAA,CAAgBJ,GAAAA,EAAK,EA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KAAAA,CAAAA,CAAOmB,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACjC5B,wBAAAA,MAAAA,CAAO6B,GAAG,CAACD,KAAK,CAAC,CAAC,eAAe,EAAErB,SAAAA,CAAU,KAAK,EAAEN,GAAAA,CAAI,EAAE,EAAE2B,KAAAA,EAAOE,WAAWF,KAAAA,CAAAA,CAAO,CAAA;AACvF,oBAAA,CAAA,CAAA,CAAA;AAEJ,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"events.js","sources":["../../../src/services/document-service/events.ts"],"sourcesContent":["import type { UID, Utils, Modules, Core } from '@strapi/types';\nimport { sanitize } from '@strapi/utils';\n\nimport { getDeepPopulate } from './utils/populate';\n\nconst EVENTS = {\n ENTRY_CREATE: 'entry.create',\n ENTRY_UPDATE: 'entry.update',\n ENTRY_DELETE: 'entry.delete',\n ENTRY_PUBLISH: 'entry.publish',\n ENTRY_UNPUBLISH: 'entry.unpublish',\n ENTRY_DRAFT_DISCARD: 'entry.draft-discard',\n};\n\ntype EventName = Utils.Object.Values<typeof EVENTS>;\n\n/**\n * Manager to trigger entry related events\n *\n * It will populate the entry if it is not a delete event.\n * So the event payload will contain the full entry.\n */\nconst createEventManager = (strapi: Core.Strapi, uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n\n const populate = getDeepPopulate(uid, {});\n\n const emitEvent = async (eventName: EventName, entry: Modules.Documents.AnyDocument) => {\n // Reading the entry again with a deep populate is the expensive part of an event: skip it,\n // along with the sanitization, when nothing would receive the event.\n if (!strapi.eventHub.hasListeners(eventName)) {\n return;\n }\n\n // There is no need to populate the entry if it has been deleted\n let populatedEntry = entry;\n if (![EVENTS.ENTRY_DELETE, EVENTS.ENTRY_UNPUBLISH].includes(eventName)) {\n populatedEntry = await strapi.db.query(uid).findOne({ where: { id: entry.id }, populate });\n }\n\n const sanitizedEntry = await sanitize.sanitizers.defaultSanitizeOutput(\n {\n schema: model,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n populatedEntry\n );\n\n await strapi.eventHub.emit(eventName, {\n model: model.modelName,\n uid: model.uid,\n entry: sanitizedEntry,\n });\n };\n\n return {\n /**\n * strapi.db.query might reuse the transaction used in the doc service request,\n * so this is executed after that transaction is committed.\n */\n emitEvent(eventName: EventName, entry: Modules.Documents.AnyDocument) {\n const context =\n strapi.config.get<boolean>('server.webhooks.deduplicateReleaseWebhooks', false) === true\n ? strapi.requestContext.get()\n : undefined;\n strapi.db.transaction(({ onCommit }) => {\n // The transaction runner discards the callback result, so a failure here\n // (e.g. the re-read of the entry) would be an unhandled rejection.\n onCommit(() =>\n (context\n ? strapi.requestContext.run(context, () => emitEvent(eventName, entry))\n : emitEvent(eventName, entry)\n ).catch((error) => {\n strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);\n })\n );\n });\n },\n };\n};\n\nexport { createEventManager };\n"],"names":["EVENTS","ENTRY_DELETE","ENTRY_UNPUBLISH","createEventManager","strapi","uid","model","getModel","populate","getDeepPopulate","emitEvent","eventName","entry","eventHub","hasListeners","populatedEntry","includes","db","query","findOne","where","id","sanitizedEntry","sanitize","sanitizers","defaultSanitizeOutput","schema","emit","modelName","context","config","get","requestContext","undefined","transaction","onCommit","run","catch","error","log","message"],"mappings":";;;;;AAKA,MAAMA,MAAAA,GAAS;IAGbC,YAAAA,EAAc,cAAA;IAEdC,eAAAA,EAAiB,iBAEnB,CAAA;AAIA;;;;;IAMA,MAAMC,kBAAAA,GAAqB,CAACC,MAAAA,EAAqBC,GAAAA,GAAAA;IAC/C,MAAMC,KAAAA,GAAQF,MAAAA,CAAOG,QAAQ,CAACF,GAAAA,CAAAA;IAE9B,MAAMG,UAAAA,GAAWC,wBAAAA,CAAgBJ,GAAAA,EAAK,EAAC,CAAA;IAEvC,MAAMK,SAAAA,GAAY,OAAOC,SAAAA,EAAsBC,KAAAA,GAAAA;;;AAG7C,QAAA,IAAI,CAACR,MAAAA,CAAOS,QAAQ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QAAAA,CAAS,IACP,CAACN,OAAAA,GACGzB,OAAO4B,cAAc,CAACI,GAAG,CAACP,OAAAA,EAAS,IAAMnB,SAAAA,CAAUC,SAAAA,EAAWC,UAC9DF,SAAAA,CAAUC,SAAAA,EAAWC,MAAK,EAC5ByB,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACPlC,wBAAAA,MAAAA,CAAOmC,GAAG,CAACD,KAAK,CAAC,CAAC,eAAe,EAAE3B,SAAAA,CAAU,KAAK,EAAEN,GAAAA,CAAI,EAAE,EAAEiC,KAAAA,EAAOE,WAAWF,KAAAA,CAAAA,CAAO,CAAA;AACvF,oBAAA,CAAA,CAAA,CAAA;AAEJ,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
@@ -46,10 +46,11 @@ const EVENTS = {
46
46
  * strapi.db.query might reuse the transaction used in the doc service request,
47
47
  * so this is executed after that transaction is committed.
48
48
  */ emitEvent (eventName, entry) {
49
+ const context = strapi.config.get('server.webhooks.deduplicateReleaseWebhooks', false) === true ? strapi.requestContext.get() : undefined;
49
50
  strapi.db.transaction(({ onCommit })=>{
50
51
  // The transaction runner discards the callback result, so a failure here
51
52
  // (e.g. the re-read of the entry) would be an unhandled rejection.
52
- onCommit(()=>emitEvent(eventName, entry).catch((error)=>{
53
+ onCommit(()=>(context ? strapi.requestContext.run(context, ()=>emitEvent(eventName, entry)) : emitEvent(eventName, entry)).catch((error)=>{
53
54
  strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);
54
55
  }));
55
56
  });
@@ -1 +1 @@
1
- {"version":3,"file":"events.mjs","sources":["../../../src/services/document-service/events.ts"],"sourcesContent":["import type { UID, Utils, Modules, Core } from '@strapi/types';\nimport { sanitize } from '@strapi/utils';\n\nimport { getDeepPopulate } from './utils/populate';\n\nconst EVENTS = {\n ENTRY_CREATE: 'entry.create',\n ENTRY_UPDATE: 'entry.update',\n ENTRY_DELETE: 'entry.delete',\n ENTRY_PUBLISH: 'entry.publish',\n ENTRY_UNPUBLISH: 'entry.unpublish',\n ENTRY_DRAFT_DISCARD: 'entry.draft-discard',\n};\n\ntype EventName = Utils.Object.Values<typeof EVENTS>;\n\n/**\n * Manager to trigger entry related events\n *\n * It will populate the entry if it is not a delete event.\n * So the event payload will contain the full entry.\n */\nconst createEventManager = (strapi: Core.Strapi, uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n\n const populate = getDeepPopulate(uid, {});\n\n const emitEvent = async (eventName: EventName, entry: Modules.Documents.AnyDocument) => {\n // Reading the entry again with a deep populate is the expensive part of an event: skip it,\n // along with the sanitization, when nothing would receive the event.\n if (!strapi.eventHub.hasListeners(eventName)) {\n return;\n }\n\n // There is no need to populate the entry if it has been deleted\n let populatedEntry = entry;\n if (![EVENTS.ENTRY_DELETE, EVENTS.ENTRY_UNPUBLISH].includes(eventName)) {\n populatedEntry = await strapi.db.query(uid).findOne({ where: { id: entry.id }, populate });\n }\n\n const sanitizedEntry = await sanitize.sanitizers.defaultSanitizeOutput(\n {\n schema: model,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n populatedEntry\n );\n\n await strapi.eventHub.emit(eventName, {\n model: model.modelName,\n uid: model.uid,\n entry: sanitizedEntry,\n });\n };\n\n return {\n /**\n * strapi.db.query might reuse the transaction used in the doc service request,\n * so this is executed after that transaction is committed.\n */\n emitEvent(eventName: EventName, entry: Modules.Documents.AnyDocument) {\n strapi.db.transaction(({ onCommit }) => {\n // The transaction runner discards the callback result, so a failure here\n // (e.g. the re-read of the entry) would be an unhandled rejection.\n onCommit(() =>\n emitEvent(eventName, entry).catch((error) => {\n strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);\n })\n );\n });\n },\n };\n};\n\nexport { createEventManager };\n"],"names":["EVENTS","ENTRY_DELETE","ENTRY_UNPUBLISH","createEventManager","strapi","uid","model","getModel","populate","getDeepPopulate","emitEvent","eventName","entry","eventHub","hasListeners","populatedEntry","includes","db","query","findOne","where","id","sanitizedEntry","sanitize","sanitizers","defaultSanitizeOutput","schema","emit","modelName","transaction","onCommit","catch","error","log","message"],"mappings":";;;AAKA,MAAMA,MAAAA,GAAS;IAGbC,YAAAA,EAAc,cAAA;IAEdC,eAAAA,EAAiB,iBAEnB,CAAA;AAIA;;;;;IAMA,MAAMC,kBAAAA,GAAqB,CAACC,MAAAA,EAAqBC,GAAAA,GAAAA;IAC/C,MAAMC,KAAAA,GAAQF,MAAAA,CAAOG,QAAQ,CAACF,GAAAA,CAAAA;IAE9B,MAAMG,QAAAA,GAAWC,eAAAA,CAAgBJ,GAAAA,EAAK,EAAC,CAAA;IAEvC,MAAMK,SAAAA,GAAY,OAAOC,SAAAA,EAAsBC,KAAAA,GAAAA;;;AAG7C,QAAA,IAAI,CAACR,MAAAA,CAAOS,QAAQ,CAACC,YAAY,CAACH,SAAAA,CAAAA,EAAY;AAC5C,YAAA;AACF,QAAA;;AAGA,QAAA,IAAII,cAAAA,GAAiBH,KAAAA;AACrB,QAAA,IAAI,CAAC;AAACZ,YAAAA,MAAAA,CAAOC,YAAY;AAAED,YAAAA,MAAAA,CAAOE;SAAgB,CAACc,QAAQ,CAACL,SAAAA,CAAAA,EAAY;YACtEI,cAAAA,GAAiB,MAAMX,OAAOa,EAAE,CAACC,KAAK,CAACb,GAAAA,CAAAA,CAAKc,OAAO,CAAC;gBAAEC,KAAAA,EAAO;AAAEC,oBAAAA,EAAAA,EAAIT,MAAMS;AAAG,iBAAA;AAAGb,gBAAAA;AAAS,aAAA,CAAA;AAC1F,QAAA;AAEA,QAAA,MAAMc,iBAAiB,MAAMC,QAAAA,CAASC,UAAU,CAACC,qBAAqB,CACpE;YACEC,MAAAA,EAAQpB,KAAAA;AACRC,YAAAA,QAAAA,EAAU,CAACF,GAAAA,GAAQD,MAAAA,CAAOG,QAAQ,CAACF,GAAAA;SACrC,EACAU,cAAAA,CAAAA;AAGF,QAAA,MAAMX,MAAAA,CAAOS,QAAQ,CAACc,IAAI,CAAChB,SAAAA,EAAW;AACpCL,YAAAA,KAAAA,EAAOA,MAAMsB,SAAS;AACtBvB,YAAAA,GAAAA,EAAKC,MAAMD,GAAG;YACdO,KAAAA,EAAOU;AACT,SAAA,CAAA;AACF,IAAA,CAAA;IAEA,OAAO;AACL;;;QAIAZ,SAAAA,CAAAA,CAAUC,SAAoB,EAAEC,KAAoC,EAAA;AAClER,YAAAA,MAAAA,CAAOa,EAAE,CAACY,WAAW,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAA;;;AAGjCA,gBAAAA,QAAAA,CAAS,IACPpB,SAAAA,CAAUC,SAAAA,EAAWC,KAAAA,CAAAA,CAAOmB,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACjC5B,wBAAAA,MAAAA,CAAO6B,GAAG,CAACD,KAAK,CAAC,CAAC,eAAe,EAAErB,SAAAA,CAAU,KAAK,EAAEN,GAAAA,CAAI,EAAE,EAAE2B,KAAAA,EAAOE,WAAWF,KAAAA,CAAAA,CAAO,CAAA;AACvF,oBAAA,CAAA,CAAA,CAAA;AAEJ,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"events.mjs","sources":["../../../src/services/document-service/events.ts"],"sourcesContent":["import type { UID, Utils, Modules, Core } from '@strapi/types';\nimport { sanitize } from '@strapi/utils';\n\nimport { getDeepPopulate } from './utils/populate';\n\nconst EVENTS = {\n ENTRY_CREATE: 'entry.create',\n ENTRY_UPDATE: 'entry.update',\n ENTRY_DELETE: 'entry.delete',\n ENTRY_PUBLISH: 'entry.publish',\n ENTRY_UNPUBLISH: 'entry.unpublish',\n ENTRY_DRAFT_DISCARD: 'entry.draft-discard',\n};\n\ntype EventName = Utils.Object.Values<typeof EVENTS>;\n\n/**\n * Manager to trigger entry related events\n *\n * It will populate the entry if it is not a delete event.\n * So the event payload will contain the full entry.\n */\nconst createEventManager = (strapi: Core.Strapi, uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n\n const populate = getDeepPopulate(uid, {});\n\n const emitEvent = async (eventName: EventName, entry: Modules.Documents.AnyDocument) => {\n // Reading the entry again with a deep populate is the expensive part of an event: skip it,\n // along with the sanitization, when nothing would receive the event.\n if (!strapi.eventHub.hasListeners(eventName)) {\n return;\n }\n\n // There is no need to populate the entry if it has been deleted\n let populatedEntry = entry;\n if (![EVENTS.ENTRY_DELETE, EVENTS.ENTRY_UNPUBLISH].includes(eventName)) {\n populatedEntry = await strapi.db.query(uid).findOne({ where: { id: entry.id }, populate });\n }\n\n const sanitizedEntry = await sanitize.sanitizers.defaultSanitizeOutput(\n {\n schema: model,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n populatedEntry\n );\n\n await strapi.eventHub.emit(eventName, {\n model: model.modelName,\n uid: model.uid,\n entry: sanitizedEntry,\n });\n };\n\n return {\n /**\n * strapi.db.query might reuse the transaction used in the doc service request,\n * so this is executed after that transaction is committed.\n */\n emitEvent(eventName: EventName, entry: Modules.Documents.AnyDocument) {\n const context =\n strapi.config.get<boolean>('server.webhooks.deduplicateReleaseWebhooks', false) === true\n ? strapi.requestContext.get()\n : undefined;\n strapi.db.transaction(({ onCommit }) => {\n // The transaction runner discards the callback result, so a failure here\n // (e.g. the re-read of the entry) would be an unhandled rejection.\n onCommit(() =>\n (context\n ? strapi.requestContext.run(context, () => emitEvent(eventName, entry))\n : emitEvent(eventName, entry)\n ).catch((error) => {\n strapi.log.error(`Could not emit ${eventName} for ${uid}: ${error?.message ?? error}`);\n })\n );\n });\n },\n };\n};\n\nexport { createEventManager };\n"],"names":["EVENTS","ENTRY_DELETE","ENTRY_UNPUBLISH","createEventManager","strapi","uid","model","getModel","populate","getDeepPopulate","emitEvent","eventName","entry","eventHub","hasListeners","populatedEntry","includes","db","query","findOne","where","id","sanitizedEntry","sanitize","sanitizers","defaultSanitizeOutput","schema","emit","modelName","context","config","get","requestContext","undefined","transaction","onCommit","run","catch","error","log","message"],"mappings":";;;AAKA,MAAMA,MAAAA,GAAS;IAGbC,YAAAA,E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F,eAAe,eAAe,CAAC"}
@@ -74,6 +74,16 @@ const addDefault = (createOrUpdate)=>{
74
74
  };
75
75
  };
76
76
  const preventCast = (validator)=>validator.transform((val, originalVal)=>originalVal);
77
+ /**
78
+ * On update, a component sent without an `id` is created, not updated (see
79
+ * `updateOrCreateComponent` in the document service). Its fields have no previous value to keep,
80
+ * so in a non-draft write they are validated as on creation.
81
+ */ const getComponentCreateOrUpdate = (createOrUpdate, componentData, options)=>{
82
+ if (createOrUpdate === 'update' && options.isDraft !== true && _.isObject(componentData) && _.get(componentData, 'id') === undefined) {
83
+ return 'creation';
84
+ }
85
+ return createOrUpdate;
86
+ };
77
87
  const createComponentValidator = (createOrUpdate)=>({ attr, updatedAttribute, componentContext }, options)=>{
78
88
  const model = strapi.getModel(attr.component);
79
89
  if (!model) {
@@ -81,7 +91,7 @@ const createComponentValidator = (createOrUpdate)=>({ attr, updatedAttribute, co
81
91
  }
82
92
  if (attr?.repeatable) {
83
93
  // FIXME: yup v1
84
- let validator = yup.array().of(yup.lazy((item)=>createModelValidator(createOrUpdate)({
94
+ let validator = yup.array().of(yup.lazy((item)=>createModelValidator(getComponentCreateOrUpdate(createOrUpdate, item, options))({
85
95
  componentContext,
86
96
  model,
87
97
  data: item
@@ -100,7 +110,7 @@ const createComponentValidator = (createOrUpdate)=>({ attr, updatedAttribute, co
100
110
  }
101
111
  return validator;
102
112
  }
103
- let validator = createModelValidator(createOrUpdate)({
113
+ let validator = createModelValidator(getComponentCreateOrUpdate(createOrUpdate, updatedAttribute.value, options))({
104
114
  model,
105
115
  data: updatedAttribute.value,
106
116
  componentContext
@@ -120,7 +130,7 @@ const createDzValidator = (createOrUpdate)=>({ attr, updatedAttribute, component
120
130
  const schema = yup.object().shape({
121
131
  __component: yup.string().required().oneOf(Object.keys(strapi.components))
122
132
  }).notNull();
123
- return model ? schema.concat(createModelValidator(createOrUpdate)({
133
+ return model ? schema.concat(createModelValidator(getComponentCreateOrUpdate(createOrUpdate, item, options))({
124
134
  model,
125
135
  data: item,
126
136
  componentContext
@@ -357,8 +367,29 @@ const createAttributeValidator = (createOrUpdate)=>(metas, options)=>{
357
367
  validator = addDefault(createOrUpdate)(validator, metas);
358
368
  return validator;
359
369
  };
370
+ /**
371
+ * Conditional visibility is evaluated against the written data. On creation, an attribute
372
+ * missing from the payload is stored with its schema default, so the condition must see that
373
+ * default. On update, a missing attribute keeps its stored value, which is not known here.
374
+ * Only used to evaluate conditions: the validated payload is left untouched.
375
+ */ const getVisibilityData = (createOrUpdate, model, data)=>{
376
+ if (createOrUpdate !== 'creation' || _.isObject(data) === false) {
377
+ return data;
378
+ }
379
+ return Object.entries(model.attributes).reduce((visibilityData, [attributeName, attribute])=>{
380
+ if (visibilityData[attributeName] !== undefined || 'default' in attribute === false || attribute.default === undefined) {
381
+ return visibilityData;
382
+ }
383
+ const defaultValue = typeof attribute.default === 'function' ? attribute.default() : attribute.default;
384
+ return {
385
+ ...visibilityData,
386
+ [attributeName]: defaultValue
387
+ };
388
+ }, data);
389
+ };
360
390
  const createModelValidator = (createOrUpdate)=>({ componentContext, model, data, entity }, options)=>{
361
391
  const writableAttributes = model ? getWritableAttributes(model) : [];
392
+ const visibilityData = model ? getVisibilityData(createOrUpdate, model, data) : data;
362
393
  const schema = writableAttributes.reduce((validators, attributeName)=>{
363
394
  const metas = {
364
395
  attr: model.attributes[attributeName],
@@ -366,7 +397,7 @@ const createModelValidator = (createOrUpdate)=>({ componentContext, model, data,
366
397
  name: attributeName,
367
398
  value: _.get(data, attributeName)
368
399
  },
369
- data,
400
+ data: visibilityData,
370
401
  model,
371
402
  entity,
372
403
  componentContext