@globalbrain/sefirot 3.20.0 → 3.22.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/lib/composables/Lang.ts +6 -0
- package/lib/http/Http.ts +34 -28
- package/package.json +14 -14
package/lib/composables/Lang.ts
CHANGED
package/lib/http/Http.ts
CHANGED
|
@@ -5,9 +5,14 @@ import { $fetch, type FetchOptions } from 'ofetch'
|
|
|
5
5
|
import { stringify } from 'qs'
|
|
6
6
|
|
|
7
7
|
export class Http {
|
|
8
|
-
static
|
|
8
|
+
static base: string | undefined = undefined
|
|
9
|
+
static xsrfUrl: string | false = '/api/csrf-cookie'
|
|
9
10
|
|
|
10
11
|
private async ensureXsrfToken(): Promise<string | undefined> {
|
|
12
|
+
if (!Http.xsrfUrl) {
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
let xsrfToken = parseCookie(document.cookie)['XSRF-TOKEN']
|
|
12
17
|
|
|
13
18
|
if (!xsrfToken) {
|
|
@@ -35,6 +40,7 @@ export class Http {
|
|
|
35
40
|
return [
|
|
36
41
|
`${url}${queryString ? `?${queryString}` : ''}`,
|
|
37
42
|
{
|
|
43
|
+
baseURL: Http.base,
|
|
38
44
|
method,
|
|
39
45
|
credentials: 'include',
|
|
40
46
|
...options,
|
|
@@ -55,33 +61,6 @@ export class Http {
|
|
|
55
61
|
return $fetch.raw<T, any>(...(await this.buildRequest(url, options)))
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
private objectToFormData(obj: any, form?: FormData, namespace?: string) {
|
|
59
|
-
const fd = form || new FormData()
|
|
60
|
-
let formKey: string
|
|
61
|
-
|
|
62
|
-
for (const property in obj) {
|
|
63
|
-
if (Reflect.has(obj, property)) {
|
|
64
|
-
if (namespace) {
|
|
65
|
-
formKey = `${namespace}[${property}]`
|
|
66
|
-
} else {
|
|
67
|
-
formKey = property
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (obj[property] === undefined) {
|
|
71
|
-
continue
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof obj[property] === 'object' && !(obj[property] instanceof Blob)) {
|
|
75
|
-
this.objectToFormData(obj[property], fd, property)
|
|
76
|
-
} else {
|
|
77
|
-
fd.append(formKey, obj[property])
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return fd
|
|
83
|
-
}
|
|
84
|
-
|
|
85
64
|
async get<T = any>(url: string, options?: FetchOptions): Promise<T> {
|
|
86
65
|
return this.performRequest<T>(url, { method: 'GET', ...options })
|
|
87
66
|
}
|
|
@@ -132,6 +111,33 @@ export class Http {
|
|
|
132
111
|
|
|
133
112
|
FileSaver.saveAs(blob, filename as string)
|
|
134
113
|
}
|
|
114
|
+
|
|
115
|
+
private objectToFormData(obj: any, form?: FormData, namespace?: string) {
|
|
116
|
+
const fd = form || new FormData()
|
|
117
|
+
let formKey: string
|
|
118
|
+
|
|
119
|
+
for (const property in obj) {
|
|
120
|
+
if (Reflect.has(obj, property)) {
|
|
121
|
+
if (namespace) {
|
|
122
|
+
formKey = `${namespace}[${property}]`
|
|
123
|
+
} else {
|
|
124
|
+
formKey = property
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (obj[property] === undefined) {
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (typeof obj[property] === 'object' && !(obj[property] instanceof Blob)) {
|
|
132
|
+
this.objectToFormData(obj[property], fd, property)
|
|
133
|
+
} else {
|
|
134
|
+
fd.append(formKey, obj[property])
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return fd
|
|
140
|
+
}
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
export type { FetchOptions }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@globalbrain/sefirot",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"packageManager": "pnpm@8.
|
|
3
|
+
"version": "3.22.0",
|
|
4
|
+
"packageManager": "pnpm@8.14.0",
|
|
5
5
|
"description": "Vue Components for Global Brain Design System.",
|
|
6
6
|
"author": "Kia Ishii <ka.ishii@globalbrains.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"@types/markdown-it": "^13.0.7",
|
|
47
47
|
"@vuelidate/core": "^2.0.3",
|
|
48
48
|
"@vuelidate/validators": "^2.0.4",
|
|
49
|
-
"@vueuse/core": "^10.7.
|
|
49
|
+
"@vueuse/core": "^10.7.1",
|
|
50
50
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
51
51
|
"fuse.js": "^7.0.0",
|
|
52
52
|
"lodash-es": "^4.17.21",
|
|
53
53
|
"markdown-it": "^14.0.0",
|
|
54
54
|
"normalize.css": "^8.0.1",
|
|
55
55
|
"pinia": "^2.1.7",
|
|
56
|
-
"postcss": "^8.4.
|
|
56
|
+
"postcss": "^8.4.33",
|
|
57
57
|
"postcss-nested": "^6.0.1",
|
|
58
58
|
"v-calendar": "^3.1.2",
|
|
59
|
-
"vue": "^3.
|
|
59
|
+
"vue": "^3.4.5",
|
|
60
60
|
"vue-router": "^4.2.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"@types/body-scroll-lock": "^3.1.2",
|
|
81
81
|
"@types/lodash-es": "^4.17.12",
|
|
82
82
|
"@types/markdown-it": "^13.0.7",
|
|
83
|
-
"@types/node": "^20.10.
|
|
84
|
-
"@vitejs/plugin-vue": "^5.0.
|
|
85
|
-
"@vitest/coverage-v8": "^1.1.
|
|
83
|
+
"@types/node": "^20.10.6",
|
|
84
|
+
"@vitejs/plugin-vue": "^5.0.2",
|
|
85
|
+
"@vitest/coverage-v8": "^1.1.2",
|
|
86
86
|
"@vue/test-utils": "^2.4.3",
|
|
87
87
|
"@vuelidate/core": "^2.0.3",
|
|
88
88
|
"@vuelidate/validators": "^2.0.4",
|
|
89
|
-
"@vueuse/core": "^10.7.
|
|
89
|
+
"@vueuse/core": "^10.7.1",
|
|
90
90
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
91
91
|
"eslint": "^8.56.0",
|
|
92
92
|
"fuse.js": "^7.0.0",
|
|
@@ -96,17 +96,17 @@
|
|
|
96
96
|
"markdown-it": "^14.0.0",
|
|
97
97
|
"normalize.css": "^8.0.1",
|
|
98
98
|
"pinia": "^2.1.7",
|
|
99
|
-
"postcss": "^8.4.
|
|
99
|
+
"postcss": "^8.4.33",
|
|
100
100
|
"postcss-nested": "^6.0.1",
|
|
101
101
|
"punycode": "^2.3.1",
|
|
102
102
|
"release-it": "^17.0.1",
|
|
103
103
|
"typescript": "~5.3.3",
|
|
104
104
|
"v-calendar": "^3.1.2",
|
|
105
105
|
"vite": "^5.0.10",
|
|
106
|
-
"vitepress": "1.0.0-rc.
|
|
107
|
-
"vitest": "^1.1.
|
|
108
|
-
"vue": "^3.
|
|
106
|
+
"vitepress": "1.0.0-rc.35",
|
|
107
|
+
"vitest": "^1.1.2",
|
|
108
|
+
"vue": "^3.4.5",
|
|
109
109
|
"vue-router": "^4.2.5",
|
|
110
|
-
"vue-tsc": "^1.8.
|
|
110
|
+
"vue-tsc": "^1.8.27"
|
|
111
111
|
}
|
|
112
112
|
}
|