js-routes 2.3.0 → 2.3.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -3
- data/Readme.md +90 -24
- data/lib/js_routes/configuration.rb +20 -1
- data/lib/js_routes/instance.rb +21 -12
- data/lib/js_routes/middleware.rb +1 -1
- data/lib/js_routes/route.rb +2 -1
- data/lib/js_routes/types.rb +12 -3
- data/lib/js_routes/version.rb +1 -1
- data/lib/routes.d.ts +0 -5
- data/lib/routes.js +1 -7
- data/lib/routes.ts +1 -9
- data/lib/templates/initializer.rb +23 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 771e5ddecccbde6b5b78778d456fe9602a4ae4b2aaa89e821cd6bda24be95565
|
4
|
+
data.tar.gz: b0ac96fe4273cc21fa616614429e270a393c7bcd11f15b5b79e1b14e56ec579f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 150bccfe350126ca0db67d03a8a7bbc22884edd63ef2e86c1cecd4ac2d0d72b941d7f1133cadbe64d19f99332be22db9891ca42f2f4ccfbec7e77447b741fb71
|
7
|
+
data.tar.gz: 2a51b7337560e055a21ff96be1b6f89d40d88bc6b541c56129a5f99823436a7c31027cc6e029f6b33b00a42805cd7986d805a30fc8a8ce5cc4e9bd5be20e2757
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.3.2
|
4
|
+
|
5
|
+
* Add `banner` option that allow to control JSDoc on top of generated file. [#324](https://github.com/bogdan/repo/issues/324).
|
6
|
+
|
7
|
+
``` ruby
|
8
|
+
JsRoutes.configure do |c|
|
9
|
+
c.banner = -> {
|
10
|
+
commit_hash = `git rev-parse --short HEAD`.strip
|
11
|
+
|
12
|
+
<<~DOC
|
13
|
+
@file Javascript Route helpers of my magic pony app.
|
14
|
+
@author Bogdan Gusiev
|
15
|
+
@license MIT
|
16
|
+
@version #{commit_hash}
|
17
|
+
DOC
|
18
|
+
}
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
## v2.3.1
|
23
|
+
|
24
|
+
* Add timestamp on when routes.js was generated into banner.
|
25
|
+
* Fix application specified directly without proc. [#323](https://github.com/railsware/js-routes/issues/323)
|
26
|
+
* Support `optional_definition_params` option. See [Related Docs](./Readme.md#optional-definition-params).
|
27
|
+
|
3
28
|
## v2.3.0
|
4
29
|
|
5
30
|
* Drop support of Rails 4.x
|
6
|
-
* Fix support of shakapacker [#321](https://github.com/railsware/js-routes/
|
7
|
-
* Fix support for Rails 8 [#319](https://github.com/railsware/js-routes/
|
31
|
+
* Fix support of shakapacker [#321](https://github.com/railsware/js-routes/issues/321).
|
32
|
+
* Fix support for Rails 8 [#319](https://github.com/railsware/js-routes/issues/319)
|
8
33
|
* Deprecated `rake js:routes:typescript`.
|
9
34
|
`rake js:routes` now automatically detects if types support can be used on not.
|
10
35
|
|
@@ -12,7 +37,7 @@
|
|
12
37
|
|
13
38
|
* Remove sorbet files from repo
|
14
39
|
* Clearly define files included in gem
|
15
|
-
* Fix Middleware and Middleware generator bugs [#316](https://github.com/railsware/js-routes/
|
40
|
+
* Fix Middleware and Middleware generator bugs [#316](https://github.com/railsware/js-routes/issues/316)
|
16
41
|
* Remove empty object linter warning on DTS module
|
17
42
|
* Generators: Add `.ts` extension when searching for main JS file of the project
|
18
43
|
|
data/Readme.md
CHANGED
@@ -42,8 +42,8 @@ There are several possible ways to setup JsRoutes:
|
|
42
42
|
|
43
43
|
### Quick Start
|
44
44
|
|
45
|
-
Setup [Rack Middleware](https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack)
|
46
|
-
to automatically generate and maintain `routes.js` file and corresponding
|
45
|
+
Setup [Rack Middleware](https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack)
|
46
|
+
to automatically generate and maintain `routes.js` file and corresponding
|
47
47
|
[Typescript definitions](https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html) `routes.d.ts`:
|
48
48
|
|
49
49
|
#### Use a Generator
|
@@ -70,13 +70,12 @@ import {post_path} from '../routes';
|
|
70
70
|
alert(post_path(1))
|
71
71
|
```
|
72
72
|
|
73
|
-
Upgrade js building process to update js-routes files in `Rakefile`:
|
73
|
+
Upgrade js building process to update js-routes files in `Rakefile`:
|
74
74
|
|
75
75
|
``` ruby
|
76
|
-
task "javascript:build" => "js:routes
|
76
|
+
task "javascript:build" => "js:routes"
|
77
77
|
# For setups without jsbundling-rails
|
78
|
-
task "assets:precompile" => "js:routes
|
79
|
-
|
78
|
+
task "assets:precompile" => "js:routes"
|
80
79
|
```
|
81
80
|
|
82
81
|
Add js-routes files to `.gitignore`:
|
@@ -236,7 +235,7 @@ JsRoutes.definitions! # to output to file
|
|
236
235
|
JsRoutes.definitions # to output to string
|
237
236
|
```
|
238
237
|
|
239
|
-
Even more advanced setups can be achieved by setting `module_type` to `DTS` inside [configuration](#module_type)
|
238
|
+
Even more advanced setups can be achieved by setting `module_type` to `DTS` inside [configuration](#module_type)
|
240
239
|
which will cause any `JsRoutes` instance to generate defintions instead of routes themselves.
|
241
240
|
|
242
241
|
<div id="sprockets"></div>
|
@@ -325,9 +324,26 @@ Options to configure JavaScript file generator. These options are only available
|
|
325
324
|
* Sample route call when option is set to true: `users() // => /users`
|
326
325
|
* `application` - a key to specify which rails engine you want to generate routes too.
|
327
326
|
* This option allows to only generate routes for a specific rails engine, that is mounted into routes instead of all Rails app routes
|
328
|
-
*
|
327
|
+
* It is recommended to wrap the value with `lambda`. This will reduce the reliance on order during initialization your application.
|
328
|
+
* Default: `-> { Rails.application }`
|
329
329
|
* `file` - a file location where generated routes are stored
|
330
330
|
* Default: `app/javascript/routes.js` if setup with Webpacker, otherwise `app/assets/javascripts/routes.js` if setup with Sprockets.
|
331
|
+
* `optional_definition_params` - make all route paramters in definition optional
|
332
|
+
* See [related compatibility issue](#optional-definition-params)
|
333
|
+
* Default: `false`
|
334
|
+
* `banner` - specify a JSDoc comment on top of the file.
|
335
|
+
* It is not stripped by minifiers by default and helps to originate the content when debugging the build.
|
336
|
+
* You may want to control how much information from backend is exposed to potential attacker at the cost of your own comfort.
|
337
|
+
* See [JSDoc Guide](https://github.com/shri/JSDoc-Style-Guide/blob/master/README.md#files)
|
338
|
+
* Supports a lazy generation with `Proc`.
|
339
|
+
* Default: A string that generates the following:
|
340
|
+
|
341
|
+
```
|
342
|
+
/**
|
343
|
+
* File generated by js-routes 2.3.1 on 2024-12-04 09:45:59 +0100
|
344
|
+
* Based on Rails 7.2.0 routes of App
|
345
|
+
*/
|
346
|
+
```
|
331
347
|
|
332
348
|
<div id="formatter-options"></div>
|
333
349
|
|
@@ -359,33 +375,33 @@ import {
|
|
359
375
|
user_path, user_project_path, company_path
|
360
376
|
} from 'routes';
|
361
377
|
|
362
|
-
users_path()
|
378
|
+
users_path()
|
363
379
|
// => "/users"
|
364
380
|
|
365
|
-
user_path(1)
|
381
|
+
user_path(1)
|
366
382
|
// => "/users/1"
|
367
|
-
|
368
|
-
user_path(1, {format: 'json'})
|
383
|
+
|
384
|
+
user_path(1, {format: 'json'})
|
369
385
|
// => "/users/1.json"
|
370
386
|
|
371
|
-
user_path(1, {anchor: 'profile'})
|
387
|
+
user_path(1, {anchor: 'profile'})
|
372
388
|
// => "/users/1#profile"
|
373
389
|
|
374
|
-
new_user_project_path(1, {format: 'json'})
|
390
|
+
new_user_project_path(1, {format: 'json'})
|
375
391
|
// => "/users/1/projects/new.json"
|
376
392
|
|
377
|
-
user_project_path(1,2, {q: 'hello', custom: true})
|
393
|
+
user_project_path(1,2, {q: 'hello', custom: true})
|
378
394
|
// => "/users/1/projects/2?q=hello&custom=true"
|
379
395
|
|
380
|
-
user_project_path(1,2, {hello: ['world', 'mars']})
|
396
|
+
user_project_path(1,2, {hello: ['world', 'mars']})
|
381
397
|
// => "/users/1/projects/2?hello%5B%5D=world&hello%5B%5D=mars"
|
382
398
|
|
383
399
|
var google = {id: 1, name: "Google"};
|
384
|
-
company_path(google)
|
400
|
+
company_path(google)
|
385
401
|
// => "/companies/1"
|
386
402
|
|
387
403
|
var google = {id: 1, name: "Google", to_param: "google"};
|
388
|
-
company_path(google)
|
404
|
+
company_path(google)
|
389
405
|
// => "/companies/google"
|
390
406
|
```
|
391
407
|
|
@@ -418,7 +434,10 @@ user_path.requiredParams() // => ['id']
|
|
418
434
|
|
419
435
|
## Rails Compatibility
|
420
436
|
|
421
|
-
JsRoutes tries to replicate the Rails routing API as closely as possible.
|
437
|
+
JsRoutes tries to replicate the Rails routing API as closely as possible.
|
438
|
+
There are only 2 known issues with compatibility that happen very rarely and have their workarounds.
|
439
|
+
|
440
|
+
If you find any incompatibilities outside of ones below, please [open an issue](https://github.com/railsware/js-routes/issues/new).
|
422
441
|
|
423
442
|
### Object and Hash distinction issue
|
424
443
|
|
@@ -428,14 +447,63 @@ In this case you would need to pass a special key to help:
|
|
428
447
|
``` js
|
429
448
|
import {company_project_path} from '../routes'
|
430
449
|
|
431
|
-
company_project_path({company_id: 1, id: 2})
|
432
|
-
|
450
|
+
company_project_path({company_id: 1, id: 2})
|
451
|
+
// => Not enough parameters
|
452
|
+
company_project_path({company_id: 1, id: 2, _options: true})
|
453
|
+
// => "/companies/1/projects/2"
|
454
|
+
```
|
455
|
+
|
456
|
+
Use `special_options_key` to configure the `_options` parameter name.
|
457
|
+
|
458
|
+
<div id="optional-definition-params"></div>
|
459
|
+
|
460
|
+
### Rails required parameters specified as optional
|
461
|
+
|
462
|
+
Rails is very flexible on how route parameters can be specified.
|
463
|
+
All of the following calls will make the same result:
|
464
|
+
|
465
|
+
``` ruby
|
466
|
+
# Given route
|
467
|
+
# /inboxes/:inbox_id/messages/:message_id/attachments/:id
|
468
|
+
# every call below returns:
|
469
|
+
# => "/inboxes/1/messages/2/attachments/3"
|
470
|
+
|
471
|
+
inbox_message_attachment_path(1, 2, 3)
|
472
|
+
inbox_message_attachment_path(1, 2, id: 3)
|
473
|
+
inbox_message_attachment_path(1, message_id: 2, id: 3)
|
474
|
+
inbox_message_attachment_path(inbox_id: 1, message_id: 2, id: 3)
|
475
|
+
|
476
|
+
# including these mad versions
|
477
|
+
inbox_message_attachment_path(2, inbox_id: 1, id: 3)
|
478
|
+
inbox_message_attachment_path(1, 3, message_id: 2)
|
479
|
+
inbox_message_attachment_path(3, inbox_id: 1, message_id: 2)
|
433
480
|
```
|
434
481
|
|
482
|
+
While all of these methods are supported by JsRoutes, it is impossible to support them in `DTS` type definitions.
|
483
|
+
If you are using routes like this, use the following configuration that will prevent required parameters presence to be validated by definition:
|
484
|
+
|
485
|
+
``` ruby
|
486
|
+
JsRoutes.configure do |c|
|
487
|
+
c.optional_definition_params = true
|
488
|
+
end
|
489
|
+
```
|
490
|
+
|
491
|
+
This will enforce the following route signature:
|
492
|
+
|
493
|
+
``` typescript
|
494
|
+
export const inbox_message_attachment_path: ((
|
495
|
+
inbox_id?: RequiredRouteParameter,
|
496
|
+
message_id?: RequiredRouteParameter,
|
497
|
+
id?: RequiredRouteParameter,
|
498
|
+
options?: RouteOptions
|
499
|
+
) => string) & RouteHelperExtras;
|
500
|
+
```
|
501
|
+
|
502
|
+
That will make every call above valid.
|
435
503
|
|
436
504
|
## What about security?
|
437
505
|
|
438
|
-
JsRoutes itself does not have security holes.
|
506
|
+
JsRoutes itself does not have security holes.
|
439
507
|
It makes URLs without access protection more reachable by potential attacker.
|
440
508
|
If that is an issue for you, you may use one of the following solutions:
|
441
509
|
|
@@ -488,5 +556,3 @@ Advantages of this one are:
|
|
488
556
|
* Full rails compatibility
|
489
557
|
* Support Rails `#to_param` convention for seo optimized paths
|
490
558
|
* Well tested
|
491
|
-
|
492
|
-
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "pathname"
|
4
4
|
require "js_routes/types"
|
5
5
|
require 'js_routes/utils'
|
6
|
+
require 'js_routes/version'
|
6
7
|
|
7
8
|
module JsRoutes
|
8
9
|
class Configuration
|
@@ -37,6 +38,10 @@ module JsRoutes
|
|
37
38
|
attr_accessor :documentation
|
38
39
|
sig { returns(T.nilable(String)) }
|
39
40
|
attr_accessor :module_type
|
41
|
+
sig { returns(T::Boolean) }
|
42
|
+
attr_accessor :optional_definition_params
|
43
|
+
sig { returns(BannerCaller) }
|
44
|
+
attr_accessor :banner
|
40
45
|
|
41
46
|
sig {params(attributes: T.nilable(Options)).void }
|
42
47
|
def initialize(attributes = nil)
|
@@ -51,9 +56,11 @@ module JsRoutes
|
|
51
56
|
@compact = T.let(false, T::Boolean)
|
52
57
|
@serializer = T.let(nil, T.nilable(String))
|
53
58
|
@special_options_key = T.let("_options", Literal)
|
54
|
-
@application = T.let(-> { Rails.application }, ApplicationCaller)
|
59
|
+
@application = T.let(T.unsafe(-> { Rails.application }), ApplicationCaller)
|
55
60
|
@module_type = T.let('ESM', T.nilable(String))
|
56
61
|
@documentation = T.let(true, T::Boolean)
|
62
|
+
@optional_definition_params = T.let(false, T::Boolean)
|
63
|
+
@banner = T.let(default_banner, BannerCaller)
|
57
64
|
|
58
65
|
return unless attributes
|
59
66
|
assign(attributes)
|
@@ -155,5 +162,17 @@ module JsRoutes
|
|
155
162
|
raise "JsRoutes namespace option can only be used if module_type is nil"
|
156
163
|
end
|
157
164
|
end
|
165
|
+
|
166
|
+
sig { returns(T.proc.returns(String)) }
|
167
|
+
def default_banner
|
168
|
+
-> () {
|
169
|
+
app = application.is_a?(Proc) ? T.unsafe(application).call : application
|
170
|
+
<<~TXT
|
171
|
+
File generated by js-routes #{JsRoutes::VERSION} on #{Time.now}
|
172
|
+
Based on Rails #{Rails.version} routes of #{app.class}
|
173
|
+
TXT
|
174
|
+
|
175
|
+
}
|
176
|
+
end
|
158
177
|
end
|
159
178
|
end
|
data/lib/js_routes/instance.rb
CHANGED
@@ -29,9 +29,9 @@ module JsRoutes
|
|
29
29
|
if named_routes.empty?
|
30
30
|
if application.is_a?(Rails::Application)
|
31
31
|
if Rails.version >= "8.0.0"
|
32
|
-
application.reload_routes_unless_loaded
|
32
|
+
T.unsafe(application).reload_routes_unless_loaded
|
33
33
|
else
|
34
|
-
application.reload_routes!
|
34
|
+
T.unsafe(application).reload_routes!
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -43,7 +43,20 @@ module JsRoutes
|
|
43
43
|
raise("Missing key #{key} in JS template")
|
44
44
|
end
|
45
45
|
end
|
46
|
-
content + routes_export + prevent_types_export
|
46
|
+
banner + content + routes_export + prevent_types_export
|
47
|
+
end
|
48
|
+
|
49
|
+
sig { returns(String) }
|
50
|
+
def banner
|
51
|
+
banner = @configuration.banner
|
52
|
+
banner = banner.call if banner.is_a?(Proc)
|
53
|
+
return "" if banner.blank?
|
54
|
+
[
|
55
|
+
"/**",
|
56
|
+
*banner.split("\n").map { |line| " * #{line}" },
|
57
|
+
" */",
|
58
|
+
"",
|
59
|
+
].join("\n")
|
47
60
|
end
|
48
61
|
|
49
62
|
sig { void }
|
@@ -76,16 +89,11 @@ module JsRoutes
|
|
76
89
|
|
77
90
|
sig { returns(T::Hash[String, String]) }
|
78
91
|
def js_variables
|
79
|
-
version = Rails.version
|
80
92
|
prefix = @configuration.prefix
|
81
93
|
prefix = prefix.call if prefix.is_a?(Proc)
|
82
94
|
{
|
83
|
-
'GEM_VERSION' => JsRoutes::VERSION,
|
84
95
|
'ROUTES_OBJECT' => routes_object,
|
85
|
-
'
|
86
|
-
'DEPRECATED_GLOBBING_BEHAVIOR' => version >= '4.0.0' && version < '4.1.0',
|
87
|
-
'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => version < '7.0.0',
|
88
|
-
'APP_CLASS' => application.class.to_s,
|
96
|
+
'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => Rails.version < '7.0.0',
|
89
97
|
'DEFAULT_URL_OPTIONS' => json(@configuration.default_url_options),
|
90
98
|
'PREFIX' => json(prefix),
|
91
99
|
'SPECIAL_OPTIONS_KEY' => json(@configuration.special_options_key),
|
@@ -118,7 +126,8 @@ module JsRoutes
|
|
118
126
|
|
119
127
|
sig { returns(Application) }
|
120
128
|
def application
|
121
|
-
@configuration.application
|
129
|
+
app = @configuration.application
|
130
|
+
app.is_a?(Proc) ? app.call : app
|
122
131
|
end
|
123
132
|
|
124
133
|
sig { params(value: T.untyped).returns(String) }
|
@@ -187,7 +196,7 @@ export {};
|
|
187
196
|
rails_engine_app = T.unsafe(app_from_route(route))
|
188
197
|
if rails_engine_app.is_a?(Class) &&
|
189
198
|
rails_engine_app < Rails::Engine && !route.path.anchored
|
190
|
-
rails_engine_app.routes.named_routes.flat_map do |_, engine_route|
|
199
|
+
T.unsafe(rails_engine_app).routes.named_routes.flat_map do |_, engine_route|
|
191
200
|
route_helpers_if_match(engine_route, route)
|
192
201
|
end
|
193
202
|
else
|
@@ -200,7 +209,7 @@ export {};
|
|
200
209
|
app = route.app
|
201
210
|
# Rails Engine can use additional
|
202
211
|
# ActionDispatch::Routing::Mapper::Constraints, which contain app
|
203
|
-
if app.is_a?(ActionDispatch::Routing::Mapper::Constraints)
|
212
|
+
if app.is_a?(T.unsafe(ActionDispatch::Routing::Mapper::Constraints))
|
204
213
|
app.app
|
205
214
|
else
|
206
215
|
app
|
data/lib/js_routes/middleware.rb
CHANGED
@@ -6,7 +6,7 @@ module JsRoutes
|
|
6
6
|
# whenever routes.rb is modified
|
7
7
|
#
|
8
8
|
# Inspired by
|
9
|
-
# https://github.com/fnando/i18n-js/blob/
|
9
|
+
# https://github.com/fnando/i18n-js/blob/v3/lib/i18n/js/middleware.rb
|
10
10
|
class Middleware
|
11
11
|
include JsRoutes::Types
|
12
12
|
include RackApp
|
data/lib/js_routes/route.rb
CHANGED
@@ -66,7 +66,8 @@ module JsRoutes
|
|
66
66
|
sig { returns(String) }
|
67
67
|
def definition_body
|
68
68
|
options_type = optional_parts_type ? "#{optional_parts_type} & RouteOptions" : "RouteOptions"
|
69
|
-
|
69
|
+
predicate = @configuration.optional_definition_params ? '?' : ''
|
70
|
+
args = required_parts.map{|p| "#{apply_case(p)}#{predicate}: RequiredRouteParameter"}
|
70
71
|
args << "options?: #{options_type}"
|
71
72
|
"((\n#{args.join(",\n").indent(2)}\n) => string) & RouteHelperExtras"
|
72
73
|
end
|
data/lib/js_routes/types.rb
CHANGED
@@ -16,11 +16,20 @@ module JsRoutes
|
|
16
16
|
Literal = T.type_alias { T.any(String, Symbol) }
|
17
17
|
JourneyRoute = T.type_alias{ActionDispatch::Journey::Route}
|
18
18
|
RouteSpec = T.type_alias {T.untyped}
|
19
|
-
Application = T.type_alias
|
20
|
-
|
19
|
+
Application = T.type_alias do
|
20
|
+
T.any(T::Class[Rails::Engine], Rails::Application)
|
21
|
+
end
|
22
|
+
ApplicationCaller = T.type_alias do
|
23
|
+
T.any(Application, T.proc.returns(Application))
|
24
|
+
end
|
25
|
+
BannerCaller = T.type_alias do
|
26
|
+
T.any(String, NilClass, T.proc.returns(T.any(String, NilClass)))
|
27
|
+
end
|
21
28
|
Clusivity = T.type_alias { T.any(Regexp, T::Array[Regexp]) }
|
22
29
|
FileName = T.type_alias { T.any(String, Pathname, NilClass) }
|
23
|
-
ConfigurationBlock = T.type_alias
|
30
|
+
ConfigurationBlock = T.type_alias do
|
31
|
+
T.proc.params(arg0: JsRoutes::Configuration).void
|
32
|
+
end
|
24
33
|
Prefix = T.type_alias do
|
25
34
|
T.any(T.proc.returns(String), String, NilClass)
|
26
35
|
end
|
data/lib/js_routes/version.rb
CHANGED
data/lib/routes.d.ts
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* File generated by js-routes RubyVariables.GEM_VERSION
|
3
|
-
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
|
4
|
-
*/
|
5
1
|
declare type Optional<T> = {
|
6
2
|
[P in keyof T]?: T[P] | null;
|
7
3
|
};
|
@@ -64,7 +60,6 @@ declare type PartsTable = Collection<{
|
|
64
60
|
declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
|
65
61
|
declare const RubyVariables: {
|
66
62
|
PREFIX: string;
|
67
|
-
DEPRECATED_GLOBBING_BEHAVIOR: boolean;
|
68
63
|
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
|
69
64
|
SPECIAL_OPTIONS_KEY: string;
|
70
65
|
DEFAULT_URL_OPTIONS: RouteParameters;
|
data/lib/routes.js
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* File generated by js-routes RubyVariables.GEM_VERSION
|
3
|
-
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
|
4
|
-
*/
|
5
1
|
// eslint-disable-next-line
|
6
2
|
RubyVariables.WRAPPER(
|
7
3
|
// eslint-disable-next-line
|
@@ -415,9 +411,7 @@ RubyVariables.WRAPPER(
|
|
415
411
|
value = value.join("/");
|
416
412
|
}
|
417
413
|
const result = this.path_identifier(value);
|
418
|
-
return
|
419
|
-
? result
|
420
|
-
: encodeURI(result);
|
414
|
+
return encodeURI(result);
|
421
415
|
}
|
422
416
|
get_prefix() {
|
423
417
|
const prefix = this.configuration.prefix;
|
data/lib/routes.ts
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* File generated by js-routes RubyVariables.GEM_VERSION
|
3
|
-
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
|
4
|
-
*/
|
5
|
-
|
6
1
|
type Optional<T> = { [P in keyof T]?: T[P] | null };
|
7
2
|
type Collection<T> = Record<string, T>;
|
8
3
|
|
@@ -82,7 +77,6 @@ type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
|
|
82
77
|
|
83
78
|
declare const RubyVariables: {
|
84
79
|
PREFIX: string;
|
85
|
-
DEPRECATED_GLOBBING_BEHAVIOR: boolean;
|
86
80
|
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
|
87
81
|
SPECIAL_OPTIONS_KEY: string;
|
88
82
|
DEFAULT_URL_OPTIONS: RouteParameters;
|
@@ -606,9 +600,7 @@ RubyVariables.WRAPPER(
|
|
606
600
|
value = value.join("/");
|
607
601
|
}
|
608
602
|
const result = this.path_identifier(value as any);
|
609
|
-
return
|
610
|
-
? result
|
611
|
-
: encodeURI(result);
|
603
|
+
return encodeURI(result);
|
612
604
|
}
|
613
605
|
|
614
606
|
get_prefix(): string {
|
@@ -1,5 +1,27 @@
|
|
1
1
|
JsRoutes.setup do |c|
|
2
2
|
# Setup your JS module system:
|
3
|
-
# ESM, CJS, AMD, UMD or nil
|
3
|
+
# ESM, CJS, AMD, UMD or nil.
|
4
4
|
# c.module_type = "ESM"
|
5
|
+
|
6
|
+
# Legacy setup for no modules system.
|
7
|
+
# Sets up a global variable `Routes`
|
8
|
+
# that holds route helpers.
|
9
|
+
# c.module_type = nil
|
10
|
+
# c.namespace = "Routes"
|
11
|
+
|
12
|
+
# Follow javascript naming convention
|
13
|
+
# but lose the ability to match helper name
|
14
|
+
# on backend and frontend consistently.
|
15
|
+
# c.camel_case = true
|
16
|
+
|
17
|
+
# Generate only helpers that match specific pattern.
|
18
|
+
# c.exclude = /^api_/
|
19
|
+
# c.include = /^admin_/
|
20
|
+
|
21
|
+
# Generate `*_url` helpers besides `*_path`
|
22
|
+
# for apps that work on multiple domains.
|
23
|
+
# c.url_links = true
|
24
|
+
|
25
|
+
# More options:
|
26
|
+
# @see https://github.com/railsware/js-routes#available-options
|
5
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -144,9 +144,9 @@ licenses:
|
|
144
144
|
- MIT
|
145
145
|
metadata:
|
146
146
|
bug_tracker_uri: https://github.com/railsware/js-routes/issues
|
147
|
-
changelog_uri: https://github.com/railsware/js-routes/blob/v2.3.
|
147
|
+
changelog_uri: https://github.com/railsware/js-routes/blob/v2.3.2/CHANGELOG.md
|
148
148
|
documentation_uri: https://github.com/railsware/js-routes
|
149
|
-
source_code_uri: https://github.com/railsware/js-routes/tree/v2.3.
|
149
|
+
source_code_uri: https://github.com/railsware/js-routes/tree/v2.3.2/activerecord
|
150
150
|
rubygems_mfa_required: 'true'
|
151
151
|
github_repo: ssh://github.com/railsware/js-routes
|
152
152
|
post_install_message:
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
|
-
rubygems_version: 3.5.
|
167
|
+
rubygems_version: 3.5.14
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Brings Rails named routes to javascript
|