@carlonicora/nextjs-jsonapi 1.117.1 → 1.119.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/dist/{BlockNoteEditor-CEWZCORH.js → BlockNoteEditor-BPACLNMB.js} +20 -20
- package/dist/{BlockNoteEditor-CEWZCORH.js.map → BlockNoteEditor-BPACLNMB.js.map} +1 -1
- package/dist/{BlockNoteEditor-K4T6QOJO.mjs → BlockNoteEditor-CEDKBT67.mjs} +5 -5
- package/dist/JsonApiRequest-HE5LTEYK.js +26 -0
- package/dist/JsonApiRequest-HE5LTEYK.js.map +1 -0
- package/dist/{JsonApiRequest-IYL5RZ7I.mjs → JsonApiRequest-SN3DNFDR.mjs} +4 -2
- package/dist/billing/index.js +347 -347
- package/dist/billing/index.mjs +4 -4
- package/dist/{chunk-6D4GJHLK.mjs → chunk-4SPL6QH3.mjs} +277 -154
- package/dist/chunk-4SPL6QH3.mjs.map +1 -0
- package/dist/{chunk-6KLR3WJQ.js → chunk-55Q43DI5.js} +9 -9
- package/dist/{chunk-6KLR3WJQ.js.map → chunk-55Q43DI5.js.map} +1 -1
- package/dist/{chunk-WEPQD5MP.mjs → chunk-5U7QDGDQ.mjs} +3 -3
- package/dist/{chunk-S2PTWBN6.js → chunk-6P7MEU7Q.js} +64 -50
- package/dist/chunk-6P7MEU7Q.js.map +1 -0
- package/dist/{chunk-56QAXZKI.js → chunk-DXTOA7OO.js} +932 -809
- package/dist/chunk-DXTOA7OO.js.map +1 -0
- package/dist/{chunk-M7XAKLSP.mjs → chunk-FWOS6PC5.mjs} +38 -24
- package/dist/chunk-FWOS6PC5.mjs.map +1 -0
- package/dist/{chunk-J5LROFGL.js → chunk-RCMIVTVL.js} +14 -11
- package/dist/chunk-RCMIVTVL.js.map +1 -0
- package/dist/{chunk-KK7PYKVI.mjs → chunk-WC2BTKJP.mjs} +13 -10
- package/dist/{chunk-KK7PYKVI.mjs.map → chunk-WC2BTKJP.mjs.map} +1 -1
- package/dist/client/index.d.mts +15 -1
- package/dist/client/index.d.ts +15 -1
- package/dist/client/index.js +7 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +6 -4
- package/dist/components/index.d.mts +72 -30
- package/dist/components/index.d.ts +72 -30
- package/dist/components/index.js +7 -5
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -4
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.d.mts +7 -2
- package/dist/core/index.d.ts +7 -2
- package/dist/core/index.js +3 -3
- package/dist/core/index.mjs +2 -2
- package/dist/features/help/index.js +37 -37
- package/dist/features/help/index.mjs +4 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/{s3.service-CihgBy97.d.mts → s3.service-CBqyDZyz.d.mts} +7 -0
- package/dist/{s3.service-Cyvfk3qV.d.ts → s3.service-gcEjq8gF.d.ts} +7 -0
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +12 -12
- package/dist/server/index.mjs +2 -2
- package/package.json +1 -1
- package/src/client/JsonApiClient.ts +23 -8
- package/src/client/__tests__/JsonApiClient.test.ts +31 -0
- package/src/components/containers/RoundPageContainer.tsx +197 -76
- package/src/components/containers/TabsContainer.tsx +14 -0
- package/src/components/containers/__tests__/partitionTabs.spec.ts +51 -0
- package/src/components/containers/index.ts +1 -0
- package/src/components/containers/partitionTabs.ts +43 -0
- package/src/components/forms/EditorSheet.tsx +7 -2
- package/src/core/abstracts/AbstractService.ts +13 -0
- package/src/core/abstracts/ClientAbstractService.ts +10 -0
- package/src/unified/JsonApiRequest.ts +22 -8
- package/src/unified/__tests__/JsonApiRequest.test.ts +29 -0
- package/dist/JsonApiRequest-OSGJ63XR.js +0 -24
- package/dist/JsonApiRequest-OSGJ63XR.js.map +0 -1
- package/dist/chunk-56QAXZKI.js.map +0 -1
- package/dist/chunk-6D4GJHLK.mjs.map +0 -1
- package/dist/chunk-J5LROFGL.js.map +0 -1
- package/dist/chunk-M7XAKLSP.mjs.map +0 -1
- package/dist/chunk-S2PTWBN6.js.map +0 -1
- /package/dist/{BlockNoteEditor-K4T6QOJO.mjs.map → BlockNoteEditor-CEDKBT67.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-IYL5RZ7I.mjs.map → JsonApiRequest-SN3DNFDR.mjs.map} +0 -0
- /package/dist/{chunk-WEPQD5MP.mjs.map → chunk-5U7QDGDQ.mjs.map} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { partitionTabs } from "../partitionTabs";
|
|
3
|
+
import type { Tab } from "../TabsContainer";
|
|
4
|
+
|
|
5
|
+
const tab = (label: string, group?: string): Tab => ({
|
|
6
|
+
label,
|
|
7
|
+
content: null,
|
|
8
|
+
group,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe("partitionTabs", () => {
|
|
12
|
+
it("returns empty partition for empty input", () => {
|
|
13
|
+
expect(partitionTabs([])).toEqual({ ungrouped: [], groups: [] });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("keeps tabs without a group in the ungrouped stratum, in declared order", () => {
|
|
17
|
+
const result = partitionTabs([tab("a"), tab("b"), tab("c")]);
|
|
18
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["a", "b", "c"]);
|
|
19
|
+
expect(result.groups).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("clusters tabs by group label", () => {
|
|
23
|
+
const result = partitionTabs([tab("a", "Casebook"), tab("b", "Casebook"), tab("c", "Work")]);
|
|
24
|
+
expect(result.ungrouped).toEqual([]);
|
|
25
|
+
expect(result.groups).toEqual([
|
|
26
|
+
{ label: "Casebook", items: [expect.objectContaining({ label: "a" }), expect.objectContaining({ label: "b" })] },
|
|
27
|
+
{ label: "Work", items: [expect.objectContaining({ label: "c" })] },
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("renders groups in the order they first appear", () => {
|
|
32
|
+
const result = partitionTabs([tab("a", "Work"), tab("b", "Casebook"), tab("c", "Work"), tab("d", "Casebook")]);
|
|
33
|
+
expect(result.groups.map((g) => g.label)).toEqual(["Work", "Casebook"]);
|
|
34
|
+
expect(result.groups[0].items.map((t) => t.label)).toEqual(["a", "c"]);
|
|
35
|
+
expect(result.groups[1].items.map((t) => t.label)).toEqual(["b", "d"]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("preserves ungrouped tabs above grouped tabs regardless of array order", () => {
|
|
39
|
+
const result = partitionTabs([tab("one", "Work"), tab("two"), tab("three", "Work"), tab("four")]);
|
|
40
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["two", "four"]);
|
|
41
|
+
expect(result.groups).toHaveLength(1);
|
|
42
|
+
expect(result.groups[0].items.map((t) => t.label)).toEqual(["one", "three"]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("treats an empty-string group as 'no group'", () => {
|
|
46
|
+
const result = partitionTabs([tab("a", ""), tab("b", "Work")]);
|
|
47
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["a"]);
|
|
48
|
+
expect(result.groups).toHaveLength(1);
|
|
49
|
+
expect(result.groups[0].label).toBe("Work");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Tab } from "./TabsContainer";
|
|
2
|
+
|
|
3
|
+
export type PartitionedTabs = {
|
|
4
|
+
ungrouped: Tab[];
|
|
5
|
+
groups: Array<{ label: string; items: Tab[] }>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Split a `Tab[]` into ungrouped + grouped strata for the
|
|
10
|
+
* `RoundPageContainer` `layout="rail"` navigation.
|
|
11
|
+
*
|
|
12
|
+
* Tabs without a `group` land in `ungrouped` (the pinned stratum) in declared
|
|
13
|
+
* order. Grouped tabs cluster under their `group` label; groups appear in the
|
|
14
|
+
* order they first occur in the input array.
|
|
15
|
+
*
|
|
16
|
+
* Pure function — safe to call on every render. Complexity O(n).
|
|
17
|
+
*/
|
|
18
|
+
export function partitionTabs(tabs: Tab[]): PartitionedTabs {
|
|
19
|
+
const ungrouped: Tab[] = [];
|
|
20
|
+
const groupMap = new Map<string, Tab[]>();
|
|
21
|
+
const groupOrder: string[] = [];
|
|
22
|
+
|
|
23
|
+
for (const tab of tabs) {
|
|
24
|
+
if (!tab.group) {
|
|
25
|
+
ungrouped.push(tab);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!groupMap.has(tab.group)) {
|
|
29
|
+
groupMap.set(tab.group, []);
|
|
30
|
+
groupOrder.push(tab.group);
|
|
31
|
+
}
|
|
32
|
+
// The map entry is guaranteed to exist because we just initialized it.
|
|
33
|
+
groupMap.get(tab.group)!.push(tab);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
ungrouped,
|
|
38
|
+
groups: groupOrder.map((label) => ({
|
|
39
|
+
label,
|
|
40
|
+
items: groupMap.get(label)!,
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useTranslations } from "next-intl";
|
|
4
|
-
import { ReactNode, useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { ReactElement, ReactNode, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { FieldValues, UseFormReturn } from "react-hook-form";
|
|
6
6
|
import { PencilIcon } from "lucide-react";
|
|
7
7
|
import { ModuleWithPermissions } from "../../permissions/types";
|
|
@@ -161,7 +161,12 @@ export function EditorSheet<T extends FieldValues>({
|
|
|
161
161
|
{dialogOpen === undefined &&
|
|
162
162
|
forceShow === undefined &&
|
|
163
163
|
(trigger ? (
|
|
164
|
-
<
|
|
164
|
+
// Base UI: the trigger renders its own <button>. Pass the caller's
|
|
165
|
+
// element via `render` (NOT as children) so it BECOMES the trigger
|
|
166
|
+
// button — otherwise an interactive trigger (e.g. <Button>) nests a
|
|
167
|
+
// <button> inside SheetTrigger's <button> (invalid HTML / hydration
|
|
168
|
+
// error). `render` also preserves the element's native `disabled`.
|
|
169
|
+
<SheetTrigger render={trigger as ReactElement} />
|
|
165
170
|
) : (
|
|
166
171
|
<SheetTrigger>
|
|
167
172
|
{isEdit ? (
|
|
@@ -147,6 +147,12 @@ export abstract class AbstractService {
|
|
|
147
147
|
files?: { [key: string]: File | Blob } | File | Blob;
|
|
148
148
|
token?: string;
|
|
149
149
|
suppressGlobalError?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Per-call override of the API base URL. When omitted, the existing global
|
|
152
|
+
* `NEXT_PUBLIC_API_URL` (or `configureJsonApi({ apiUrl })`) resolution is used —
|
|
153
|
+
* fully backward compatible. Ignored when `endpoint` starts with "http" (passthrough).
|
|
154
|
+
*/
|
|
155
|
+
baseUrl?: string;
|
|
150
156
|
}): Promise<T> {
|
|
151
157
|
// Dynamic import to avoid bundling issues
|
|
152
158
|
const { JsonApiGet, JsonApiPost, JsonApiPut, JsonApiPatch, JsonApiDelete } =
|
|
@@ -171,6 +177,7 @@ export abstract class AbstractService {
|
|
|
171
177
|
endpoint: params.endpoint,
|
|
172
178
|
companyId: params.companyId,
|
|
173
179
|
language: language,
|
|
180
|
+
baseUrl: params.baseUrl,
|
|
174
181
|
});
|
|
175
182
|
break;
|
|
176
183
|
case HttpMethod.POST:
|
|
@@ -184,6 +191,7 @@ export abstract class AbstractService {
|
|
|
184
191
|
responseType: params.responseType,
|
|
185
192
|
files: params.files,
|
|
186
193
|
token: params.token,
|
|
194
|
+
baseUrl: params.baseUrl,
|
|
187
195
|
});
|
|
188
196
|
break;
|
|
189
197
|
case HttpMethod.PUT:
|
|
@@ -195,6 +203,7 @@ export abstract class AbstractService {
|
|
|
195
203
|
language: language,
|
|
196
204
|
responseType: params.responseType,
|
|
197
205
|
files: params.files,
|
|
206
|
+
baseUrl: params.baseUrl,
|
|
198
207
|
});
|
|
199
208
|
break;
|
|
200
209
|
case HttpMethod.PATCH:
|
|
@@ -207,6 +216,7 @@ export abstract class AbstractService {
|
|
|
207
216
|
language: language,
|
|
208
217
|
responseType: params.responseType,
|
|
209
218
|
files: params.files,
|
|
219
|
+
baseUrl: params.baseUrl,
|
|
210
220
|
});
|
|
211
221
|
break;
|
|
212
222
|
case HttpMethod.DELETE:
|
|
@@ -216,6 +226,7 @@ export abstract class AbstractService {
|
|
|
216
226
|
companyId: params.companyId,
|
|
217
227
|
language: language,
|
|
218
228
|
responseType: params.responseType,
|
|
229
|
+
baseUrl: params.baseUrl,
|
|
219
230
|
});
|
|
220
231
|
break;
|
|
221
232
|
default:
|
|
@@ -359,6 +370,7 @@ export abstract class AbstractService {
|
|
|
359
370
|
method: HttpMethod;
|
|
360
371
|
endpoint: string;
|
|
361
372
|
companyId?: string;
|
|
373
|
+
baseUrl?: string;
|
|
362
374
|
suppressGlobalError?: boolean;
|
|
363
375
|
}): Promise<any> {
|
|
364
376
|
const { JsonApiGet } = await import("../../unified/JsonApiRequest");
|
|
@@ -377,6 +389,7 @@ export abstract class AbstractService {
|
|
|
377
389
|
classKey: params.type,
|
|
378
390
|
endpoint: params.endpoint,
|
|
379
391
|
companyId: params.companyId,
|
|
392
|
+
baseUrl: params.baseUrl,
|
|
380
393
|
language: language,
|
|
381
394
|
});
|
|
382
395
|
|
|
@@ -147,6 +147,11 @@ export abstract class ClientAbstractService {
|
|
|
147
147
|
total?: ClientTotalRef;
|
|
148
148
|
responseType?: ApiRequestDataTypeInterface;
|
|
149
149
|
files?: { [key: string]: File | Blob } | File | Blob;
|
|
150
|
+
/**
|
|
151
|
+
* Per-call override of the API base URL (mirrors `AbstractService.callApi`'s `baseUrl`).
|
|
152
|
+
* Omitted => existing global `NEXT_PUBLIC_API_URL` resolution, unchanged.
|
|
153
|
+
*/
|
|
154
|
+
baseUrl?: string;
|
|
150
155
|
}): Promise<T> {
|
|
151
156
|
let apiResponse: ApiResponseInterface;
|
|
152
157
|
|
|
@@ -160,6 +165,7 @@ export abstract class ClientAbstractService {
|
|
|
160
165
|
endpoint: params.endpoint,
|
|
161
166
|
companyId: params.companyId,
|
|
162
167
|
language: language,
|
|
168
|
+
baseUrl: params.baseUrl,
|
|
163
169
|
});
|
|
164
170
|
break;
|
|
165
171
|
case ClientHttpMethod.POST:
|
|
@@ -172,6 +178,7 @@ export abstract class ClientAbstractService {
|
|
|
172
178
|
language: language,
|
|
173
179
|
responseType: params.responseType,
|
|
174
180
|
files: params.files,
|
|
181
|
+
baseUrl: params.baseUrl,
|
|
175
182
|
});
|
|
176
183
|
break;
|
|
177
184
|
case ClientHttpMethod.PUT:
|
|
@@ -183,6 +190,7 @@ export abstract class ClientAbstractService {
|
|
|
183
190
|
language: language,
|
|
184
191
|
responseType: params.responseType,
|
|
185
192
|
files: params.files,
|
|
193
|
+
baseUrl: params.baseUrl,
|
|
186
194
|
});
|
|
187
195
|
break;
|
|
188
196
|
case ClientHttpMethod.PATCH:
|
|
@@ -195,6 +203,7 @@ export abstract class ClientAbstractService {
|
|
|
195
203
|
language: language,
|
|
196
204
|
responseType: params.responseType,
|
|
197
205
|
files: params.files,
|
|
206
|
+
baseUrl: params.baseUrl,
|
|
198
207
|
});
|
|
199
208
|
break;
|
|
200
209
|
case ClientHttpMethod.DELETE:
|
|
@@ -204,6 +213,7 @@ export abstract class ClientAbstractService {
|
|
|
204
213
|
companyId: params.companyId,
|
|
205
214
|
language: language,
|
|
206
215
|
responseType: params.responseType,
|
|
216
|
+
baseUrl: params.baseUrl,
|
|
207
217
|
});
|
|
208
218
|
break;
|
|
209
219
|
default:
|
|
@@ -167,9 +167,17 @@ function runBootstrapper(): void {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Resolve the final request URL for an endpoint.
|
|
172
|
+
*
|
|
173
|
+
* - `endpoint` starting with "http" is always passed through unchanged (existing behaviour).
|
|
174
|
+
* - Otherwise, an explicit `baseUrl` (per-call override) takes precedence over the global
|
|
175
|
+
* `getApiUrl()` resolution. Omitting `baseUrl` preserves today's behaviour exactly.
|
|
176
|
+
*/
|
|
177
|
+
export function buildUrl(endpoint: string, baseUrl?: string): string {
|
|
178
|
+
if (endpoint.startsWith("http")) return endpoint;
|
|
179
|
+
const apiUrl = baseUrl ?? getApiUrl();
|
|
180
|
+
return `${apiUrl}${endpoint}`;
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
export async function JsonApiGet(params: {
|
|
@@ -177,13 +185,14 @@ export async function JsonApiGet(params: {
|
|
|
177
185
|
endpoint: string;
|
|
178
186
|
companyId?: string;
|
|
179
187
|
language: string;
|
|
188
|
+
baseUrl?: string;
|
|
180
189
|
}): Promise<ApiResponseInterface> {
|
|
181
190
|
runBootstrapper();
|
|
182
191
|
const token = await getToken();
|
|
183
192
|
|
|
184
193
|
const apiResponse = await makeRequest({
|
|
185
194
|
method: "GET",
|
|
186
|
-
url: buildUrl(params.endpoint),
|
|
195
|
+
url: buildUrl(params.endpoint, params.baseUrl),
|
|
187
196
|
token,
|
|
188
197
|
cache: params.classKey.cache,
|
|
189
198
|
companyId: params.companyId,
|
|
@@ -202,6 +211,7 @@ export async function JsonApiGet(params: {
|
|
|
202
211
|
endpoint,
|
|
203
212
|
companyId: params.companyId,
|
|
204
213
|
language: params.language,
|
|
214
|
+
baseUrl: params.baseUrl,
|
|
205
215
|
}),
|
|
206
216
|
});
|
|
207
217
|
}
|
|
@@ -216,6 +226,7 @@ export async function JsonApiPost(params: {
|
|
|
216
226
|
language: string;
|
|
217
227
|
responseType?: ApiRequestDataTypeInterface;
|
|
218
228
|
token?: string;
|
|
229
|
+
baseUrl?: string;
|
|
219
230
|
}): Promise<ApiResponseInterface> {
|
|
220
231
|
runBootstrapper();
|
|
221
232
|
const token = params.token ?? (await getToken());
|
|
@@ -229,7 +240,7 @@ export async function JsonApiPost(params: {
|
|
|
229
240
|
|
|
230
241
|
const apiResponse = await makeRequest({
|
|
231
242
|
method: "POST",
|
|
232
|
-
url: buildUrl(params.endpoint),
|
|
243
|
+
url: buildUrl(params.endpoint, params.baseUrl),
|
|
233
244
|
token,
|
|
234
245
|
body,
|
|
235
246
|
files: params.files,
|
|
@@ -254,6 +265,7 @@ export async function JsonApiPut(params: {
|
|
|
254
265
|
files?: { [key: string]: File | Blob } | File | Blob;
|
|
255
266
|
language: string;
|
|
256
267
|
responseType?: ApiRequestDataTypeInterface;
|
|
268
|
+
baseUrl?: string;
|
|
257
269
|
}): Promise<ApiResponseInterface> {
|
|
258
270
|
runBootstrapper();
|
|
259
271
|
const token = await getToken();
|
|
@@ -267,7 +279,7 @@ export async function JsonApiPut(params: {
|
|
|
267
279
|
|
|
268
280
|
const apiResponse = await makeRequest({
|
|
269
281
|
method: "PUT",
|
|
270
|
-
url: buildUrl(params.endpoint),
|
|
282
|
+
url: buildUrl(params.endpoint, params.baseUrl),
|
|
271
283
|
token,
|
|
272
284
|
body,
|
|
273
285
|
files: params.files,
|
|
@@ -293,6 +305,7 @@ export async function JsonApiPatch(params: {
|
|
|
293
305
|
overridesJsonApiCreation?: boolean;
|
|
294
306
|
responseType?: ApiRequestDataTypeInterface;
|
|
295
307
|
language: string;
|
|
308
|
+
baseUrl?: string;
|
|
296
309
|
}): Promise<ApiResponseInterface> {
|
|
297
310
|
runBootstrapper();
|
|
298
311
|
const token = await getToken();
|
|
@@ -306,7 +319,7 @@ export async function JsonApiPatch(params: {
|
|
|
306
319
|
|
|
307
320
|
const apiResponse = await makeRequest({
|
|
308
321
|
method: "PATCH",
|
|
309
|
-
url: buildUrl(params.endpoint),
|
|
322
|
+
url: buildUrl(params.endpoint, params.baseUrl),
|
|
310
323
|
token,
|
|
311
324
|
body,
|
|
312
325
|
files: params.files,
|
|
@@ -329,13 +342,14 @@ export async function JsonApiDelete(params: {
|
|
|
329
342
|
companyId?: string;
|
|
330
343
|
language: string;
|
|
331
344
|
responseType?: ApiRequestDataTypeInterface;
|
|
345
|
+
baseUrl?: string;
|
|
332
346
|
}): Promise<ApiResponseInterface> {
|
|
333
347
|
runBootstrapper();
|
|
334
348
|
const token = await getToken();
|
|
335
349
|
|
|
336
350
|
const apiResponse = await makeRequest({
|
|
337
351
|
method: "DELETE",
|
|
338
|
-
url: buildUrl(params.endpoint),
|
|
352
|
+
url: buildUrl(params.endpoint, params.baseUrl),
|
|
339
353
|
token,
|
|
340
354
|
companyId: params.companyId,
|
|
341
355
|
language: params.language,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { buildUrl } from "../JsonApiRequest";
|
|
3
|
+
|
|
4
|
+
describe("buildUrl", () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
vi.unstubAllEnvs();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("uses NEXT_PUBLIC_API_URL when baseUrl is omitted", () => {
|
|
10
|
+
vi.stubEnv("NEXT_PUBLIC_API_URL", "https://api.example.com");
|
|
11
|
+
|
|
12
|
+
expect(buildUrl("/sncass/sync")).toBe("https://api.example.com/sncass/sync");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("uses the per-call baseUrl override when provided", () => {
|
|
16
|
+
vi.stubEnv("NEXT_PUBLIC_API_URL", "https://api.example.com");
|
|
17
|
+
|
|
18
|
+
expect(buildUrl("/sncass/sync", "https://corpus.example.com")).toBe("https://corpus.example.com/sncass/sync");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("passes through an http-prefixed endpoint regardless of baseUrl", () => {
|
|
22
|
+
vi.stubEnv("NEXT_PUBLIC_API_URL", "https://api.example.com");
|
|
23
|
+
|
|
24
|
+
expect(buildUrl("https://elsewhere.example.com/sncass/sync", "https://corpus.example.com")).toBe(
|
|
25
|
+
"https://elsewhere.example.com/sncass/sync",
|
|
26
|
+
);
|
|
27
|
+
expect(buildUrl("https://elsewhere.example.com/sncass/sync")).toBe("https://elsewhere.example.com/sncass/sync");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkJ5LROFGLjs = require('./chunk-J5LROFGL.js');
|
|
12
|
-
require('./chunk-7QVYU63E.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.JsonApiDelete = _chunkJ5LROFGLjs.JsonApiDelete; exports.JsonApiGet = _chunkJ5LROFGLjs.JsonApiGet; exports.JsonApiPatch = _chunkJ5LROFGLjs.JsonApiPatch; exports.JsonApiPost = _chunkJ5LROFGLjs.JsonApiPost; exports.JsonApiPut = _chunkJ5LROFGLjs.JsonApiPut; exports.configureJsonApi = _chunkJ5LROFGLjs.configureJsonApi; exports.getApiUrl = _chunkJ5LROFGLjs.getApiUrl; exports.getAppUrl = _chunkJ5LROFGLjs.getAppUrl; exports.getTrackablePages = _chunkJ5LROFGLjs.getTrackablePages;
|
|
24
|
-
//# sourceMappingURL=JsonApiRequest-OSGJ63XR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/JsonApiRequest-OSGJ63XR.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,meAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/JsonApiRequest-OSGJ63XR.js"}
|