foobara-typescript-remote-command-generator 1.3.1 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf59c3786304e34b238364d087ca029225bd01bf158bf9ddb928112aa8e3a234
4
- data.tar.gz: 6b3fdc12eb0c6d9f4391b12ea5ed9b351ef90a48cf0aad1e8fa30288f56c7163
3
+ metadata.gz: 16a68cb56fbf77e520f577b5ef5d0b6c677d6461fb69ce242906d608b6412e3f
4
+ data.tar.gz: 35dcccf09cff04cad00c02423b77ebecdebc3643080cc9e534bae8e957dd273c
5
5
  SHA512:
6
- metadata.gz: 7c0b909fc48ecdeb842417d9b6b4f04ad556771c2dc949775e555ff6fd1f1f1f94b820e222246135abb51a5bcb737771028c5c2e68c160a6e1358e61e71dec20
7
- data.tar.gz: 64881ffe38ce0ce810b73bdc7a6d71fce9c7400979da2794a550403c2c1f81c19df4b9810f2c99fd003803c09400c0b3cf2be9df5aa5ddf8db84e96f48a4852e
6
+ metadata.gz: 952c659c1ace30fbbd24f980c8382db56f95757ac5a802b25ed19e5c6faf276dd1647f6fe999cb3afc49c3bb35b90003e95765ad2363f1ce160846cd9d3100d3
7
+ data.tar.gz: 78c60b378c18f6786c9d6cd29db44d7c693c45c433977deedeaec79694ccb4f640f092159349758be3d1094d04c83f379e6caaea4c3e3bd4c9d5e820e4929fcc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.4.0] - 2026-03-19
2
+
3
+ - Make things work with Vite instead of CRA
4
+
1
5
  ## [1.3.1] - 2026-02-28
2
6
 
3
7
  - Use a channel to make other tabs automatically reload their queries
@@ -148,6 +148,10 @@ module Foobara
148
148
  def attribute_names
149
149
  attributes_type.attribute_names
150
150
  end
151
+
152
+ def import_destructure
153
+ "{ type #{scoped_short_name} }"
154
+ end
151
155
  end
152
156
  end
153
157
  end
@@ -4,4 +4,4 @@
4
4
 
5
5
  type Inputs = <%= foobara_type_to_ts_type(inputs_type, dependency_group:, model_and_entity_free: true) %>
6
6
 
7
- export default Inputs
7
+ export type { Inputs as default }
@@ -6,4 +6,4 @@ type Result = <%=
6
6
  result_type.nil? ? "null" : foobara_type_to_ts_type(result_type, dependency_group:, association_depth:)
7
7
  %>
8
8
 
9
- export default Result
9
+ export type { Result as default }
@@ -1,4 +1,4 @@
1
- import Result from "./Result"
1
+ import type Result from "./Result"
2
2
 
3
3
  <% dependency_roots.each do |dependency_root| %>
4
4
  import <%= dependency_root.import_destructure %> from "<%= path_to_root %><%= dependency_root.import_path %>"
@@ -2,9 +2,9 @@
2
2
  import <%= dependency_root.import_destructure %> from "<%= path_to_root %><%= dependency_root.import_path %>"
3
3
  <% end %>
4
4
 
5
- import Inputs from "./Inputs"
6
- import Result from "./Result"
7
- import { Error } from "./Errors"
5
+ import type Inputs from "./Inputs"
6
+ import type Result from "./Result"
7
+ import { type Error } from "./Errors"
8
8
  <% if result_json_requires_cast? %>
9
9
  import castJsonResult from "./castJsonResult"
10
10
  <% end %>
@@ -1,4 +1,4 @@
1
- let _urlBase = process.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
1
+ let _urlBase = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
2
2
 
