I think we are missing formal construct of the Collection metadata
information: filtered ( "true" / "false" ) , "updatedSince ( "true" /
"false" ), and sorted ( "true" / "false" ) that describes whether the
requests params for collection of data is supported for both JSON-RPC
and REST endpoints.
There are 2 places I saw mention this:
http://opensocial-resources.googlecode.com/svn/spec/trunk/Core-Data.xml#ActivityStreamsCollection
and
http://opensocial-resources.googlecode.com/svn/spec/trunk/Core-API-Server.xml#rfc.section.6.2.7
The specs basically said that IF the container does not support
filter, updatedSince, or sort request params then response MUST return
false for those type of properties.
This behavior actually contradicts the XML schema for REST response
and kinda hard to check using JavaScript.
Imagine that we have this code:
var params = {
userId: "@me",
groupId: "@self",
fields: "@all",
count: 10
};
osapi.activitystreams.get(params).execute(function(result) {
if(result.filtered) {
// DO STUFF
}
});
The check for "if(result.filtered)" could return false for either the
result object have "filtered" property sets to false or its undefined,
which suppose to mean that it support filtered request parameter.
Hence the code to check if result.filtered exist should do look like
if(!result.hasOwnProperty()) or if(typeof result.filtered !==
"undefined") which neither are good.
I recommend we REQUIRED collection data type to be accompanied by the
metadata about its supported behavior all the times to make the spec
more strict and easier for programmers to code against it.
- Henry