@wordpress/core-data 7.41.0 → 7.41.2-next.v.202603102151.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/CHANGELOG.md +6 -0
- package/build/actions.cjs +8 -6
- package/build/actions.cjs.map +2 -2
- package/build/entity-provider.cjs +15 -6
- package/build/entity-provider.cjs.map +2 -2
- package/build/hooks/use-entity-prop.cjs +32 -2
- package/build/hooks/use-entity-prop.cjs.map +2 -2
- package/build/private-actions.cjs +1 -1
- package/build/private-actions.cjs.map +2 -2
- package/build/queried-data/actions.cjs +1 -1
- package/build/queried-data/actions.cjs.map +2 -2
- package/build/queried-data/reducer.cjs +19 -13
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/reducer.cjs +2 -1
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +4 -2
- package/build/resolvers.cjs.map +2 -2
- package/build/sync.cjs +3 -0
- package/build/sync.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs +22 -26
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt.cjs +1 -3
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/user-permissions.cjs +1 -4
- package/build/utils/user-permissions.cjs.map +2 -2
- package/build-module/actions.mjs +13 -7
- package/build-module/actions.mjs.map +2 -2
- package/build-module/entity-provider.mjs +15 -6
- package/build-module/entity-provider.mjs.map +2 -2
- package/build-module/hooks/use-entity-prop.mjs +33 -3
- package/build-module/hooks/use-entity-prop.mjs.map +2 -2
- package/build-module/private-actions.mjs +1 -1
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/queried-data/actions.mjs +1 -1
- package/build-module/queried-data/actions.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs +19 -13
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/reducer.mjs +2 -1
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +4 -2
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/sync.mjs +2 -0
- package/build-module/sync.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs +22 -26
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +1 -3
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/user-permissions.mjs +1 -4
- package/build-module/utils/user-permissions.mjs.map +2 -2
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts +11 -6
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/sync.d.ts +2 -2
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/user-permissions.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/actions.js +24 -10
- package/src/entity-provider.js +24 -11
- package/src/hooks/use-entity-prop.js +41 -3
- package/src/private-actions.js +1 -1
- package/src/queried-data/actions.js +1 -1
- package/src/queried-data/reducer.js +26 -14
- package/src/reducer.js +4 -1
- package/src/resolvers.js +5 -3
- package/src/sync.ts +2 -0
- package/src/test/private-actions.js +1 -1
- package/src/test/resolvers.js +24 -3
- package/src/test/store.js +116 -0
- package/src/utils/crdt-blocks.ts +47 -54
- package/src/utils/crdt.ts +2 -5
- package/src/utils/test/crdt-blocks.ts +42 -24
- package/src/utils/user-permissions.js +4 -5
|
@@ -31,6 +31,13 @@ jest.mock( '@wordpress/blocks', () => ( {
|
|
|
31
31
|
name: 'core/paragraph',
|
|
32
32
|
attributes: { content: { type: 'rich-text' } },
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
name: 'core/image',
|
|
36
|
+
attributes: {
|
|
37
|
+
blob: { type: 'string', role: 'local' },
|
|
38
|
+
url: { type: 'string' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
34
41
|
],
|
|
35
42
|
} ) );
|
|
36
43
|
|
|
@@ -175,32 +182,30 @@ describe( 'crdt-blocks', () => {
|
|
|
175
182
|
expect( innerBlock.get( 'name' ) ).toBe( 'core/paragraph' );
|
|
176
183
|
} );
|
|
177
184
|
|
|
178
|
-
it( '
|
|
179
|
-
const
|
|
185
|
+
it( 'strips local attributes when syncing blocks', () => {
|
|
186
|
+
const imageWithBlob: Block[] = [
|
|
180
187
|
{
|
|
181
|
-
name: 'core/
|
|
182
|
-
attributes: {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
url: 'http://example.com/image.jpg',
|
|
188
|
-
blob: 'blob:...',
|
|
189
|
-
},
|
|
190
|
-
innerBlocks: [],
|
|
191
|
-
},
|
|
192
|
-
],
|
|
188
|
+
name: 'core/image',
|
|
189
|
+
attributes: {
|
|
190
|
+
url: 'http://example.com/image.jpg',
|
|
191
|
+
blob: 'blob:...',
|
|
192
|
+
},
|
|
193
|
+
innerBlocks: [],
|
|
193
194
|
},
|
|
194
195
|
];
|
|
195
196
|
|
|
196
|
-
mergeCrdtBlocks( yblocks,
|
|
197
|
+
mergeCrdtBlocks( yblocks, imageWithBlob, null );
|
|
197
198
|
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
expect( yblocks.length ).toBe( 1 );
|
|
200
|
+
const block = yblocks.get( 0 );
|
|
201
|
+
expect( block.get( 'name' ) ).toBe( 'core/image' );
|
|
202
|
+
const attrs = block.get( 'attributes' ) as YBlockAttributes;
|
|
203
|
+
expect( attrs.get( 'url' ) ).toBe( 'http://example.com/image.jpg' );
|
|
204
|
+
expect( attrs.has( 'blob' ) ).toBe( false );
|
|
200
205
|
} );
|
|
201
206
|
|
|
202
|
-
it( '
|
|
203
|
-
const
|
|
207
|
+
it( 'strips local attributes from inner blocks', () => {
|
|
208
|
+
const galleryWithBlobs: Block[] = [
|
|
204
209
|
{
|
|
205
210
|
name: 'core/gallery',
|
|
206
211
|
attributes: {},
|
|
@@ -209,6 +214,7 @@ describe( 'crdt-blocks', () => {
|
|
|
209
214
|
name: 'core/image',
|
|
210
215
|
attributes: {
|
|
211
216
|
url: 'http://example.com/image.jpg',
|
|
217
|
+
blob: 'blob:...',
|
|
212
218
|
},
|
|
213
219
|
innerBlocks: [],
|
|
214
220
|
},
|
|
@@ -216,11 +222,17 @@ describe( 'crdt-blocks', () => {
|
|
|
216
222
|
},
|
|
217
223
|
];
|
|
218
224
|
|
|
219
|
-
mergeCrdtBlocks( yblocks,
|
|
225
|
+
mergeCrdtBlocks( yblocks, galleryWithBlobs, null );
|
|
220
226
|
|
|
221
227
|
expect( yblocks.length ).toBe( 1 );
|
|
222
|
-
const
|
|
223
|
-
expect(
|
|
228
|
+
const gallery = yblocks.get( 0 );
|
|
229
|
+
expect( gallery.get( 'name' ) ).toBe( 'core/gallery' );
|
|
230
|
+
const innerBlocks = gallery.get( 'innerBlocks' ) as YBlocks;
|
|
231
|
+
expect( innerBlocks.length ).toBe( 1 );
|
|
232
|
+
const image = innerBlocks.get( 0 );
|
|
233
|
+
const attrs = image.get( 'attributes' ) as YBlockAttributes;
|
|
234
|
+
expect( attrs.get( 'url' ) ).toBe( 'http://example.com/image.jpg' );
|
|
235
|
+
expect( attrs.has( 'blob' ) ).toBe( false );
|
|
224
236
|
} );
|
|
225
237
|
|
|
226
238
|
it( 'handles block reordering', () => {
|
|
@@ -522,7 +534,7 @@ describe( 'crdt-blocks', () => {
|
|
|
522
534
|
expect( content2.toString() ).toBe( 'Freeform content' );
|
|
523
535
|
} );
|
|
524
536
|
|
|
525
|
-
it( '
|
|
537
|
+
it( 'strips local attributes from deeply nested blocks', () => {
|
|
526
538
|
const nestedGallery: Block[] = [
|
|
527
539
|
{
|
|
528
540
|
name: 'core/group',
|
|
@@ -554,7 +566,13 @@ describe( 'crdt-blocks', () => {
|
|
|
554
566
|
|
|
555
567
|
const innerBlocks = groupBlock.get( 'innerBlocks' ) as YBlocks;
|
|
556
568
|
expect( innerBlocks.length ).toBe( 1 );
|
|
557
|
-
|
|
569
|
+
const gallery = innerBlocks.get( 0 );
|
|
570
|
+
const galleryInner = gallery.get( 'innerBlocks' ) as YBlocks;
|
|
571
|
+
expect( galleryInner.length ).toBe( 1 );
|
|
572
|
+
const image = galleryInner.get( 0 );
|
|
573
|
+
const attrs = image.get( 'attributes' ) as YBlockAttributes;
|
|
574
|
+
expect( attrs.get( 'url' ) ).toBe( 'http://example.com/image.jpg' );
|
|
575
|
+
expect( attrs.has( 'blob' ) ).toBe( false );
|
|
558
576
|
} );
|
|
559
577
|
|
|
560
578
|
it( 'handles complex block reordering', () => {
|
|
@@ -7,18 +7,17 @@ export const ALLOWED_RESOURCE_ACTIONS = [
|
|
|
7
7
|
|
|
8
8
|
export function getUserPermissionsFromAllowHeader( allowedMethods ) {
|
|
9
9
|
const permissions = {};
|
|
10
|
-
if ( ! allowedMethods ) {
|
|
11
|
-
return permissions;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
const methods = {
|
|
15
11
|
create: 'POST',
|
|
16
12
|
read: 'GET',
|
|
17
13
|
update: 'PUT',
|
|
18
14
|
delete: 'DELETE',
|
|
19
15
|
};
|
|
16
|
+
|
|
20
17
|
for ( const [ actionName, methodName ] of Object.entries( methods ) ) {
|
|
21
|
-
permissions[ actionName ] = allowedMethods
|
|
18
|
+
permissions[ actionName ] = allowedMethods
|
|
19
|
+
? allowedMethods.includes( methodName )
|
|
20
|
+
: false;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
return permissions;
|