@animalab-netizen/typescript-ode 0.2.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.
- package/CHANGELOG.md +15 -0
- package/CONTRIBUTING.md +16 -0
- package/LICENSE +172 -0
- package/PUBLICATION.md +29 -0
- package/README.md +256 -0
- package/USECASE_GUIDE.md +18 -0
- package/dist/Business/DTO/Outputs.d.ts +32 -0
- package/dist/Business/DTO/Outputs.js +61 -0
- package/dist/Business/Exception/ODEErrors.d.ts +18 -0
- package/dist/Business/Exception/ODEErrors.js +26 -0
- package/dist/Business/Interactor/CallbackDecorator.d.ts +7 -0
- package/dist/Business/Interactor/CallbackDecorator.js +15 -0
- package/dist/Business/Interactor/ChainUseCase.d.ts +9 -0
- package/dist/Business/Interactor/ChainUseCase.js +21 -0
- package/dist/Business/Interactor/SequenceUseCase.d.ts +8 -0
- package/dist/Business/Interactor/SequenceUseCase.js +23 -0
- package/dist/Business/Interactor/UseCase.d.ts +15 -0
- package/dist/Business/Interactor/UseCase.js +28 -0
- package/dist/Business/Interactor/UseCaseDispatcher.d.ts +6 -0
- package/dist/Business/Interactor/UseCaseDispatcher.js +7 -0
- package/dist/Gateway/MVVM/BaseViewModel.d.ts +17 -0
- package/dist/Gateway/MVVM/BaseViewModel.js +40 -0
- package/dist/Gateway/MVVM/Controller.d.ts +4 -0
- package/dist/Gateway/MVVM/Controller.js +1 -0
- package/dist/Gateway/MVVM/ControllerFactory.d.ts +3 -0
- package/dist/Gateway/MVVM/ControllerFactory.js +1 -0
- package/dist/View/UI/OutputHandlingStrategy.d.ts +7 -0
- package/dist/View/UI/OutputHandlingStrategy.js +13 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/package.json +50 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- aligned npm publication metadata with the `animalab-netizen` repository
|
|
6
|
+
- added homepage, repository, bugs and public publish configuration
|
|
7
|
+
- prepared the package for the next npm release under ÂnimaLab ownership
|
|
8
|
+
- superseded the legacy V2 npm metadata line with the new public repository identity
|
|
9
|
+
|
|
10
|
+
## 0.1.0
|
|
11
|
+
|
|
12
|
+
- created the standalone `@animalab-netizen/typescript-ode` package
|
|
13
|
+
- added direct, chain, sequence and guard-oriented runtime primitives
|
|
14
|
+
- added typed outputs and lightweight MVVM channels
|
|
15
|
+
- documented npm publication flow and local validation
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for contributing to `@animalab-netizen/typescript-ode`.
|
|
4
|
+
|
|
5
|
+
## Local Validation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run build
|
|
9
|
+
npm test
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Principles
|
|
13
|
+
|
|
14
|
+
- preserve conceptual parity with the ODE family
|
|
15
|
+
- keep examples small and explainable
|
|
16
|
+
- avoid framework lock-in inside the core runtime
|
package/LICENSE
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
|
|
135
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
136
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
137
|
+
except as required for reasonable and customary use in describing the
|
|
138
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
139
|
+
|
|
140
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
141
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
142
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
143
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
144
|
+
implied, including, without limitation, any warranties or conditions
|
|
145
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
146
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
147
|
+
appropriateness of using or redistributing the Work and assume any
|
|
148
|
+
risks associated with Your exercise of permissions under this License.
|
|
149
|
+
|
|
150
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
151
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
152
|
+
unless required by applicable law (such as deliberate and grossly
|
|
153
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
154
|
+
liable to You for damages, including any direct, indirect, special,
|
|
155
|
+
incidental, or consequential damages of any character arising as a
|
|
156
|
+
result of this License or out of the use or inability to use the
|
|
157
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
158
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
159
|
+
other commercial damages or losses), even if such Contributor
|
|
160
|
+
has been advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
164
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
165
|
+
or other liability obligations and/or rights consistent with this
|
|
166
|
+
License. However, in accepting such obligations, You may act only
|
|
167
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
168
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
package/PUBLICATION.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Publication Guide
|
|
2
|
+
|
|
3
|
+
## Current State
|
|
4
|
+
|
|
5
|
+
`@animalab-netizen/typescript-ode` is structured as a standalone npm package.
|
|
6
|
+
|
|
7
|
+
Current coordinates:
|
|
8
|
+
|
|
9
|
+
- package: `@animalab-netizen/typescript-ode`
|
|
10
|
+
- version: `0.2.0`
|
|
11
|
+
- npm owner target: `animalab-netizen`
|
|
12
|
+
- repository: [github.com/animalab-netizen/typescript-ode](https://github.com/animalab-netizen/typescript-ode)
|
|
13
|
+
|
|
14
|
+
## Release Checklist
|
|
15
|
+
|
|
16
|
+
1. Run `npm run build`
|
|
17
|
+
2. Run `npm test`
|
|
18
|
+
3. Update `CHANGELOG.md`
|
|
19
|
+
4. Confirm version in `package.json`
|
|
20
|
+
5. Confirm npm authentication for the intended owner
|
|
21
|
+
6. Publish with `npm publish --access public`
|
|
22
|
+
7. Verify the package page and installation command from a clean consumer
|
|
23
|
+
|
|
24
|
+
## Packaging Notes
|
|
25
|
+
|
|
26
|
+
- the package ships from `dist/`
|
|
27
|
+
- generated types are emitted with the JS bundle
|
|
28
|
+
- the runtime has no third-party production dependencies
|
|
29
|
+
- `publishConfig.access` is set to `public`
|
package/README.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# @animalab-netizen/typescript-ode
|
|
2
|
+
|
|
3
|
+
`@animalab-netizen/typescript-ode` is the web and server-side counterpart of the ODE architecture style.
|
|
4
|
+
|
|
5
|
+
The package provides a compact architectural runtime for:
|
|
6
|
+
|
|
7
|
+
- use case execution
|
|
8
|
+
- delivery and result orchestration
|
|
9
|
+
- guard-first dispatch flow
|
|
10
|
+
- typed output publication
|
|
11
|
+
- lightweight MVVM-style channels for viewmodel driven interfaces
|
|
12
|
+
|
|
13
|
+
The goal is to make application flow easier to standardize, easier to inspect, and less vulnerable to common mistakes around asynchronous delivery, branching orchestration and UI-facing state transitions.
|
|
14
|
+
|
|
15
|
+
## Repository
|
|
16
|
+
|
|
17
|
+
- source: [github.com/animalab-netizen/typescript-ode](https://github.com/animalab-netizen/typescript-ode)
|
|
18
|
+
|
|
19
|
+
## Status
|
|
20
|
+
|
|
21
|
+
`@animalab-netizen/typescript-ode` is prepared as a standalone publishable package and is intended to be consumed by web examples such as `typescript-ode-consumer`.
|
|
22
|
+
|
|
23
|
+
The package is maintained by ÂnimaLab and is being positioned as the TypeScript member of the same ODE family already expressed in Kotlin and Swift.
|
|
24
|
+
|
|
25
|
+
## Coordinates
|
|
26
|
+
|
|
27
|
+
Current coordinates:
|
|
28
|
+
|
|
29
|
+
- package: `@animalab-netizen/typescript-ode`
|
|
30
|
+
- version: `0.2.0`
|
|
31
|
+
|
|
32
|
+
Installation:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @animalab-netizen/typescript-ode
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Public API
|
|
39
|
+
|
|
40
|
+
The intended public surface of `@animalab-netizen/typescript-ode` is centered on these concepts:
|
|
41
|
+
|
|
42
|
+
- `UseCase<P, R>`
|
|
43
|
+
- `UseCaseDispatcher`
|
|
44
|
+
- `Output`, `ValueOutput`, `ErrorOutput`, `EmptyOutput`, `Outputs`
|
|
45
|
+
- `BaseViewModel`
|
|
46
|
+
- `Channel`
|
|
47
|
+
- `Controller`
|
|
48
|
+
- `ControllerFactory`
|
|
49
|
+
- `SequenceUseCase`
|
|
50
|
+
- `ChainUseCase`
|
|
51
|
+
- `HttpError`, `ConnectionError`, `GuardRejectedError`, `UnexpectedResponseError`
|
|
52
|
+
|
|
53
|
+
Internal helpers should not be treated as product contract and may change without notice.
|
|
54
|
+
|
|
55
|
+
## API Stability Notes
|
|
56
|
+
|
|
57
|
+
Current guidance:
|
|
58
|
+
|
|
59
|
+
- prefer matching on the explicit `Output` hierarchy instead of treating delivery as raw values and thrown exceptions
|
|
60
|
+
- keep guard logic inside the use case instead of distributing pre-validation across views and services
|
|
61
|
+
- use `BaseViewModel` channels as explicit delivery surfaces when the package is consumed from UI code
|
|
62
|
+
- do not couple application code to internal implementation details of dispatch sequencing
|
|
63
|
+
|
|
64
|
+
The preferred mental model for delivery handling is:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
switch (output.kind) {
|
|
68
|
+
case "value":
|
|
69
|
+
render(output.value);
|
|
70
|
+
break;
|
|
71
|
+
case "error":
|
|
72
|
+
handleError(output.error);
|
|
73
|
+
break;
|
|
74
|
+
case "empty":
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Core Concepts
|
|
80
|
+
|
|
81
|
+
### 1. UseCase
|
|
82
|
+
|
|
83
|
+
`UseCase<P, R>` is the main business execution abstraction.
|
|
84
|
+
|
|
85
|
+
It provides a standard lifecycle for:
|
|
86
|
+
|
|
87
|
+
- input validation via `guard`
|
|
88
|
+
- execution via `execute`
|
|
89
|
+
- result normalization via `onResult`
|
|
90
|
+
- failure handling via `onError`
|
|
91
|
+
|
|
92
|
+
This helps teams keep business flow explicit instead of re-implementing orchestration rules in controllers, hooks, or service layers.
|
|
93
|
+
|
|
94
|
+
### 2. Dispatcher
|
|
95
|
+
|
|
96
|
+
`UseCaseDispatcher` executes use cases and optionally emits the resulting `Output` to a listener.
|
|
97
|
+
|
|
98
|
+
This gives consumers a single, predictable way to trigger business work and receive typed delivery.
|
|
99
|
+
|
|
100
|
+
### 3. Outputs
|
|
101
|
+
|
|
102
|
+
`@animalab-netizen/typescript-ode` uses an explicit output hierarchy:
|
|
103
|
+
|
|
104
|
+
- `ValueOutput<T>`
|
|
105
|
+
- `ErrorOutput<T>`
|
|
106
|
+
- `EmptyOutput`
|
|
107
|
+
|
|
108
|
+
The `Outputs` helper provides convenient constructors while keeping the final delivery contract typed and readable.
|
|
109
|
+
|
|
110
|
+
### 4. ChainUseCase
|
|
111
|
+
|
|
112
|
+
`ChainUseCase` is intended for a two-step flow where the first successful result provides the context for the second step.
|
|
113
|
+
|
|
114
|
+
This is useful when:
|
|
115
|
+
|
|
116
|
+
- a first entity must be resolved before comparing or enriching it
|
|
117
|
+
- a direct one-shot use case would hide meaningful orchestration
|
|
118
|
+
|
|
119
|
+
### 5. SequenceUseCase
|
|
120
|
+
|
|
121
|
+
`SequenceUseCase` is intended for ordered execution across three or more entries.
|
|
122
|
+
|
|
123
|
+
It keeps the request order explicit in the final delivery, which is especially useful for comparison and showcase scenarios.
|
|
124
|
+
|
|
125
|
+
### 6. BaseViewModel
|
|
126
|
+
|
|
127
|
+
`BaseViewModel` provides:
|
|
128
|
+
|
|
129
|
+
- typed channel creation
|
|
130
|
+
- observation registration
|
|
131
|
+
- output publication through named channels
|
|
132
|
+
- direct use case dispatch into a chosen channel
|
|
133
|
+
|
|
134
|
+
This is the bridge between business flow and browser or UI-facing consumers when a viewmodel style is preferred.
|
|
135
|
+
|
|
136
|
+
## Basic Examples
|
|
137
|
+
|
|
138
|
+
### Direct UseCase
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { UseCase } from "@animalab-netizen/typescript-ode";
|
|
142
|
+
|
|
143
|
+
class LoadPokemonUseCase extends UseCase<string, string> {
|
|
144
|
+
protected override async execute(name: string): Promise<string> {
|
|
145
|
+
return `spotlight:${name}`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Guarded UseCase
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { GuardRejectedError, UseCase } from "@animalab-netizen/typescript-ode";
|
|
154
|
+
|
|
155
|
+
class ComparePokemonUseCase extends UseCase<{ left: string; right: string }, string> {
|
|
156
|
+
protected override guard(param: { left: string; right: string }) {
|
|
157
|
+
if (!param.left || !param.right || param.left === param.right) {
|
|
158
|
+
return {
|
|
159
|
+
allowed: false,
|
|
160
|
+
error: new GuardRejectedError("Comparison requires two distinct pokemon."),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return { allowed: true };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
protected override async execute(param: { left: string; right: string }): Promise<string> {
|
|
168
|
+
return `${param.left} vs ${param.right}`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### ViewModel Example
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { BaseViewModel, type OutputOf, UseCase } from "@animalab-netizen/typescript-ode";
|
|
177
|
+
|
|
178
|
+
class LoadNameUseCase extends UseCase<void, string> {
|
|
179
|
+
protected override async execute(): Promise<string> {
|
|
180
|
+
return "pikachu";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
class DemoViewModel extends BaseViewModel {
|
|
185
|
+
readonly channel = this.channel<OutputOf<string>>("name");
|
|
186
|
+
|
|
187
|
+
async load() {
|
|
188
|
+
await this.dispatchUseCase(undefined, new LoadNameUseCase(), this.channel);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Channel Observation
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
const viewModel = new DemoViewModel();
|
|
197
|
+
|
|
198
|
+
const stop = viewModel.observe(viewModel.channel, (output) => {
|
|
199
|
+
if (output.kind === "value") {
|
|
200
|
+
console.log(output.value);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
await viewModel.load();
|
|
205
|
+
stop();
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Publishing
|
|
209
|
+
|
|
210
|
+
Local validation:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm run build
|
|
214
|
+
npm test
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Public publication target:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm publish --access public
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
See [PUBLICATION.md](/Users/caiosanchezchristino/Desktop/ode-projects/typescript-ode/PUBLICATION.md) for the release checklist and packaging notes.
|
|
224
|
+
|
|
225
|
+
## Compatibility Notes
|
|
226
|
+
|
|
227
|
+
The package targets modern TypeScript and ESM-based JavaScript runtimes.
|
|
228
|
+
|
|
229
|
+
Current assumptions:
|
|
230
|
+
|
|
231
|
+
- TypeScript 6 for local build and declaration emission
|
|
232
|
+
- Node.js 20+ for repository validation
|
|
233
|
+
- modern bundlers or ESM-capable runtimes when consumed from apps
|
|
234
|
+
|
|
235
|
+
If you consume the package from another project, keep your TypeScript and module settings reasonably aligned with the published artifact.
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
See [CONTRIBUTING.md](/Users/caiosanchezchristino/Desktop/ode-projects/typescript-ode/CONTRIBUTING.md).
|
|
240
|
+
|
|
241
|
+
## Changelog
|
|
242
|
+
|
|
243
|
+
See [CHANGELOG.md](/Users/caiosanchezchristino/Desktop/ode-projects/typescript-ode/CHANGELOG.md).
|
|
244
|
+
|
|
245
|
+
## Maintainer
|
|
246
|
+
|
|
247
|
+
- name: `ÂnimaLab`
|
|
248
|
+
- email: `animalab.desenvolvimento@gmail.com`
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
This project is licensed under Apache-2.0. See [LICENSE](/Users/caiosanchezchristino/Desktop/ode-projects/typescript-ode/LICENSE).
|
|
253
|
+
|
|
254
|
+
## UseCase Guide
|
|
255
|
+
|
|
256
|
+
See [USECASE_GUIDE.md](/Users/caiosanchezchristino/Desktop/ode-projects/typescript-ode/USECASE_GUIDE.md) for combinations, adoption guidance and common implementation doubts.
|
package/USECASE_GUIDE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# UseCase Guide
|
|
2
|
+
|
|
3
|
+
## Direct
|
|
4
|
+
|
|
5
|
+
Use a regular `UseCase` when one request produces one delivery.
|
|
6
|
+
|
|
7
|
+
## Chain
|
|
8
|
+
|
|
9
|
+
Use `ChainUseCase` when a first result determines the second step, typically for two-entity comparisons.
|
|
10
|
+
|
|
11
|
+
## Sequence
|
|
12
|
+
|
|
13
|
+
Use `SequenceUseCase` when you need ordered execution across three or more entries.
|
|
14
|
+
|
|
15
|
+
## Guard
|
|
16
|
+
|
|
17
|
+
Use `guard` in `UseCase` when a request must be validated before any I/O happens.
|
|
18
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
export declare abstract class Output<T> {
|
|
3
|
+
abstract readonly kind: "value" | "error" | "empty";
|
|
4
|
+
get hasValue(): boolean;
|
|
5
|
+
get isError(): boolean;
|
|
6
|
+
get isEmpty(): boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class ValueOutput<T> extends Output<T> {
|
|
9
|
+
readonly value: T;
|
|
10
|
+
readonly kind: "value";
|
|
11
|
+
constructor(value: T);
|
|
12
|
+
}
|
|
13
|
+
export declare class ErrorOutput<T = never> extends Output<T> {
|
|
14
|
+
readonly error: unknown;
|
|
15
|
+
readonly value?: T | undefined;
|
|
16
|
+
readonly kind: "error";
|
|
17
|
+
constructor(error: unknown, value?: T | undefined);
|
|
18
|
+
}
|
|
19
|
+
export declare class EmptyOutput extends Output<never> {
|
|
20
|
+
readonly kind: "empty";
|
|
21
|
+
}
|
|
22
|
+
export type OutputLike<T> = OutputOf<T> | T | null | undefined;
|
|
23
|
+
export type OutputOf<T> = ValueOutput<T> | ErrorOutput<T> | EmptyOutput;
|
|
24
|
+
export declare const Outputs: {
|
|
25
|
+
value<T>(value: T): ValueOutput<T>;
|
|
26
|
+
error<T = never>(error: unknown, value?: T): ErrorOutput<T>;
|
|
27
|
+
empty(): EmptyOutput;
|
|
28
|
+
};
|
|
29
|
+
export declare function normalizeOutput<T>(value: OutputLike<T>): OutputOf<T>;
|
|
30
|
+
export declare function isValueOutput<T>(output: OutputOf<T>): output is ValueOutput<T>;
|
|
31
|
+
export declare function isErrorOutput<T>(output: OutputOf<T>): output is ErrorOutput<T>;
|
|
32
|
+
export declare function isEmptyOutput<T>(output: OutputOf<T>): output is EmptyOutput;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export class Output {
|
|
2
|
+
get hasValue() {
|
|
3
|
+
return this.kind === "value";
|
|
4
|
+
}
|
|
5
|
+
get isError() {
|
|
6
|
+
return this.kind === "error";
|
|
7
|
+
}
|
|
8
|
+
get isEmpty() {
|
|
9
|
+
return this.kind === "empty";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ValueOutput extends Output {
|
|
13
|
+
value;
|
|
14
|
+
kind = "value";
|
|
15
|
+
constructor(value) {
|
|
16
|
+
super();
|
|
17
|
+
this.value = value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class ErrorOutput extends Output {
|
|
21
|
+
error;
|
|
22
|
+
value;
|
|
23
|
+
kind = "error";
|
|
24
|
+
constructor(error, value) {
|
|
25
|
+
super();
|
|
26
|
+
this.error = error;
|
|
27
|
+
this.value = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class EmptyOutput extends Output {
|
|
31
|
+
kind = "empty";
|
|
32
|
+
}
|
|
33
|
+
export const Outputs = {
|
|
34
|
+
value(value) {
|
|
35
|
+
return new ValueOutput(value);
|
|
36
|
+
},
|
|
37
|
+
error(error, value) {
|
|
38
|
+
return new ErrorOutput(error, value);
|
|
39
|
+
},
|
|
40
|
+
empty() {
|
|
41
|
+
return new EmptyOutput();
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export function normalizeOutput(value) {
|
|
45
|
+
if (value instanceof Output) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
if (value === null || value === undefined) {
|
|
49
|
+
return Outputs.empty();
|
|
50
|
+
}
|
|
51
|
+
return Outputs.value(value);
|
|
52
|
+
}
|
|
53
|
+
export function isValueOutput(output) {
|
|
54
|
+
return output.kind === "value";
|
|
55
|
+
}
|
|
56
|
+
export function isErrorOutput(output) {
|
|
57
|
+
return output.kind === "error";
|
|
58
|
+
}
|
|
59
|
+
export function isEmptyOutput(output) {
|
|
60
|
+
return output.kind === "empty";
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class ODEError extends Error {
|
|
2
|
+
constructor(message: string, options?: {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
export declare class GuardRejectedError extends ODEError {
|
|
7
|
+
}
|
|
8
|
+
export declare class HttpError extends ODEError {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly url: string;
|
|
11
|
+
constructor(status: number, url: string, message?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ConnectionError extends ODEError {
|
|
14
|
+
readonly url: string;
|
|
15
|
+
constructor(url: string, message?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class UnexpectedResponseError extends ODEError {
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class ODEError extends Error {
|
|
2
|
+
constructor(message, options) {
|
|
3
|
+
super(message, options);
|
|
4
|
+
this.name = new.target.name;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class GuardRejectedError extends ODEError {
|
|
8
|
+
}
|
|
9
|
+
export class HttpError extends ODEError {
|
|
10
|
+
status;
|
|
11
|
+
url;
|
|
12
|
+
constructor(status, url, message = `HTTP ${status} while loading ${url}`) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.url = url;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class ConnectionError extends ODEError {
|
|
19
|
+
url;
|
|
20
|
+
constructor(url, message = `Unable to reach ${url}`) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.url = url;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class UnexpectedResponseError extends ODEError {
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OutputOf } from "../DTO/Outputs.js";
|
|
2
|
+
export type OutputCallbacks<T> = {
|
|
3
|
+
onValue?: (value: T) => void;
|
|
4
|
+
onError?: (error: unknown) => void;
|
|
5
|
+
onEmpty?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function createOutputCallback<T>(callbacks: OutputCallbacks<T>): (output: OutputOf<T>) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createOutputCallback(callbacks) {
|
|
2
|
+
return (output) => {
|
|
3
|
+
switch (output.kind) {
|
|
4
|
+
case "value":
|
|
5
|
+
callbacks.onValue?.(output.value);
|
|
6
|
+
return;
|
|
7
|
+
case "error":
|
|
8
|
+
callbacks.onError?.(output.error);
|
|
9
|
+
return;
|
|
10
|
+
case "empty":
|
|
11
|
+
callbacks.onEmpty?.();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MaybePromise, type OutputLike, type OutputOf } from "../DTO/Outputs.js";
|
|
2
|
+
import { UseCase } from "./UseCase.js";
|
|
3
|
+
export type ChainStep<P, A, R> = (value: A, param: P) => MaybePromise<OutputLike<R>>;
|
|
4
|
+
export declare class ChainUseCase<P, A, R> extends UseCase<P, R> {
|
|
5
|
+
private readonly first;
|
|
6
|
+
private readonly next;
|
|
7
|
+
constructor(first: UseCase<P, A>, next: ChainStep<P, A, R>);
|
|
8
|
+
protected execute(param: P): Promise<OutputOf<R>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Outputs, normalizeOutput } from "../DTO/Outputs.js";
|
|
2
|
+
import { UseCase } from "./UseCase.js";
|
|
3
|
+
export class ChainUseCase extends UseCase {
|
|
4
|
+
first;
|
|
5
|
+
next;
|
|
6
|
+
constructor(first, next) {
|
|
7
|
+
super();
|
|
8
|
+
this.first = first;
|
|
9
|
+
this.next = next;
|
|
10
|
+
}
|
|
11
|
+
async execute(param) {
|
|
12
|
+
const firstOutput = await this.first.process(param);
|
|
13
|
+
if (firstOutput.kind === "error") {
|
|
14
|
+
return Outputs.error(firstOutput.error);
|
|
15
|
+
}
|
|
16
|
+
if (firstOutput.kind === "empty") {
|
|
17
|
+
return Outputs.empty();
|
|
18
|
+
}
|
|
19
|
+
return normalizeOutput(await this.next(firstOutput.value, param));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MaybePromise, type OutputLike, type OutputOf } from "../DTO/Outputs.js";
|
|
2
|
+
import { UseCase } from "./UseCase.js";
|
|
3
|
+
export type SequenceStep<P, R> = (param: P, index: number) => MaybePromise<OutputLike<R>>;
|
|
4
|
+
export declare class SequenceUseCase<P, R> extends UseCase<readonly P[], R[]> {
|
|
5
|
+
private readonly step;
|
|
6
|
+
constructor(step: SequenceStep<P, R>);
|
|
7
|
+
protected execute(params: readonly P[]): Promise<OutputOf<R[]>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Outputs, normalizeOutput } from "../DTO/Outputs.js";
|
|
2
|
+
import { UseCase } from "./UseCase.js";
|
|
3
|
+
export class SequenceUseCase extends UseCase {
|
|
4
|
+
step;
|
|
5
|
+
constructor(step) {
|
|
6
|
+
super();
|
|
7
|
+
this.step = step;
|
|
8
|
+
}
|
|
9
|
+
async execute(params) {
|
|
10
|
+
const collected = [];
|
|
11
|
+
for (const [index, param] of params.entries()) {
|
|
12
|
+
const output = normalizeOutput(await this.step(param, index));
|
|
13
|
+
if (output.kind === "error") {
|
|
14
|
+
return Outputs.error(output.error, collected.length > 0 ? collected : undefined);
|
|
15
|
+
}
|
|
16
|
+
if (output.kind === "empty") {
|
|
17
|
+
return Outputs.empty();
|
|
18
|
+
}
|
|
19
|
+
collected.push(output.value);
|
|
20
|
+
}
|
|
21
|
+
return collected.length > 0 ? Outputs.value(collected) : Outputs.empty();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MaybePromise, type OutputLike, type OutputOf } from "../DTO/Outputs.js";
|
|
2
|
+
export type GuardResult = {
|
|
3
|
+
allowed: true;
|
|
4
|
+
} | {
|
|
5
|
+
allowed: false;
|
|
6
|
+
error?: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class UseCase<P, R> {
|
|
9
|
+
protected guard(_param: P): MaybePromise<GuardResult>;
|
|
10
|
+
protected abstract execute(param: P): MaybePromise<OutputLike<R>>;
|
|
11
|
+
protected onResult(output: OutputOf<R>): MaybePromise<OutputLike<R>>;
|
|
12
|
+
protected onError(error: unknown): MaybePromise<OutputLike<R>>;
|
|
13
|
+
protected onGuardError(error?: unknown): MaybePromise<OutputLike<R>>;
|
|
14
|
+
process(param: P): Promise<OutputOf<R>>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Outputs, normalizeOutput } from "../DTO/Outputs.js";
|
|
2
|
+
export class UseCase {
|
|
3
|
+
guard(_param) {
|
|
4
|
+
return { allowed: true };
|
|
5
|
+
}
|
|
6
|
+
onResult(output) {
|
|
7
|
+
return output;
|
|
8
|
+
}
|
|
9
|
+
onError(error) {
|
|
10
|
+
return Outputs.error(error);
|
|
11
|
+
}
|
|
12
|
+
onGuardError(error) {
|
|
13
|
+
return error ? Outputs.error(error) : Outputs.empty();
|
|
14
|
+
}
|
|
15
|
+
async process(param) {
|
|
16
|
+
try {
|
|
17
|
+
const guardResult = await this.guard(param);
|
|
18
|
+
if (!guardResult.allowed) {
|
|
19
|
+
return normalizeOutput(await this.onGuardError(guardResult.error));
|
|
20
|
+
}
|
|
21
|
+
const output = normalizeOutput(await this.execute(param));
|
|
22
|
+
return normalizeOutput(await this.onResult(output));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return normalizeOutput(await this.onError(error));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OutputOf } from "../DTO/Outputs.js";
|
|
2
|
+
import type { UseCase } from "./UseCase.js";
|
|
3
|
+
export type DispatchListener<R> = (output: OutputOf<R>) => void;
|
|
4
|
+
export declare class UseCaseDispatcher {
|
|
5
|
+
dispatch<P, R>(param: P, useCase: UseCase<P, R>, listener?: DispatchListener<R>): Promise<OutputOf<R>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OutputOf } from "../../Business/DTO/Outputs.js";
|
|
2
|
+
import type { UseCase } from "../../Business/Interactor/UseCase.js";
|
|
3
|
+
export declare class Channel<T> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
constructor(name: string);
|
|
6
|
+
}
|
|
7
|
+
type Observer<T> = (value: T) => void;
|
|
8
|
+
export declare class BaseViewModel {
|
|
9
|
+
private readonly observers;
|
|
10
|
+
private readonly dispatcher;
|
|
11
|
+
channel<T>(name: string): Channel<T>;
|
|
12
|
+
observe<T>(channel: Channel<T>, observer: Observer<T>): () => void;
|
|
13
|
+
postValue<T>(channel: Channel<T>, value: T): void;
|
|
14
|
+
dispatchUseCase<P, R>(param: P, useCase: UseCase<P, R>, channel: Channel<OutputOf<R>>): Promise<OutputOf<R>>;
|
|
15
|
+
clearObservers(): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UseCaseDispatcher } from "../../Business/Interactor/UseCaseDispatcher.js";
|
|
2
|
+
export class Channel {
|
|
3
|
+
name;
|
|
4
|
+
constructor(name) {
|
|
5
|
+
this.name = name;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class BaseViewModel {
|
|
9
|
+
observers = new Map();
|
|
10
|
+
dispatcher = new UseCaseDispatcher();
|
|
11
|
+
channel(name) {
|
|
12
|
+
return new Channel(name);
|
|
13
|
+
}
|
|
14
|
+
observe(channel, observer) {
|
|
15
|
+
const set = this.observers.get(channel.name) ?? new Set();
|
|
16
|
+
set.add(observer);
|
|
17
|
+
this.observers.set(channel.name, set);
|
|
18
|
+
return () => {
|
|
19
|
+
const current = this.observers.get(channel.name);
|
|
20
|
+
current?.delete(observer);
|
|
21
|
+
if (current && current.size === 0) {
|
|
22
|
+
this.observers.delete(channel.name);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
postValue(channel, value) {
|
|
27
|
+
const current = this.observers.get(channel.name);
|
|
28
|
+
current?.forEach((observer) => {
|
|
29
|
+
observer(value);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async dispatchUseCase(param, useCase, channel) {
|
|
33
|
+
const output = await this.dispatcher.dispatch(param, useCase);
|
|
34
|
+
this.postValue(channel, output);
|
|
35
|
+
return output;
|
|
36
|
+
}
|
|
37
|
+
clearObservers() {
|
|
38
|
+
this.observers.clear();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OutputOf } from "../../Business/DTO/Outputs.js";
|
|
2
|
+
export type OutputHandlingStrategy<T> = {
|
|
3
|
+
onValue: (value: T) => void;
|
|
4
|
+
onError: (error: unknown) => void;
|
|
5
|
+
onEmpty?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function handleOutput<T>(output: OutputOf<T>, strategy: OutputHandlingStrategy<T>): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function handleOutput(output, strategy) {
|
|
2
|
+
switch (output.kind) {
|
|
3
|
+
case "value":
|
|
4
|
+
strategy.onValue(output.value);
|
|
5
|
+
return;
|
|
6
|
+
case "error":
|
|
7
|
+
strategy.onError(output.error);
|
|
8
|
+
return;
|
|
9
|
+
case "empty":
|
|
10
|
+
strategy.onEmpty?.();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./Business/DTO/Outputs.js";
|
|
2
|
+
export * from "./Business/Exception/ODEErrors.js";
|
|
3
|
+
export * from "./Business/Interactor/CallbackDecorator.js";
|
|
4
|
+
export * from "./Business/Interactor/ChainUseCase.js";
|
|
5
|
+
export * from "./Business/Interactor/SequenceUseCase.js";
|
|
6
|
+
export * from "./Business/Interactor/UseCase.js";
|
|
7
|
+
export * from "./Business/Interactor/UseCaseDispatcher.js";
|
|
8
|
+
export * from "./Gateway/MVVM/BaseViewModel.js";
|
|
9
|
+
export * from "./Gateway/MVVM/Controller.js";
|
|
10
|
+
export * from "./Gateway/MVVM/ControllerFactory.js";
|
|
11
|
+
export * from "./View/UI/OutputHandlingStrategy.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./Business/DTO/Outputs.js";
|
|
2
|
+
export * from "./Business/Exception/ODEErrors.js";
|
|
3
|
+
export * from "./Business/Interactor/CallbackDecorator.js";
|
|
4
|
+
export * from "./Business/Interactor/ChainUseCase.js";
|
|
5
|
+
export * from "./Business/Interactor/SequenceUseCase.js";
|
|
6
|
+
export * from "./Business/Interactor/UseCase.js";
|
|
7
|
+
export * from "./Business/Interactor/UseCaseDispatcher.js";
|
|
8
|
+
export * from "./Gateway/MVVM/BaseViewModel.js";
|
|
9
|
+
export * from "./Gateway/MVVM/Controller.js";
|
|
10
|
+
export * from "./Gateway/MVVM/ControllerFactory.js";
|
|
11
|
+
export * from "./View/UI/OutputHandlingStrategy.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@animalab-netizen/typescript-ode",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Opinionated delivery engine for TypeScript applications.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"homepage": "https://github.com/animalab-netizen/typescript-ode",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/animalab-netizen/typescript-ode.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/animalab-netizen/typescript-ode/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"CONTRIBUTING.md",
|
|
30
|
+
"PUBLICATION.md",
|
|
31
|
+
"USECASE_GUIDE.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"prepare": "npm run build",
|
|
37
|
+
"test": "npm run build && node --test tests/*.test.mjs"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"ode",
|
|
41
|
+
"typescript",
|
|
42
|
+
"architecture",
|
|
43
|
+
"usecase",
|
|
44
|
+
"mvvm",
|
|
45
|
+
"workflow",
|
|
46
|
+
"delivery-engine"
|
|
47
|
+
],
|
|
48
|
+
"author": "ÂnimaLab <animalab.desenvolvimento@gmail.com>",
|
|
49
|
+
"license": "Apache-2.0"
|
|
50
|
+
}
|