Skip to content

Commit 692b3d5

Browse files
authored
Automated docs + releases (#522)
* Adds minami template * Release docs on each merge + tags - Adds CloudCode.js file - Updates travis.yaml for releases - Adds release script * Adds all original Cloud Code functions * Adds parse-server cloud functions documentations * Adds additional documentation on current parse-server capabilities * Line breaks
1 parent 2e11780 commit 692b3d5

File tree

7 files changed

+292
-15
lines changed

7 files changed

+292
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ integration/test_logs
1010
.idea/
1111
integration/test_logs
1212
out/
13+
docs/
1314

.travis.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
1-
---
21
language: node_js
2+
dist: trusty
33
node_js:
44
- '6.11.4'
55

66
branches:
77
only:
88
- master
99
- /^greenkeeper/.*$/
10+
- /^v?[0-9]+.[0-9]+.[0-9]+(-.*)?$/
1011

11-
env:
12-
- MONGODB_VERSION=3.2.13
12+
cache:
13+
directories:
14+
- node_modules
15+
- "$HOME/.mongodb/versions"
1316

14-
services: mongodb
15-
before_script:
16-
- npm install -g mongodb-runner
17-
- mongodb-runner start
18-
script: npm test -- --maxWorkers=4 && ./run_integration.sh
19-
after_script: cat ./coverage/coverage-final.json | ./node_modules/codecov.io/bin/codecov.io.js && rm -rf ./coverage
17+
jobs:
18+
include:
19+
- stage: test
20+
env:
21+
- MONGODB_VERSION=3.2.13
22+
before_script:
23+
- npm install -g mongodb-runner
24+
- mongodb-runner start
25+
script: npm test -- --maxWorkers=4 && ./run_integration.sh
26+
after_script: cat ./coverage/coverage-final.json | ./node_modules/codecov.io/bin/codecov.io.js && rm -rf ./coverage
27+
# release on github latest branch
28+
- stage: release
29+
env:
30+
before_script: skip
31+
after_script: skip
32+
script: npm run release_docs
33+
deploy:
34+
- provider: pages
35+
skip_cleanup: true
36+
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
37+
local_dir: docs/
38+
on:
39+
all_branches: true
40+
- prov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qiSTiMtHfSSn7933V666PW+NOl/Cp6qESOI7KBZpI+45vyeBCQDP0vYdIIMg9xFLKPdiCltBxLOcCpZTGlWi5kkYA7DpzferPIybn6uiLqLHgEN891blevYZgr4sGFnHU29rZF17hDvWlZiRi4IFKbDl10RH7voSot71xf/47Iiq/J0MnlndUqqS6Ufj0QWLshoUlQxNH7TREwnw/Fo3Kz0ADY7sVeWjwzlZX2t+qkd1Xt8U73bLVjitY87EDIGRo5bMu5FMlJCUff5QAVYXE98hNkDDogqFJyvK6vuZteFMw3ouU1RwJyyYJqQP2/anZ4JysrFVguGdxObOV5Meq7+Wa/w="
46+
on:
47+
tags: true
48+
all_branches: true
49+
repo: parse-community/Parse-SDK-JS

integration/test/ParseQueryAggregateTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Parse Aggregate Query', () => {
6363
assert.equal(results[0], 10);
6464
assert.equal(results[1], 20);
6565
done();
66-
});
66+
}).catch(done.fail);
6767
});
6868

