@enfyra/sdk-nuxt 0.3.14 → 0.3.16
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/composables/useEnfyraApi.d.ts +7 -11
- package/dist/composables/useEnfyraApi.d.ts.map +1 -0
- package/dist/composables/useEnfyraApi.js +363 -0
- package/dist/composables/useEnfyraApi.mjs +6 -1
- package/dist/composables/useEnfyraAuth.d.ts +87 -7
- package/dist/composables/useEnfyraAuth.d.ts.map +1 -0
- package/dist/composables/useEnfyraAuth.js +77 -0
- package/dist/constants/config.d.ts +2 -5
- package/dist/constants/config.d.ts.map +1 -0
- package/dist/constants/config.js +1 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.cts +5 -6
- package/dist/module.d.mts +5 -6
- package/dist/module.d.ts +5 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/http.d.ts +8 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +57 -0
- package/dist/utils/url.d.ts +12 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +77 -0
- package/index.ts +3 -0
- package/module.d.ts +14 -0
- package/package.json +21 -6
- package/src/composables/useEnfyraApi.ts +8 -1
- package/src/module.ts +12 -1
- package/src/types/nuxt-imports.d.ts +17 -0
- package/dist/auth.d.ts.map +0 -1
- package/dist/composables.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- /package/dist/{auth.d.ts → types/auth.d.ts} +0 -0
- /package/dist/{auth.js → types/auth.js} +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{index.js → types/index.js} +0 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { ApiOptions, UseEnfyraApiSSRReturn, UseEnfyraApiClientReturn } from "../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
):
|
|
8
|
-
|
|
9
|
-
export declare function useEnfyraApi<T = any>(
|
|
10
|
-
path: (() => string) | string,
|
|
11
|
-
opts?: ApiOptions<T> & { ssr?: false | undefined }
|
|
12
|
-
): UseEnfyraApiClientReturn<T>;
|
|
2
|
+
export declare function useEnfyraApi<T = any>(path: (() => string) | string, opts: ApiOptions<T> & {
|
|
3
|
+
ssr: true;
|
|
4
|
+
}): UseEnfyraApiSSRReturn<T>;
|
|
5
|
+
export declare function useEnfyraApi<T = any>(path: (() => string) | string, opts?: ApiOptions<T> & {
|
|
6
|
+
ssr?: false | undefined;
|
|
7
|
+
}): UseEnfyraApiClientReturn<T>;
|
|
8
|
+
//# sourceMappingURL=useEnfyraApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnfyraApi.d.ts","sourceRoot":"","sources":["../../src/composables/useEnfyraApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAGV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,UAAU,CAAC;AA4BlB,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAClC,IAAI,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EAC7B,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GAClC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAE5B,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAClC,IAAI,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EAC7B,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,GACjD,wBAAwB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { ref, unref, toRaw } from "vue";
|
|
2
|
+
import { $fetch } from "../utils/http";
|
|
3
|
+
import { getAppUrl, normalizeUrl } from "../utils/url";
|
|
4
|
+
import { ENFYRA_API_PREFIX } from "../constants/config";
|
|
5
|
+
import { useRuntimeConfig, useFetch, useRequestHeaders, useNuxtApp } from "#imports";
|
|
6
|
+
function handleError(error, context, customHandler) {
|
|
7
|
+
const apiError = {
|
|
8
|
+
message: error?.message || error?.data?.message || "Request failed",
|
|
9
|
+
status: error?.status || error?.response?.status,
|
|
10
|
+
data: error?.data || error?.response?.data,
|
|
11
|
+
response: error?.response || error,
|
|
12
|
+
};
|
|
13
|
+
if (customHandler) {
|
|
14
|
+
customHandler(apiError, context);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
console.error(`[Enfyra API Error]`, { error: apiError, context });
|
|
18
|
+
}
|
|
19
|
+
return apiError;
|
|
20
|
+
}
|
|
21
|
+
export function useEnfyraApi(path, opts = {}) {
|
|
22
|
+
const { method = "get", body, query, errorContext, onError, ssr, key } = opts;
|
|
23
|
+
const batchOptions = opts;
|
|
24
|
+
const { batchSize, concurrent, onProgress } = batchOptions;
|
|
25
|
+
if (ssr) {
|
|
26
|
+
const config = useRuntimeConfig().public.enfyraSDK;
|
|
27
|
+
const basePath = (typeof path === "function" ? path() : path)
|
|
28
|
+
.replace(/^\/?api\/?/, "")
|
|
29
|
+
.replace(/^\/+/, "");
|
|
30
|
+
const appUrl = getAppUrl();
|
|
31
|
+
const finalUrl = normalizeUrl(appUrl, config?.apiPrefix || ENFYRA_API_PREFIX, basePath);
|
|
32
|
+
const clientHeaders = process.client
|
|
33
|
+
? {}
|
|
34
|
+
: useRequestHeaders([
|
|
35
|
+
"authorization",
|
|
36
|
+
"cookie",
|
|
37
|
+
"user-agent",
|
|
38
|
+
"accept",
|
|
39
|
+
"accept-language",
|
|
40
|
+
"referer",
|
|
41
|
+
]);
|
|
42
|
+
const serverHeaders = { ...clientHeaders };
|
|
43
|
+
delete serverHeaders.connection;
|
|
44
|
+
delete serverHeaders["keep-alive"];
|
|
45
|
+
delete serverHeaders.host;
|
|
46
|
+
delete serverHeaders["content-length"];
|
|
47
|
+
const nuxtApp = useNuxtApp();
|
|
48
|
+
const fetchOptions = {
|
|
49
|
+
method: method,
|
|
50
|
+
body: body,
|
|
51
|
+
query: query,
|
|
52
|
+
headers: {
|
|
53
|
+
...serverHeaders,
|
|
54
|
+
...opts.headers,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
// Pass all useFetch-specific options
|
|
58
|
+
if (key !== undefined) {
|
|
59
|
+
fetchOptions.key = key;
|
|
60
|
+
}
|
|
61
|
+
if (opts.default !== undefined) {
|
|
62
|
+
fetchOptions.default = opts.default;
|
|
63
|
+
}
|
|
64
|
+
if (opts.server !== undefined) {
|
|
65
|
+
fetchOptions.server = opts.server;
|
|
66
|
+
}
|
|
67
|
+
if (opts.lazy !== undefined) {
|
|
68
|
+
fetchOptions.lazy = opts.lazy;
|
|
69
|
+
}
|
|
70
|
+
if (opts.immediate !== undefined) {
|
|
71
|
+
fetchOptions.immediate = opts.immediate;
|
|
72
|
+
}
|
|
73
|
+
if (opts.transform !== undefined) {
|
|
74
|
+
fetchOptions.transform = opts.transform;
|
|
75
|
+
}
|
|
76
|
+
if (opts.pick !== undefined) {
|
|
77
|
+
fetchOptions.pick = opts.pick;
|
|
78
|
+
}
|
|
79
|
+
if (opts.watch !== undefined) {
|
|
80
|
+
fetchOptions.watch = opts.watch;
|
|
81
|
+
}
|
|
82
|
+
if (opts.deep !== undefined) {
|
|
83
|
+
fetchOptions.deep = opts.deep;
|
|
84
|
+
}
|
|
85
|
+
if (opts.getCachedData !== undefined) {
|
|
86
|
+
fetchOptions.getCachedData = opts.getCachedData;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Auto-add getCachedData to ensure cache is used in SPA navigation
|
|
90
|
+
fetchOptions.getCachedData = (cacheKey) => {
|
|
91
|
+
return nuxtApp.payload.data[cacheKey] || nuxtApp.static.data[cacheKey];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (opts.refresh !== undefined) {
|
|
95
|
+
fetchOptions.refresh = opts.refresh;
|
|
96
|
+
}
|
|
97
|
+
if (opts.refreshInterval !== undefined) {
|
|
98
|
+
fetchOptions.refreshInterval = opts.refreshInterval;
|
|
99
|
+
}
|
|
100
|
+
if (opts.dedupe !== undefined) {
|
|
101
|
+
fetchOptions.dedupe = opts.dedupe;
|
|
102
|
+
}
|
|
103
|
+
const result = useFetch(finalUrl, fetchOptions);
|
|
104
|
+
// Map pending to loading for better naming
|
|
105
|
+
// useFetch returns AsyncData with 'pending', but UseEnfyraApiSSRReturn uses 'loading'
|
|
106
|
+
return {
|
|
107
|
+
...result,
|
|
108
|
+
loading: result.pending,
|
|
109
|
+
pending: result.pending, // Keep for backward compatibility
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const data = ref(null);
|
|
113
|
+
const error = ref(null);
|
|
114
|
+
const pending = ref(false);
|
|
115
|
+
const execute = async (executeOpts) => {
|
|
116
|
+
pending.value = true;
|
|
117
|
+
error.value = null;
|
|
118
|
+
try {
|
|
119
|
+
const config = useRuntimeConfig().public.enfyraSDK;
|
|
120
|
+
const apiUrl = getAppUrl();
|
|
121
|
+
const apiPrefix = config?.apiPrefix;
|
|
122
|
+
const basePath = (typeof path === "function" ? path() : path)
|
|
123
|
+
.replace(/^\/?api\/?/, "")
|
|
124
|
+
.replace(/^\/+/, "");
|
|
125
|
+
const finalBody = executeOpts?.body || unref(body);
|
|
126
|
+
const finalQuery = executeOpts?.query || unref(query);
|
|
127
|
+
const isBatchOperation = !opts.disableBatch &&
|
|
128
|
+
((executeOpts?.ids &&
|
|
129
|
+
executeOpts.ids.length > 0 &&
|
|
130
|
+
(method.toLowerCase() === "patch" ||
|
|
131
|
+
method.toLowerCase() === "delete")) ||
|
|
132
|
+
(method.toLowerCase() === "post" &&
|
|
133
|
+
executeOpts?.files &&
|
|
134
|
+
Array.isArray(executeOpts.files) &&
|
|
135
|
+
executeOpts.files.length > 0));
|
|
136
|
+
const effectiveBatchSize = isBatchOperation
|
|
137
|
+
? executeOpts?.batchSize ?? batchSize
|
|
138
|
+
: undefined;
|
|
139
|
+
const effectiveConcurrent = isBatchOperation
|
|
140
|
+
? executeOpts?.concurrent ?? concurrent
|
|
141
|
+
: undefined;
|
|
142
|
+
const effectiveOnProgress = isBatchOperation
|
|
143
|
+
? executeOpts?.onProgress ?? onProgress
|
|
144
|
+
: undefined;
|
|
145
|
+
const buildPath = (...segments) => {
|
|
146
|
+
return segments.filter(Boolean).join("/");
|
|
147
|
+
};
|
|
148
|
+
const fullBaseURL = normalizeUrl(apiUrl, apiPrefix || ENFYRA_API_PREFIX);
|
|
149
|
+
async function processBatch(items, processor) {
|
|
150
|
+
const results = [];
|
|
151
|
+
const progressResults = [];
|
|
152
|
+
const startTime = Date.now();
|
|
153
|
+
let completed = 0;
|
|
154
|
+
let failed = 0;
|
|
155
|
+
const chunks = effectiveBatchSize
|
|
156
|
+
? Array.from({ length: Math.ceil(items.length / effectiveBatchSize) }, (_, i) => items.slice(i * effectiveBatchSize, i * effectiveBatchSize + effectiveBatchSize))
|
|
157
|
+
: [items];
|
|
158
|
+
const totalBatches = chunks.length;
|
|
159
|
+
let currentBatch = 0;
|
|
160
|
+
const updateProgress = (inProgress = 0) => {
|
|
161
|
+
if (effectiveOnProgress) {
|
|
162
|
+
const elapsed = Date.now() - startTime;
|
|
163
|
+
const progress = items.length > 0
|
|
164
|
+
? Math.round((completed / items.length) * 100)
|
|
165
|
+
: 0;
|
|
166
|
+
const averageTime = completed > 0 ? elapsed / completed : undefined;
|
|
167
|
+
const operationsPerSecond = completed > 0 ? (completed / elapsed) * 1000 : undefined;
|
|
168
|
+
const estimatedTimeRemaining = averageTime && items.length > completed
|
|
169
|
+
? Math.round(averageTime * (items.length - completed))
|
|
170
|
+
: undefined;
|
|
171
|
+
const progressData = {
|
|
172
|
+
progress,
|
|
173
|
+
completed,
|
|
174
|
+
total: items.length,
|
|
175
|
+
failed,
|
|
176
|
+
inProgress,
|
|
177
|
+
estimatedTimeRemaining,
|
|
178
|
+
averageTime,
|
|
179
|
+
currentBatch: currentBatch + 1,
|
|
180
|
+
totalBatches,
|
|
181
|
+
operationsPerSecond,
|
|
182
|
+
results: [...progressResults],
|
|
183
|
+
};
|
|
184
|
+
effectiveOnProgress(progressData);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
updateProgress(0);
|
|
188
|
+
if (!effectiveBatchSize && !effectiveConcurrent) {
|
|
189
|
+
updateProgress(items.length);
|
|
190
|
+
const promises = items.map(async (item, index) => {
|
|
191
|
+
const itemStartTime = Date.now();
|
|
192
|
+
try {
|
|
193
|
+
const result = await processor(item, index);
|
|
194
|
+
const duration = Date.now() - itemStartTime;
|
|
195
|
+
completed++;
|
|
196
|
+
progressResults.push({
|
|
197
|
+
index,
|
|
198
|
+
status: "completed",
|
|
199
|
+
result,
|
|
200
|
+
duration,
|
|
201
|
+
});
|
|
202
|
+
updateProgress(items.length - completed);
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const duration = Date.now() - itemStartTime;
|
|
207
|
+
failed++;
|
|
208
|
+
completed++;
|
|
209
|
+
progressResults.push({
|
|
210
|
+
index,
|
|
211
|
+
status: "failed",
|
|
212
|
+
error: error,
|
|
213
|
+
duration,
|
|
214
|
+
});
|
|
215
|
+
updateProgress(items.length - completed);
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const results = await Promise.all(promises);
|
|
220
|
+
updateProgress(0);
|
|
221
|
+
return results;
|
|
222
|
+
}
|
|
223
|
+
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
224
|
+
currentBatch = chunkIndex;
|
|
225
|
+
const chunk = chunks[chunkIndex];
|
|
226
|
+
if (effectiveConcurrent && chunk.length > effectiveConcurrent) {
|
|
227
|
+
for (let i = 0; i < chunk.length; i += effectiveConcurrent) {
|
|
228
|
+
const batch = chunk.slice(i, i + effectiveConcurrent);
|
|
229
|
+
const baseIndex = chunkIndex * (effectiveBatchSize || items.length) + i;
|
|
230
|
+
updateProgress(batch.length);
|
|
231
|
+
const batchPromises = batch.map(async (item, batchItemIndex) => {
|
|
232
|
+
const globalIndex = baseIndex + batchItemIndex;
|
|
233
|
+
const itemStartTime = Date.now();
|
|
234
|
+
try {
|
|
235
|
+
const result = await processor(item, globalIndex);
|
|
236
|
+
const duration = Date.now() - itemStartTime;
|
|
237
|
+
completed++;
|
|
238
|
+
progressResults.push({
|
|
239
|
+
index: globalIndex,
|
|
240
|
+
status: "completed",
|
|
241
|
+
result,
|
|
242
|
+
duration,
|
|
243
|
+
});
|
|
244
|
+
updateProgress(Math.max(0, batch.length - (batchItemIndex + 1)));
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const duration = Date.now() - itemStartTime;
|
|
249
|
+
failed++;
|
|
250
|
+
completed++;
|
|
251
|
+
progressResults.push({
|
|
252
|
+
index: globalIndex,
|
|
253
|
+
status: "failed",
|
|
254
|
+
error: error,
|
|
255
|
+
duration,
|
|
256
|
+
});
|
|
257
|
+
updateProgress(Math.max(0, batch.length - (batchItemIndex + 1)));
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const batchResults = await Promise.all(batchPromises);
|
|
262
|
+
results.push(...batchResults);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const baseIndex = chunkIndex * (effectiveBatchSize || items.length);
|
|
267
|
+
updateProgress(chunk.length);
|
|
268
|
+
const chunkPromises = chunk.map(async (item, chunkItemIndex) => {
|
|
269
|
+
const globalIndex = baseIndex + chunkItemIndex;
|
|
270
|
+
const itemStartTime = Date.now();
|
|
271
|
+
try {
|
|
272
|
+
const result = await processor(item, globalIndex);
|
|
273
|
+
const duration = Date.now() - itemStartTime;
|
|
274
|
+
completed++;
|
|
275
|
+
progressResults.push({
|
|
276
|
+
index: globalIndex,
|
|
277
|
+
status: "completed",
|
|
278
|
+
result,
|
|
279
|
+
duration,
|
|
280
|
+
});
|
|
281
|
+
updateProgress(Math.max(0, chunk.length - (chunkItemIndex + 1)));
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
const duration = Date.now() - itemStartTime;
|
|
286
|
+
failed++;
|
|
287
|
+
completed++;
|
|
288
|
+
progressResults.push({
|
|
289
|
+
index: globalIndex,
|
|
290
|
+
status: "failed",
|
|
291
|
+
error: error,
|
|
292
|
+
duration,
|
|
293
|
+
});
|
|
294
|
+
updateProgress(Math.max(0, chunk.length - (chunkItemIndex + 1)));
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
const chunkResults = await Promise.all(chunkPromises);
|
|
299
|
+
results.push(...chunkResults);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
updateProgress(0);
|
|
303
|
+
return results;
|
|
304
|
+
}
|
|
305
|
+
if (isBatchOperation && executeOpts?.ids && executeOpts.ids.length > 0) {
|
|
306
|
+
const responses = await processBatch(executeOpts.ids, async (id) => {
|
|
307
|
+
const finalPath = buildPath(basePath, id);
|
|
308
|
+
return $fetch(finalPath, {
|
|
309
|
+
baseURL: fullBaseURL,
|
|
310
|
+
method: method,
|
|
311
|
+
body: finalBody ? toRaw(finalBody) : undefined,
|
|
312
|
+
headers: opts.headers,
|
|
313
|
+
query: finalQuery,
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
data.value = responses;
|
|
317
|
+
return responses;
|
|
318
|
+
}
|
|
319
|
+
if (isBatchOperation &&
|
|
320
|
+
executeOpts?.files &&
|
|
321
|
+
Array.isArray(executeOpts.files) &&
|
|
322
|
+
executeOpts.files.length > 0) {
|
|
323
|
+
const responses = await processBatch(executeOpts.files, async (fileObj) => {
|
|
324
|
+
return $fetch(basePath, {
|
|
325
|
+
baseURL: fullBaseURL,
|
|
326
|
+
method: method,
|
|
327
|
+
body: fileObj,
|
|
328
|
+
headers: opts.headers,
|
|
329
|
+
query: finalQuery,
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
data.value = responses;
|
|
333
|
+
return responses;
|
|
334
|
+
}
|
|
335
|
+
const finalPath = executeOpts?.id
|
|
336
|
+
? buildPath(basePath, executeOpts.id)
|
|
337
|
+
: basePath;
|
|
338
|
+
const response = await $fetch(finalPath, {
|
|
339
|
+
baseURL: fullBaseURL,
|
|
340
|
+
method: method,
|
|
341
|
+
body: finalBody ? toRaw(finalBody) : undefined,
|
|
342
|
+
headers: opts.headers,
|
|
343
|
+
query: finalQuery,
|
|
344
|
+
});
|
|
345
|
+
data.value = response;
|
|
346
|
+
return response;
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
const apiError = handleError(err, errorContext, onError);
|
|
350
|
+
error.value = apiError;
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
pending.value = false;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
data,
|
|
359
|
+
error,
|
|
360
|
+
pending,
|
|
361
|
+
execute,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
@@ -2,7 +2,7 @@ import { ref, unref, toRaw } from "vue";
|
|
|
2
2
|
import { $fetch } from "../utils/http";
|
|
3
3
|
import { getAppUrl, normalizeUrl } from "../utils/url";
|
|
4
4
|
import { ENFYRA_API_PREFIX } from "../constants/config";
|
|
5
|
-
import { useRuntimeConfig, useFetch, useRequestHeaders } from "#imports";
|
|
5
|
+
import { useRuntimeConfig, useFetch, useRequestHeaders, useNuxtApp } from "#imports";
|
|
6
6
|
function handleError(error, context, customHandler) {
|
|
7
7
|
const apiError = {
|
|
8
8
|
message: error?.message || error?.data?.message || "Request failed",
|
|
@@ -43,6 +43,7 @@ export function useEnfyraApi(path, opts = {}) {
|
|
|
43
43
|
delete serverHeaders["keep-alive"];
|
|
44
44
|
delete serverHeaders.host;
|
|
45
45
|
delete serverHeaders["content-length"];
|
|
46
|
+
const nuxtApp = useNuxtApp();
|
|
46
47
|
const fetchOptions = {
|
|
47
48
|
method,
|
|
48
49
|
body,
|
|
@@ -81,6 +82,10 @@ export function useEnfyraApi(path, opts = {}) {
|
|
|
81
82
|
}
|
|
82
83
|
if (opts.getCachedData !== void 0) {
|
|
83
84
|
fetchOptions.getCachedData = opts.getCachedData;
|
|
85
|
+
} else {
|
|
86
|
+
fetchOptions.getCachedData = (cacheKey) => {
|
|
87
|
+
return nuxtApp.payload.data[cacheKey] || nuxtApp.static.data[cacheKey];
|
|
88
|
+
};
|
|
84
89
|
}
|
|
85
90
|
if (opts.refresh !== void 0) {
|
|
86
91
|
fetchOptions.refresh = opts.refresh;
|
|
@@ -1,9 +1,89 @@
|
|
|
1
1
|
import type { LoginPayload, User } from "../types/auth";
|
|
2
|
-
import type { Ref, ComputedRef } from 'vue';
|
|
3
2
|
export declare function useEnfyraAuth(): {
|
|
4
|
-
me: Ref<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
readonly me: import("vue").Ref<{
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
isRootAdmin: boolean;
|
|
7
|
+
isSystem: boolean;
|
|
8
|
+
role?: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
routePermissions: {
|
|
12
|
+
id: string;
|
|
13
|
+
isEnabled: boolean;
|
|
14
|
+
allowedUsers?: {
|
|
15
|
+
id: string;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
methods: {
|
|
18
|
+
id: string;
|
|
19
|
+
method: string;
|
|
20
|
+
}[];
|
|
21
|
+
route: {
|
|
22
|
+
id: string;
|
|
23
|
+
path: string;
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
} | undefined;
|
|
27
|
+
allowedRoutePermissions?: {
|
|
28
|
+
id: string;
|
|
29
|
+
isEnabled: boolean;
|
|
30
|
+
allowedUsers?: {
|
|
31
|
+
id: string;
|
|
32
|
+
}[] | undefined;
|
|
33
|
+
methods: {
|
|
34
|
+
id: string;
|
|
35
|
+
method: string;
|
|
36
|
+
}[];
|
|
37
|
+
route: {
|
|
38
|
+
id: string;
|
|
39
|
+
path: string;
|
|
40
|
+
};
|
|
41
|
+
}[] | undefined;
|
|
42
|
+
} | null, User | {
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
isRootAdmin: boolean;
|
|
46
|
+
isSystem: boolean;
|
|
47
|
+
role?: {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
routePermissions: {
|
|
51
|
+
id: string;
|
|
52
|
+
isEnabled: boolean;
|
|
53
|
+
allowedUsers?: {
|
|
54
|
+
id: string;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
methods: {
|
|
57
|
+
id: string;
|
|
58
|
+
method: string;
|
|
59
|
+
}[];
|
|
60
|
+
route: {
|
|
61
|
+
id: string;
|
|
62
|
+
path: string;
|
|
63
|
+
};
|
|
64
|
+
}[];
|
|
65
|
+
} | undefined;
|
|
66
|
+
allowedRoutePermissions?: {
|
|
67
|
+
id: string;
|
|
68
|
+
isEnabled: boolean;
|
|
69
|
+
allowedUsers?: {
|
|
70
|
+
id: string;
|
|
71
|
+
}[] | undefined;
|
|
72
|
+
methods: {
|
|
73
|
+
id: string;
|
|
74
|
+
method: string;
|
|
75
|
+
}[];
|
|
76
|
+
route: {
|
|
77
|
+
id: string;
|
|
78
|
+
path: string;
|
|
79
|
+
};
|
|
80
|
+
}[] | undefined;
|
|
81
|
+
} | null>;
|
|
82
|
+
readonly login: (payload: LoginPayload) => Promise<any>;
|
|
83
|
+
readonly logout: () => Promise<void>;
|
|
84
|
+
readonly fetchUser: (options?: {
|
|
85
|
+
fields?: string[];
|
|
86
|
+
}) => Promise<void>;
|
|
87
|
+
readonly isLoggedIn: import("vue").ComputedRef<boolean>;
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=useEnfyraAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnfyraAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useEnfyraAuth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAuB,MAAM,eAAe,CAAC;AAM7E,wBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAgDG,YAAY;;mCAzBP;QAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;;EAqEzD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ref, computed } from "vue";
|
|
2
|
+
import { useEnfyraApi } from "./useEnfyraApi";
|
|
3
|
+
const me = ref(null);
|
|
4
|
+
const isLoading = ref(false);
|
|
5
|
+
export function useEnfyraAuth() {
|
|
6
|
+
const { data: loginData, execute: executeLogin, error: loginError, } = useEnfyraApi("/login", {
|
|
7
|
+
method: "post",
|
|
8
|
+
errorContext: "Login",
|
|
9
|
+
});
|
|
10
|
+
const { execute: executeLogout } = useEnfyraApi("/logout", {
|
|
11
|
+
method: "post",
|
|
12
|
+
errorContext: "Logout",
|
|
13
|
+
});
|
|
14
|
+
const { data: meData, execute: executeFetchUser, error: fetchUserError, } = useEnfyraApi("/me", {
|
|
15
|
+
errorContext: "Fetch User Profile",
|
|
16
|
+
});
|
|
17
|
+
const fetchUser = async (options) => {
|
|
18
|
+
isLoading.value = true;
|
|
19
|
+
try {
|
|
20
|
+
const queryParams = {};
|
|
21
|
+
if (options?.fields && options.fields.length > 0) {
|
|
22
|
+
queryParams.fields = options.fields.join(",");
|
|
23
|
+
}
|
|
24
|
+
await executeFetchUser({
|
|
25
|
+
query: queryParams,
|
|
26
|
+
});
|
|
27
|
+
if (fetchUserError.value) {
|
|
28
|
+
me.value = null;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
me.value = meData.value?.data?.[0];
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
isLoading.value = false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const login = async (payload) => {
|
|
38
|
+
isLoading.value = true;
|
|
39
|
+
try {
|
|
40
|
+
await executeLogin({ body: payload });
|
|
41
|
+
if (loginError.value) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return loginData.value;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
isLoading.value = false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const logout = async () => {
|
|
51
|
+
isLoading.value = true;
|
|
52
|
+
try {
|
|
53
|
+
await executeLogout();
|
|
54
|
+
me.value = null;
|
|
55
|
+
if (typeof window !== "undefined") {
|
|
56
|
+
window.location.reload();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
me.value = null;
|
|
61
|
+
if (typeof window !== "undefined") {
|
|
62
|
+
window.location.reload();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
isLoading.value = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const isLoggedIn = computed(() => !!me.value);
|
|
70
|
+
return {
|
|
71
|
+
me,
|
|
72
|
+
login,
|
|
73
|
+
logout,
|
|
74
|
+
fetchUser,
|
|
75
|
+
isLoggedIn,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* This ensures no conflicts with application routes
|
|
4
|
-
*/
|
|
5
|
-
export declare const ENFYRA_API_PREFIX = "/enfyra/api";
|
|
1
|
+
export declare const ENFYRA_API_PREFIX = "/enfyra/api";
|
|
2
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/constants/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ENFYRA_API_PREFIX = "/enfyra/api";
|
package/dist/module.cjs
CHANGED
|
@@ -49,6 +49,11 @@ enfyraSDK: {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
kit.addImportsDir(resolve("./composables"));
|
|
52
|
+
nuxt.hook("prepare:types", ({ declarations, references }) => {
|
|
53
|
+
references.push({
|
|
54
|
+
path: resolve("./types/nuxt-imports.d.ts")
|
|
55
|
+
});
|
|
56
|
+
});
|
|
52
57
|
kit.addServerHandler({
|
|
53
58
|
handler: resolve("./runtime/server/middleware/auth"),
|
|
54
59
|
middleware: true
|
package/dist/module.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ModuleOptions {
|
|
4
4
|
apiUrl: string;
|
|
5
|
-
apiPrefix
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
apiPrefix: string;
|
|
9
|
-
}, false>;
|
|
5
|
+
apiPrefix?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
10
8
|
|
|
11
9
|
export { _default as default };
|
|
10
|
+
export type { ModuleOptions };
|
package/dist/module.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ModuleOptions {
|
|
4
4
|
apiUrl: string;
|
|
5
|
-
apiPrefix
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
apiPrefix: string;
|
|
9
|
-
}, false>;
|
|
5
|
+
apiPrefix?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
10
8
|
|
|
11
9
|
export { _default as default };
|
|
10
|
+
export type { ModuleOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ModuleOptions {
|
|
4
4
|
apiUrl: string;
|
|
5
|
-
apiPrefix
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
apiPrefix: string;
|
|
9
|
-
}, false>;
|
|
5
|
+
apiPrefix?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
10
8
|
|
|
11
9
|
export { _default as default };
|
|
10
|
+
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -46,6 +46,11 @@ enfyraSDK: {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
addImportsDir(resolve("./composables"));
|
|
49
|
+
nuxt.hook("prepare:types", ({ declarations, references }) => {
|
|
50
|
+
references.push({
|
|
51
|
+
path: resolve("./types/nuxt-imports.d.ts")
|
|
52
|
+
});
|
|
53
|
+
});
|
|
49
54
|
addServerHandler({
|
|
50
55
|
handler: resolve("./runtime/server/middleware/auth"),
|
|
51
56
|
middleware: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,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;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,OAAO,CAAC,CAAC,CAAC,CAoEZ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export async function $fetch(path, options = {}) {
|
|
2
|
+
const { method = "GET", body, headers: optionHeaders = {}, query = {}, baseURL, } = options;
|
|
3
|
+
if (!baseURL) {
|
|
4
|
+
throw new Error('baseURL is required for $fetch');
|
|
5
|
+
}
|
|
6
|
+
const url = new URL(path.startsWith("/") ? path.slice(1) : path, baseURL.endsWith("/") ? baseURL : `${baseURL}/`);
|
|
7
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
8
|
+
if (value !== undefined && value !== null) {
|
|
9
|
+
if (typeof value === 'object') {
|
|
10
|
+
url.searchParams.append(key, JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
url.searchParams.append(key, String(value));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const headers = {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
...optionHeaders,
|
|
20
|
+
};
|
|
21
|
+
const fetchOptions = {
|
|
22
|
+
method: method.toUpperCase(),
|
|
23
|
+
headers,
|
|
24
|
+
};
|
|
25
|
+
if (body && method.toUpperCase() !== "GET") {
|
|
26
|
+
if (body instanceof FormData) {
|
|
27
|
+
delete headers["Content-Type"]; // Let browser set boundary for FormData
|
|
28
|
+
fetchOptions.body = body;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
fetchOptions.body = JSON.stringify(body);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(url.toString(), fetchOptions);
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
let errorData;
|
|
38
|
+
try {
|
|
39
|
+
errorData = await response.json();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
errorData = { message: response.statusText };
|
|
43
|
+
}
|
|
44
|
+
throw { response: { data: errorData } };
|
|
45
|
+
}
|
|
46
|
+
const contentType = response.headers.get("content-type");
|
|
47
|
+
if (contentType?.includes("application/json")) {
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return (await response.text());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/utils/url.d.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes URL segments to avoid double slashes when concatenating
|
|
3
|
+
* Removes trailing slashes from base URL and leading slashes from path segments
|
|
4
|
+
* Also normalizes multiple consecutive slashes within segments
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeUrl(...segments: (string | undefined | null)[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Joins URL paths safely, avoiding double slashes
|
|
9
|
+
*/
|
|
10
|
+
export declare function joinUrlPath(...paths: (string | undefined | null)[]): string;
|
|
11
|
+
export declare function getAppUrl(): string;
|
|
12
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAmB/E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAQ3E;AAED,wBAAgB,SAAS,IAAI,MAAM,CA8ClC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes URL segments to avoid double slashes when concatenating
|
|
3
|
+
* Removes trailing slashes from base URL and leading slashes from path segments
|
|
4
|
+
* Also normalizes multiple consecutive slashes within segments
|
|
5
|
+
*/
|
|
6
|
+
export function normalizeUrl(...segments) {
|
|
7
|
+
const validSegments = segments.filter((s) => Boolean(s));
|
|
8
|
+
if (validSegments.length === 0)
|
|
9
|
+
return '';
|
|
10
|
+
// First segment is the base URL - remove trailing slashes
|
|
11
|
+
let result = validSegments[0].replace(/\/+$/, '');
|
|
12
|
+
// For remaining segments, remove leading and trailing slashes, normalize internal slashes, then join
|
|
13
|
+
for (let i = 1; i < validSegments.length; i++) {
|
|
14
|
+
const segment = validSegments[i]
|
|
15
|
+
.replace(/^\/+/, '') // Remove leading slashes
|
|
16
|
+
.replace(/\/+$/, '') // Remove trailing slashes
|
|
17
|
+
.replace(/\/+/g, '/'); // Normalize multiple consecutive slashes to single slash
|
|
18
|
+
if (segment) {
|
|
19
|
+
result += '/' + segment;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Joins URL paths safely, avoiding double slashes
|
|
26
|
+
*/
|
|
27
|
+
export function joinUrlPath(...paths) {
|
|
28
|
+
const validPaths = paths.filter((p) => Boolean(p));
|
|
29
|
+
if (validPaths.length === 0)
|
|
30
|
+
return '';
|
|
31
|
+
return validPaths
|
|
32
|
+
.map(path => path.replace(/^\/+/, '').replace(/\/+$/, ''))
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join('/');
|
|
35
|
+
}
|
|
36
|
+
export function getAppUrl() {
|
|
37
|
+
if (process.client && typeof window !== 'undefined') {
|
|
38
|
+
return window.location.origin;
|
|
39
|
+
}
|
|
40
|
+
if (process.server) {
|
|
41
|
+
try {
|
|
42
|
+
let useRequestHeaders;
|
|
43
|
+
let useRequestURL;
|
|
44
|
+
try {
|
|
45
|
+
const imports = eval('require("#imports")');
|
|
46
|
+
useRequestHeaders = imports.useRequestHeaders;
|
|
47
|
+
useRequestURL = imports.useRequestURL;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const url = useRequestURL();
|
|
54
|
+
if (url) {
|
|
55
|
+
return `${url.protocol}//${url.host}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
}
|
|
60
|
+
const headers = useRequestHeaders();
|
|
61
|
+
const forwarded = headers['x-forwarded-host'] || headers['x-forwarded-server'];
|
|
62
|
+
const protocol = headers['x-forwarded-proto'] || 'https';
|
|
63
|
+
if (forwarded) {
|
|
64
|
+
return `${protocol}://${forwarded}`;
|
|
65
|
+
}
|
|
66
|
+
const host = headers.host;
|
|
67
|
+
if (host) {
|
|
68
|
+
const isHttps = protocol === 'https' || headers['x-forwarded-ssl'] === 'on';
|
|
69
|
+
return `${isHttps ? 'https' : 'http'}://${host}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.warn('[Enfyra SDK] Could not auto-detect app URL on server:', e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return '';
|
|
77
|
+
}
|
package/index.ts
ADDED
package/module.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ModuleOptions } from './src/module'
|
|
2
|
+
|
|
3
|
+
declare module '@nuxt/schema' {
|
|
4
|
+
interface NuxtConfig {
|
|
5
|
+
enfyraSDK?: ModuleOptions
|
|
6
|
+
}
|
|
7
|
+
interface NuxtOptions {
|
|
8
|
+
enfyraSDK?: ModuleOptions
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { ModuleOptions } from './src/module'
|
|
13
|
+
export type * from './src/types'
|
|
14
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enfyra/sdk-nuxt",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"description": "Nuxt SDK for Enfyra CMS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,17 +11,31 @@
|
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/dothinh115/enfyra-sdk-nuxt#readme",
|
|
13
13
|
"main": "./dist/module.mjs",
|
|
14
|
-
"types": "./dist/
|
|
14
|
+
"types": "./dist/types.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"import": "./dist/module.mjs",
|
|
18
18
|
"require": "./dist/module.cjs",
|
|
19
|
-
"types": "./dist/
|
|
19
|
+
"types": "./dist/types.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./src/composables/useEnfyraApi": {
|
|
22
|
+
"types": "./src/composables/useEnfyraApi.ts",
|
|
23
|
+
"import": "./src/composables/useEnfyraApi.ts"
|
|
24
|
+
},
|
|
25
|
+
"./src/composables/useEnfyraAuth": {
|
|
26
|
+
"types": "./src/composables/useEnfyraAuth.ts",
|
|
27
|
+
"import": "./src/composables/useEnfyraAuth.ts"
|
|
28
|
+
},
|
|
29
|
+
"./types": {
|
|
30
|
+
"types": "./dist/types/index.d.ts",
|
|
31
|
+
"import": "./dist/types/index.js"
|
|
20
32
|
}
|
|
21
33
|
},
|
|
22
34
|
"files": [
|
|
23
35
|
"dist/",
|
|
24
|
-
"src/"
|
|
36
|
+
"src/",
|
|
37
|
+
"module.d.ts",
|
|
38
|
+
"index.ts"
|
|
25
39
|
],
|
|
26
40
|
"keywords": [
|
|
27
41
|
"nuxt",
|
|
@@ -36,8 +50,8 @@
|
|
|
36
50
|
},
|
|
37
51
|
"scripts": {
|
|
38
52
|
"dev": "nuxi dev playground",
|
|
39
|
-
"build": "nuxt-module-build build && npx tsc -p tsconfig.build.json
|
|
40
|
-
"prepack": "nuxt-module-build build && npx tsc -p tsconfig.build.json
|
|
53
|
+
"build": "nuxt-module-build build && npx tsc -p tsconfig.build.json",
|
|
54
|
+
"prepack": "nuxt-module-build build && npx tsc -p tsconfig.build.json",
|
|
41
55
|
"test": "vitest",
|
|
42
56
|
"test:ui": "vitest --ui",
|
|
43
57
|
"test:run": "vitest run"
|
|
@@ -52,6 +66,7 @@
|
|
|
52
66
|
},
|
|
53
67
|
"devDependencies": {
|
|
54
68
|
"@nuxt/module-builder": "^0.8.4",
|
|
69
|
+
"@types/node": "^24.10.1",
|
|
55
70
|
"@vitest/ui": "^3.2.4",
|
|
56
71
|
"nuxt": "^3.18.1",
|
|
57
72
|
"typescript": "^5.0.0",
|
|
@@ -11,7 +11,7 @@ import { $fetch } from "../utils/http";
|
|
|
11
11
|
import { getAppUrl, normalizeUrl } from "../utils/url";
|
|
12
12
|
import { ENFYRA_API_PREFIX } from "../constants/config";
|
|
13
13
|
|
|
14
|
-
import { useRuntimeConfig, useFetch, useRequestHeaders } from "#imports";
|
|
14
|
+
import { useRuntimeConfig, useFetch, useRequestHeaders, useNuxtApp } from "#imports";
|
|
15
15
|
|
|
16
16
|
function handleError(
|
|
17
17
|
error: any,
|
|
@@ -82,6 +82,8 @@ export function useEnfyraApi<T = any>(
|
|
|
82
82
|
delete serverHeaders.host;
|
|
83
83
|
delete serverHeaders["content-length"];
|
|
84
84
|
|
|
85
|
+
const nuxtApp = useNuxtApp()
|
|
86
|
+
|
|
85
87
|
const fetchOptions: any = {
|
|
86
88
|
method: method as any,
|
|
87
89
|
body: body,
|
|
@@ -122,6 +124,11 @@ export function useEnfyraApi<T = any>(
|
|
|
122
124
|
}
|
|
123
125
|
if (opts.getCachedData !== undefined) {
|
|
124
126
|
fetchOptions.getCachedData = opts.getCachedData;
|
|
127
|
+
} else {
|
|
128
|
+
// Auto-add getCachedData to ensure cache is used in SPA navigation
|
|
129
|
+
fetchOptions.getCachedData = (cacheKey: string) => {
|
|
130
|
+
return nuxtApp.payload.data[cacheKey] || nuxtApp.static.data[cacheKey]
|
|
131
|
+
}
|
|
125
132
|
}
|
|
126
133
|
if (opts.refresh !== undefined) {
|
|
127
134
|
fetchOptions.refresh = opts.refresh;
|
package/src/module.ts
CHANGED
|
@@ -7,7 +7,12 @@ import {
|
|
|
7
7
|
} from "@nuxt/kit";
|
|
8
8
|
import { ENFYRA_API_PREFIX } from "./constants/config";
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export interface ModuleOptions {
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
apiPrefix?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default defineNuxtModule<ModuleOptions>({
|
|
11
16
|
meta: {
|
|
12
17
|
name: "@enfyra/sdk-nuxt",
|
|
13
18
|
configKey: "enfyraSDK",
|
|
@@ -67,6 +72,12 @@ export default defineNuxtModule({
|
|
|
67
72
|
|
|
68
73
|
addImportsDir(resolve("./composables"));
|
|
69
74
|
|
|
75
|
+
nuxt.hook('prepare:types', ({ declarations, references }: any) => {
|
|
76
|
+
references.push({
|
|
77
|
+
path: resolve('./types/nuxt-imports.d.ts'),
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
70
81
|
addServerHandler({
|
|
71
82
|
handler: resolve("./runtime/server/middleware/auth"),
|
|
72
83
|
middleware: true,
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* These are provided at runtime by Nuxt but need declarations for TypeScript
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
declare global {
|
|
7
|
+
const useEnfyraApi: typeof import('../composables/useEnfyraApi').useEnfyraApi
|
|
8
|
+
const useEnfyraAuth: typeof import('../composables/useEnfyraAuth').useEnfyraAuth
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
declare module '#imports' {
|
|
7
12
|
export const useRuntimeConfig: () => {
|
|
8
13
|
public: {
|
|
@@ -25,6 +30,18 @@ declare module '#imports' {
|
|
|
25
30
|
options?: any
|
|
26
31
|
) => any;
|
|
27
32
|
|
|
33
|
+
export const useNuxtApp: () => {
|
|
34
|
+
payload: {
|
|
35
|
+
data: Record<string, any>;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
static: {
|
|
39
|
+
data: Record<string, any>;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
|
|
28
45
|
export const defineNuxtPlugin: (plugin: any) => any;
|
|
29
46
|
|
|
30
47
|
export const defineCachedEventHandler: (handler: any, options?: any) => any;
|
package/dist/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,gBAAgB,EAAE,eAAe,EAAE,CAAA;KACpC,CAAA;IACD,uBAAuB,CAAC,EAAE,eAAe,EAAE,CAAA;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC/B,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACzC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;IACpB,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACzB"}
|
package/dist/composables.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Ref, ComputedRef } from 'vue';
|
|
2
|
-
import type { LoginPayload, User, ApiOptions, UseEnfyraApiSSRReturn, UseEnfyraApiClientReturn } from './index';
|
|
3
|
-
|
|
4
|
-
export declare function useEnfyraAuth(): {
|
|
5
|
-
me: Ref<User | null>;
|
|
6
|
-
login: (payload: LoginPayload) => Promise<any>;
|
|
7
|
-
logout: () => Promise<void>;
|
|
8
|
-
fetchUser: (options?: { fields?: string[] }) => Promise<void>;
|
|
9
|
-
isLoggedIn: ComputedRef<boolean>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// Function overloads for proper TypeScript support
|
|
13
|
-
export declare function useEnfyraApi<T = any>(
|
|
14
|
-
path: (() => string) | string,
|
|
15
|
-
opts: ApiOptions<T> & { ssr: true }
|
|
16
|
-
): UseEnfyraApiSSRReturn<T>;
|
|
17
|
-
|
|
18
|
-
export declare function useEnfyraApi<T = any>(
|
|
19
|
-
path: (() => string) | string,
|
|
20
|
-
opts?: ApiOptions<T> & { ssr?: false | undefined }
|
|
21
|
-
): UseEnfyraApiClientReturn<T>;
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sDAAsD;IACtD,OAAO,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;QAC/B,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,KAAK,CAAC,EAAE,QAAQ,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ;AAED,UAAU,cAAc,C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