@strapi/core 5.10.3 → 5.11.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.
- package/dist/index.js +165 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -18
- package/dist/index.mjs.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/utils/bidirectional-relations.d.ts +95 -0
- package/dist/services/document-service/utils/bidirectional-relations.d.ts.map +1 -0
- package/package.json +12 -12
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAqB3E,eAAO,MAAM,2BAA2B,EAAE,uBAqazC,CAAC"}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import type { UID } from '@strapi/types';
|
2
|
+
interface LoadContext {
|
3
|
+
oldVersions: {
|
4
|
+
id: string;
|
5
|
+
locale: string;
|
6
|
+
}[];
|
7
|
+
newVersions: {
|
8
|
+
id: string;
|
9
|
+
locale: string;
|
10
|
+
}[];
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Loads all bidirectional relations that need to be synchronized when content entries change state
|
14
|
+
* (e.g., during publish/unpublish operations).
|
15
|
+
*
|
16
|
+
* In Strapi, bidirectional relations allow maintaining order from both sides of the relation.
|
17
|
+
* When an entry is published, the following occurs:
|
18
|
+
*
|
19
|
+
* 1. The old published entry is deleted
|
20
|
+
* 2. A new entry is created with all its relations
|
21
|
+
*
|
22
|
+
* This process affects relation ordering in the following way:
|
23
|
+
*
|
24
|
+
* Initial state (Entry A related to X, Y, Z):
|
25
|
+
* ```
|
26
|
+
* Entry A (draft) Entry A (published)
|
27
|
+
* │ │
|
28
|
+
* ├──(1)→ X ├──(1)→ X
|
29
|
+
* ├──(2)→ Y ├──(2)→ Y
|
30
|
+
* └──(3)→ Z └──(3)→ Z
|
31
|
+
*
|
32
|
+
* X's perspective: Y's perspective: Z's perspective:
|
33
|
+
* └──(2)→ Entry A └──(1)→ Entry A └──(3)→ Entry A
|
34
|
+
* ```
|
35
|
+
*
|
36
|
+
* After publishing Entry A (without relation order sync):
|
37
|
+
* ```
|
38
|
+
* Entry A (draft) Entry A (new published)
|
39
|
+
* │ │
|
40
|
+
* ├──(1)→ X ├──(1)→ X
|
41
|
+
* ├──(2)→ Y ├──(2)→ Y
|
42
|
+
* └──(3)→ Z └──(3)→ Z
|
43
|
+
*
|
44
|
+
* X's perspective: Y's perspective: Z's perspective:
|
45
|
+
* └──(3)→ Entry A └──(3)→ Entry A └──(3)→ Entry A
|
46
|
+
* (all relations appear last in order)
|
47
|
+
* ```
|
48
|
+
*
|
49
|
+
* This module preserves the original ordering from both perspectives by:
|
50
|
+
* 1. Capturing the relation order before the entry state changes
|
51
|
+
* 2. Restoring this order after the new relations are created
|
52
|
+
*
|
53
|
+
* @param uid - The unique identifier of the content type being processed
|
54
|
+
* @param context - Object containing arrays of old and new entry versions
|
55
|
+
* @returns Array of objects containing join table metadata and relations to be updated
|
56
|
+
*/
|
57
|
+
declare const load: (uid: UID.ContentType, { oldVersions }: LoadContext) => Promise<any>;
|
58
|
+
/**
|
59
|
+
* Synchronizes the order of bidirectional relations after content entries have changed state.
|
60
|
+
*
|
61
|
+
* When entries change state (e.g., draft → published), their IDs change and all relations are recreated.
|
62
|
+
* While the order of relations from the entry's perspective is maintained (as they're created in order),
|
63
|
+
* the inverse relations (from related entries' perspective) would all appear last in order since they're new.
|
64
|
+
*
|
65
|
+
* Example:
|
66
|
+
* ```
|
67
|
+
* Before publish:
|
68
|
+
* Article(id:1) →(order:1)→ Category(id:5)
|
69
|
+
* Category(id:5) →(order:3)→ Article(id:1)
|
70
|
+
*
|
71
|
+
* After publish (without sync):
|
72
|
+
* Article(id:2) →(order:1)→ Category(id:5) [order preserved]
|
73
|
+
* Category(id:5) →(order:99)→ Article(id:2) [order lost - appears last]
|
74
|
+
*
|
75
|
+
* After sync:
|
76
|
+
* Article(id:2) →(order:1)→ Category(id:5) [order preserved]
|
77
|
+
* Category(id:5) →(order:3)→ Article(id:2) [order restored]
|
78
|
+
* ```
|
79
|
+
*
|
80
|
+
* @param oldEntries - Array of previous entry versions with their IDs and locales
|
81
|
+
* @param newEntries - Array of new entry versions with their IDs and locales
|
82
|
+
* @param existingRelations - Array of join table data containing the relations to be updated
|
83
|
+
*/
|
84
|
+
declare const sync: (oldEntries: {
|
85
|
+
id: string;
|
86
|
+
locale: string;
|
87
|
+
}[], newEntries: {
|
88
|
+
id: string;
|
89
|
+
locale: string;
|
90
|
+
}[], existingRelations: {
|
91
|
+
joinTable: any;
|
92
|
+
relations: any[];
|
93
|
+
}[]) => Promise<void>;
|
94
|
+
export { load, sync };
|
95
|
+
//# sourceMappingURL=bidirectional-relations.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bidirectional-relations.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/bidirectional-relations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAU,MAAM,eAAe,CAAC;AAEjD,UAAU,WAAW;IACnB,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,IAAI,QAAe,IAAI,WAAW,mBAAmB,WAAW,iBA6CrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,IAAI,eACI;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,cAChC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,qBACzB;IAAE,SAAS,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,GAAG,EAAE,CAAA;CAAE,EAAE,kBAwC1D,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@strapi/core",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.11.0",
|
4
4
|
"description": "Core of Strapi",
|
5
5
|
"homepage": "https://strapi.io",
|
6
6
|
"bugs": {
|
@@ -56,14 +56,14 @@
|
|
56
56
|
"@koa/cors": "5.0.0",
|
57
57
|
"@koa/router": "12.0.2",
|
58
58
|
"@paralleldrive/cuid2": "2.2.2",
|
59
|
-
"@strapi/admin": "5.
|
60
|
-
"@strapi/database": "5.
|
61
|
-
"@strapi/generators": "5.
|
62
|
-
"@strapi/logger": "5.
|
63
|
-
"@strapi/permissions": "5.
|
64
|
-
"@strapi/types": "5.
|
65
|
-
"@strapi/typescript-utils": "5.
|
66
|
-
"@strapi/utils": "5.
|
59
|
+
"@strapi/admin": "5.11.0",
|
60
|
+
"@strapi/database": "5.11.0",
|
61
|
+
"@strapi/generators": "5.11.0",
|
62
|
+
"@strapi/logger": "5.11.0",
|
63
|
+
"@strapi/permissions": "5.11.0",
|
64
|
+
"@strapi/types": "5.11.0",
|
65
|
+
"@strapi/typescript-utils": "5.11.0",
|
66
|
+
"@strapi/utils": "5.11.0",
|
67
67
|
"bcryptjs": "2.4.3",
|
68
68
|
"boxen": "5.1.2",
|
69
69
|
"chalk": "4.1.2",
|
@@ -82,7 +82,7 @@
|
|
82
82
|
"http-errors": "2.0.0",
|
83
83
|
"inquirer": "8.2.5",
|
84
84
|
"is-docker": "2.2.1",
|
85
|
-
"koa": "2.15.
|
85
|
+
"koa": "2.15.4",
|
86
86
|
"koa-body": "6.0.1",
|
87
87
|
"koa-compose": "4.1.0",
|
88
88
|
"koa-compress": "5.1.1",
|
@@ -126,9 +126,9 @@
|
|
126
126
|
"@types/node": "18.19.24",
|
127
127
|
"@types/node-schedule": "2.1.7",
|
128
128
|
"@types/statuses": "2.0.1",
|
129
|
-
"eslint-config-custom": "5.
|
129
|
+
"eslint-config-custom": "5.11.0",
|
130
130
|
"supertest": "6.3.3",
|
131
|
-
"tsconfig": "5.
|
131
|
+
"tsconfig": "5.11.0"
|
132
132
|
},
|
133
133
|
"engines": {
|
134
134
|
"node": ">=18.0.0 <=22.x.x",
|