foobara-typescript-remote-command-generator 1.1.5 → 1.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8215d8808315c6f8fd3d1e630ce0e580a6a577c5b1c70a417347ee2dc334998
4
- data.tar.gz: 9cda7eed3bea9cd2dadb446857d1fb4c133e0b35cbad491c7c1527d49d682d1a
3
+ metadata.gz: 4ded6d4d4e950f079230273d922ef380455597c4dd0fcf01005396156871291e
4
+ data.tar.gz: 9f2ff8044bd23a32c5db7768a4783e17c3be1742f43edf7d6c60664935e9ff1f
5
5
  SHA512:
6
- metadata.gz: 83ce0b3291adbc9bff8e6328f7f7c2a7bd386fb46aae876282ed4f7ee88bb401148cd99720f38fdbbf31d5bf73df3e5a9167a0830a120409a38cd4a5f8e90f8d
7
- data.tar.gz: 829447664b106704867d6c4345d677a6f252b2ffe730a4f54719ffa37b7998a6ec8385f7a22abf3ac57e2a5f8b2e0841b14fdc6ade33415adf80cb8fe76048b7
6
+ metadata.gz: 4447f6d43c30e80f514c8db191bbf8bb115ded65df4febaa030c877bffd88db7820db66d637185353e7bb7aab81d666dc38002d5413d99358f5a07e217fdcbfc
7
+ data.tar.gz: 4929a9a0ccb737f0df18979adcfc7d3d223c272c810f44aef208441b01077b77fcde6a114e0f822347530a39774c5bd06b0d2463ddb6503835a18d3853ea7449
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.1.6] - 2025-10-17
2
+
3
+ - Dirty all queries on login/logout, not just GetCurrentUser
4
+ - Remove no-longer needed /setup.ts file generation
5
+
1
6
  ## [1.1.5] - 2025-10-15
2
7
 
3
8
  - Implement castJsonResult
@@ -36,10 +36,7 @@ module Foobara
36
36
  when "Foobara::Auth::Logout"
37
37
  Services::Auth::LogoutGenerator
38
38
  when /\bGetCurrentUser$/
39
- [
40
- Services::Auth::RequiresAuthGenerator,
41
- Services::Auth::SetupGenerator
42
- ]
39
+ Services::Auth::RequiresAuthGenerator
43
40
  else
44
41
  if manifest.requires_authentication?
45
42
  Services::Auth::RequiresAuthGenerator
@@ -383,12 +380,7 @@ module Foobara
383
380
 
384
381
  def path_to_root
385
382
  path = super
386
-
387
- if path.empty?
388
- "./"
389
- else
390
- path
391
- end
383
+ path.empty? ? "./" : path
392
384
  end
393
385
  end
394
386
  end
@@ -59,7 +59,6 @@ module Foobara
59
59
 
60
60
  def run_post_generation_tasks
61
61
  eslint_fix
62
- warn_about_adding_setup_to_index
63
62
  end
64
63
 
65
64
  def eslint_fix
@@ -74,24 +73,6 @@ module Foobara
74
73
  end
75
74
  end
76
75
  end
77
-
78
- def warn_about_adding_setup_to_index
79
- if paths_to_source_code.key?("setup.ts")
80
- index_tsx_path = "#{output_directory}/../index.tsx"
81
-
82
- if File.exist?(index_tsx_path)
83
- unless File.read(index_tsx_path) =~ /import.*domains\/setup/
84
- warn "WARNING: you should add the following to src/index.tsx:\n\n" \
85
- "import './domains/setup'"
86
- end
87
- else
88
- # :nocov:
89
- warn "WARNING: Make sure you add the following somewhere:\n\n" \
90
- "import './domains/setup'"
91
- # :nocov:
92
- end
93
- end
94
- end
95
76
  end
96
77
  end
97
78
  end
@@ -1,31 +1,25 @@
1
1
  import type Query from '../../../base/Query'
2
2
  import type RemoteCommand from '../../../base/RemoteCommand'
3
+ import { forEachQuery } from '../../../base/QueryCache'
3
4
 
