@enfyra/sdk-nuxt 0.3.15 → 0.3.17
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/index.ts +3 -0
- package/module.d.ts +14 -0
- package/{src/module.ts → module.ts} +21 -9
- package/package.json +32 -21
- package/src/composables/useEnfyraAuth.ts +1 -1
- package/src/types/nuxt-imports.d.ts +5 -0
- package/dist/auth.d.ts +0 -43
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -1
- package/dist/composables/useEnfyraApi.d.ts +0 -12
- package/dist/composables/useEnfyraApi.mjs +0 -345
- package/dist/composables/useEnfyraAuth.d.ts +0 -9
- package/dist/composables/useEnfyraAuth.mjs +0 -81
- package/dist/composables.d.ts +0 -21
- package/dist/constants/auth.d.ts +0 -0
- package/dist/constants/auth.mjs +0 -3
- package/dist/constants/config.d.ts +0 -5
- package/dist/constants/config.mjs +0 -1
- package/dist/index.d.ts +0 -141
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/module.cjs +0 -77
- package/dist/module.d.cts +0 -11
- package/dist/module.d.mts +0 -11
- package/dist/module.d.ts +0 -11
- package/dist/module.json +0 -9
- package/dist/module.mjs +0 -74
- package/dist/runtime/plugin/config-error.client.d.ts +0 -0
- package/dist/runtime/plugin/config-error.client.js +0 -107
- package/dist/runtime/plugin/config-error.client.mjs +0 -107
- package/dist/runtime/server/api/all.d.ts +0 -0
- package/dist/runtime/server/api/all.js +0 -5
- package/dist/runtime/server/api/all.mjs +0 -5
- package/dist/runtime/server/api/login.post.d.ts +0 -0
- package/dist/runtime/server/api/login.post.js +0 -62
- package/dist/runtime/server/api/login.post.mjs +0 -62
- package/dist/runtime/server/api/logout.post.d.ts +0 -0
- package/dist/runtime/server/api/logout.post.js +0 -35
- package/dist/runtime/server/api/logout.post.mjs +0 -35
- package/dist/runtime/server/middleware/auth.d.ts +0 -0
- package/dist/runtime/server/middleware/auth.js +0 -36
- package/dist/runtime/server/middleware/auth.mjs +0 -36
- package/dist/types.d.mts +0 -7
- package/dist/types.d.ts +0 -7
- package/dist/utils/config.d.ts +0 -0
- package/dist/utils/config.mjs +0 -16
- package/dist/utils/http.d.ts +0 -0
- package/dist/utils/http.mjs +0 -61
- package/dist/utils/server/proxy.d.ts +0 -0
- package/dist/utils/server/proxy.mjs +0 -14
- package/dist/utils/server/refreshToken.d.ts +0 -0
- package/dist/utils/server/refreshToken.mjs +0 -69
- package/dist/utils/url.d.ts +0 -0
- package/dist/utils/url.mjs +0 -56
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ref, computed } from "vue";
|
|
2
|
-
import { useEnfyraApi } from "./useEnfyraApi.mjs";
|
|
3
|
-
const me = ref(null);
|
|
4
|
-
const isLoading = ref(false);
|
|
5
|
-
export function useEnfyraAuth() {
|
|
6
|
-
const {
|
|
7
|
-
data: loginData,
|
|
8
|
-
execute: executeLogin,
|
|
9
|
-
error: loginError
|
|
10
|
-
} = useEnfyraApi("/login", {
|
|
11
|
-
method: "post",
|
|
12
|
-
errorContext: "Login"
|
|
13
|
-
});
|
|
14
|
-
const { execute: executeLogout } = useEnfyraApi("/logout", {
|
|
15
|
-
method: "post",
|
|
16
|
-
errorContext: "Logout"
|
|
17
|
-
});
|
|
18
|
-
const {
|
|
19
|
-
data: meData,
|
|
20
|
-
execute: executeFetchUser,
|
|
21
|
-
error: fetchUserError
|
|
22
|
-
} = useEnfyraApi("/me", {
|
|
23
|
-
errorContext: "Fetch User Profile"
|
|
24
|
-
});
|
|
25
|
-
const fetchUser = async (options) => {
|
|
26
|
-
isLoading.value = true;
|
|
27
|
-
try {
|
|
28
|
-
const queryParams = {};
|
|
29
|
-
if (options?.fields && options.fields.length > 0) {
|
|
30
|
-
queryParams.fields = options.fields.join(",");
|
|
31
|
-
}
|
|
32
|
-
await executeFetchUser({
|
|
33
|
-
query: queryParams
|
|
34
|
-
});
|
|
35
|
-
if (fetchUserError.value) {
|
|
36
|
-
me.value = null;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
me.value = meData.value?.data?.[0];
|
|
40
|
-
} finally {
|
|
41
|
-
isLoading.value = false;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const login = async (payload) => {
|
|
45
|
-
isLoading.value = true;
|
|
46
|
-
try {
|
|
47
|
-
await executeLogin({ body: payload });
|
|
48
|
-
if (loginError.value) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return loginData.value;
|
|
52
|
-
} finally {
|
|
53
|
-
isLoading.value = false;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const logout = async () => {
|
|
57
|
-
isLoading.value = true;
|
|
58
|
-
try {
|
|
59
|
-
await executeLogout();
|
|
60
|
-
me.value = null;
|
|
61
|
-
if (typeof window !== "undefined") {
|
|
62
|
-
window.location.reload();
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
me.value = null;
|
|
66
|
-
if (typeof window !== "undefined") {
|
|
67
|
-
window.location.reload();
|
|
68
|
-
}
|
|
69
|
-
} finally {
|
|
70
|
-
isLoading.value = false;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const isLoggedIn = computed(() => !!me.value);
|
|
74
|
-
return {
|
|
75
|
-
me,
|
|
76
|
-
login,
|
|
77
|
-
logout,
|
|
78
|
-
fetchUser,
|
|
79
|
-
isLoggedIn
|
|
80
|
-
};
|
|
81
|
-
}
|
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/constants/auth.d.ts
DELETED
|
File without changes
|
package/dist/constants/auth.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const ENFYRA_API_PREFIX = "/enfyra/api";
|
package/dist/index.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export interface EnfyraConfig {
|
|
2
|
-
apiUrl: string;
|
|
3
|
-
defaultHeaders?: Record<string, string>;
|
|
4
|
-
}
|
|
5
|
-
export interface ApiError {
|
|
6
|
-
message: string;
|
|
7
|
-
status?: number;
|
|
8
|
-
data?: any;
|
|
9
|
-
response?: any;
|
|
10
|
-
}
|
|
11
|
-
export interface BatchProgress {
|
|
12
|
-
/** Current progress percentage (0-100) */
|
|
13
|
-
progress: number;
|
|
14
|
-
/** Number of completed operations */
|
|
15
|
-
completed: number;
|
|
16
|
-
/** Total number of operations */
|
|
17
|
-
total: number;
|
|
18
|
-
/** Number of failed operations */
|
|
19
|
-
failed: number;
|
|
20
|
-
/** Number of operations currently in progress */
|
|
21
|
-
inProgress: number;
|
|
22
|
-
/** Estimated time remaining in milliseconds */
|
|
23
|
-
estimatedTimeRemaining?: number;
|
|
24
|
-
/** Average time per operation in milliseconds */
|
|
25
|
-
averageTime?: number;
|
|
26
|
-
/** Current batch being processed */
|
|
27
|
-
currentBatch: number;
|
|
28
|
-
/** Total number of batches */
|
|
29
|
-
totalBatches: number;
|
|
30
|
-
/** Processing speed (operations per second) */
|
|
31
|
-
operationsPerSecond?: number;
|
|
32
|
-
/** Detailed results array for completed operations */
|
|
33
|
-
results: Array<{
|
|
34
|
-
index: number;
|
|
35
|
-
status: 'completed' | 'failed';
|
|
36
|
-
result?: any;
|
|
37
|
-
error?: ApiError;
|
|
38
|
-
duration?: number;
|
|
39
|
-
}>;
|
|
40
|
-
}
|
|
41
|
-
interface BaseApiOptions<T> {
|
|
42
|
-
method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
43
|
-
body?: any;
|
|
44
|
-
query?: Record<string, any>;
|
|
45
|
-
headers?: Record<string, string>;
|
|
46
|
-
errorContext?: string;
|
|
47
|
-
onError?: (error: ApiError, context?: string) => void;
|
|
48
|
-
disableBatch?: boolean;
|
|
49
|
-
default?: () => T;
|
|
50
|
-
/** Enable SSR with useFetch instead of $fetch */
|
|
51
|
-
ssr?: boolean;
|
|
52
|
-
/** Unique key for useFetch caching */
|
|
53
|
-
key?: string;
|
|
54
|
-
/** Whether to fetch on server (default: true) - Only applies when ssr: true */
|
|
55
|
-
server?: boolean;
|
|
56
|
-
/** Don't block navigation (default: false) - Only applies when ssr: true */
|
|
57
|
-
lazy?: boolean;
|
|
58
|
-
/** Execute immediately (default: true) - Only applies when ssr: true */
|
|
59
|
-
immediate?: boolean;
|
|
60
|
-
/** Transform the response data - Only applies when ssr: true */
|
|
61
|
-
transform?: (data: any) => T;
|
|
62
|
-
/** Pick specific fields from response - Only applies when ssr: true */
|
|
63
|
-
pick?: string[];
|
|
64
|
-
/** Watch reactive sources and refetch when they change - Only applies when ssr: true */
|
|
65
|
-
watch?: any[];
|
|
66
|
-
/** Deep watch (default: false) - Only applies when ssr: true */
|
|
67
|
-
deep?: boolean;
|
|
68
|
-
/** Custom cache data retrieval function - Only applies when ssr: true */
|
|
69
|
-
getCachedData?: (key: string) => T | null;
|
|
70
|
-
/** Enable refresh (default: true) - Only applies when ssr: true */
|
|
71
|
-
refresh?: boolean;
|
|
72
|
-
/** Auto refresh interval in milliseconds - Only applies when ssr: true */
|
|
73
|
-
refreshInterval?: number;
|
|
74
|
-
/** Deduplication key - Only applies when ssr: true */
|
|
75
|
-
dedupe?: string;
|
|
76
|
-
}
|
|
77
|
-
interface BatchApiOptions {
|
|
78
|
-
/** Batch size for chunking large operations (default: no limit) - Only available for batch operations */
|
|
79
|
-
batchSize?: number;
|
|
80
|
-
/** Maximum concurrent requests (default: no limit) - Only available for batch operations */
|
|
81
|
-
concurrent?: number;
|
|
82
|
-
/** Real-time progress callback for batch operations - Only available for batch operations */
|
|
83
|
-
onProgress?: (progress: BatchProgress) => void;
|
|
84
|
-
}
|
|
85
|
-
type ConditionalBatchOptions<T> = T extends {
|
|
86
|
-
method?: 'patch' | 'delete' | 'PATCH' | 'DELETE';
|
|
87
|
-
} ? BatchApiOptions : T extends {
|
|
88
|
-
method?: 'post' | 'POST';
|
|
89
|
-
} ? BatchApiOptions : T extends {
|
|
90
|
-
method?: undefined;
|
|
91
|
-
} ? Partial<BatchApiOptions> : {};
|
|
92
|
-
export type ApiOptions<T> = BaseApiOptions<T> & ConditionalBatchOptions<BaseApiOptions<T>>;
|
|
93
|
-
export interface BackendError {
|
|
94
|
-
success: false;
|
|
95
|
-
message: string;
|
|
96
|
-
}
|
|
97
|
-
export interface BackendErrorExtended extends BackendError {
|
|
98
|
-
error: {
|
|
99
|
-
code: string;
|
|
100
|
-
message: string;
|
|
101
|
-
details?: any;
|
|
102
|
-
timestamp: string;
|
|
103
|
-
path: string;
|
|
104
|
-
method: string;
|
|
105
|
-
correlationId?: string;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
import type { Ref } from 'vue';
|
|
109
|
-
import type { AsyncData } from 'nuxt/app';
|
|
110
|
-
export interface UseEnfyraApiSSRReturn<T> extends Omit<AsyncData<T | null, ApiError>, 'pending' | 'error'> {
|
|
111
|
-
data: Ref<T | null>;
|
|
112
|
-
loading: Ref<boolean>;
|
|
113
|
-
error: Ref<ApiError | null>;
|
|
114
|
-
refresh: () => Promise<void>;
|
|
115
|
-
pending?: Ref<boolean>;
|
|
116
|
-
}
|
|
117
|
-
interface BaseExecuteOptions {
|
|
118
|
-
body?: any;
|
|
119
|
-
id?: string | number;
|
|
120
|
-
query?: Record<string, any>;
|
|
121
|
-
}
|
|
122
|
-
interface BatchExecuteOptions {
|
|
123
|
-
ids?: (string | number)[];
|
|
124
|
-
/** Array of FormData objects for batch upload */
|
|
125
|
-
files?: FormData[];
|
|
126
|
-
/** Override batch size for this specific execution */
|
|
127
|
-
batchSize?: number;
|
|
128
|
-
/** Override concurrent limit for this specific execution */
|
|
129
|
-
concurrent?: number;
|
|
130
|
-
/** Override progress callback for this specific execution */
|
|
131
|
-
onProgress?: (progress: BatchProgress) => void;
|
|
132
|
-
}
|
|
133
|
-
export type ExecuteOptions = BaseExecuteOptions & BatchExecuteOptions;
|
|
134
|
-
export interface UseEnfyraApiClientReturn<T> {
|
|
135
|
-
data: Ref<T | null>;
|
|
136
|
-
error: Ref<ApiError | null>;
|
|
137
|
-
pending: Ref<boolean>;
|
|
138
|
-
execute: (executeOpts?: ExecuteOptions) => Promise<T | T[] | null>;
|
|
139
|
-
}
|
|
140
|
-
export * from './auth';
|
|
141
|
-
//# sourceMappingURL=index.d.ts.map
|
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,CA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kB;IAC1B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,iDAAiD;IACjD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CAChD;AAQD,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEtE,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;CACpE;AAGD,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './auth';
|
package/dist/module.cjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const kit = require('@nuxt/kit');
|
|
4
|
-
const config_mjs = require('../dist/constants/config.mjs');
|
|
5
|
-
|
|
6
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
-
const module$1 = kit.defineNuxtModule({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "@enfyra/sdk-nuxt",
|
|
10
|
-
configKey: "enfyraSDK"
|
|
11
|
-
},
|
|
12
|
-
defaults: {
|
|
13
|
-
apiUrl: "",
|
|
14
|
-
apiPrefix: config_mjs.ENFYRA_API_PREFIX
|
|
15
|
-
},
|
|
16
|
-
setup(options, nuxt) {
|
|
17
|
-
const normalizedOptions = {
|
|
18
|
-
...options,
|
|
19
|
-
apiUrl: typeof options.apiUrl === "string" ? options.apiUrl.replace(/\/+$/, "") : options.apiUrl,
|
|
20
|
-
apiPrefix: typeof options.apiPrefix === "string" ? options.apiPrefix.trim() ? "/" + options.apiPrefix.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/") : config_mjs.ENFYRA_API_PREFIX : config_mjs.ENFYRA_API_PREFIX
|
|
21
|
-
};
|
|
22
|
-
const apiPrefix = normalizedOptions.apiPrefix;
|
|
23
|
-
const { resolve } = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('module.cjs', document.baseURI).href)));
|
|
24
|
-
if (!normalizedOptions.apiUrl) {
|
|
25
|
-
console.warn(
|
|
26
|
-
`[Enfyra SDK Nuxt] Missing required configuration:
|
|
27
|
-
- apiUrl is required
|
|
28
|
-
Please configure it in your nuxt.config.ts:
|
|
29
|
-
enfyraSDK: {
|
|
30
|
-
apiUrl: 'https://your-api-url'
|
|
31
|
-
}`
|
|
32
|
-
);
|
|
33
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
34
|
-
...normalizedOptions,
|
|
35
|
-
apiPrefix,
|
|
36
|
-
configError: true,
|
|
37
|
-
configErrorMessage: "Enfyra SDK: apiUrl is required. Please configure it in nuxt.config.ts"
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
41
|
-
...normalizedOptions,
|
|
42
|
-
apiPrefix
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (!normalizedOptions.apiUrl) {
|
|
46
|
-
kit.addPlugin({
|
|
47
|
-
src: resolve("./runtime/plugin/config-error.client"),
|
|
48
|
-
mode: "client"
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
kit.addImportsDir(resolve("./composables"));
|
|
52
|
-
kit.addServerHandler({
|
|
53
|
-
handler: resolve("./runtime/server/middleware/auth"),
|
|
54
|
-
middleware: true
|
|
55
|
-
});
|
|
56
|
-
kit.addServerHandler({
|
|
57
|
-
route: `${apiPrefix}/login`,
|
|
58
|
-
handler: resolve("./runtime/server/api/login.post"),
|
|
59
|
-
method: "post"
|
|
60
|
-
});
|
|
61
|
-
kit.addServerHandler({
|
|
62
|
-
route: `${apiPrefix}/logout`,
|
|
63
|
-
handler: resolve("./runtime/server/api/logout.post"),
|
|
64
|
-
method: "post"
|
|
65
|
-
});
|
|
66
|
-
kit.addServerHandler({
|
|
67
|
-
route: "/assets/**",
|
|
68
|
-
handler: resolve("./runtime/server/api/all")
|
|
69
|
-
});
|
|
70
|
-
kit.addServerHandler({
|
|
71
|
-
route: `${apiPrefix}/**`,
|
|
72
|
-
handler: resolve("./runtime/server/api/all")
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
module.exports = module$1;
|
package/dist/module.d.cts
DELETED
package/dist/module.d.mts
DELETED
package/dist/module.d.ts
DELETED
package/dist/module.json
DELETED
package/dist/module.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addServerHandler } from '@nuxt/kit';
|
|
2
|
-
import { ENFYRA_API_PREFIX } from '../dist/constants/config.mjs';
|
|
3
|
-
|
|
4
|
-
const module = defineNuxtModule({
|
|
5
|
-
meta: {
|
|
6
|
-
name: "@enfyra/sdk-nuxt",
|
|
7
|
-
configKey: "enfyraSDK"
|
|
8
|
-
},
|
|
9
|
-
defaults: {
|
|
10
|
-
apiUrl: "",
|
|
11
|
-
apiPrefix: ENFYRA_API_PREFIX
|
|
12
|
-
},
|
|
13
|
-
setup(options, nuxt) {
|
|
14
|
-
const normalizedOptions = {
|
|
15
|
-
...options,
|
|
16
|
-
apiUrl: typeof options.apiUrl === "string" ? options.apiUrl.replace(/\/+$/, "") : options.apiUrl,
|
|
17
|
-
apiPrefix: typeof options.apiPrefix === "string" ? options.apiPrefix.trim() ? "/" + options.apiPrefix.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/") : ENFYRA_API_PREFIX : ENFYRA_API_PREFIX
|
|
18
|
-
};
|
|
19
|
-
const apiPrefix = normalizedOptions.apiPrefix;
|
|
20
|
-
const { resolve } = createResolver(import.meta.url);
|
|
21
|
-
if (!normalizedOptions.apiUrl) {
|
|
22
|
-
console.warn(
|
|
23
|
-
`[Enfyra SDK Nuxt] Missing required configuration:
|
|
24
|
-
- apiUrl is required
|
|
25
|
-
Please configure it in your nuxt.config.ts:
|
|
26
|
-
enfyraSDK: {
|
|
27
|
-
apiUrl: 'https://your-api-url'
|
|
28
|
-
}`
|
|
29
|
-
);
|
|
30
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
31
|
-
...normalizedOptions,
|
|
32
|
-
apiPrefix,
|
|
33
|
-
configError: true,
|
|
34
|
-
configErrorMessage: "Enfyra SDK: apiUrl is required. Please configure it in nuxt.config.ts"
|
|
35
|
-
};
|
|
36
|
-
} else {
|
|
37
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
38
|
-
...normalizedOptions,
|
|
39
|
-
apiPrefix
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (!normalizedOptions.apiUrl) {
|
|
43
|
-
addPlugin({
|
|
44
|
-
src: resolve("./runtime/plugin/config-error.client"),
|
|
45
|
-
mode: "client"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
addImportsDir(resolve("./composables"));
|
|
49
|
-
addServerHandler({
|
|
50
|
-
handler: resolve("./runtime/server/middleware/auth"),
|
|
51
|
-
middleware: true
|
|
52
|
-
});
|
|
53
|
-
addServerHandler({
|
|
54
|
-
route: `${apiPrefix}/login`,
|
|
55
|
-
handler: resolve("./runtime/server/api/login.post"),
|
|
56
|
-
method: "post"
|
|
57
|
-
});
|
|
58
|
-
addServerHandler({
|
|
59
|
-
route: `${apiPrefix}/logout`,
|
|
60
|
-
handler: resolve("./runtime/server/api/logout.post"),
|
|
61
|
-
method: "post"
|
|
62
|
-
});
|
|
63
|
-
addServerHandler({
|
|
64
|
-
route: "/assets/**",
|
|
65
|
-
handler: resolve("./runtime/server/api/all")
|
|
66
|
-
});
|
|
67
|
-
addServerHandler({
|
|
68
|
-
route: `${apiPrefix}/**`,
|
|
69
|
-
handler: resolve("./runtime/server/api/all")
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export { module as default };
|
|
File without changes
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
|
|
2
|
-
export default defineNuxtPlugin(() => {
|
|
3
|
-
const config = useRuntimeConfig().public?.enfyraSDK;
|
|
4
|
-
if (config?.configError) {
|
|
5
|
-
if (typeof window !== "undefined" && document) {
|
|
6
|
-
let showError = function() {
|
|
7
|
-
const errorDiv = document.createElement("div");
|
|
8
|
-
errorDiv.id = "enfyra-config-error";
|
|
9
|
-
errorDiv.style.cssText = `
|
|
10
|
-
position: fixed;
|
|
11
|
-
top: 0;
|
|
12
|
-
left: 0;
|
|
13
|
-
right: 0;
|
|
14
|
-
bottom: 0;
|
|
15
|
-
background: rgba(0, 0, 0, 0.9);
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
z-index: 999999;
|
|
20
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
21
|
-
`;
|
|
22
|
-
const content = document.createElement("div");
|
|
23
|
-
content.style.cssText = `
|
|
24
|
-
background: white;
|
|
25
|
-
padding: 40px;
|
|
26
|
-
border-radius: 12px;
|
|
27
|
-
max-width: 600px;
|
|
28
|
-
width: 90%;
|
|
29
|
-
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
30
|
-
`;
|
|
31
|
-
content.innerHTML = `
|
|
32
|
-
<div style="display: flex; align-items: center; margin-bottom: 20px;">
|
|
33
|
-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" style="margin-right: 12px;">
|
|
34
|
-
<circle cx="12" cy="12" r="10" stroke="#ef4444" stroke-width="2"/>
|
|
35
|
-
<path d="M12 8v4M12 16h.01" stroke="#ef4444" stroke-width="2" stroke-linecap="round"/>
|
|
36
|
-
</svg>
|
|
37
|
-
<h1 style="margin: 0; color: #1f2937; font-size: 24px; font-weight: 600;">
|
|
38
|
-
Configuration Error
|
|
39
|
-
</h1>
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<div style="color: #4b5563; margin-bottom: 24px; line-height: 1.6;">
|
|
43
|
-
<p style="margin: 0 0 16px 0; font-size: 16px;">
|
|
44
|
-
<strong>Enfyra SDK</strong> is not configured properly.
|
|
45
|
-
</p>
|
|
46
|
-
<p style="margin: 0; color: #6b7280; font-size: 14px;">
|
|
47
|
-
${config?.configErrorMessage || "Missing required configuration"}
|
|
48
|
-
</p>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 24px;">
|
|
52
|
-
<p style="margin: 0 0 12px 0; color: #6b7280; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px;">
|
|
53
|
-
Add to your nuxt.config.ts:
|
|
54
|
-
</p>
|
|
55
|
-
<pre style="margin: 0; background: #1f2937; color: #f3f4f6; padding: 16px; border-radius: 6px; overflow-x: auto; font-size: 14px; line-height: 1.4;"><code>export default defineNuxtConfig({
|
|
56
|
-
modules: ["@enfyra/sdk-nuxt"],
|
|
57
|
-
enfyraSDK: {
|
|
58
|
-
<span style="color: #fbbf24;">apiUrl</span>: <span style="color: #34d399;">"https://your-api-url"</span>
|
|
59
|
-
}
|
|
60
|
-
})</code></pre>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div style="display: flex; gap: 12px;">
|
|
64
|
-
<button onclick="location.reload()" style="
|
|
65
|
-
background: #3b82f6;
|
|
66
|
-
color: white;
|
|
67
|
-
border: none;
|
|
68
|
-
padding: 10px 20px;
|
|
69
|
-
border-radius: 6px;
|
|
70
|
-
font-size: 14px;
|
|
71
|
-
font-weight: 500;
|
|
72
|
-
cursor: pointer;
|
|
73
|
-
transition: background 0.2s;
|
|
74
|
-
" onmouseover="this.style.background='#2563eb'" onmouseout="this.style.background='#3b82f6'">
|
|
75
|
-
Reload Page
|
|
76
|
-
</button>
|
|
77
|
-
<button onclick="document.getElementById('enfyra-config-error').style.display='none'" style="
|
|
78
|
-
background: #f3f4f6;
|
|
79
|
-
color: #4b5563;
|
|
80
|
-
border: 1px solid #e5e7eb;
|
|
81
|
-
padding: 10px 20px;
|
|
82
|
-
border-radius: 6px;
|
|
83
|
-
font-size: 14px;
|
|
84
|
-
font-weight: 500;
|
|
85
|
-
cursor: pointer;
|
|
86
|
-
transition: all 0.2s;
|
|
87
|
-
" onmouseover="this.style.background='#e5e7eb'" onmouseout="this.style.background='#f3f4f6'">
|
|
88
|
-
Dismiss
|
|
89
|
-
</button>
|
|
90
|
-
</div>
|
|
91
|
-
`;
|
|
92
|
-
errorDiv.appendChild(content);
|
|
93
|
-
document.body.appendChild(errorDiv);
|
|
94
|
-
console.error(
|
|
95
|
-
"%c\u26A0\uFE0F Enfyra SDK Configuration Error",
|
|
96
|
-
"color: #ef4444; font-size: 16px; font-weight: bold;",
|
|
97
|
-
"\n\n" + (config?.configErrorMessage || "Missing required configuration") + '\n\nPlease add the following to your nuxt.config.ts:\n\nenfyraSDK: {\n apiUrl: "https://your-api-url"\n}'
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
if (document.readyState === "loading") {
|
|
101
|
-
document.addEventListener("DOMContentLoaded", showError);
|
|
102
|
-
} else {
|
|
103
|
-
showError();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|