3
3
  const config = {
4
4
  get urlBase(): string {
@@ -1,5 +1,5 @@
1
1
  import {
2
- <%= entity_short_name %>AttributesType
2
+ type <%= entity_short_name %>AttributesType
3
3
  } from "./Ambiguous"
4
4
 
5
5
  <% dependency_roots.each do |dependency_root| %>
@@ -1,5 +1,5 @@
1
1
  import {
2
- <%= entity_short_name %>AttributesType
2
+ type <%= entity_short_name %>AttributesType
3
3
  } from "./Ambiguous"
4
4
  import { Loaded<%= entity_short_name %> } from "./Loaded"
5
5
  <% dependency_roots.each do |dependency_root| %>
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  <%= entity_short_name %>,
3
- <%= entity_short_name %>AttributesType
3
+ type <%= entity_short_name %>AttributesType
4
4
  } from "./Ambiguous"
5
5
 
6
6
  export class Loaded<%= entity_short_name %><T extends <%= entity_short_name %>AttributesType = <%= entity_short_name %>AttributesType> extends <%= entity_short_name %><T> {
@@ -1,8 +1,8 @@
1
- import { Never } from "<%= path_to_root %>base/Entity"
1
+ import { type Never } from "<%= path_to_root %>base/Entity"
2
2
  import {
3
3
  <%= entity_short_name %>,
4
- <%= entity_short_name %>PrimaryKeyType,
5
- <%= entity_short_name %>AttributesType
4
+ type <%= entity_short_name %>PrimaryKeyType,
5
+ type <%= entity_short_name %>AttributesType
6
6
  } from "./Ambiguous"
7
7
 
8
8
  export type Unloaded<%= entity_short_name %>AttributesType = Never<<%= entity_short_name %>AttributesType>
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  <%= entity_short_name %>,
3
- <%= entity_short_name %>PrimaryKeyType,
3
+ type <%= entity_short_name %>PrimaryKeyType,
4
4
  <%= entity_name_downcase %>PrimaryKeyAttributeName,
5
- <%= entity_short_name %>AttributesType
5
+ type <%= entity_short_name %>AttributesType
6
6
  } from "./<%= entity_short_name %>/Ambiguous"
7
7
  import {
8
8
  Unloaded<%= entity_short_name %>,
9
- Unloaded<%= entity_short_name %>AttributesType
9
+ type Unloaded<%= entity_short_name %>AttributesType
10
10
  } from "./<%= entity_short_name %>/Unloaded"
11
11
  import {
12
12
  Loaded<%= entity_short_name %>
@@ -15,11 +15,11 @@ import {
15
15
  <% if has_associations? %>
16
16
  import {
17
17
  <%= entity_short_name %>Atom,
18
- <%= entity_short_name %>AtomAttributesType
18
+ type <%= entity_short_name %>AtomAttributesType
19
19
  } from "./<%= entity_short_name %>/Atom"
20
20
  import {
21
21
  <%= entity_short_name %>Aggregate,
22
- <%= entity_short_name %>AggregateAttributesType
22
+ type <%= entity_short_name %>AggregateAttributesType
23
23
  } from "./<%= entity_short_name %>/Aggregate"
24
24
  <% end %>
25
25
 
@@ -2,6 +2,7 @@ import RemoteCommand from '../../base/RemoteCommand'
2
2
  import { type Outcome } from '../../base/Outcome'
3
3
  import { type FoobaraError } from '../../base/Error'
4
4
  import { tokenForUrl } from './utils/accessTokens'
5
+ import { RefreshLogin } from './RefreshLogin'
5
6
 
6
7
  export default class RequiresAuthCommand<Inputs, Result, Error extends FoobaraError<any>>
7
8
  extends RemoteCommand<Inputs, Result, Error> {
@@ -27,7 +28,6 @@ export default class RequiresAuthCommand<Inputs, Result, Error extends FoobaraEr
27
28
  if (response.status === 401) {
28
29
  this.commandState = 'refreshing_authentication'
29
30
 
30
- const { RefreshLogin } = await import('./RefreshLogin')
31
31
  // See if we can authenticate using the refresh token
32
32
  const refreshCommand = new RefreshLogin()
33
33
  const outcome = await refreshCommand.run()
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  <%= model_short_name %>,
3
- <%= model_short_name %>AttributesType
3
+ type <%= model_short_name %>AttributesType
4
4
  } from "./<%= model_short_name %>"
5
5
  <% dependency_roots.each do |dependency_root| %>
6
6
  import <%= dependency_root.import_destructure %> from "<%= path_to_root %><%= dependency_root.import_path %>"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  <%= model_short_name %>,
3
- <%= model_short_name %>AttributesType
3
+ type <%= model_short_name %>AttributesType
4
4
  } from "./<%= model_short_name %>"
5
5
  <% dependency_roots.each do |dependency_root| %>
6
6
  import <%= dependency_root.import_destructure %> from "<%= path_to_root %><%= dependency_root.import_path %>"
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  <%= model_short_name %>,
3
- <%= model_short_name %>AttributesType
3
+ type <%= model_short_name %>AttributesType
4
4
  } from "./<%= model_short_name %>/<%= model_short_name %>"
5
5
 
6
6
  <% if has_associations? %>
7
7
  import {
8
8
  <%= model_short_name %>Atom,
9
- <%= model_short_name %>AtomAttributesType
9
+ type <%= model_short_name %>AtomAttributesType
10
10
  } from "./<%= model_short_name %>/Atom"
11
11
  import {
12
12
  <%= model_short_name %>Aggregate,
13
- <%= model_short_name %>AggregateAttributesType
13
+ type <%= model_short_name %>AggregateAttributesType
14
14
  } from "./<%= model_short_name %>/Aggregate"
15
15
  <% end %>
16
16
 
@@ -1,4 +1,4 @@
1
- let _urlBase = process.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
1
+ let _urlBase = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
2
2
 
3
3
  const config = {
4
4
  get urlBase(): string {
@@ -10,12 +10,12 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
10
10
  static organizationName: string
11
11
  static domainName: string
12
12
 
13
- // TODO: make use of domain's config instead of process.env directly.
13
+ // TODO: make use of domain's config instead of import.meta.env directly.
14
14
  static get urlBase (): string {
15
15
  let base = this._urlBase
16
16
 
17
17
  if (base == null) {
18
- base = process.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
18
+ base = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
19
19
  }
20
20
 
21
21
  if (base == null) {
@@ -4,7 +4,7 @@ import {
4
4
  type InputsOf, type ResultOf, type ErrorOf, type RemoteCommandConstructor
5
5
  } from '../base/RemoteCommandTypes'
6
6
  import type Query from '../base/Query'
7
- import { useState, useRef, useEffect } from 'react'
7
+ import { useState, useEffect } from 'react'
8
8
  import { getQuery } from '../base/QueryCache'
9
9
 
10
10
  interface QueryState<CommandT extends RemoteCommand<any, any, any>> {
@@ -43,14 +43,7 @@ export default function useQuery<CommandT extends RemoteCommand<any, any, any>>
43
43
  CommandClass: RemoteCommandConstructor<CommandT>,
44
44
  inputs: InputsOf<CommandT> | undefined = undefined
45
45
  ): QueryState<CommandT> {
46
- const queryRef = useRef<Query<CommandT>>(null)
47
-
48
- let query = queryRef.current
49
-
50
- if (query == null) {
51
- query = getQuery(CommandClass, inputs)
52
- queryRef.current = query
53
- }
46
+ const [query] = useState<Query<CommandT>>(() => getQuery(CommandClass, inputs))
54
47
 
55
48
  const [queryState, setQueryState] = useState<QueryState<CommandT>>(
56
49
  queryToQueryState<CommandT>(query)
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.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi