You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where the @context is an array with a second item for vcard. Within the test suite of this library I found a test:
it("should allow using .set() when the @context is an array", async () => {
const string = await as.activity()
.context([
'https://www.w3.org/ns/activitystreams',
{ vcard: 'http://www.w3.org/2006/vcard/ns#' }
])
.actor(
as.person()
.name('Denis Prša')
.id('https://github.com/denisprsa')
)
.object(
as.offer()
.name('Thank you')
.id('https://github.com/jasnell/activitystrea.ms/issues/13#issuecomment-376722358')
.set('vcard:given-name', 'Thank')
)
.name('The offer')
.content('Evan offered his thanks to Denis for his bug report')
.set({h: 'd'})
.published(new Date())
.prettyWrite();
assert(string); // <-- seems to me missing a test case.
})
However, this test is invalid. Because the .context adjusts the context 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 the as.person() should be rewritten as as.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.
The text was updated successfully, but these errors were encountered:
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:
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
.The text was updated successfully, but these errors were encountered: