@veritree/services 2.30.1-1 → 2.30.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "2.30.1-1",
3
+ "version": "2.30.2",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -12,6 +12,5 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "np": "^7.6.2"
15
- },
16
- "devDependencies": {}
15
+ }
17
16
  }
@@ -1,9 +1,9 @@
1
- import Api from "../helpers/api";
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 = "organizations";
6
+ this.resource = 'organizations';
7
7
  }
8
8
 
9
9
  tasks(orgId) {
@@ -14,12 +14,6 @@ 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
- */
23
17
  const create = async (data) => {
24
18
  url = `${url}${this.getUrlParams()}`;
25
19
  return await this.post(url, data);
@@ -17,8 +17,8 @@ class PasswordApi extends Api {
17
17
  * Sends a recovery password email to the specified email address.
18
18
  *
19
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.
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
22
  * @returns {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the email was sent successfully.
23
23
  */
24
24
  const post = async (data) => {
@@ -75,6 +75,36 @@ class PlantingSitesApi extends Api {
75
75
  all,
76
76
  };
77
77
  }
78
+
79
+ evidence(subsiteId, params) {
80
+ let url = `${this.getUrl()}/${subsiteId}/evidence`;
81
+
82
+ console.log(url);
83
+
84
+ const all = async () => {
85
+ url = `${url}${this.getUrlParams(params)}`;
86
+ return await this.get(url);
87
+ };
88
+
89
+ const attach = async (formData) => {
90
+ url = `${url}${this.getUrlParams(params)}`;
91
+ return await this.post(url, formData);
92
+ };
93
+
94
+ const remove = async (evidenceType, evidenceId) => {
95
+ url = `${url}/${evidenceType}/${evidenceId}${this.getUrlParams(
96
+ params
97
+ )}`;
98
+
99
+ return await this.post(url, null, "delete");
100
+ };
101
+
102
+ return {
103
+ all,
104
+ attach,
105
+ delete: remove,
106
+ };
107
+ }
78
108
  }
79
109
 
80
110
  export const PlantingSites = new PlantingSitesApi();
@@ -1,7 +1,46 @@
1
1
  import { getCookie } from "./cookies";
2
- import { getSession } from "./session";
3
2
  import { createParamsStringFromArgs } from "../utils/args";
3
+ import { getSession } from "./session";
4
+
5
+ /**
6
+ * Returns the runtime configuration object for Nuxt 3.
7
+ *
8
+ * Note:
9
+ * This function should only be used with Nuxt 3.
10
+ * For Nuxt 2, the environment variables will work as expected.
11
+ *
12
+ * @returns {Object|null} - The runtime configuration object, or null if it's not available.
13
+ */
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
+ // }
4
35
 
36
+ /**
37
+ * Adds a version parameter to a URL if it does not already have one.
38
+ * If an environment variable called API_VERITREE_VERSION is defined, its value is used as the version,
39
+ * otherwise the default version "5.0.0" is used.
40
+ *
41
+ * @param {string} url - The URL to modify.
42
+ * @returns {string} The modified URL with the version parameter appended to it.
43
+ */
5
44
  function addVersionParam(url) {
6
45
  // If URL is invalid or already has the result parameter, return it as is
7
46
  if (!url || url.includes("_result=1")) {
@@ -13,7 +52,8 @@ function addVersionParam(url) {
13
52
  return url;
14
53
  }
15
54
 
16
- const version = '10.0.0';
55
+ // Use environment variable if available, otherwise use default version
56
+ const version = process.env.API_VERITREE_VERSION || "5.0.0";
17
57
 
18
58
  // Append version parameter to URL
19
59
  const urlVersionParam = url.includes("?")
@@ -65,7 +105,16 @@ function getConfig(method, data, as) {
65
105
 
66
106
  export default class Api {
67
107
  constructor(resource) {
68
- this.baseUrl = null;
108
+ // Nuxt 3
109
+ // const nuxtConfig = getNuxtRuntimeConfig();
110
+ // const url =
111
+ // nuxtConfig?.public?.API_VERITREE_URL ||
112
+ // process?.env?.API_VERITREE_URL ||
113
+ // null;
114
+
115
+ // this.baseUrl = url + "/api";
116
+
117
+ this.baseUrl = process.env ? `${process.env.API_VERITREE_URL}/api` : null;
69
118
  this.resource = resource ? resource : "";
70
119
  this.orgId = null;
71
120
  this.orgType = null;
package/jsdoc.json DELETED
@@ -1,16 +0,0 @@
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
- }