6969
it('distinct equalTo query', (done) => {

jsdoc-conf.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"plugins": ["node_modules/jsdoc-babel"],
2+
"plugins": ["node_modules/jsdoc-babel", "plugins/markdown"],
33
"babel": {
44
"plugins": ["transform-flow-strip-types"]
55
},
66
"source": {
7-
"include": ["./package.json", "./README.md"],
7+
"include": ["./README.md"],
88
"excludePattern": "(^|\\/|\\\\)_"
99
},
1010
"templates": {
@@ -15,6 +15,9 @@
1515
"monospaceLinks": false
1616
},
1717
"opts": {
18-
"recurse": true
18+
"recurse": true,
19+
"template": "node_modules/minami",
20+
"showInheritedInNav": true,
21+
"useLongnameInNav": true
1922
}
20-
}
23+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@
5555
"jest-cli": "^19.0.2",
5656
"jsdoc": "^3.5.5",
5757
"jsdoc-babel": "^0.3.0",
58+
"minami": "^1.2.3",
5859
"vinyl-source-stream": "^1.1.0"
5960
},
6061
"scripts": {
6162
"build": "./build_releases.sh",
6263
"release": "./build_releases.sh && npm publish",
6364
"test": "PARSE_BUILD=node jest",
64-
"docs": "jsdoc -c ./jsdoc-conf.json ./src"
65+
"docs": "jsdoc -c ./jsdoc-conf.json ./src",
66+
"release_docs": "./release_docs.sh"
6567
},
6668
"jest": {
6769
"automock": true,

release_docs.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh -e
2+
set -x
3+
if [ "${TRAVIS_REPO_SLUG}" = "" ];
4+
then
5+
echo "Cannot release docs without TRAVIS_REPO_SLUG set"
6+
exit 0;
7+
fi
8+
REPO="https://github.com/${TRAVIS_REPO_SLUG}"
9+
10+
rm -rf docs
11+
git clone -b gh-pages --single-branch $REPO ./docs
12+
cd docs
13+
git pull origin gh-pages
14+
cd ..
15+
16+
DEST="master"
17+
18+
if [ "${TRAVIS_TAG}" != "" ];
19+
then
20+
DEST="${TRAVIS_TAG}"
21+
# change the default page to the latest
22+
echo "<meta http-equiv='refresh' content='0; url=/Parse-SDK-JS/api/${DEST}'>" > "docs/api/index.html"
23+
fi
24+
25+
npm run docs
26+
27+
mkdir -p "docs/api/${DEST}"
28+
cp -R out/* "docs/api/${DEST}"

src/CloudCode.js

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
/**
2+
* Defines a Cloud Function.
3+
*
4+
* **Available in Cloud Code only.**
5+
*
6+
* @method define
7+
* @name Parse.Cloud.define
8+
* @param {String} name The name of the Cloud Function
9+
* @param {Function} data The Cloud Function to register. This function should take two parameters a {@link Parse.Cloud.FunctionRequest} and a {@link Parse.Cloud.FunctionResponse}
10+
*/
11+
12+
/**
13+
* Registers an after delete function.
14+
*
15+
* **Available in Cloud Code only.**
16+
*
17+
* If you want to use afterDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
18+
* ```
19+
* Parse.Cloud.afterDelete('MyCustomClass', (request) => {
20+
* // code here
21+
* })
22+
*
23+
* Parse.Cloud.afterDelete(Parse.User, (request) => {
24+
* // code here
25+
* })
26+
*```
27+
*
28+
* @method afterDelete
29+
* @name Parse.Cloud.afterDelete
30+
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass.
31+
* @param {Function} func The function to run after a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
32+
*/
33+
34+
/**
35+
*
36+
* Registers an after save function.
37+
*
38+
* **Available in Cloud Code only.**
39+
*
40+
* If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
41+
*
42+
* ```
43+
* Parse.Cloud.afterSave('MyCustomClass', function(request) {
44+
* // code here
45+
* })
46+
*
47+
* Parse.Cloud.afterSave(Parse.User, function(request) {
48+
* // code here
49+
* })
50+
* ```
51+
*
52+
* @method afterSave
53+
* @name Parse.Cloud.afterSave
54+
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
55+
* @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
56+
*/
57+
58+
/**
59+
* Registers an before delete function.
60+
*
61+
* **Available in Cloud Code only.**
62+
*
63+
* If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
64+
* ```
65+
* Parse.Cloud.beforeDelete('MyCustomClass', (request, response) => {
66+
* // code here
67+
* })
68+
*
69+
* Parse.Cloud.beforeDelete(Parse.User, (request, response) => {
70+
* // code here
71+
* })
72+
*```
73+
*
74+
* @method beforeDelete
75+
* @name Parse.Cloud.beforeDelete
76+
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass.
77+
* @param {Function} func The function to run before a delete. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeDeleteResponse}.
78+
*/
79+
80+
/**
81+
*
82+
* Registers an before save function.
83+
*
84+
* **Available in Cloud Code only.**
85+
*
86+
* If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
87+
*
88+
* ```
89+
* Parse.Cloud.beforeSave('MyCustomClass', (request, response) => {
90+
* // code here
91+
* })
92+
*
93+
* Parse.Cloud.beforeSave(Parse.User, (request, response) => {
94+
* // code here
95+
* })
96+
* ```
97+
*
98+
* @method beforeSave
99+
* @name Parse.Cloud.beforeSave
100+
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
101+
* @param {Function} func The function to run before a save. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeSaveResponse}.
102+
*/
103+
104+
/**
105+
* Makes an HTTP Request.
106+
*
107+
* **Available in Cloud Code only.**
108+
*
109+
* By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the {@link Parse.Cloud.HTTPOptions} object to change this behavior.
110+
*
111+
* Sample request:
112+
* ```
113+
* Parse.Cloud.httpRequest({
114+
* url: 'http://www.parse.com/'
115+
* }).then(function(httpResponse) {
116+
* // success
117+
* console.log(httpResponse.text);
118+
* },function(httpResponse) {
119+
* // error
120+
* console.error('Request failed with response code ' + httpResponse.status);
121+
* });
122+
* ```
123+
*
124+
* @method httpRequest
125+
* @name Parse.Cloud.httpRequest
126+
* @param {Parse.Cloud.HTTPOptions} options The Parse.Cloud.HTTPOptions object that makes the request.
127+
* @return {Parse.Promise<Parse.Cloud.HTTPResponse>} A promise that will be resolved with a {@link Parse.Cloud.HTTPResponse} object when the request completes.
128+
*/
129+
130+
/**
131+
* Defines a Background Job.
132+
*
133+
* **Available in Cloud Code only.**
134+
*
135+
* @method job
136+
* @name Parse.Cloud.job
137+
* @param {String} name The name of the Background Job
138+
* @param {Function} func The Background Job to register. This function should take two parameters a {@link Parse.Cloud.JobRequest} and a {@link Parse.Cloud.JobStatus}
139+
*
140+
*/
141+
142+
/**
143+
* @typedef Parse.Cloud.TriggerRequest
144+
* @property {String} installationId If set, the installationId triggering the request.
145+
* @property {Boolean} master If true, means the master key was used.
146+
* @property {Parse.User} user If set, the user that made the request.
147+
* @property {Parse.Object} object The object triggering the hook.
148+
* @property {String} ip The IP address of the client making the request.
149+
* @property {Object} headers The original HTTP headers for the request.
150+
* @property {String} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...)
151+
* @property {Object} log The current logger inside Parse Server.
152+
* @property {Parse.Object} original If set, the object, as currently stored.
153+
*/
154+
155+
/**
156+
* @typedef Parse.Cloud.FunctionRequest
157+
* @property {String} installationId If set, the installationId triggering the request.
158+
* @property {Boolean} master If true, means the master key was used.
159+
* @property {Parse.User} user If set, the user that made the request.
160+
* @property {Object} params The params passed to the cloud function.
161+
*/
162+
163+
/**
164+
* @typedef Parse.Cloud.JobRequest
165+
* @property {Object} params The params passed to the background job.
166+
*/
167+
168+
/**
169+
* @typedef Parse.Cloud.JobStatus
170+
* @property {function} error If error is called, will end the job unsuccessfully with an optional completion message to be stored in the job status.
171+
* @property {function} message If message is called with a string argument, will update the current message to be stored in the job status.
172+
* @property {function} success If success is called, will end the job successfullly with the optional completion message to be stored in the job status.
173+
*/
174+
175+
/**
176+
* @typedef Parse.Cloud.BeforeSaveResponse
177+
* @property {function} success If called, will allow the save to happen. If a Parse.Object is passed in, then the passed in object will be saved instead.
178+
* @property {function} error If called, will reject the save. An optional error message may be passed in.
179+
*/
180+
181+
/**
182+
* @typedef Parse.Cloud.BeforeDeleteResponse
183+
* @property {function} success If called, will allow the delete to happen.
184+
* @property {function} error If called, will reject the save. An optional error message may be passed in.
185+
*/
186+
187+
/**
188+
* @typedef Parse.Cloud.FunctionResponse
189+
* @property {function} success If success is called, will return a successful response with the optional argument to the caller.
190+
* @property {function} error If error is called, will return an error response with an optionally passed message.
191+
*/
192+
193+
/**
194+
* @typedef Parse.Cloud.HTTPOptions
195+
* @property {String|Object} body The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent.
196+
* @property {function} error The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object.
197+
* @property {Boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false.
198+
* @property {Object} headers The headers for the request.
199+
* @property {String} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified.
200+
* @property {String|Object} params The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott.
201+
* @property {function} success The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object.
202+
* @property {string} url The url to send the request to.
203+
*/
204+
205+
/**
206+
* @typedef Parse.Cloud.HTTPResponse
207+
* @property {Buffer} buffer The raw byte representation of the response body. Use this to receive binary data. See Buffer for more details.
208+
* @property {Object} cookies The cookies sent by the server. The keys in this object are the names of the cookies. The values are Parse.Cloud.Cookie objects.
209+
* @property {Object} data The parsed response body as a JavaScript object. This is only available when the response Content-Type is application/x-www-form-urlencoded or application/json.
210+
* @property {Object} headers The headers sent by the server. The keys in this object are the names of the headers. We do not support multiple response headers with the same name. In the common case of Set-Cookie headers, please use the cookies field instead.
211+
* @property {Number} status The status code.
212+
* @property {String} text The raw text representation of the response body.
213+
*/

0 commit comments

Comments
 (0)