@turtleclub/hooks 0.4.0-beta.1 → 0.4.0-beta.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/dist/index.cjs +12 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/lib/api-client.ts +11 -10
- package/src/v2/products/api.ts +9 -9
package/dist/index.cjs
CHANGED
|
@@ -4335,9 +4335,15 @@ var ApiError = class extends Error {
|
|
|
4335
4335
|
this.name = "ApiError";
|
|
4336
4336
|
}
|
|
4337
4337
|
};
|
|
4338
|
+
var getEarnUrl = () => {
|
|
4339
|
+
return process.env.NEXT_PUBLIC_EARN_URL || process.env.VITE_EARN_URL || EARN_BASE_URL;
|
|
4340
|
+
};
|
|
4341
|
+
var getApiUrl = () => {
|
|
4342
|
+
return process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || API_BASE_URL;
|
|
4343
|
+
};
|
|
4338
4344
|
async function apiClient(endpoint, options) {
|
|
4339
4345
|
const { debug, domain = "api", ...fetchOptions } = options ?? {};
|
|
4340
|
-
const baseUrl = domain === "earn" ?
|
|
4346
|
+
const baseUrl = domain === "earn" ? getEarnUrl() : getApiUrl();
|
|
4341
4347
|
const url = `${baseUrl}${endpoint}`;
|
|
4342
4348
|
if (debug) {
|
|
4343
4349
|
console.log("[API Request]", {
|
|
@@ -4378,11 +4384,7 @@ async function apiClient(endpoint, options) {
|
|
|
4378
4384
|
if (error instanceof ApiError) {
|
|
4379
4385
|
throw error;
|
|
4380
4386
|
}
|
|
4381
|
-
throw new ApiError(
|
|
4382
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
4383
|
-
0,
|
|
4384
|
-
error
|
|
4385
|
-
);
|
|
4387
|
+
throw new ApiError(error instanceof Error ? error.message : "Unknown error", 0, error);
|
|
4386
4388
|
}
|
|
4387
4389
|
}
|
|
4388
4390
|
|
|
@@ -4608,7 +4610,7 @@ var productUpdateInputSchema = productCreateInputSchema.extend({
|
|
|
4608
4610
|
async function getProducts(options) {
|
|
4609
4611
|
const params = new URLSearchParams();
|
|
4610
4612
|
const queryString = params.toString();
|
|
4611
|
-
const endpoint = `/
|
|
4613
|
+
const endpoint = `/admin/products${queryString ? `?${queryString}` : ""}`;
|
|
4612
4614
|
const data = await apiClient(endpoint, {
|
|
4613
4615
|
method: "GET",
|
|
4614
4616
|
debug: options?.debug
|
|
@@ -4621,7 +4623,7 @@ async function getProducts(options) {
|
|
|
4621
4623
|
return result.data;
|
|
4622
4624
|
}
|
|
4623
4625
|
async function createProduct(input, options) {
|
|
4624
|
-
const endpoint = `/
|
|
4626
|
+
const endpoint = `/admin/products`;
|
|
4625
4627
|
const data = await apiClient(endpoint, {
|
|
4626
4628
|
method: "POST",
|
|
4627
4629
|
body: JSON.stringify(input),
|
|
@@ -4638,7 +4640,7 @@ async function createProduct(input, options) {
|
|
|
4638
4640
|
return result.data;
|
|
4639
4641
|
}
|
|
4640
4642
|
async function updateProduct(input, options) {
|
|
4641
|
-
const endpoint = `/
|
|
4643
|
+
const endpoint = `/admin/products/${input.id}`;
|
|
4642
4644
|
const data = await apiClient(endpoint, {
|
|
4643
4645
|
method: "PUT",
|
|
4644
4646
|
body: JSON.stringify(input),
|
|
@@ -4655,7 +4657,7 @@ async function updateProduct(input, options) {
|
|
|
4655
4657
|
return result.data;
|
|
4656
4658
|
}
|
|
4657
4659
|
async function deleteProduct(id, options) {
|
|
4658
|
-
const endpoint = `/
|
|
4660
|
+
const endpoint = `/admin/products/${id}`;
|
|
4659
4661
|
const data = await apiClient(endpoint, {
|
|
4660
4662
|
method: "DELETE",
|
|
4661
4663
|
headers: {
|