foobara-typescript-remote-command-generator 0.0.11 → 0.0.13
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 +12 -0
- data/src/remote_generator/services/error_generator.rb +4 -5
- data/src/remote_generator/services/loaded_entity_generator.rb +4 -0
- data/src/remote_generator/services/type_generator.rb +1 -1
- data/src/remote_generator/services/typescript_from_manifest_base_generator.rb +1 -1
- data/src/remote_generator/services/unloaded_entity_generator.rb +4 -0
- data/templates/Error.ts.erb +1 -1
- data/templates/base/RemoteCommand.ts +19 -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: 5045b4f54238822deb4764d5ea2f259b482c3350c20e348472b20d30fd1feb83
|
4
|
+
data.tar.gz: 24187f3f79dc8fcd275ff4a8b98010dbac41128b4a6dd92faaf073544746eb7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae7f0d944f64a64faf54c8cc78f9d0afc53f9c4e857c75efff8993c3132ecefcaa96aec799909444f80dd38b3023db947ab3381a116f298e365b2fb0455432e3
|
7
|
+
data.tar.gz: 8b8b124b10f82ce701b48216f338561b7104d44b45f0793148df2d0545d41947cde9d5b12dd2dea4796c9a5c79005d4f9489ebc6f52cbf68d39cf1698b863b26
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## [0.0.13] - 2025-03-17
|
2
|
+
|
3
|
+
- Fix bug incorrectly generating model typescript for detached entities
|
4
|
+
- Fix bug preventing Loaded/Unloaded entity import from being destructured properly
|
5
|
+
- Handle errors with prefixes
|
6
|
+
- Include custom types and models in error generator dependencies
|
7
|
+
- Fix bug preventing allow_nil from having an effect
|
8
|
+
|
9
|
+
## [0.0.12] - 2025-03-02
|
10
|
+
|
11
|
+
- Add ability to ask RemoteCommand for its state and outcome
|
12
|
+
|
1
13
|
## [0.0.11] - 2025-02-26
|
2
14
|
|
3
15
|
- Implement support for command result types that are arrays
|
@@ -9,17 +9,17 @@ module Foobara
|
|
9
9
|
def target_path
|
10
10
|
p = parent
|
11
11
|
|
12
|
-
basename = "#{error_name}.ts"
|
12
|
+
basename = "#{error_name}.ts".split("::")
|
13
13
|
|
14
14
|
case parent
|
15
15
|
when OrganizationGenerator, DomainGenerator, CommandGenerator
|
16
|
-
[*p.target_dir, "errors", basename]
|
16
|
+
[*p.target_dir, "errors", *basename]
|
17
17
|
when nil
|
18
18
|
# :nocov:
|
19
19
|
raise "Expected #{error_name} to have a parent but it did not"
|
20
20
|
# :nocov:
|
21
21
|
else
|
22
|
-
[*p.target_dir, basename]
|
22
|
+
[*p.target_dir, *basename]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -50,8 +50,7 @@ module Foobara
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def dependencies
|
53
|
-
|
54
|
-
types_depended_on.select(&:detached_entity?)
|
53
|
+
types_depended_on.select { |type| type.detached_entity? || type.custom? || type.model? }
|
55
54
|
end
|
56
55
|
|
57
56
|
def ts_type_full_path
|
data/templates/Error.ts.erb
CHANGED
@@ -4,5 +4,5 @@ import <%= dependency_root.import_destructure %> from "<%= path_to_root %><%= de
|
|
4
4
|
|
5
5
|
import { <%= error_base_class %> } from "<%= path_to_root %>base/Error"
|
6
6
|
|
7
|
-
export class <%=
|
7
|
+
export class <%= short_error_name %> extends <%= error_base_class %><<%= context_ts_type %>> {
|
8
8
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { type Outcome, SuccessfulOutcome, ErrorOutcome } from './Outcome'
|
2
2
|
import { type FoobaraError } from './Error'
|
3
3
|
|
4
|
+
export type commandState = 'initialized' | 'executing' | 'succeeded' | 'errored' | 'failed'
|
5
|
+
|
4
6
|
export default abstract class RemoteCommand<Inputs, Result, CommandError extends FoobaraError> {
|
5
7
|
static _urlBase: string | undefined
|
6
8
|
static commandName: string
|
@@ -16,7 +18,7 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
|
|
16
18
|
}
|
17
19
|
|
18
20
|
if (base == null) {
|
19
|
-
throw new Error(
|
21
|
+
throw new Error('urlBase is not set and REACT_APP_FOOBARA_GLOBAL_URL_BASE is undefined')
|
20
22
|
}
|
21
23
|
|
22
24
|
return base
|
@@ -35,9 +37,13 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
|
|
35
37
|
}
|
36
38
|
|
37
39
|
inputs: Inputs
|
40
|
+
outcome: null | Outcome<Result, CommandError>
|
41
|
+
commandState: commandState
|
38
42
|
|
39
43
|
constructor (inputs: Inputs) {
|
40
44
|
this.inputs = inputs
|
45
|
+
this.commandState = 'initialized'
|
46
|
+
this.outcome = null
|
41
47
|
}
|
42
48
|
|
43
49
|
get commandName (): string {
|
@@ -51,10 +57,10 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
|
|
51
57
|
static get fullCommandName (): string {
|
52
58
|
const path = []
|
53
59
|
|
54
|
-
if (this.organizationName != null && this.organizationName !==
|
60
|
+
if (this.organizationName != null && this.organizationName !== 'GlobalOrganization') {
|
55
61
|
path.push(this.organizationName)
|
56
62
|
}
|
57
|
-
if (this.domainName != null && this.domainName !==
|
63
|
+
if (this.domainName != null && this.domainName !== 'GlobalDomain') {
|
58
64
|
path.push(this.domainName)
|
59
65
|
}
|
60
66
|
if (this.commandName != null) {
|
@@ -70,18 +76,26 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
|
|
70
76
|
async run (): Promise<Outcome<Result, CommandError>> {
|
71
77
|
const url = `${this.urlBase}/run/${this.fullCommandName}`
|
72
78
|
|
79
|
+
this.commandState = 'executing'
|
73
80
|
const response = await fetch(url, {
|
74
81
|
method: 'POST',
|
75
82
|
headers: { 'Content-Type': 'application/json' },
|
76
83
|
body: JSON.stringify(this.inputs)
|
77
84
|
})
|
78
85
|
|
86
|
+
const body = await response.json()
|
87
|
+
|
79
88
|
if (response.ok) {
|
80
|
-
|
89
|
+
this.commandState = 'succeeded'
|
90
|
+
this.outcome = new SuccessfulOutcome<Result, CommandError>(body)
|
81
91
|
} else if (response.status === 422) {
|
82
|
-
|
92
|
+
this.commandState = 'errored'
|
93
|
+
this.outcome = new ErrorOutcome<Result, CommandError>(body)
|
83
94
|
} else {
|
95
|
+
this.commandState = 'failed'
|
84
96
|
throw new Error(`not sure how to handle ${await response.text()}`)
|
85
97
|
}
|
98
|
+
|
99
|
+
return this.outcome
|
86
100
|
}
|
87
101
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-typescript-remote-command-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.6.
|
137
|
+
rubygems_version: 3.6.5
|
138
138
|
specification_version: 4
|
139
139
|
summary: Generates remote commands for Typescript from a foobara manifest
|
140
140
|
test_files: []
|