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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8212448863dcae6fbb3ddafc3b281fdb3b04eb0886859bda832c0126e145d24
4
- data.tar.gz: 715cbeefbfd98e88942ad4b13d9ae8514452a1f7527653218a79ac54a93b2400
3
+ metadata.gz: 8e0bdcb75fbd43e55803cc7c21203215a2cba5a42d840dc925b595767a947138
4
+ data.tar.gz: 9da00247066e1b51919e4619b3fdc290a5f25a8772ff1c358836a3f0fa71c445
5
5
  SHA512:
6
- metadata.gz: 3703dce9fa9f65e75d1456c429a426ae4c6d26c87d087fe308d2a508d031d6b55a428fc70c1fab38312c1c5ffd2ab2068c9860a9e126419e239f8ea1746984c1
7
- data.tar.gz: fdc6850e87c3e89a144e2cb1555e686fda91bab1a2e37ce70de8892cc95824e18880245a42521af86b606c069eb1dc9a2276513c5478f06339d4b257fec6ce54
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?: any
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
- Params extends Exclude<Resource['Params'], undefined>[Method],
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.1.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-18 00:00:00.000000000 Z
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.1.2
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