@bagelink/sdk 1.4.64 → 1.4.69
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/bin/index.ts +2 -3
- package/bin/utils.ts +22 -20
- package/package.json +1 -2
- package/bin/authClientCode.ts +0 -50
package/bin/index.ts
CHANGED
|
@@ -4,9 +4,9 @@ import fs from 'node:fs'
|
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { openAPI } from '@bagelink/sdk'
|
|
6
6
|
import { splitClientCode } from './splitClientGen'
|
|
7
|
-
import { formatAndWriteCode, getKwargs,
|
|
7
|
+
import { formatAndWriteCode, getKwargs, runEsLintOnDir } from './utils'
|
|
8
8
|
|
|
9
|
-
const { bagelinkDir,
|
|
9
|
+
const { bagelinkDir, shouldSplitFiles, openApiUrl, proc } = getKwargs()
|
|
10
10
|
|
|
11
11
|
export async function loadTypes() {
|
|
12
12
|
const { types, code } = await openAPI(
|
|
@@ -44,7 +44,6 @@ export async function loadTypes() {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
await handleAuthCode(withAuth, bagelinkDir)
|
|
48
47
|
console.log('Attempting to format generated files...')
|
|
49
48
|
await runEsLintOnDir(bagelinkDir)
|
|
50
49
|
|
package/bin/utils.ts
CHANGED
|
@@ -9,9 +9,7 @@ import { loadEnv } from 'vite'
|
|
|
9
9
|
const cwd = proc.cwd()
|
|
10
10
|
const env = loadEnv('', cwd)
|
|
11
11
|
|
|
12
|
-
const [_, __, dirFlag
|
|
13
|
-
|
|
14
|
-
const withAuth = withAuthArg === '--auth'
|
|
12
|
+
const [_, __, dirFlag] = proc.argv as Partial<string[]>
|
|
15
13
|
|
|
16
14
|
// Parse command line arguments
|
|
17
15
|
const shouldSplitFiles = proc.argv.includes('--split')
|
|
@@ -36,7 +34,6 @@ export function getKwargs() {
|
|
|
36
34
|
baseUrlEnvStr,
|
|
37
35
|
openApiUrl,
|
|
38
36
|
bagelinkDir,
|
|
39
|
-
withAuth,
|
|
40
37
|
shouldSplitFiles,
|
|
41
38
|
cwd,
|
|
42
39
|
env,
|
|
@@ -56,22 +53,27 @@ export async function runEsLintOnDir(dir: string) {
|
|
|
56
53
|
return
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
try {
|
|
57
|
+
const eslint = new ESLint({
|
|
58
|
+
fix: true,
|
|
59
|
+
overrideConfigFile: join(cwd, 'eslint.config.js'),
|
|
60
|
+
cwd,
|
|
61
|
+
// Override specific problematic rules
|
|
62
|
+
overrideConfig: {
|
|
63
|
+
rules: {
|
|
64
|
+
'import/default': 'off',
|
|
65
|
+
'import/named': 'off',
|
|
66
|
+
'import/namespace': 'off',
|
|
67
|
+
'import/no-unresolved': 'off',
|
|
68
|
+
'import/export': 'off',
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
const results = await eslint.lintFiles(`${dir}/**/*.ts`)
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
'utf8'
|
|
70
|
-
).replace(
|
|
71
|
-
'// @ts-expect-error - required for axios to work',
|
|
72
|
-
''
|
|
73
|
-
)
|
|
74
|
-
const authPath = join(_bagelinkDir, 'auth.ts')
|
|
75
|
-
await formatAndWriteCode(authPath, authCode)
|
|
74
|
+
await ESLint.outputFixes(results)
|
|
75
|
+
} catch (error: any) {
|
|
76
|
+
console.warn('ESLint formatting failed, but files were generated successfully:', error.message)
|
|
77
|
+
console.log('You may need to manually format the generated files or fix your ESLint configuration')
|
|
76
78
|
}
|
|
77
79
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.69",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Neveh Allon",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"files": [
|
|
44
44
|
"dist",
|
|
45
45
|
"src",
|
|
46
|
-
"bin/authClientCode.ts",
|
|
47
46
|
"bin/splitClientGen.ts",
|
|
48
47
|
"bin/utils.ts"
|
|
49
48
|
],
|
package/bin/authClientCode.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance, AxiosResponse } from 'axios'
|
|
2
|
-
// @ts-expect-error - required for axios to work
|
|
3
|
-
import { axios } from './api'
|
|
4
|
-
|
|
5
|
-
export interface NewPasswordPayload {
|
|
6
|
-
token: string
|
|
7
|
-
new_password: string
|
|
8
|
-
}
|
|
9
|
-
const ax: AxiosInstance = axios
|
|
10
|
-
|
|
11
|
-
ax.interceptors.request.use((config) => {
|
|
12
|
-
const token = localStorage.getItem('access_token')
|
|
13
|
-
if (token !== null && config.headers) {
|
|
14
|
-
config.headers.Authorization = `Bearer ${token}`
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const urlParams = new URLSearchParams(window.location.search)
|
|
18
|
-
const resetToken = urlParams.get('token')
|
|
19
|
-
|
|
20
|
-
if (resetToken !== null && config.headers) {
|
|
21
|
-
config.headers.Authorization = `Bearer ${resetToken}`
|
|
22
|
-
}
|
|
23
|
-
return config
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export async function login(username: string, password: string) {
|
|
27
|
-
const { data } = await ax.post(
|
|
28
|
-
'/auth/login',
|
|
29
|
-
{
|
|
30
|
-
username: username.toLowerCase(),
|
|
31
|
-
password
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
localStorage.setItem('access_token', data.access_token)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function logout() {
|
|
38
|
-
localStorage.removeItem('access_token')
|
|
39
|
-
window.location.reload()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function passwordRecovery(email?: string): Promise<AxiosResponse> {
|
|
43
|
-
return ax.post(`/auth/password-recovery`, { email })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function resetPassword(
|
|
47
|
-
newPassword: NewPasswordPayload['new_password']
|
|
48
|
-
): Promise<AxiosResponse> {
|
|
49
|
-
return ax.post('/auth/reset-password', { new_password: newPassword })
|
|
50
|
-
}
|