@quenk/frontend 0.20.1
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/README.md +19 -0
- package/lib/app/display.d.ts +140 -0
- package/lib/app/display.js +167 -0
- package/lib/app/display.js.map +1 -0
- package/lib/app/index.d.ts +26 -0
- package/lib/app/index.js +29 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/model/http.d.ts +147 -0
- package/lib/app/model/http.js +184 -0
- package/lib/app/model/http.js.map +1 -0
- package/lib/app/model/index.d.ts +36 -0
- package/lib/app/model/index.js +3 -0
- package/lib/app/model/index.js.map +1 -0
- package/lib/app/router/hash.d.ts +143 -0
- package/lib/app/router/hash.js +178 -0
- package/lib/app/router/hash.js.map +1 -0
- package/lib/app/router/index.d.ts +49 -0
- package/lib/app/router/index.js +3 -0
- package/lib/app/router/index.js.map +1 -0
- package/lib/app/scene/dialog/alert.d.ts +13 -0
- package/lib/app/scene/dialog/alert.js +18 -0
- package/lib/app/scene/dialog/alert.js.map +1 -0
- package/lib/app/scene/dialog/confirm.d.ts +39 -0
- package/lib/app/scene/dialog/confirm.js +36 -0
- package/lib/app/scene/dialog/confirm.js.map +1 -0
- package/lib/app/scene/dialog/index.d.ts +65 -0
- package/lib/app/scene/dialog/index.js +71 -0
- package/lib/app/scene/dialog/index.js.map +1 -0
- package/lib/app/scene/director.d.ts +90 -0
- package/lib/app/scene/director.js +111 -0
- package/lib/app/scene/director.js.map +1 -0
- package/lib/app/scene/index.d.ts +66 -0
- package/lib/app/scene/index.js +50 -0
- package/lib/app/scene/index.js.map +1 -0
- package/lib/app/search/filters.d.ts +258 -0
- package/lib/app/search/filters.js +372 -0
- package/lib/app/search/filters.js.map +1 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# J'ouvert
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
|
|
5
|
+
J'ouvert is a client-side web framework developed and used by
|
|
6
|
+
[Quenk Technologies](https://quenk.com).
|
|
7
|
+
|
|
8
|
+
It is based mainly on the [potoo](https://github.com/quenktechnologies/potoo)
|
|
9
|
+
framework and uses other elements of the Quenk JavaScript platform.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --save-dev @quenk/jouvert
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Apache-2.0 (c) Quenk Technologies Ltd 2019
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { View } from '@quenk/wml';
|
|
2
|
+
import { Yield } from '@quenk/noni/lib/control/monad/future';
|
|
3
|
+
import { Lazy } from '@quenk/noni/lib/data/lazy';
|
|
4
|
+
import { TypeCase } from '@quenk/noni/lib/control/match/case';
|
|
5
|
+
import { Immutable } from '@quenk/potoo/lib/actor/framework/resident';
|
|
6
|
+
import { Runtime } from '@quenk/potoo/lib/actor/system/vm/runtime';
|
|
7
|
+
import { Address } from '@quenk/potoo/lib/actor/address';
|
|
8
|
+
import { Layout } from '@quenk/wml-widgets/lib/layout';
|
|
9
|
+
/**
|
|
10
|
+
* ViewName is used to identify views.
|
|
11
|
+
*/
|
|
12
|
+
export type ViewName = string;
|
|
13
|
+
/**
|
|
14
|
+
* DisplayMessage is the type of messages the Display handles.
|
|
15
|
+
*/
|
|
16
|
+
export type DisplayMessage = Show | Push | Pop | Close;
|
|
17
|
+
/**
|
|
18
|
+
* ViewDelegate is the object the Display delegates actual handling of the
|
|
19
|
+
* view to.
|
|
20
|
+
*/
|
|
21
|
+
export interface ViewDelegate {
|
|
22
|
+
/**
|
|
23
|
+
* set changes which view (if any) is attached to the view.
|
|
24
|
+
*/
|
|
25
|
+
set(view: View): void;
|
|
26
|
+
/**
|
|
27
|
+
* unset removes the current view from the DOM.
|
|
28
|
+
*/
|
|
29
|
+
unset(): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* HTMLElementViewDelegate is a ViewDelegate implementation that uses a
|
|
33
|
+
* HTMLElement to display the view.
|
|
34
|
+
*/
|
|
35
|
+
export declare class HTMLElementViewDelegate implements ViewDelegate {
|
|
36
|
+
node: Lazy<HTMLElement>;
|
|
37
|
+
constructor(node: Lazy<HTMLElement>);
|
|
38
|
+
set(view: View): void;
|
|
39
|
+
unset(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* WMLLayoutViewDelegate is a ViewDelegate implementation that uses a WML layout
|
|
43
|
+
* instance to display the view.
|
|
44
|
+
*/
|
|
45
|
+
export declare class WMLLayoutViewDelegate implements ViewDelegate {
|
|
46
|
+
layout: Lazy<Layout>;
|
|
47
|
+
constructor(layout: Lazy<Layout>);
|
|
48
|
+
set(view: View): void;
|
|
49
|
+
unset(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Show triggers the display of dialog content.
|
|
53
|
+
*/
|
|
54
|
+
export declare class Show {
|
|
55
|
+
name: ViewName;
|
|
56
|
+
view: View;
|
|
57
|
+
source: Address;
|
|
58
|
+
constructor(name: ViewName, view: View, source: Address);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Push pushes a [[View]] on to the stack making it the one displayed.
|
|
62
|
+
*/
|
|
63
|
+
export declare class Push extends Show {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Pop pops the current [[View]] off of the view stack.
|
|
67
|
+
*
|
|
68
|
+
* If there are no more Views, the dialog is closed.
|
|
69
|
+
*/
|
|
70
|
+
export declare class Pop {
|
|
71
|
+
source: Address;
|
|
72
|
+
constructor(source: Address);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Close instructs the service to "close" the view. The content displayed
|
|
76
|
+
* will be destroyed by the delegate.
|
|
77
|
+
*/
|
|
78
|
+
export declare class Close {
|
|
79
|
+
source: Address;
|
|
80
|
+
constructor(source: Address);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* ViewShown indicates to the receiver that the named view has been shown.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ViewShown {
|
|
86
|
+
name: ViewName;
|
|
87
|
+
constructor(name: ViewName);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* ViewStackEmpty indicates the view stack is empty and cannot be popped.
|
|
91
|
+
*/
|
|
92
|
+
export declare class ViewStackEmpty {
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* ViewRemoved indicates the content of a [[View]] has been removed.
|
|
96
|
+
*/
|
|
97
|
+
export declare class ViewRemoved {
|
|
98
|
+
name: ViewName;
|
|
99
|
+
constructor(name: ViewName);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* DisplayListener is an interface for actors interested in receiving event
|
|
103
|
+
* messages related to the display.
|
|
104
|
+
*/
|
|
105
|
+
export interface DisplayListener {
|
|
106
|
+
/**
|
|
107
|
+
* afterViewShown is called when the listener receives a ViewShown
|
|
108
|
+
* message.
|
|
109
|
+
*/
|
|
110
|
+
afterViewShown(msg: ViewShown): Yield<void>;
|
|
111
|
+
/**
|
|
112
|
+
* afterViewRemoved is called when the listener receives a ViewRemoved
|
|
113
|
+
* message.
|
|
114
|
+
*/
|
|
115
|
+
afterViewRemoved(msg: ViewRemoved): Yield<void>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Display serves as the "display" for Jouvert applications that utilize
|
|
119
|
+
* WML views for content.
|
|
120
|
+
*
|
|
121
|
+
* The details of actually showing a View is left up to the specified
|
|
122
|
+
* ViewDelegate instance, allowing for a degree of flexibility.
|
|
123
|
+
* At any point in time, only one View is expected to be displayed, the current
|
|
124
|
+
* View can be changed via a [[Show]] message. However, Views can be stacked up
|
|
125
|
+
* via [[Push]] messages and later restored via [[Pop]].
|
|
126
|
+
*
|
|
127
|
+
* Use this to implement navigation independent of the address bar when needed
|
|
128
|
+
* for example.
|
|
129
|
+
*/
|
|
130
|
+
export declare class Display extends Immutable {
|
|
131
|
+
delegate: ViewDelegate;
|
|
132
|
+
runtime: Runtime;
|
|
133
|
+
constructor(delegate: ViewDelegate, runtime: Runtime);
|
|
134
|
+
stack: Show[];
|
|
135
|
+
selectors(): (TypeCase<typeof Show, void> | TypeCase<typeof Pop, void>)[];
|
|
136
|
+
show(m: Show): void;
|
|
137
|
+
push(m: Push): void;
|
|
138
|
+
pop(m: Pop): void;
|
|
139
|
+
close(): void;
|
|
140
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Display = exports.ViewRemoved = exports.ViewStackEmpty = exports.ViewShown = exports.Close = exports.Pop = exports.Push = exports.Show = exports.WMLLayoutViewDelegate = exports.HTMLElementViewDelegate = void 0;
|
|
4
|
+
const lazy_1 = require("@quenk/noni/lib/data/lazy");
|
|
5
|
+
const array_1 = require("@quenk/noni/lib/data/array");
|
|
6
|
+
const case_1 = require("@quenk/noni/lib/control/match/case");
|
|
7
|
+
const resident_1 = require("@quenk/potoo/lib/actor/framework/resident");
|
|
8
|
+
/**
|
|
9
|
+
* HTMLElementViewDelegate is a ViewDelegate implementation that uses a
|
|
10
|
+
* HTMLElement to display the view.
|
|
11
|
+
*/
|
|
12
|
+
class HTMLElementViewDelegate {
|
|
13
|
+
constructor(node) {
|
|
14
|
+
this.node = node;
|
|
15
|
+
}
|
|
16
|
+
set(view) {
|
|
17
|
+
this.unset();
|
|
18
|
+
(0, lazy_1.evaluate)(this.node).appendChild(view.render());
|
|
19
|
+
}
|
|
20
|
+
unset() {
|
|
21
|
+
let node = (0, lazy_1.evaluate)(this.node);
|
|
22
|
+
while (node.firstChild != null)
|
|
23
|
+
node.removeChild(node.firstChild);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.HTMLElementViewDelegate = HTMLElementViewDelegate;
|
|
27
|
+
/**
|
|
28
|
+
* WMLLayoutViewDelegate is a ViewDelegate implementation that uses a WML layout
|
|
29
|
+
* instance to display the view.
|
|
30
|
+
*/
|
|
31
|
+
class WMLLayoutViewDelegate {
|
|
32
|
+
constructor(layout) {
|
|
33
|
+
this.layout = layout;
|
|
34
|
+
}
|
|
35
|
+
set(view) {
|
|
36
|
+
this.unset();
|
|
37
|
+
(0, lazy_1.evaluate)(this.layout).setContent(view.render());
|
|
38
|
+
}
|
|
39
|
+
unset() {
|
|
40
|
+
(0, lazy_1.evaluate)(this.layout).removeContent();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.WMLLayoutViewDelegate = WMLLayoutViewDelegate;
|
|
44
|
+
/**
|
|
45
|
+
* Show triggers the display of dialog content.
|
|
46
|
+
*/
|
|
47
|
+
class Show {
|
|
48
|
+
constructor(name, view, source) {
|
|
49
|
+
this.name = name;
|
|
50
|
+
this.view = view;
|
|
51
|
+
this.source = source;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Show = Show;
|
|
55
|
+
/**
|
|
56
|
+
* Push pushes a [[View]] on to the stack making it the one displayed.
|
|
57
|
+
*/
|
|
58
|
+
class Push extends Show {
|
|
59
|
+
}
|
|
60
|
+
exports.Push = Push;
|
|
61
|
+
/**
|
|
62
|
+
* Pop pops the current [[View]] off of the view stack.
|
|
63
|
+
*
|
|
64
|
+
* If there are no more Views, the dialog is closed.
|
|
65
|
+
*/
|
|
66
|
+
class Pop {
|
|
67
|
+
constructor(source) {
|
|
68
|
+
this.source = source;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.Pop = Pop;
|
|
72
|
+
/**
|
|
73
|
+
* Close instructs the service to "close" the view. The content displayed
|
|
74
|
+
* will be destroyed by the delegate.
|
|
75
|
+
*/
|
|
76
|
+
class Close {
|
|
77
|
+
constructor(source) {
|
|
78
|
+
this.source = source;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Close = Close;
|
|
82
|
+
/**
|
|
83
|
+
* ViewShown indicates to the receiver that the named view has been shown.
|
|
84
|
+
*/
|
|
85
|
+
class ViewShown {
|
|
86
|
+
constructor(name) {
|
|
87
|
+
this.name = name;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ViewShown = ViewShown;
|
|
91
|
+
/**
|
|
92
|
+
* ViewStackEmpty indicates the view stack is empty and cannot be popped.
|
|
93
|
+
*/
|
|
94
|
+
class ViewStackEmpty {
|
|
95
|
+
}
|
|
96
|
+
exports.ViewStackEmpty = ViewStackEmpty;
|
|
97
|
+
/**
|
|
98
|
+
* ViewRemoved indicates the content of a [[View]] has been removed.
|
|
99
|
+
*/
|
|
100
|
+
class ViewRemoved {
|
|
101
|
+
constructor(name) {
|
|
102
|
+
this.name = name;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.ViewRemoved = ViewRemoved;
|
|
106
|
+
/**
|
|
107
|
+
* Display serves as the "display" for Jouvert applications that utilize
|
|
108
|
+
* WML views for content.
|
|
109
|
+
*
|
|
110
|
+
* The details of actually showing a View is left up to the specified
|
|
111
|
+
* ViewDelegate instance, allowing for a degree of flexibility.
|
|
112
|
+
* At any point in time, only one View is expected to be displayed, the current
|
|
113
|
+
* View can be changed via a [[Show]] message. However, Views can be stacked up
|
|
114
|
+
* via [[Push]] messages and later restored via [[Pop]].
|
|
115
|
+
*
|
|
116
|
+
* Use this to implement navigation independent of the address bar when needed
|
|
117
|
+
* for example.
|
|
118
|
+
*/
|
|
119
|
+
class Display extends resident_1.Immutable {
|
|
120
|
+
constructor(delegate, runtime) {
|
|
121
|
+
super(runtime);
|
|
122
|
+
this.delegate = delegate;
|
|
123
|
+
this.runtime = runtime;
|
|
124
|
+
this.stack = [];
|
|
125
|
+
}
|
|
126
|
+
selectors() {
|
|
127
|
+
return [
|
|
128
|
+
new case_1.TypeCase(Show, (m) => this.show(m)),
|
|
129
|
+
new case_1.TypeCase(Push, (m) => this.push(m)),
|
|
130
|
+
new case_1.TypeCase(Pop, (m) => this.pop(m)),
|
|
131
|
+
new case_1.TypeCase(Close, () => this.close())
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
show(m) {
|
|
135
|
+
if (!(0, array_1.empty)(this.stack))
|
|
136
|
+
this.close();
|
|
137
|
+
this.push(m);
|
|
138
|
+
}
|
|
139
|
+
push(m) {
|
|
140
|
+
this.stack.push(m);
|
|
141
|
+
this.delegate.set(m.view);
|
|
142
|
+
this.tell(m.source, new ViewShown(m.name));
|
|
143
|
+
}
|
|
144
|
+
pop(m) {
|
|
145
|
+
if ((0, array_1.empty)(this.stack)) {
|
|
146
|
+
this.tell(m.source, new ViewStackEmpty());
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
let current = this.stack.pop();
|
|
150
|
+
this.delegate.unset();
|
|
151
|
+
this.tell(current.source, new ViewRemoved(current.name));
|
|
152
|
+
if (!(0, array_1.empty)(this.stack)) {
|
|
153
|
+
this.push(this.stack.pop());
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
;
|
|
158
|
+
close() {
|
|
159
|
+
this.delegate.unset();
|
|
160
|
+
this.stack.forEach(m => {
|
|
161
|
+
this.tell(m.source, new ViewRemoved(m.name));
|
|
162
|
+
});
|
|
163
|
+
this.stack = [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.Display = Display;
|
|
167
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/app/display.ts"],"names":[],"mappings":";;;AAGA,oDAA2D;AAC3D,sDAAmD;AACnD,6DAA8D;AAE9D,wEAAsE;AAuCtE;;;GAGG;AACH,MAAa,uBAAuB;IAEhC,YAAmB,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAI,CAAC;IAE/C,GAAG,CAAC,IAAU;QAEV,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,IAAA,eAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAc,IAAI,C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actor/system/vm';
|
|
4
|
+
export { Template };
|
|
5
|
+
/**
|
|
6
|
+
* Jouvert is meant to be the main class of any jouvert application.
|
|
7
|
+
*
|
|
8
|
+
* This class serves as the container for the actor system from which all
|
|
9
|
+
* actors will be descended from (indirectly via the embedded vm). By making the
|
|
10
|
+
* wrapper for the actor system our main class, we combine the overview of the
|
|
11
|
+
* entire application with control over the actor system allowing everything
|
|
12
|
+
* to be managed in one place and via one interface.
|
|
13
|
+
*
|
|
14
|
+
* Additional helpful methods and properties can be declared here if desired
|
|
15
|
+
* and made available to all actors of the system. State should not be shared
|
|
16
|
+
* between actors however, static constant values should not do much harm.
|
|
17
|
+
*
|
|
18
|
+
* "System" level operations in an application such as network requests,
|
|
19
|
+
* application cleanup, caching, could also be handle in the Jouvert instance
|
|
20
|
+
* and exposed to actors via message passing if desired.
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class App {
|
|
23
|
+
conf: Partial<Conf>;
|
|
24
|
+
vm: PVM;
|
|
25
|
+
constructor(conf?: Partial<Conf>, vm?: PVM);
|
|
26
|
+
}
|
package/lib/app/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.App = void 0;
|
|
4
|
+
const vm_1 = require("@quenk/potoo/lib/actor/system/vm");
|
|
5
|
+
/**
|
|
6
|
+
* Jouvert is meant to be the main class of any jouvert application.
|
|
7
|
+
*
|
|
8
|
+
* This class serves as the container for the actor system from which all
|
|
9
|
+
* actors will be descended from (indirectly via the embedded vm). By making the
|
|
10
|
+
* wrapper for the actor system our main class, we combine the overview of the
|
|
11
|
+
* entire application with control over the actor system allowing everything
|
|
12
|
+
* to be managed in one place and via one interface.
|
|
13
|
+
*
|
|
14
|
+
* Additional helpful methods and properties can be declared here if desired
|
|
15
|
+
* and made available to all actors of the system. State should not be shared
|
|
16
|
+
* between actors however, static constant values should not do much harm.
|
|
17
|
+
*
|
|
18
|
+
* "System" level operations in an application such as network requests,
|
|
19
|
+
* application cleanup, caching, could also be handle in the Jouvert instance
|
|
20
|
+
* and exposed to actors via message passing if desired.
|
|
21
|
+
*/
|
|
22
|
+
class App {
|
|
23
|
+
constructor(conf = {}, vm = vm_1.PVM.create(conf)) {
|
|
24
|
+
this.conf = conf;
|
|
25
|
+
this.vm = vm;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.App = App;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":";;;AAEA,yDAAuD;AAIvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAsB,GAAG;IAErB,YACW,OAAsB,EAAI,EAC1B,KAAU,QAAG,CAAC,MAAM,CAAE,IAAI,CAAC;QAD3B,SAAI,GAAJ,IAAI,CAAsB;QAC1B,OAAE,GAAF,EAAE,CAAyB;IAAK,CAAC;CAE/C;AAND,kBAMC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Future } from '@quenk/noni/lib/control/monad/future';
|
|
2
|
+
import { Maybe } from '@quenk/noni/lib/data/maybe';
|
|
3
|
+
import { Object } from '@quenk/noni/lib/data/jsonx';
|
|
4
|
+
import { Record } from '@quenk/noni/lib/data/record';
|
|
5
|
+
import { Agent } from '@quenk/jhr/lib/agent';
|
|
6
|
+
import { Response } from '@quenk/jhr/lib/response';
|
|
7
|
+
import { Request } from '@quenk/jhr/lib/request';
|
|
8
|
+
import { Id, Model } from './';
|
|
9
|
+
export { Id, Model };
|
|
10
|
+
/**
|
|
11
|
+
* Result is the structure of the response body expected after a successful
|
|
12
|
+
* CSUGR operation.
|
|
13
|
+
*/
|
|
14
|
+
export type Result<T extends Object> = CreateResult | SearchResult<T> | T | void;
|
|
15
|
+
/**
|
|
16
|
+
* CreateResponse is a Response with a [[CreateResult]] body.
|
|
17
|
+
*/
|
|
18
|
+
export type CreateResponse = Response<CreateResult>;
|
|
19
|
+
/**
|
|
20
|
+
* SearchResponse is a Response with a [[SearchResult]] body.
|
|
21
|
+
*/
|
|
22
|
+
export type SearchResponse<T extends Object> = Response<SearchResult<T>>;
|
|
23
|
+
/**
|
|
24
|
+
* GetResult is a Response with a [[GetResult]] body.
|
|
25
|
+
*/
|
|
26
|
+
export type GetResponse<T extends Object> = Response<T>;
|
|
27
|
+
/**
|
|
28
|
+
* CreateResult is the response body expected after a successful create()
|
|
29
|
+
* operation.
|
|
30
|
+
*/
|
|
31
|
+
export interface CreateResult {
|
|
32
|
+
data: {
|
|
33
|
+
id: Id;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* SearchResult is the response body expected after a successful search()
|
|
38
|
+
* operation.
|
|
39
|
+
*/
|
|
40
|
+
export interface SearchResult<T extends Object> {
|
|
41
|
+
data: T[];
|
|
42
|
+
pages: PageData;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* PageData contains the pagination details of a successful search.
|
|
46
|
+
*/
|
|
47
|
+
export interface PageData {
|
|
48
|
+
/**
|
|
49
|
+
* current page the returned results are from.
|
|
50
|
+
*/
|
|
51
|
+
current: number;
|
|
52
|
+
/**
|
|
53
|
+
* currentCount of the current page
|
|
54
|
+
*/
|
|
55
|
+
currentCount: number;
|
|
56
|
+
/**
|
|
57
|
+
* maxPerPage indicates how many rows are allowed per page.
|
|
58
|
+
*/
|
|
59
|
+
maxPerPage: number;
|
|
60
|
+
/**
|
|
61
|
+
* totalPages available for the entire result.
|
|
62
|
+
*/
|
|
63
|
+
totalPages: number;
|
|
64
|
+
/**
|
|
65
|
+
* totalCount of the entire result set.
|
|
66
|
+
*/
|
|
67
|
+
totalCount: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Paths is a record of actor addresses to use for each of the CSUGR
|
|
71
|
+
* operations of a RemoteModel.
|
|
72
|
+
*/
|
|
73
|
+
export interface Paths extends Record<string> {
|
|
74
|
+
}
|
|
75
|
+
export declare const NO_PATH = "?invalid?";
|
|
76
|
+
/**
|
|
77
|
+
* RequestFactory generates request objects with paths from the provided
|
|
78
|
+
* Paths object.
|
|
79
|
+
*
|
|
80
|
+
* A set of internal rules are used for each operation to determine the path.
|
|
81
|
+
* This helps reduce the amount of paths that need to be supplied by re-using
|
|
82
|
+
* the "search" path for "create" etc.
|
|
83
|
+
*/
|
|
84
|
+
export declare class RequestFactory {
|
|
85
|
+
paths: Paths;
|
|
86
|
+
constructor(paths?: Paths);
|
|
87
|
+
/**
|
|
88
|
+
* create generates a request for the model "create" method.
|
|
89
|
+
*/
|
|
90
|
+
create<T extends Object>(data: T): Request<T>;
|
|
91
|
+
/**
|
|
92
|
+
* search generates a request for the model "search" method.
|
|
93
|
+
*/
|
|
94
|
+
search(qry: Object): Request<Object>;
|
|
95
|
+
/**
|
|
96
|
+
* update generates a request for the model "update" method.
|
|
97
|
+
*/
|
|
98
|
+
update<T extends Object>(id: Id, changes: Partial<T>): Request<Partial<T>>;
|
|
99
|
+
/**
|
|
100
|
+
* get generates a request for the model "get" method.
|
|
101
|
+
*/
|
|
102
|
+
get<T extends Object>(id: Id): Request<T>;
|
|
103
|
+
/**
|
|
104
|
+
* remove generates a request for the model "remove" method.
|
|
105
|
+
*/
|
|
106
|
+
remove(id: Id): Request<Object>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* HttpModel is an abstract implementation of a Model class that uses http
|
|
110
|
+
* for CSUGR operations.
|
|
111
|
+
*
|
|
112
|
+
* To use send requests via jhr directly, use the child class in this module,
|
|
113
|
+
* to utilize a Remote actor, see the RemoteModel implementation elsewhere.
|
|
114
|
+
*/
|
|
115
|
+
export declare abstract class HttpModel<T extends Object> implements Model<T> {
|
|
116
|
+
/**
|
|
117
|
+
* requests factory used to create Request objects.
|
|
118
|
+
*/
|
|
119
|
+
abstract requests: RequestFactory;
|
|
120
|
+
/**
|
|
121
|
+
* send is left abstract for child classes to implement.
|
|
122
|
+
*/
|
|
123
|
+
abstract send(req: Request<Object>): Future<Response<Result<T>>>;
|
|
124
|
+
create(data: T): Future<Id>;
|
|
125
|
+
search(qry: Object): Future<T[]>;
|
|
126
|
+
update(id: Id, changes: Partial<T>): Future<boolean>;
|
|
127
|
+
get(id: Id): Future<Maybe<T>>;
|
|
128
|
+
remove(id: Id): Future<boolean>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* SimpleHttpModel is an HttpModel that uses the JHR lib directly.
|
|
132
|
+
*
|
|
133
|
+
* There is no intermediate transformations or interception other than what
|
|
134
|
+
* the jhr agent is configured for. Use this in smaller, less complicated apps
|
|
135
|
+
* where these abstraction are not needed. See the RemoteModel class if you
|
|
136
|
+
* need something more complicated.
|
|
137
|
+
*/
|
|
138
|
+
export declare class SimpleHttpModel<T extends Object> extends HttpModel<T> {
|
|
139
|
+
agent: Agent<Object, Object>;
|
|
140
|
+
requests: RequestFactory;
|
|
141
|
+
constructor(agent: Agent<Object, Object>, requests: RequestFactory);
|
|
142
|
+
/**
|
|
143
|
+
* fromPaths generates a new HttpModel using Paths object.
|
|
144
|
+
*/
|
|
145
|
+
static fromPaths(agent: Agent<Object, Object>, paths: Paths): SimpleHttpModel<Object>;
|
|
146
|
+
send(req: Request<Object>): Future<Response<Result<T>>>;
|
|
147
|
+
}
|