lemon-core 4.2.7 → 4.3.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/README.md CHANGED
@@ -69,6 +69,7 @@ See [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)
69
69
 
70
70
  | Version | Description
71
71
  |-- |--
72
+ | 4.3.0 | embed cores template layer as extended/cores
72
73
  | 4.2.6 | optimized `$protocol.execute()` to support async lambda invocation.
73
74
  | 4.2.5 | optimized `isBase64Encoded` to support apigwBinary. (from `4.1.17`)
74
75
  | 4.2.4 | optimized `doReportError` to ignore in local dev. (from `4.1.16`)
@@ -0,0 +1,170 @@
1
+ import { GeneralWEBController } from '../../controllers/';
2
+ import { CoreModel, AbstractTransformer, View, Body, NextContext, NextHandler, SimpleSet } from 'lemon-model';
3
+ import { BulkBody, ListResult, PaginatedListResult, PaginateParam } from './types';
4
+ import { MyCoreManager, MyCoreService, MyCoreProxy } from './abstract-services';
5
+ export { CoreModel, AbstractTransformer, GeneralWEBController };
6
+ /**
7
+ * type: `CRUDCreationOptions`
8
+ * - options for cunstructor.
9
+ */
10
+ interface CRUDCreationOptions {
11
+ /**
12
+ * (optional) flag to use `identity-token` (known as session) in CRUD
13
+ * - initialize this as `true` if required to use `identity-token`
14
+ *
15
+ * @see proxy.getCurrentSession()
16
+ */
17
+ useSession?: boolean;
18
+ /**
19
+ * (optional) flag to use `throwable` in `getCurrentSession()`
20
+ * - default might be `true`
21
+ *
22
+ * @see proxy.makeModelBase()
23
+ */
24
+ throwable?: boolean;
25
+ }
26
+ /**
27
+ * class: `AbstractCRUDController`
28
+ * - abstract high level class not to create directly.
29
+ */
30
+ export declare abstract class AbstractCRUDController<ModelType extends string, MyModel extends CoreModel<ModelType>, MyView extends View, MyBody extends Body, MyService extends MyCoreService<MyModel, any, MyCoreProxy<any, any>>, MyManager extends MyCoreManager<MyModel, any, MyCoreService<MyModel, any, any>>, MyTransformer extends AbstractTransformer<MyModel, MyView, MyBody>> extends GeneralWEBController {
31
+ /**
32
+ * service instances
33
+ */
34
+ protected readonly service: MyService;
35
+ /**
36
+ * namespace for log(print)
37
+ */
38
+ protected readonly logNS: string;
39
+ /**
40
+ * my model manager
41
+ */
42
+ protected readonly manager: MyManager;
43
+ /**
44
+ * transformer between model and view.
45
+ */
46
+ protected readonly transformer: MyTransformer;
47
+ /** options in creation */
48
+ protected readonly options?: CRUDCreationOptions;
49
+ /**
50
+ * public constructor
51
+ *
52
+ * @param type - api controller's type name (ex: tests for `/tests`)
53
+ * @param service - backend service
54
+ * @param manager - my model manager in backend-service
55
+ * @param transformer - GeneralCRUDWEBControllerOptions
56
+ */
57
+ constructor(type: string, service: MyService, manager: MyManager, transformer: MyTransformer, options?: CRUDCreationOptions);
58
+ /**
59
+ * get the manager's type (= model-type)
60
+ */
61
+ get modelType(): any;
62
+ /**
63
+ * get config of using session.
64
+ */
65
+ get confUseSession(): boolean;
66
+ /**
67
+ * get config of using session.
68
+ */
69
+ get confThrowable(): boolean;
70
+ /**
71
+ * model transformer from model to view
72
+ */
73
+ modelAsView(model: MyModel, options?: {
74
+ useOnlyDefined?: boolean;
75
+ hasCores?: boolean;
76
+ }): MyView;
77
+ /**
78
+ * model transformer from body to body
79
+ */
80
+ bodyToModel(body: MyBody, isCreate?: boolean): MyModel;
81
+ /**
82
+ * from `identity-token`, make base of model { sid, uid }
83
+ * @param proxy the current proxy.
84
+ * @returns base model
85
+ */
86
+ protected makeModelBase(proxy: MyCoreProxy<ModelType, any>, options?: {
87
+ /** use this parent to prepare base-model. (hiher than session) */
88
+ parent?: CoreModel;
89
+ /** flag to use session (default as confUseSession) */
90
+ useSession?: boolean;
91
+ /** flag to throw error (default true) */
92
+ throwable?: boolean;
93
+ }): Promise<MyModel>;
94
+ /** load yml as model list */
95
+ loadMockData<T extends object>(name: string, base?: string): Promise<T[]>;
96
+ /**
97
+ * load mock-model from `.yml` file.
98
+ */
99
+ loadFromFile(file: string): Promise<MyModel & {
100
+ list: any[];
101
+ }>;
102
+ /**
103
+ * say hello
104
+ */
105
+ hello: () => string;
106
+ /**
107
+ * GET /<typeName>
108
+ * - list types
109
+ *
110
+ * ```sh
111
+ * $ http ':8888/<typeName>'
112
+ */
113
+ doList: NextHandler<PaginateParam & SimpleSet, PaginatedListResult<MyView>>;
114
+ /**
115
+ * list types by id
116
+ * - id means the search(query) id to use.
117
+ *
118
+ * ```sh
119
+ * $ http ':8888/<typeName>/<id>/list'
120
+ */
121
+ doGetList: NextHandler<PaginateParam & SimpleSet, PaginatedListResult<MyView>>;
122
+ /**
123
+ * internal admin command
124
+ */
125
+ doGetAdmin: NextHandler;
126
+ /**
127
+ * read a `MyModel`
128
+ *
129
+ * ```sh
130
+ * $ http ':8888/<typeName>/1'
131
+ */
132
+ doGet: NextHandler<any, MyView>;
133
+ /**
134
+ * create(or insert) a `MyModel`
135
+ * - `id` must be empty (or '0')
136
+ *
137
+ * ```sh
138
+ * $ http POST ':8888/<typeName>/0' "key"="modelValue"
139
+ */
140
+ doPost(id: string, param: any, body: MyBody, $ctx?: NextContext): Promise<MyView>;
141
+ /**
142
+ * create(or insert) multi `MyModel`
143
+ * - `id` must be empty (or '0')
144
+ *
145
+ * ```sh
146
+ * $ http POST ':8888/<typeName>/0/bulk' "key"="modelValue"
147
+ */
148
+ doPostBulk: NextHandler<any, MyView[], BulkBody<MyBody> | MyBody[]>;
149
+ /**
150
+ * update a `MyModel`
151
+ *
152
+ * ```sh
153
+ * $ http PUT ':8888/<typeName>/1000002' name="test-update"
154
+ */
155
+ doPut: NextHandler<any, MyView, MyBody>;
156
+ /**
157
+ * bulk update a `TypeModel`
158
+ *
159
+ * ```sh
160
+ * $ http PUT ':8888/types/0/bulk'
161
+ */
162
+ doPutBulk: NextHandler<any, ListResult<MyView>, BulkBody<MyBody> | MyBody[]>;
163
+ /**
164
+ * delete a `MyModel`
165
+ *
166
+ * ```sh
167
+ * $ http DELETE ':8888/<typeName>/1000003'
168
+ */
169
+ doDelete: NextHandler<any, MyView>;
170
+ }