@wordpress/core-data 4.4.1 → 4.4.4
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/build/queried-data/get-query-parts.js +4 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +4 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/package.json +11 -11
- package/src/queried-data/get-query-parts.js +3 -0
- package/src/queried-data/test/get-query-parts.js +4 -0
|
@@ -93,6 +93,10 @@ function getQueryParts(query) {
|
|
|
93
93
|
if (key === 'include') {
|
|
94
94
|
var _getNormalizedCommaSe2;
|
|
95
95
|
|
|
96
|
+
if (typeof value === 'number') {
|
|
97
|
+
value = value.toString();
|
|
98
|
+
}
|
|
99
|
+
|
|
96
100
|
parts.include = ((_getNormalizedCommaSe2 = (0, _utils.getNormalizedCommaSeparable)(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number); // Normalize value for `stableKey`.
|
|
97
101
|
|
|
98
102
|
value = parts.include.join();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","map","slice"],"mappings":";;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AACtC;AACD;AACA;AACC,QAAMC,KAAK,GAAG;AACbC,IAAAA,SAAS,EAAE,EADE;AAEbC,IAAAA,IAAI,EAAE,CAFO;AAGbC,IAAAA,OAAO,EAAE,EAHI;AAIbC,IAAAA,MAAM,EAAE,IAJK;AAKbC,IAAAA,OAAO,EAAE,IALI;AAMbC,IAAAA,OAAO,EAAE;AANI,GAAd,CAJsC,CAatC;;AACA,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaR,KAAb,EAAqBU,IAArB,EAAb;;AAEA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,IAAI,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAwC;AACvC,UAAME,GAAG,GAAGL,IAAI,CAAEG,CAAF,CAAhB;AACA,QAAIG,KAAK,GAAGd,KAAK,CAAEa,GAAF,CAAjB;;AAEA,YAASA,GAAT;AACC,WAAK,MAAL;AACCZ,QAAAA,KAAK,CAAEY,GAAF,CAAL,GAAeE,MAAM,CAAED,KAAF,CAArB;AACA;;AAED,WAAK,UAAL;AACCb,QAAAA,KAAK,CAACG,OAAN,GAAgBW,MAAM,CAAED,KAAF,CAAtB;AACA;;AAED,WAAK,SAAL;AACCb,QAAAA,KAAK,CAACM,OAAN,GAAgBO,KAAhB;AACA;;AAED;AACC;AACA;AACA;AACA;AACA;AACA,YAAKD,GAAG,KAAK,SAAb,EAAyB;AAAA;;AACxBZ,UAAAA,KAAK,CAACI,MAAN,4BAAe,wCAA6BS,KAA7B,CAAf,yEAAuD,EAAvD,CADwB,CAExB;;AACAA,UAAAA,KAAK,GAAGb,KAAK,CAACI,MAAN,CAAaW,IAAb,EAAR;AACA,SAVF,CAYC;;;AACA,YAAKH,GAAG,KAAK,SAAb,EAAyB;AAAA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","toString","map","slice"],"mappings":";;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AACG,QAAN,EAAR;AACA;;AACDhB,UAAAA,KAAK,CAACK,OAAN,GAAgB,2BACf,wCAA6BQ,KAA7B,CADe,2EACyB,EADzB,EAEdI,GAFc,CAETH,MAFS,CAAhB,CAJwB,CAOxB;;AACAD,UAAAA,KAAK,GAAGb,KAAK,CAACK,OAAN,CAAcU,IAAd,EAAR;AACA,SAtBF,CAwBC;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAf,QAAAA,KAAK,CAACC,SAAN,IACC,CAAED,KAAK,CAACC,SAAN,GAAkB,GAAlB,GAAwB,EAA1B,IACA,uBAAc,EAAd,EAAkB;AAAE,WAAEW,GAAF,GAASC;AAAX,SAAlB,EAAuCK,KAAvC,CAA8C,CAA9C,CAFD;AA5CF;AAgDA;;AAED,SAAOlB,KAAP;AACA;;eAEc,6BAAkBF,aAAlB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"]}
|
|
@@ -83,6 +83,10 @@ export function getQueryParts(query) {
|
|
|
83
83
|
if (key === 'include') {
|
|
84
84
|
var _getNormalizedCommaSe2;
|
|
85
85
|
|
|
86
|
+
if (typeof value === 'number') {
|
|
87
|
+
value = value.toString();
|
|
88
|
+
}
|
|
89
|
+
|
|
86
90
|
parts.include = ((_getNormalizedCommaSe2 = getNormalizedCommaSeparable(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number); // Normalize value for `stableKey`.
|
|
87
91
|
|
|
88
92
|
value = parts.include.join();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","map","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,2BAA3B,QAA8D,UAA9D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC;AACD;AACA;AACC,QAAMC,KAAK,GAAG;AACbC,IAAAA,SAAS,EAAE,EADE;AAEbC,IAAAA,IAAI,EAAE,CAFO;AAGbC,IAAAA,OAAO,EAAE,EAHI;AAIbC,IAAAA,MAAM,EAAE,IAJK;AAKbC,IAAAA,OAAO,EAAE,IALI;AAMbC,IAAAA,OAAO,EAAE;AANI,GAAd,CAJsC,CAatC;;AACA,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaR,KAAb,EAAqBU,IAArB,EAAb;;AAEA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,IAAI,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAwC;AACvC,UAAME,GAAG,GAAGL,IAAI,CAAEG,CAAF,CAAhB;AACA,QAAIG,KAAK,GAAGd,KAAK,CAAEa,GAAF,CAAjB;;AAEA,YAASA,GAAT;AACC,WAAK,MAAL;AACCZ,QAAAA,KAAK,CAAEY,GAAF,CAAL,GAAeE,MAAM,CAAED,KAAF,CAArB;AACA;;AAED,WAAK,UAAL;AACCb,QAAAA,KAAK,CAACG,OAAN,GAAgBW,MAAM,CAAED,KAAF,CAAtB;AACA;;AAED,WAAK,SAAL;AACCb,QAAAA,KAAK,CAACM,OAAN,GAAgBO,KAAhB;AACA;;AAED;AACC;AACA;AACA;AACA;AACA;AACA,YAAKD,GAAG,KAAK,SAAb,EAAyB;AAAA;;AACxBZ,UAAAA,KAAK,CAACI,MAAN,4BAAeP,2BAA2B,CAAEgB,KAAF,CAA1C,yEAAuD,EAAvD,CADwB,CAExB;;AACAA,UAAAA,KAAK,GAAGb,KAAK,CAACI,MAAN,CAAaW,IAAb,EAAR;AACA,SAVF,CAYC;;;AACA,YAAKH,GAAG,KAAK,SAAb,EAAyB;AAAA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","toString","map","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,2BAA3B,QAA8D,UAA9D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;A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AAAA,KAAK,GAAGA,KAAK,CAACG,QAAN,EAAR;AACA;;AACDhB,UAAAA,KAAK,CAACK,OAAN,GAAgB,2BACfR,2BAA2B,CAAEgB,KAAF,CADZ,2EACyB,EADzB,EAEdI,GAFc,CAETH,MAFS,CAAhB,CAJwB,CAOxB;;AACAD,UAAAA,KAAK,GAAGb,KAAK,CAACK,OAAN,CAAcU,IAAd,EAAR;AACA,SAtBF,CAwBC;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAf,QAAAA,KAAK,CAACC,SAAN,IACC,CAAED,KAAK,CAACC,SAAN,GAAkB,GAAlB,GAAwB,EAA1B,IACAN,YAAY,CAAE,EAAF,EAAM;AAAE,WAAEiB,GAAF,GAASC;AAAX,SAAN,CAAZ,CAAuCK,KAAvC,CAA8C,CAA9C,CAFD;AA5CF;AAgDA;;AAED,SAAOlB,KAAP;AACA;AAED,eAAeJ,gBAAgB,CAAEE,aAAF,CAA/B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-data",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.4",
|
|
4
4
|
"description": "Access to and manipulation of core WordPress entities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.16.0",
|
|
33
|
-
"@wordpress/api-fetch": "^6.3.
|
|
34
|
-
"@wordpress/blocks": "^11.5.
|
|
35
|
-
"@wordpress/data": "^6.6.
|
|
36
|
-
"@wordpress/deprecated": "^3.6.
|
|
37
|
-
"@wordpress/element": "^4.4.
|
|
38
|
-
"@wordpress/html-entities": "^3.6.
|
|
39
|
-
"@wordpress/i18n": "^4.6.
|
|
40
|
-
"@wordpress/is-shallow-equal": "^4.6.
|
|
41
|
-
"@wordpress/url": "^3.7.
|
|
33
|
+
"@wordpress/api-fetch": "^6.3.1",
|
|
34
|
+
"@wordpress/blocks": "^11.5.3",
|
|
35
|
+
"@wordpress/data": "^6.6.1",
|
|
36
|
+
"@wordpress/deprecated": "^3.6.1",
|
|
37
|
+
"@wordpress/element": "^4.4.1",
|
|
38
|
+
"@wordpress/html-entities": "^3.6.1",
|
|
39
|
+
"@wordpress/i18n": "^4.6.1",
|
|
40
|
+
"@wordpress/is-shallow-equal": "^4.6.1",
|
|
41
|
+
"@wordpress/url": "^3.7.1",
|
|
42
42
|
"equivalent-key-map": "^0.2.2",
|
|
43
43
|
"lodash": "^4.17.21",
|
|
44
44
|
"memize": "^1.1.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1fdd4758150247d6b690051aed18fa27c15f3a32"
|
|
55
55
|
}
|
|
@@ -80,6 +80,9 @@ export function getQueryParts( query ) {
|
|
|
80
80
|
|
|
81
81
|
// Two requests with different include values cannot have same results.
|
|
82
82
|
if ( key === 'include' ) {
|
|
83
|
+
if ( typeof value === 'number' ) {
|
|
84
|
+
value = value.toString();
|
|
85
|
+
}
|
|
83
86
|
parts.include = (
|
|
84
87
|
getNormalizedCommaSeparable( value ) ?? []
|
|
85
88
|
).map( Number );
|
|
@@ -18,8 +18,12 @@ describe( 'getQueryParts', () => {
|
|
|
18
18
|
} );
|
|
19
19
|
|
|
20
20
|
it( 'parses out `include` ID filtering', () => {
|
|
21
|
+
const first = getQueryParts( { include: '1' } );
|
|
22
|
+
const second = getQueryParts( { include: 1 } );
|
|
21
23
|
const parts = getQueryParts( { include: [ 1 ] } );
|
|
22
24
|
|
|
25
|
+
expect( first ).toEqual( second );
|
|
26
|
+
expect( second ).toEqual( parts );
|
|
23
27
|
expect( parts ).toEqual( {
|
|
24
28
|
context: 'default',
|
|
25
29
|
page: 1,
|