Open Jimmy89 opened 5 months ago
I found out that @context
could be expanded through the environment
option when creating an activity.
For that you need to implement the Environment class, which is not exported.
As workaround you can import import Environment from "activitystrea.ms/src/environment.js";
Then at initialization you must specify the @context through:
as.create(undefined,
new Environment({ "@context": [
'https://www.w3.org/ns/activitystreams',
{ vcard: 'http://www.w3.org/2006/vcard/ns#' },
] }))
Secondly, when using the write
or similar command, you must provide the option useOriginalContext: true
.
However, there is a bug within the function, it looks for the getter options.origContext, which is the wrong getter name, it should be originalContext
.
So, two bugs: 1) provide a direct export for the environment class; 2) search for originalContext instead of origContext.
The current workaround is:
import Environment from "activitystrea.ms/src/environment.js";
class EnvironmentFixed extends Environment {
constructor(...args) {
super(...args);
}
get origContext() {
return super.originalContext;
}
}
const result = await as.create(undefined,
new EnvironmentFixed({ "@context": [
'https://www.w3.org/ns/activitystreams',
{
"vcard": "http://www.w3.org/2006/vcard/ns",
},
] })).write({ useOriginalContext: true });
.....
Hello,
I'm trying out this plugin for activity streams and I noticed that there is no way to expand the
@context
of a record.For example, I am trying to rebuild the example within the spec
Where the
@context
is an array with a second item for vcard. Within the test suite of this library I found a test:However, this test is invalid. Because the
.context
adjusts thecontext
field, which has a different meaning than the@context
. The input of the test is something that must be added to@context
instead.In other words: there seems to be no way of setting
@context
currently and its test is invalid.Side note: I also think the
vcard:given-name
should also be set on the person and not on the offer, in which case theas.person()
should be rewritten asas.person("vcard:Individual")
Also not so sure what.set({h: 'd'})
should do, as that item is not set at all. Maybe the test should check that the property was not created? I guess that the test could also check whether the keyword namespace is included within the@context
.