@veritree/services 2.25.1 → 2.26.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/package.json +1 -1
- package/src/endpoints/subsites.js +2 -2
- package/src/helpers/api.js +42 -5
package/package.json
CHANGED
|
@@ -43,9 +43,9 @@ class SubsitesApi extends Api {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
stats(
|
|
46
|
+
stats(subsiteId, args) {
|
|
47
47
|
const all = async () => {
|
|
48
|
-
const url = `${this.getUrl()}/${
|
|
48
|
+
const url = `${this.getUrl()}/${subsiteId}/stats${this.getUrlParams(args)}`;
|
|
49
49
|
return await this.get(url);
|
|
50
50
|
};
|
|
51
51
|
|
package/src/helpers/api.js
CHANGED
|
@@ -2,6 +2,29 @@ import { getCookie } from "./cookies";
|
|
|
2
2
|
import { createParamsStringFromArgs } from "../utils/args";
|
|
3
3
|
import { getSession } from "./session";
|
|
4
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
|
+
return getNuxtRuntimeConfig()?.public?.API_VERITREE_VERSION ||
|
|
24
|
+
process?.env?.API_VERITREE_VERSION ||
|
|
25
|
+
"5.0.0";
|
|
26
|
+
}
|
|
27
|
+
|
|
5
28
|
/**
|
|
6
29
|
* Adds a version parameter to a URL if it does not already have one.
|
|
7
30
|
* If an environment variable called API_VERITREE_VERSION is defined, its value is used as the version,
|
|
@@ -22,7 +45,7 @@ function addVersionParam(url) {
|
|
|
22
45
|
}
|
|
23
46
|
|
|
24
47
|
// Use environment variable if available, otherwise use default version
|
|
25
|
-
const version =
|
|
48
|
+
const version = getVersion();
|
|
26
49
|
|
|
27
50
|
// Append version parameter to URL
|
|
28
51
|
const urlVersionParam = url.includes("?")
|
|
@@ -74,7 +97,13 @@ function getConfig(method, data, as) {
|
|
|
74
97
|
|
|
75
98
|
export default class Api {
|
|
76
99
|
constructor(resource) {
|
|
77
|
-
|
|
100
|
+
const nuxtConfig = getNuxtRuntimeConfig();
|
|
101
|
+
const url =
|
|
102
|
+
nuxtConfig?.public?.API_VERITREE_URL ||
|
|
103
|
+
process?.env?.API_VERITREE_URL ||
|
|
104
|
+
null;
|
|
105
|
+
|
|
106
|
+
this.baseUrl = url + "/api";
|
|
78
107
|
this.resource = resource ? resource : "";
|
|
79
108
|
this.orgId = null;
|
|
80
109
|
this.orgType = null;
|
|
@@ -200,9 +229,17 @@ export default class Api {
|
|
|
200
229
|
}
|
|
201
230
|
|
|
202
231
|
if (!isOrgLess && !isOrgAs) {
|
|
203
|
-
if (this.orgId)
|
|
204
|
-
|
|
205
|
-
|
|
232
|
+
if (this.orgId) {
|
|
233
|
+
orgIdParam = `org_id=${this.orgId}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this.orgType) {
|
|
237
|
+
orgTypeParam = `&org_type=${this.orgType}`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (args && args.orgType) {
|
|
241
|
+
orgTypeParam = `&org_type=${args.orgType}`;
|
|
242
|
+
}
|
|
206
243
|
}
|
|
207
244
|
|
|
208
245
|
return `?${orgIdParam}${orgTypeParam}${createParamsStringFromArgs(args)}`;
|