4
- let getCurrentUserQuery: Query<RemoteCommand<any, any, any>> | undefined
5
-
6
- export function setGetCurrentUserQuery (query: Query<RemoteCommand<any, any, any>>): void {
7
- getCurrentUserQuery = query
8
- }
9
-
10
- function setCurrentUserDirty () {
11
- console.log('setCurrentUserDirty')
12
- if (getCurrentUserQuery != null) {
13
- getCurrentUserQuery.setDirty()
14
- }
5
+ function dirtyAllQueries () {
6
+ forEachQuery((query: Query<RemoteCommand<any, any, any>>) => {
7
+ query.setDirty()
8
+ })
15
9
  }
16
10
 
17
11
  const accessTokens = new Map<string, string>()
18
12
 
19
13
  const logout = (urlBase: string): void => {
20
14
  accessTokens.delete(urlBase)
21
- setCurrentUserDirty()
15
+ dirtyAllQueries()
22
16
  }
23
17
  let handleLogout: (baseUrl: string) => void = logout
24
18
 
25
19
  const tokenForUrl = (baseUrl: string): string | undefined => accessTokens.get(baseUrl)
26
20
  const handleLogin: (baseUrl: string, accessToken: string) => void = (baseUrl, accessToken) => {
27
21
  accessTokens.set(baseUrl, accessToken)
28
- setCurrentUserDirty()
22
+ dirtyAllQueries()
29
23
  }
30
24
 
31
25
  if (typeof BroadcastChannel !== 'undefined') {
@@ -33,6 +33,10 @@ export function getQuery<CommandT extends RemoteCommand<any, any, any>> (
33
33
  return query
34
34
  }
35
35
 
36
+ export function forEachQuery (callback: (query: Query<RemoteCommand<any, any, any>>) => void): void {
37
+ queryCache.forEach(callback)
38
+ }
39
+
36
40
  function toKey<CommandT extends RemoteCommand<any, any, any>> (
37
41
  CommandClass: RemoteCommandConstructor<CommandT>,
38
42
  inputs: InputsOf<CommandT> | undefined
@@ -57,19 +57,23 @@ export default function useQuery<CommandT extends RemoteCommand<any, any, any>>
57
57
  queryRef.current = query
58
58
  }
59
59
 
60
+ const [queryState, setQueryState] = useState<QueryState<CommandT>>(
61
+ queryToQueryState<CommandT>(query)
62
+ )
63
+
60
64
  useEffect(() => {
61
- const unsubscribe = query?.onChange(() => {
62
- if (query != null) { // just here to satisfy type checker
65
+ if (query == null) {
66
+ return undefined
67
+ }
68
+
69
+ const removeListener = query.onChange(() => {
70
+ if (query != null) { // Just here to satisfy type check
63
71
  setQueryState(queryToQueryState<CommandT>(query))
64
72
  }
65
73
  })
66
74
 
67
- return unsubscribe
75
+ return removeListener
68
76
  }, [query])
69
77
 
70
- const [queryState, setQueryState] = useState<QueryState<CommandT>>(
71
- queryToQueryState<CommandT>(query)
72
- )
73
-
74
78
  return queryState
75
79
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-typescript-remote-command-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -70,7 +70,6 @@ files:
70
70
  - src/remote_generator/services/auth/refresh_login_generator.rb
71
71
  - src/remote_generator/services/auth/requires_auth_command_generator.rb
72
72
  - src/remote_generator/services/auth/requires_auth_generator.rb
73
- - src/remote_generator/services/auth/setup_generator.rb
74
73
  - src/remote_generator/services/command_cast_result_generator.rb
75
74
  - src/remote_generator/services/command_errors_generator.rb
76
75
  - src/remote_generator/services/command_errors_index_generator.rb
@@ -136,7 +135,6 @@ files:
136
135
  - templates/base/RemoteCommand.ts
137
136
  - templates/base/RemoteCommandTypes.ts
138
137
  - templates/hooks/useQuery.ts
139
- - templates/setup.ts.erb
140
138
  homepage: https://github.com/foobara/typescript-remote-command-generator
141
139
  licenses:
142
140
  - Apache-2.0
@@ -1,25 +0,0 @@
1
- module Foobara
2
- module RemoteGenerator
3
- class Services
4
- module Auth
5
- class SetupGenerator < CommandGenerator
6
- def template_path
7
- "setup.ts.erb"
8
- end
9
-
10
- def target_path
11
- ["setup.ts"]
12
- end
13
-
14
- def command_generator
15
- generator_for(command_manifest)
16
- end
17
-
18
- def dependencies
19
- [command_generator]
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,6 +0,0 @@
1
- import { getQuery } from './base/QueryCache'
2
- import { setGetCurrentUserQuery } from './Foobara/Auth/utils/accessTokens'
3
-
4
- import <%= command_generator.import_destructure %> from "<%= path_to_root %><%= command_generator.import_path %>"
5
-
6
- setGetCurrentUserQuery(getQuery(<%= dependency_group.non_colliding_type(command_generator) %>, undefined))