@quenk/frontend 0.20.1 → 0.20.2
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/lib/app/display.d.ts +17 -10
- package/lib/app/display.js +22 -13
- package/lib/app/display.js.map +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/model/http.d.ts +36 -12
- package/lib/app/model/http.js +69 -64
- package/lib/app/model/http.js.map +1 -1
- package/lib/app/model/index.d.ts +6 -6
- package/lib/app/router/hash.d.ts +8 -9
- package/lib/app/router/hash.js +17 -24
- package/lib/app/router/hash.js.map +1 -1
- package/lib/app/router/index.d.ts +4 -5
- package/lib/app/scene/dialog/alert.js.map +1 -1
- package/lib/app/scene/dialog/confirm.d.ts +1 -1
- package/lib/app/scene/dialog/confirm.js +2 -2
- package/lib/app/scene/dialog/confirm.js.map +1 -1
- package/lib/app/scene/dialog/index.d.ts +2 -2
- package/lib/app/scene/dialog/index.js +6 -6
- package/lib/app/scene/dialog/index.js.map +1 -1
- package/lib/app/scene/director.d.ts +4 -4
- package/lib/app/scene/director.js +7 -11
- package/lib/app/scene/director.js.map +1 -1
- package/lib/app/scene/form/index.d.ts +183 -0
- package/lib/app/scene/form/index.js +142 -0
- package/lib/app/scene/form/index.js.map +1 -0
- package/lib/app/scene/form/model.d.ts +44 -0
- package/lib/app/scene/form/model.js +47 -0
- package/lib/app/scene/form/model.js.map +1 -0
- package/lib/app/scene/form/validator/index.d.ts +70 -0
- package/lib/app/scene/form/validator/index.js +31 -0
- package/lib/app/scene/form/validator/index.js.map +1 -0
- package/lib/app/scene/form/validator/strategy.d.ts +94 -0
- package/lib/app/scene/form/validator/strategy.js +85 -0
- package/lib/app/scene/form/validator/strategy.js.map +1 -0
- package/lib/app/scene/index.d.ts +2 -2
- package/lib/app/scene/index.js +5 -5
- package/lib/app/scene/index.js.map +1 -1
- package/lib/app/scene/page.d.ts +56 -0
- package/lib/app/scene/page.js +83 -0
- package/lib/app/scene/page.js.map +1 -0
- package/lib/app/search/filters.d.ts +2 -2
- package/lib/app/search/filters.js +19 -25
- package/lib/app/search/filters.js.map +1 -1
- package/package.json +1 -1
package/lib/app/display.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { View } from '@quenk/wml';
|
|
2
|
-
import { Yield } from '@quenk/noni/lib/control/monad/future';
|
|
3
2
|
import { Lazy } from '@quenk/noni/lib/data/lazy';
|
|
4
3
|
import { TypeCase } from '@quenk/noni/lib/control/match/case';
|
|
5
4
|
import { Immutable } from '@quenk/potoo/lib/actor/framework/resident';
|
|
@@ -34,7 +33,8 @@ export interface ViewDelegate {
|
|
|
34
33
|
*/
|
|
35
34
|
export declare class HTMLElementViewDelegate implements ViewDelegate {
|
|
36
35
|
node: Lazy<HTMLElement>;
|
|
37
|
-
|
|
36
|
+
view?: View | undefined;
|
|
37
|
+
constructor(node: Lazy<HTMLElement>, view?: View | undefined);
|
|
38
38
|
set(view: View): void;
|
|
39
39
|
unset(): void;
|
|
40
40
|
}
|
|
@@ -107,12 +107,12 @@ export interface DisplayListener {
|
|
|
107
107
|
* afterViewShown is called when the listener receives a ViewShown
|
|
108
108
|
* message.
|
|
109
109
|
*/
|
|
110
|
-
afterViewShown(msg: ViewShown):
|
|
110
|
+
afterViewShown(msg: ViewShown): Promise<void>;
|
|
111
111
|
/**
|
|
112
112
|
* afterViewRemoved is called when the listener receives a ViewRemoved
|
|
113
113
|
* message.
|
|
114
114
|
*/
|
|
115
|
-
afterViewRemoved(msg: ViewRemoved):
|
|
115
|
+
afterViewRemoved(msg: ViewRemoved): Promise<void>;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Display serves as the "display" for Jouvert applications that utilize
|
|
@@ -128,13 +128,20 @@ export interface DisplayListener {
|
|
|
128
128
|
* for example.
|
|
129
129
|
*/
|
|
130
130
|
export declare class Display extends Immutable {
|
|
131
|
-
delegate: ViewDelegate;
|
|
132
131
|
runtime: Runtime;
|
|
133
|
-
|
|
132
|
+
delegate: ViewDelegate;
|
|
133
|
+
view?: View | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* @param runtime - the actor system runtime.
|
|
136
|
+
* @param delegate - the ViewDelegate to use for displaying views.
|
|
137
|
+
* @param view - the initial view to display.
|
|
138
|
+
*/
|
|
139
|
+
constructor(runtime: Runtime, delegate: ViewDelegate, view?: View | undefined);
|
|
134
140
|
stack: Show[];
|
|
135
|
-
selectors(): (TypeCase<typeof Show, void> | TypeCase<typeof Pop, void
|
|
141
|
+
selectors(): (TypeCase<typeof Show, void> | TypeCase<typeof Pop, Promise<void>>)[];
|
|
136
142
|
show(m: Show): void;
|
|
137
|
-
push(m: Push): void
|
|
138
|
-
pop(m: Pop): void
|
|
139
|
-
close(): void
|
|
143
|
+
push(m: Push): Promise<void>;
|
|
144
|
+
pop(m: Pop): Promise<void>;
|
|
145
|
+
close(): Promise<void>;
|
|
146
|
+
run(): Promise<void>;
|
|
140
147
|
}
|
package/lib/app/display.js
CHANGED
|
@@ -10,8 +10,9 @@ const resident_1 = require("@quenk/potoo/lib/actor/framework/resident");
|
|
|
10
10
|
* HTMLElement to display the view.
|
|
11
11
|
*/
|
|
12
12
|
class HTMLElementViewDelegate {
|
|
13
|
-
constructor(node) {
|
|
13
|
+
constructor(node, view) {
|
|
14
14
|
this.node = node;
|
|
15
|
+
this.view = view;
|
|
15
16
|
}
|
|
16
17
|
set(view) {
|
|
17
18
|
this.unset();
|
|
@@ -117,10 +118,16 @@ exports.ViewRemoved = ViewRemoved;
|
|
|
117
118
|
* for example.
|
|
118
119
|
*/
|
|
119
120
|
class Display extends resident_1.Immutable {
|
|
120
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @param runtime - the actor system runtime.
|
|
123
|
+
* @param delegate - the ViewDelegate to use for displaying views.
|
|
124
|
+
* @param view - the initial view to display.
|
|
125
|
+
*/
|
|
126
|
+
constructor(runtime, delegate, view) {
|
|
121
127
|
super(runtime);
|
|
122
|
-
this.delegate = delegate;
|
|
123
128
|
this.runtime = runtime;
|
|
129
|
+
this.delegate = delegate;
|
|
130
|
+
this.view = view;
|
|
124
131
|
this.stack = [];
|
|
125
132
|
}
|
|
126
133
|
selectors() {
|
|
@@ -136,32 +143,34 @@ class Display extends resident_1.Immutable {
|
|
|
136
143
|
this.close();
|
|
137
144
|
this.push(m);
|
|
138
145
|
}
|
|
139
|
-
push(m) {
|
|
146
|
+
async push(m) {
|
|
140
147
|
this.stack.push(m);
|
|
141
148
|
this.delegate.set(m.view);
|
|
142
|
-
this.tell(m.source, new ViewShown(m.name));
|
|
149
|
+
await this.tell(m.source, new ViewShown(m.name));
|
|
143
150
|
}
|
|
144
|
-
pop(m) {
|
|
151
|
+
async pop(m) {
|
|
145
152
|
if ((0, array_1.empty)(this.stack)) {
|
|
146
|
-
this.tell(m.source, new ViewStackEmpty());
|
|
153
|
+
await this.tell(m.source, new ViewStackEmpty());
|
|
147
154
|
}
|
|
148
155
|
else {
|
|
149
156
|
let current = this.stack.pop();
|
|
150
157
|
this.delegate.unset();
|
|
151
|
-
this.tell(current.source, new ViewRemoved(current.name));
|
|
158
|
+
await this.tell(current.source, new ViewRemoved(current.name));
|
|
152
159
|
if (!(0, array_1.empty)(this.stack)) {
|
|
153
160
|
this.push(this.stack.pop());
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
|
-
|
|
158
|
-
close() {
|
|
164
|
+
async close() {
|
|
159
165
|
this.delegate.unset();
|
|
160
|
-
this.stack.
|
|
161
|
-
this.tell(m.source, new ViewRemoved(m.name));
|
|
162
|
-
});
|
|
166
|
+
await Promise.allSettled(this.stack.map(m => this.tell(m.source, new ViewRemoved(m.name))));
|
|
163
167
|
this.stack = [];
|
|
164
168
|
}
|
|
169
|
+
async run() {
|
|
170
|
+
if (this.view) {
|
|
171
|
+
this.delegate.set(this.view);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
175
|
exports.Display = Display;
|
|
167
176
|
//# sourceMappingURL=display.js.map
|
package/lib/app/display.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/app/display.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/app/display.ts"],"names":[],"mappings":";;;AAEA,oDAA2D;AAC3D,sDAAmD;AACnD,6DAA8D;AAE9D,wEAAsE;AAgCtE;;;GAGG;AACH,MAAa,uBAAuB;IAChC,YACW,IAAuB,EACvB,IAAW;QADX,SAAI,GAAJ,IAAI,CAAmB;QACvB,SAAI,GAAJ,IAAI,CAAO;IACnB,CAAC;IAEJ,GAAG,CAAC,IAAU;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,IAAA,eAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAc,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,KAAK;QACD,IAAI,IAAI,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI;YAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACJ;AAjBD,0DAiBC;AAED;;;GAGG;AACH,MAAa,qBAAqB;IAC9B,YAAmB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE3C,GAAG,CAAC,IAAU;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,IAAA,eAAQ,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAc,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,KAAK;QACD,IAAA,eAAQ,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IAC1C,CAAC;CACJ;AAZD,sDAYC;AAED;;GAEG;AACH,MAAa,IAAI;IACb,YACW,IAAc,EAC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C,IAAI,CAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEtB,MAAM,OAAO,CAAC,UAAU,CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACpE,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,GAAG;QACL,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACL,CAAC;CACJ;AAzED,0BAyEC"}
|
package/lib/app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":";;;AAEA,yDAAuD;AAIvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAsB,GAAG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":";;;AAEA,yDAAuD;AAIvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAsB,GAAG;IACrB,YACW,OAAsB,EAAE,EACxB,KAAU,QAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAD1B,SAAI,GAAJ,IAAI,CAAoB;QACxB,OAAE,GAAF,EAAE,CAAwB;IAClC,CAAC;CACP;AALD,kBAKC"}
|
package/lib/app/model/http.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Future } from '@quenk/noni/lib/control/monad/future';
|
|
2
1
|
import { Maybe } from '@quenk/noni/lib/data/maybe';
|
|
3
2
|
import { Object } from '@quenk/noni/lib/data/jsonx';
|
|
4
3
|
import { Record } from '@quenk/noni/lib/data/record';
|
|
4
|
+
import { Type } from '@quenk/noni/lib/data/type';
|
|
5
|
+
import { Except } from '@quenk/noni/lib/control/except';
|
|
5
6
|
import { Agent } from '@quenk/jhr/lib/agent';
|
|
6
7
|
import { Response } from '@quenk/jhr/lib/response';
|
|
7
8
|
import { Request } from '@quenk/jhr/lib/request';
|
|
8
9
|
import { Id, Model } from './';
|
|
9
10
|
export { Id, Model };
|
|
11
|
+
export declare const ERR_REQUEST_FAILED = "ERR_REQUEST_FAILED";
|
|
10
12
|
/**
|
|
11
13
|
* Result is the structure of the response body expected after a successful
|
|
12
14
|
* CSUGR operation.
|
|
@@ -28,7 +30,7 @@ export type GetResponse<T extends Object> = Response<T>;
|
|
|
28
30
|
* CreateResult is the response body expected after a successful create()
|
|
29
31
|
* operation.
|
|
30
32
|
*/
|
|
31
|
-
export interface CreateResult {
|
|
33
|
+
export interface CreateResult extends Object {
|
|
32
34
|
data: {
|
|
33
35
|
id: Id;
|
|
34
36
|
};
|
|
@@ -37,14 +39,14 @@ export interface CreateResult {
|
|
|
37
39
|
* SearchResult is the response body expected after a successful search()
|
|
38
40
|
* operation.
|
|
39
41
|
*/
|
|
40
|
-
export interface SearchResult<T extends Object> {
|
|
42
|
+
export interface SearchResult<T extends Object> extends Object {
|
|
41
43
|
data: T[];
|
|
42
44
|
pages: PageData;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* PageData contains the pagination details of a successful search.
|
|
46
48
|
*/
|
|
47
|
-
export interface PageData {
|
|
49
|
+
export interface PageData extends Object {
|
|
48
50
|
/**
|
|
49
51
|
* current page the returned results are from.
|
|
50
52
|
*/
|
|
@@ -105,6 +107,24 @@ export declare class RequestFactory {
|
|
|
105
107
|
*/
|
|
106
108
|
remove(id: Id): Request<Object>;
|
|
107
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* HttpCallback is a set of optional callbacks that can be used to
|
|
112
|
+
* hook into and handle undesired responses.
|
|
113
|
+
*/
|
|
114
|
+
export interface HttpCallback {
|
|
115
|
+
onConflict(res: Response<Object>): void;
|
|
116
|
+
onBadRequest(res: Response<Object>): void;
|
|
117
|
+
onUnauthorized(res: Response<Object>): void;
|
|
118
|
+
onForbidden(res: Response<Object>): void;
|
|
119
|
+
onError(res: Response<Object>): void;
|
|
120
|
+
}
|
|
121
|
+
export declare class DefaultHttpCallback {
|
|
122
|
+
onConflict(_: Response<Object>): void;
|
|
123
|
+
onBadRequest(_: Response<Object>): void;
|
|
124
|
+
onUnauthorized(_: Response<Object>): void;
|
|
125
|
+
onForbidden(_: Response<Object>): void;
|
|
126
|
+
onError(_: Response<Object>): void;
|
|
127
|
+
}
|
|
108
128
|
/**
|
|
109
129
|
* HttpModel is an abstract implementation of a Model class that uses http
|
|
110
130
|
* for CSUGR operations.
|
|
@@ -113,6 +133,8 @@ export declare class RequestFactory {
|
|
|
113
133
|
* to utilize a Remote actor, see the RemoteModel implementation elsewhere.
|
|
114
134
|
*/
|
|
115
135
|
export declare abstract class HttpModel<T extends Object> implements Model<T> {
|
|
136
|
+
callback: HttpCallback;
|
|
137
|
+
constructor(callback?: HttpCallback);
|
|
116
138
|
/**
|
|
117
139
|
* requests factory used to create Request objects.
|
|
118
140
|
*/
|
|
@@ -120,12 +142,13 @@ export declare abstract class HttpModel<T extends Object> implements Model<T> {
|
|
|
120
142
|
/**
|
|
121
143
|
* send is left abstract for child classes to implement.
|
|
122
144
|
*/
|
|
123
|
-
abstract send(req: Request<Object>):
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
abstract send(req: Request<Object>): Promise<Response<Result<T>>>;
|
|
146
|
+
handleResponse<A>(res: Response<Type>): Except<A>;
|
|
147
|
+
create(data: T): Promise<Except<Id>>;
|
|
148
|
+
search(qry: Object): Promise<Except<T[]>>;
|
|
149
|
+
update(id: Id, changes: Partial<T>): Promise<Except<boolean>>;
|
|
150
|
+
get(id: Id): Promise<Except<Maybe<T>>>;
|
|
151
|
+
remove(id: Id): Promise<Except<boolean>>;
|
|
129
152
|
}
|
|
130
153
|
/**
|
|
131
154
|
* SimpleHttpModel is an HttpModel that uses the JHR lib directly.
|
|
@@ -138,10 +161,11 @@ export declare abstract class HttpModel<T extends Object> implements Model<T> {
|
|
|
138
161
|
export declare class SimpleHttpModel<T extends Object> extends HttpModel<T> {
|
|
139
162
|
agent: Agent<Object, Object>;
|
|
140
163
|
requests: RequestFactory;
|
|
141
|
-
|
|
164
|
+
callbacks?: HttpCallback | undefined;
|
|
165
|
+
constructor(agent: Agent<Object, Object>, requests: RequestFactory, callbacks?: HttpCallback | undefined);
|
|
142
166
|
/**
|
|
143
167
|
* fromPaths generates a new HttpModel using Paths object.
|
|
144
168
|
*/
|
|
145
169
|
static fromPaths(agent: Agent<Object, Object>, paths: Paths): SimpleHttpModel<Object>;
|
|
146
|
-
send(req: Request<Object>):
|
|
170
|
+
send(req: Request<Object>): Promise<Response<Result<T>>>;
|
|
147
171
|
}
|
package/lib/app/model/http.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleHttpModel = exports.HttpModel = exports.RequestFactory = exports.NO_PATH = void 0;
|
|
3
|
+
exports.SimpleHttpModel = exports.HttpModel = exports.DefaultHttpCallback = exports.RequestFactory = exports.NO_PATH = exports.ERR_REQUEST_FAILED = void 0;
|
|
4
4
|
const status = require("@quenk/jhr/lib/status");
|
|
5
|
-
const future_1 = require("@quenk/noni/lib/control/monad/future");
|
|
6
5
|
const maybe_1 = require("@quenk/noni/lib/data/maybe");
|
|
7
6
|
const string_1 = require("@quenk/noni/lib/data/string");
|
|
8
7
|
const record_1 = require("@quenk/noni/lib/data/record");
|
|
9
8
|
const type_1 = require("@quenk/noni/lib/data/type");
|
|
9
|
+
const either_1 = require("@quenk/noni/lib/data/either");
|
|
10
10
|
const request_1 = require("@quenk/jhr/lib/request");
|
|
11
|
+
exports.ERR_REQUEST_FAILED = 'ERR_REQUEST_FAILED';
|
|
11
12
|
exports.NO_PATH = '?invalid?';
|
|
12
13
|
/**
|
|
13
14
|
* RequestFactory generates request objects with paths from the provided
|
|
@@ -49,9 +50,7 @@ class RequestFactory {
|
|
|
49
50
|
* update generates a request for the model "update" method.
|
|
50
51
|
*/
|
|
51
52
|
update(id, changes) {
|
|
52
|
-
return new request_1.Patch((0, string_1.interpolate)(this.paths.update ||
|
|
53
|
-
this.paths.get ||
|
|
54
|
-
exports.NO_PATH, { id }), changes, {
|
|
53
|
+
return new request_1.Patch((0, string_1.interpolate)(this.paths.update || this.paths.get || exports.NO_PATH, { id }), changes, {
|
|
55
54
|
tags: {
|
|
56
55
|
path: this.paths.update,
|
|
57
56
|
verb: 'patch',
|
|
@@ -75,9 +74,7 @@ class RequestFactory {
|
|
|
75
74
|
* remove generates a request for the model "remove" method.
|
|
76
75
|
*/
|
|
77
76
|
remove(id) {
|
|
78
|
-
return new request_1.Delete((0, string_1.interpolate)(this.paths.remove ||
|
|
79
|
-
this.paths.get ||
|
|
80
|
-
exports.NO_PATH, { id }), {}, {
|
|
77
|
+
return new request_1.Delete((0, string_1.interpolate)(this.paths.remove || this.paths.get || exports.NO_PATH, { id }), {}, {
|
|
81
78
|
tags: {
|
|
82
79
|
path: this.paths.remove,
|
|
83
80
|
verb: 'delete',
|
|
@@ -87,14 +84,14 @@ class RequestFactory {
|
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
exports.RequestFactory = RequestFactory;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
87
|
+
class DefaultHttpCallback {
|
|
88
|
+
onConflict(_) { }
|
|
89
|
+
onBadRequest(_) { }
|
|
90
|
+
onUnauthorized(_) { }
|
|
91
|
+
onForbidden(_) { }
|
|
92
|
+
onError(_) { }
|
|
93
|
+
}
|
|
94
|
+
exports.DefaultHttpCallback = DefaultHttpCallback;
|
|
98
95
|
/**
|
|
99
96
|
* HttpModel is an abstract implementation of a Model class that uses http
|
|
100
97
|
* for CSUGR operations.
|
|
@@ -103,56 +100,63 @@ const response2Error = (r) => new Error(errors[r.code] || errors.other);
|
|
|
103
100
|
* to utilize a Remote actor, see the RemoteModel implementation elsewhere.
|
|
104
101
|
*/
|
|
105
102
|
class HttpModel {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return (0, future_1.doFuture)(function* () {
|
|
109
|
-
let res = yield that.send(that.requests.create(data));
|
|
110
|
-
if (res.code !== status.CREATED)
|
|
111
|
-
return (0, future_1.raise)(response2Error(res));
|
|
112
|
-
return (0, future_1.pure)(res.body.data.id);
|
|
113
|
-
});
|
|
103
|
+
constructor(callback = new DefaultHttpCallback()) {
|
|
104
|
+
this.callback = callback;
|
|
114
105
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
handleResponse(res) {
|
|
107
|
+
switch (res.code) {
|
|
108
|
+
case status.BAD_REQUEST:
|
|
109
|
+
this.callback.onBadRequest(res);
|
|
110
|
+
break;
|
|
111
|
+
case status.UNAUTHORIZED:
|
|
112
|
+
this.callback.onUnauthorized(res);
|
|
113
|
+
break;
|
|
114
|
+
case status.FORBIDDEN:
|
|
115
|
+
this.callback.onForbidden(res);
|
|
116
|
+
break;
|
|
117
|
+
case status.CONFLICT:
|
|
118
|
+
this.callback.onConflict(res);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
this.callback.onError(res);
|
|
122
|
+
}
|
|
123
|
+
return either_1.Either.left(new Error(exports.ERR_REQUEST_FAILED));
|
|
125
124
|
}
|
|
126
|
-
|
|
127
|
-
let
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return (0, future_1.pure)(false);
|
|
132
|
-
if (res.code !== status.OK)
|
|
133
|
-
return (0, future_1.raise)(response2Error(res));
|
|
134
|
-
return (0, future_1.pure)(true);
|
|
135
|
-
});
|
|
125
|
+
async create(data) {
|
|
126
|
+
let res = await this.send(this.requests.create(data));
|
|
127
|
+
return res.code !== status.CREATED
|
|
128
|
+
? this.handleResponse(res)
|
|
129
|
+
: either_1.Either.right(res.body.data.id);
|
|
136
130
|
}
|
|
137
|
-
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return (0, future_1.raise)(response2Error(res));
|
|
145
|
-
return (0, future_1.pure)((0, maybe_1.fromNullable)(res.body));
|
|
146
|
-
});
|
|
131
|
+
async search(qry) {
|
|
132
|
+
let res = await this.send(this.requests.search(qry));
|
|
133
|
+
if (res.code !== status.OK && res.code !== status.NO_CONTENT)
|
|
134
|
+
return this.handleResponse(res);
|
|
135
|
+
return either_1.Either.right(res.code === status.NO_CONTENT
|
|
136
|
+
? []
|
|
137
|
+
: res.body.data);
|
|
147
138
|
}
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
async update(id, changes) {
|
|
140
|
+
let res = await this.send(this.requests.update(id, changes));
|
|
141
|
+
if (res.code === status.NOT_FOUND)
|
|
142
|
+
return either_1.Either.right(false);
|
|
143
|
+
if (res.code !== status.OK)
|
|
144
|
+
return this.handleResponse(res);
|
|
145
|
+
return either_1.Either.right(true);
|
|
146
|
+
}
|
|
147
|
+
async get(id) {
|
|
148
|
+
let res = await this.send(this.requests.get(id));
|
|
149
|
+
if (res.code === status.NOT_FOUND)
|
|
150
|
+
return either_1.Either.right((0, maybe_1.nothing)());
|
|
151
|
+
if (res.code !== status.OK)
|
|
152
|
+
return this.handleResponse(res);
|
|
153
|
+
return either_1.Either.right((0, maybe_1.fromNullable)(res.body));
|
|
154
|
+
}
|
|
155
|
+
async remove(id) {
|
|
156
|
+
let res = await this.send(this.requests.remove(id));
|
|
157
|
+
if (res.code !== status.OK)
|
|
158
|
+
return this.handleResponse(res);
|
|
159
|
+
return either_1.Either.right(true);
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
exports.HttpModel = HttpModel;
|
|
@@ -165,10 +169,11 @@ exports.HttpModel = HttpModel;
|
|
|
165
169
|
* need something more complicated.
|
|
166
170
|
*/
|
|
167
171
|
class SimpleHttpModel extends HttpModel {
|
|
168
|
-
constructor(agent, requests) {
|
|
169
|
-
super();
|
|
172
|
+
constructor(agent, requests, callbacks) {
|
|
173
|
+
super(callbacks);
|
|
170
174
|
this.agent = agent;
|
|
171
175
|
this.requests = requests;
|
|
176
|
+
this.callbacks = callbacks;
|
|
172
177
|
}
|
|
173
178
|
/**
|
|
174
179
|
* fromPaths generates a new HttpModel using Paths object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/app/model/http.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/app/model/http.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAEhD,sDAA0E;AAE1E,wDAA0D;AAC1D,wDAA4D;AAC5D,oDAA2D;AAC3D,wDAAqD;AAMrD,oDAAkE;AAMrD,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAmF1C,QAAA,OAAO,GAAG,WAAW,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAa,cAAc;IACvB,YAAmB,QAAe,EAAE;QAAjB,UAAK,GAAL,KAAK,CAAY;IAAG,CAAC;IAExC;;OAEG;IACH,MAAM,CAAmB,IAAO;QAC5B,OAAO,IAAI,cAAI,CACX,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,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;;;;GAOG;AACH,MAAa,eAAkC,SAAQ,SAAY;IAC/D,YACW,KAA4B,EAC5B,QAAwB,EACxB,SAAwB;QAE/B,KAAK,CAAC,SAAS,CAAC,CAAC;QAJV,UAAK,GAAL,KAAK,CAAuB;QAC5B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,cAAS,GAAT,SAAS,CAAe;IAGnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAA4B,EAAE,KAAY;QACvD,OAAO,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,CAAC,GAAoB;QACrB,OAA8C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC;IACxE,CAAC;CACJ;AAnBD,0CAmBC"}
|
package/lib/app/model/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Except } from '@quenk/noni/lib/control/except';
|
|
1
2
|
import { Object } from '@quenk/noni/lib/data/jsonx';
|
|
2
3
|
import { Maybe } from '@quenk/noni/lib/data/maybe';
|
|
3
|
-
import { Future } from '@quenk/noni/lib/control/monad/future';
|
|
4
4
|
/**
|
|
5
5
|
* Id is a valid unique identifier for a single record.
|
|
6
6
|
*/
|
|
@@ -16,21 +16,21 @@ export interface Model<T extends Object> {
|
|
|
16
16
|
/**
|
|
17
17
|
* create a new entry for the data type.
|
|
18
18
|
*/
|
|
19
|
-
create(data: T):
|
|
19
|
+
create(data: T): Promise<Except<Id>>;
|
|
20
20
|
/**
|
|
21
21
|
* search for entries that match the specified query criteria.
|
|
22
22
|
*/
|
|
23
|
-
search(qry: Object):
|
|
23
|
+
search(qry: Object): Promise<Except<T[]>>;
|
|
24
24
|
/**
|
|
25
25
|
* update a single entry with the data provided.
|
|
26
26
|
*/
|
|
27
|
-
update(id: Id, changes: Partial<T>):
|
|
27
|
+
update(id: Id, changes: Partial<T>): Promise<Except<boolean>>;
|
|
28
28
|
/**
|
|
29
29
|
* get a single entry using its id.
|
|
30
30
|
*/
|
|
31
|
-
get(id: Id):
|
|
31
|
+
get(id: Id): Promise<Except<Maybe<T>>>;
|
|
32
32
|
/**
|
|
33
33
|
* remove a single entry using its id
|
|
34
34
|
*/
|
|
35
|
-
remove(id: Id):
|
|
35
|
+
remove(id: Id): Promise<Except<boolean>>;
|
|
36
36
|
}
|
package/lib/app/router/hash.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as router from './';
|
|
2
2
|
import { Key } from 'path-to-regexp';
|
|
3
3
|
import { Object as JObject } from '@quenk/noni/lib/data/json';
|
|
4
|
-
import { Future } from '@quenk/noni/lib/control/monad/future';
|
|
5
4
|
/**
|
|
6
5
|
* Path type alias.
|
|
7
6
|
*/
|
|
@@ -25,11 +24,11 @@ export type Handler<R extends Request> = router.Handler<R>;
|
|
|
25
24
|
/**
|
|
26
25
|
* OnError type.
|
|
27
26
|
*/
|
|
28
|
-
export type OnError = (e: Error) =>
|
|
27
|
+
export type OnError = (e: Error) => Promise<void>;
|
|
29
28
|
/**
|
|
30
29
|
* OnNotFound type.
|
|
31
30
|
*/
|
|
32
|
-
export type OnNotFound = (path: Path) =>
|
|
31
|
+
export type OnNotFound = (path: Path) => Promise<void>;
|
|
33
32
|
/**
|
|
34
33
|
* Routes table.
|
|
35
34
|
*/
|
|
@@ -76,15 +75,15 @@ export declare abstract class AbstractHashRouter<R extends Request> implements r
|
|
|
76
75
|
/**
|
|
77
76
|
* createRequest is a constructor for new Request instances.
|
|
78
77
|
*/
|
|
79
|
-
abstract createRequest(path: Path, query: Query, params: Params):
|
|
78
|
+
abstract createRequest(path: Path, query: Query, params: Params): Promise<R>;
|
|
80
79
|
/**
|
|
81
80
|
* onError is invoked when an non-thrown error is invoked.
|
|
82
81
|
*/
|
|
83
|
-
abstract onError(e: Error):
|
|
82
|
+
abstract onError(e: Error): Promise<void>;
|
|
84
83
|
/**
|
|
85
84
|
* onNotFound is invoked each time the user navigates to an unknown route.
|
|
86
85
|
*/
|
|
87
|
-
abstract onNotFound(path: Path):
|
|
86
|
+
abstract onNotFound(path: Path): Promise<void>;
|
|
88
87
|
handleEvent(_: Event): void;
|
|
89
88
|
/**
|
|
90
89
|
* add a Handler to the route table for a specific path.
|
|
@@ -118,7 +117,7 @@ export declare class HashRouter extends AbstractHashRouter<DefaultRequest> {
|
|
|
118
117
|
error: OnError;
|
|
119
118
|
notFound: OnNotFound;
|
|
120
119
|
constructor(window: Window, routes?: Routes<DefaultRequest>, error?: OnError, notFound?: OnNotFound);
|
|
121
|
-
createRequest(path: Path, query: Query, params: Params):
|
|
120
|
+
createRequest(path: Path, query: Query, params: Params): Promise<DefaultRequest>;
|
|
122
121
|
/**
|
|
123
122
|
* navigate to a new path without user interaction.
|
|
124
123
|
*
|
|
@@ -128,8 +127,8 @@ export declare class HashRouter extends AbstractHashRouter<DefaultRequest> {
|
|
|
128
127
|
* @param path - The path to navigate to; should not include '#'.
|
|
129
128
|
*/
|
|
130
129
|
navigate(path: Path): void;
|
|
131
|
-
onError(e: Error):
|
|
132
|
-
onNotFound(path: Path):
|
|
130
|
+
onError(e: Error): Promise<void>;
|
|
131
|
+
onNotFound(path: Path): Promise<void>;
|
|
133
132
|
}
|
|
134
133
|
/**
|
|
135
134
|
* takeHash from a Window object.
|