forked from OpenSocial/activitystreams.js
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Twipped/contrib
Hefty contrib PR
- Loading branch information
Showing
37 changed files
with
4,993 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version = 1 | ||
|
||
[[analyzers]] | ||
name = "javascript" | ||
enabled = true | ||
|
||
[analyzers.meta] | ||
environment = [ | ||
"nodejs", | ||
"mocha" | ||
] | ||
style_guide = "standard" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 2022 | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ master ] | ||
schedule: | ||
- cron: '45 17 * * 0' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'javascript' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] | ||
# Learn more: | ||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
# queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v1 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 https://git.io/JvXDl | ||
|
||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
# and modify them (or add more) to build your code if your project | ||
# uses a compiled language | ||
|
||
#- run: | | ||
# make bootstrap | ||
# make release | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,104 @@ | ||
node_modules | ||
npm-debug.log | ||
graph.js | ||
# Logs | ||
logs | ||
*.log | ||
.vscode | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
## Modifications | ||
|
||
As required by the Apache license: | ||
Please note that all files dated 01/01/2021 & newer have been modified from the original... | ||
|
||
# Activity Streams 2.0 | ||
|
||
Based on: | ||
|
@@ -10,8 +15,6 @@ Includes experimental support for: | |
* http://ns.jasnell.me/interval | ||
* http://ns.jasnell.me/social | ||
|
||
Starting with version `v0.8.0`, a minimum of Node v4.0.0 / ES6 is required. | ||
|
||
## Getting Started | ||
|
||
### Installation | ||
|
@@ -24,17 +27,14 @@ Starting with version `v0.8.0`, a minimum of Node v4.0.0 / ES6 is required. | |
const as = require('activitystrea.ms'); | ||
|
||
// Create a simple object | ||
as.object(). | ||
const doc = await as.object(). | ||
name('baz'). | ||
content( | ||
as.langmap() | ||
.set('en', 'bar') | ||
.set('fr', 'foo')). | ||
publishedNow(). | ||
prettyWrite((err,doc) => { | ||
if (err) throw err; | ||
console.log(doc); | ||
}); | ||
prettyWrite(); | ||
``` | ||
|
||
Which produces the output: | ||
|
@@ -54,13 +54,10 @@ Which produces the output: | |
|
||
```javascript | ||
// Create a simple activity | ||
as.create(). | ||
const doc = await as.create(). | ||
actor('acct:[email protected]'). | ||
object('http://www.example.org/post'). | ||
prettyWrite((err,doc) => { | ||
if (err) throw err; | ||
console.log(doc); | ||
}); | ||
prettyWrite(); | ||
``` | ||
|
||
Which produces the output: | ||
|
@@ -220,27 +217,19 @@ To serialize the Activity Streams object out as JSON, use the `write`, | |
```javascript | ||
const as = require('activitystrea.ms'); | ||
|
||
as.note(). | ||
const doc = await as.note(). | ||
name('foo'). | ||
content('this is a simple note'). | ||
write((err, doc) => { | ||
if (err) throw err; | ||
// doc is a string | ||
console.log(doc); | ||
}); | ||
write(); | ||
``` | ||
|
||
```javascript | ||
const as = require('activitystrea.ms'); | ||
|
||
as.note(). | ||
const doc = await as.note(). | ||
name('foo'). | ||
content('this is a simple note'). | ||
prettyWrite((err, doc) => { | ||
if (err) throw err; | ||
// doc is a string | ||
console.log(doc); | ||
}); | ||
prettyWrite(); | ||
``` | ||
|
||
```javascript | ||
|
@@ -252,9 +241,8 @@ as.object() | |
.pipe(process.stdout); | ||
``` | ||
|
||
Note that The `export`, `write`, and `prettyWrite` methods are all async. You | ||
MUST pass in a callback function. This is largely because of the JSON-LD | ||
processing that's happening under the covers. | ||
Note that The `export`, `write`, and `prettyWrite` methods are all async and return promises. | ||
This is largely because of the JSON-LD processing that's happening under the covers. | ||
|
||
## API | ||
|
||
|
@@ -546,9 +534,9 @@ Returns true if the object has a value for the specified `key` | |
|
||
Returns the value for the specified `key`. The return value will vary based on the property being requested. The return value can be a JavaScript primitive, a `as.models.Base` instance, or an Iterable of JavaScript primitives or `as.models.Base` instances. Will returned `undefined` if the no value is specified for the given `key` | ||
|
||
#### Method: `<void> as.models.Base.prototype.export([options, ] callback)` | ||
#### Method: `<Promise> as.models.Base.prototype.export([options])` | ||
|
||
Exports the object by performing a JSON-LD compaction. If export fails, the callback will be called with the error as the first argument. If the export succeeds, the exported JavaScript object will be passed as the second argument of the callback. | ||
Exports the object by performing a JSON-LD compaction. If export fails, the promise will reject with the error. If the export succeeds, the promise will resolve with the exported JavaScript object. | ||
|
||
```javascript | ||
const obj = as.object().name('Joe').get(); | ||
|
@@ -559,9 +547,9 @@ obj.export((err,exp) => { | |
}); | ||
``` | ||
|
||
#### Method: `<void> as.models.Base.prototype.write([options, ] callback)` | ||
#### Method: `<Promise> as.models.Base.prototype.write([options])` | ||
|
||
Write the object out to a JSON-LD string. If writing fails, the callback will will be called with the error as the first argument. If the write succeeds, the JSON-LD string will be passed as the second argument of the callback. | ||
Write the object out to a JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string. | ||
|
||
```javascript | ||
const obj = as.object().name('Joe').get(); | ||
|
@@ -571,9 +559,9 @@ obj.write((err,string) => { | |
}); | ||
``` | ||
|
||
#### Method: `<void> as.models.Base.prototype.prettyWrite([options, ] callback)` | ||
#### Method: `<Promise> as.models.Base.prototype.prettyWrite([options])` | ||
|
||
Write the object out to a JSON-LD string. If writing fails, the callback will will be called with the error as the first argument. If the write succeeds, the JSON-LD string will be passed as the second argument of the callback. | ||
Write the object out to a JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string. | ||
|
||
```javascript | ||
const obj = as.object().name('Joe').get(); | ||
|
Oops, something went wrong.