@veritree/services 2.29.2 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -1
- package/jsdoc.json +16 -0
- package/package.json +7 -1
- package/src/endpoints/organizations.js +8 -2
- package/src/endpoints/password.js +58 -0
- package/src/helpers/api.js +29 -31
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import { PlantingSites } from './src/endpoints/planting-sites';
|
|
|
36
36
|
import { Organizations } from './src/endpoints/organizations';
|
|
37
37
|
import { Tasks } from './src/endpoints/tasks';
|
|
38
38
|
import { Geometries } from './src/endpoints/geometries';
|
|
39
|
+
import { Password } from './src/endpoints/password';
|
|
39
40
|
|
|
40
41
|
export {
|
|
41
42
|
BulkUploads,
|
|
@@ -75,5 +76,6 @@ export {
|
|
|
75
76
|
PlantingSites,
|
|
76
77
|
Organizations,
|
|
77
78
|
Tasks,
|
|
78
|
-
Geometries
|
|
79
|
+
Geometries,
|
|
80
|
+
Password
|
|
79
81
|
};
|
package/jsdoc.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": {
|
|
3
|
+
"include": ["src/endpoints"],
|
|
4
|
+
"includePattern": ".js$",
|
|
5
|
+
"excludePattern": "(node_modules/|docs)"
|
|
6
|
+
},
|
|
7
|
+
"plugins": ["plugins/markdown"],
|
|
8
|
+
"templates": {
|
|
9
|
+
"cleverLinks": true,
|
|
10
|
+
"monospaceLinks": true
|
|
11
|
+
},
|
|
12
|
+
"opts": {
|
|
13
|
+
"recurse": true,
|
|
14
|
+
"destination": "./documentation/"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritree/services",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"description": "A collection of javascript functions/services to talk to veritree API",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"doc": "jsdoc -c jsdoc.json"
|
|
8
|
+
},
|
|
6
9
|
"main": "index.js",
|
|
7
10
|
"repository": "https://github.com/tentree-org/veritree-services.git",
|
|
8
11
|
"author": "cyroveritree <cyro@veritree.com>",
|
|
@@ -12,5 +15,8 @@
|
|
|
12
15
|
},
|
|
13
16
|
"dependencies": {
|
|
14
17
|
"np": "^7.6.2"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"jsdoc": "^4.0.2"
|
|
15
21
|
}
|
|
16
22
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Api from
|
|
1
|
+
import Api from "../helpers/api";
|
|
2
2
|
|
|
3
3
|
class OrganizationsApi extends Api {
|
|
4
4
|
constructor(resource) {
|
|
5
5
|
super(resource);
|
|
6
|
-
this.resource =
|
|
6
|
+
this.resource = "organizations";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
tasks(orgId) {
|
|
@@ -14,6 +14,12 @@ class OrganizationsApi extends Api {
|
|
|
14
14
|
return await this.get(url);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new task with the specified data.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} taskData - An object containing the data for the new task.
|
|
21
|
+
* @returns {Promise<Object>} - A Promise that resolves to the created task object.
|
|
22
|
+
*/
|
|
17
23
|
const create = async (data) => {
|
|
18
24
|
url = `${url}${this.getUrlParams()}`;
|
|
19
25
|
return await this.post(url, data);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Api from "../helpers/api";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a namespace that contains documentation elements
|
|
5
|
+
* belonging to the Password domain.
|
|
6
|
+
*
|
|
7
|
+
* @namespace Password
|
|
8
|
+
*/
|
|
9
|
+
class PasswordApi extends Api {
|
|
10
|
+
constructor(resource) {
|
|
11
|
+
super(resource);
|
|
12
|
+
this.resource = "password";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
recovery() {
|
|
16
|
+
/**
|
|
17
|
+
* Sends a recovery password email to the specified email address.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} data - An object containing the following properties:
|
|
20
|
+
* @param {string} data.email - The email address to send the recovery email to.
|
|
21
|
+
* @param {string} [data.return_url] - The URL to redirect the user to after they reset their password.
|
|
22
|
+
* @returns {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the email was sent successfully.
|
|
23
|
+
*/
|
|
24
|
+
const post = async (data) => {
|
|
25
|
+
const url = `${this.getUrl()}/email`;
|
|
26
|
+
|
|
27
|
+
return await this.post(url, data);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
post,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
reset() {
|
|
36
|
+
/**
|
|
37
|
+
* Sends a POST request to reset a password with the specified email, token, and password.
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} data - An object containing the following properties:
|
|
40
|
+
* @param {string} data.email - The email address of the user whose password is being reset.
|
|
41
|
+
* @param {string} data.token - The token associated with the password reset request.
|
|
42
|
+
* @param {string} data.password - The new password to set for the user.
|
|
43
|
+
* @param {string} data.password_confirmation - The new password confimation to set for the user.
|
|
44
|
+
* @returns {Promise<Object>} - A Promise that resolves to the result of the POST request.
|
|
45
|
+
*/
|
|
46
|
+
const post = async (data) => {
|
|
47
|
+
const url = `${this.getUrl()}/reset`
|
|
48
|
+
|
|
49
|
+
return await this.post(url, data);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
post,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Password = new PasswordApi();
|
package/src/helpers/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCookie } from "./cookies";
|
|
2
|
-
import { createParamsStringFromArgs } from "../utils/args";
|
|
3
2
|
import { getSession } from "./session";
|
|
3
|
+
import { createParamsStringFromArgs } from "../utils/args";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the runtime configuration object for Nuxt 3.
|
|
@@ -11,27 +11,27 @@ import { getSession } from "./session";
|
|
|
11
11
|
*
|
|
12
12
|
* @returns {Object|null} - The runtime configuration object, or null if it's not available.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
function getNuxtRuntimeConfig() {
|
|
15
|
+
if (typeof useRuntimeConfig === "function") {
|
|
16
|
+
return useRuntimeConfig();
|
|
17
|
+
} else {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getVersion() {
|
|
23
|
+
if (process) {
|
|
24
|
+
process?.env?.API_VERITREE_VERSION;
|
|
25
|
+
} else {
|
|
26
|
+
const nuxtRuntimeConfig = getNuxtRuntimeConfig();
|
|
27
|
+
|
|
28
|
+
if (nuxtRuntimeConfig) {
|
|
29
|
+
return nuxtRuntimeConfig.public.API_VERITREE_VERSION;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return "5.0.0";
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Adds a version parameter to a URL if it does not already have one.
|
|
@@ -53,7 +53,7 @@ function addVersionParam(url) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Use environment variable if available, otherwise use default version
|
|
56
|
-
const version =
|
|
56
|
+
const version = getVersion();
|
|
57
57
|
|
|
58
58
|
// Append version parameter to URL
|
|
59
59
|
const urlVersionParam = url.includes("?")
|
|
@@ -106,15 +106,13 @@ function getConfig(method, data, as) {
|
|
|
106
106
|
export default class Api {
|
|
107
107
|
constructor(resource) {
|
|
108
108
|
// Nuxt 3
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// this.baseUrl = url + "/api";
|
|
109
|
+
const nuxtConfig = getNuxtRuntimeConfig();
|
|
110
|
+
const url =
|
|
111
|
+
nuxtConfig?.public?.API_VERITREE_URL ||
|
|
112
|
+
process?.env?.API_VERITREE_URL ||
|
|
113
|
+
null;
|
|
116
114
|
|
|
117
|
-
this.baseUrl =
|
|
115
|
+
this.baseUrl = url ? `${url}/api` : null;
|
|
118
116
|
this.resource = resource ? resource : "";
|
|
119
117
|
this.orgId = null;
|
|
120
118
|
this.orgType = null;
|