rbs_ts_generator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/rbs_ts/templates/rbs_ts_runtime.ts +3 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e0bdcb75fbd43e55803cc7c21203215a2cba5a42d840dc925b595767a947138
|
4
|
+
data.tar.gz: 9da00247066e1b51919e4619b3fdc290a5f25a8772ff1c358836a3f0fa71c445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd4417dadbb8f9b18c6f3dc4d3e85f80cd0f7dad4954db298f49c58048ddd7d5341e37361aead84038132b9068127e74a5241e8dfea9515d1508b0188db00e2
|
7
|
+
data.tar.gz: d6f7285ff572d6ce0e1854a34c01ac62dd9ec763fdc13b7f06579efd050cff0c1a788bda584682910697a146f79249bfd241779d963e336f5fb3449e64b1ef7a
|
@@ -2,16 +2,14 @@ type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'
|
|
2
2
|
type BaseResource = {
|
3
3
|
path: (args: any) => string
|
4
4
|
names: string[]
|
5
|
-
Methods?:
|
5
|
+
Methods?: HttpMethods
|
6
6
|
Params?: { [method in HttpMethods]?: any }
|
7
7
|
Return?: { [method in HttpMethods]?: any }
|
8
8
|
}
|
9
9
|
export async function railsApi<
|
10
10
|
Method extends Exclude<Resource['Methods'], undefined>,
|
11
11
|
Resource extends BaseResource,
|
12
|
-
|
13
|
-
Return extends Exclude<Resource['Return'], undefined>[Method]
|
14
|
-
>(method: Method, { path, names }: Resource, params: Params): Promise<{ status: number, json: Return }> {
|
12
|
+
>(method: Method, { path, names }: Resource, params: Exclude<Resource['Params'], undefined>[Method]): Promise<{ status: number, json: Exclude<Resource['Return'], undefined>[Method] }> {
|
15
13
|
const tag = document.querySelector<HTMLMetaElement>('meta[name=csrf-token]')
|
16
14
|
const paramsNotInNames = Object.keys(params).reduce<object>((ps, key) => names.indexOf(key) === - 1 ? { ...ps, [key]: params[key] } : ps, {})
|
17
15
|
const searchParams = new URLSearchParams()
|
@@ -29,6 +27,6 @@ export async function railsApi<
|
|
29
27
|
'X-CSRF-Token': tag.content
|
30
28
|
}
|
31
29
|
})
|
32
|
-
const json = await response.json() as Return
|
30
|
+
const json = await response.json() as Exclude<Resource['Return'], undefined>[Method]
|
33
31
|
return new Promise((resolve) => resolve({ status: response.status, json: json }))
|
34
32
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_ts_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seiei Miyagi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.2.0.pre1
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Generate TypeScript that includes routes definition and request / response
|