lemon-model 1.0.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/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/types/core-storage.d.ts +103 -0
- package/dist/types/core-storage.js +20 -0
- package/dist/types/core-storage.js.map +1 -0
- package/dist/types/core-types.d.ts +417 -0
- package/dist/types/core-types.js +15 -0
- package/dist/types/core-types.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +29 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 LemonCloud Co Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# lemon-model
|
|
2
|
+
|
|
3
|
+
Common shared model definitions for both backend and frontend.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
To develop backend-api, use `lemon-core` instead of this.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install --save lemon-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Contribution
|
|
15
|
+
|
|
16
|
+
Plz, request PR.
|
|
17
|
+
|
|
18
|
+
See [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## LICENSE
|
|
22
|
+
|
|
23
|
+
[MIT](LICENSE) - (C) 2019 LemonCloud Co Ltd. - All Rights Reserved.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
----------------
|
|
27
|
+
# VERSION INFO #
|
|
28
|
+
|
|
29
|
+
| Version | Description
|
|
30
|
+
|-- |--
|
|
31
|
+
| 1.0.0 | initial types out of the original `lemon-core@3.1.1`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `index.ts`
|
|
3
|
+
* - main index
|
|
4
|
+
*
|
|
5
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
6
|
+
* @date 2019-08-09 initial commit
|
|
7
|
+
* @date 2019-11-26 cleanup and optimized for `lemon-core#v2`
|
|
8
|
+
*
|
|
9
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
export * from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* `index.ts`
|
|
19
|
+
* - main index
|
|
20
|
+
*
|
|
21
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
22
|
+
* @date 2019-08-09 initial commit
|
|
23
|
+
* @date 2019-11-26 cleanup and optimized for `lemon-core#v2`
|
|
24
|
+
*
|
|
25
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
26
|
+
*/
|
|
27
|
+
__exportStar(require("./types"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAAwB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `core-storage.ts`
|
|
3
|
+
* - common types for core storage
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
7
|
+
* @date 2019-11-20 initial version
|
|
8
|
+
* @date 2020-01-03 support cognito-identity
|
|
9
|
+
* @date 2021-12-07 support SearchBody
|
|
10
|
+
*
|
|
11
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* only for type information for internal partition-key.
|
|
15
|
+
*/
|
|
16
|
+
export interface InternalKey {
|
|
17
|
+
/** default partition-key name. */
|
|
18
|
+
_id?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* use shared `NoSQL` data storage. (ex: DynamoDB, MongoDB, ...)
|
|
22
|
+
* - use `key-value` simple storage service.
|
|
23
|
+
* - `no-search`: need to support 'search' function. (but scan)
|
|
24
|
+
*/
|
|
25
|
+
export interface StorageModel extends InternalKey {
|
|
26
|
+
/** unique id value. */
|
|
27
|
+
id?: string;
|
|
28
|
+
/** type of data. */
|
|
29
|
+
type?: string;
|
|
30
|
+
/** stereo of type. */
|
|
31
|
+
stereo?: string;
|
|
32
|
+
/** json formated string (or parsed object). */
|
|
33
|
+
meta?: string | any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* class: `InternalModel`
|
|
37
|
+
* - common internal properties. (ONLY FOR INTERNAL PROCESSING)
|
|
38
|
+
*/
|
|
39
|
+
export interface InternalModel {
|
|
40
|
+
/**
|
|
41
|
+
* internal unique partition-key (valid if using default idName )
|
|
42
|
+
*/
|
|
43
|
+
_id?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* class: `CoreModel`
|
|
47
|
+
* - general model out of base Model to support the common usage
|
|
48
|
+
*/
|
|
49
|
+
export interface CoreModel<ModelType extends string = string> extends StorageModel, InternalModel {
|
|
50
|
+
/**
|
|
51
|
+
* namespace
|
|
52
|
+
*/
|
|
53
|
+
ns?: string;
|
|
54
|
+
/**
|
|
55
|
+
* type of model
|
|
56
|
+
*/
|
|
57
|
+
type?: ModelType;
|
|
58
|
+
/**
|
|
59
|
+
* stereo: stereo-type in common type.
|
|
60
|
+
*/
|
|
61
|
+
stereo?: string;
|
|
62
|
+
/**
|
|
63
|
+
* site-id
|
|
64
|
+
*/
|
|
65
|
+
sid?: string;
|
|
66
|
+
/**
|
|
67
|
+
* user-id
|
|
68
|
+
*/
|
|
69
|
+
uid?: string;
|
|
70
|
+
/**
|
|
71
|
+
* group-id
|
|
72
|
+
*/
|
|
73
|
+
gid?: string;
|
|
74
|
+
/**
|
|
75
|
+
* lock count to secure sync
|
|
76
|
+
*/
|
|
77
|
+
lock?: number;
|
|
78
|
+
/**
|
|
79
|
+
* next sequence number (use `nextSeq()`)
|
|
80
|
+
*/
|
|
81
|
+
next?: number;
|
|
82
|
+
/**
|
|
83
|
+
* meta the json stringified string.
|
|
84
|
+
*/
|
|
85
|
+
meta?: string | any;
|
|
86
|
+
/**
|
|
87
|
+
* created timestamp
|
|
88
|
+
*/
|
|
89
|
+
createdAt?: number;
|
|
90
|
+
/**
|
|
91
|
+
* updated timestamp
|
|
92
|
+
*/
|
|
93
|
+
updatedAt?: number;
|
|
94
|
+
/**
|
|
95
|
+
* deleted timestamp
|
|
96
|
+
*/
|
|
97
|
+
deletedAt?: number;
|
|
98
|
+
/**
|
|
99
|
+
* error message will be set if error occurred
|
|
100
|
+
*/
|
|
101
|
+
error?: string;
|
|
102
|
+
}
|
|
103
|
+
export declare const CORE_FIELDS: string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `core-storage.ts`
|
|
4
|
+
* - common types for core storage
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
8
|
+
* @date 2019-11-20 initial version
|
|
9
|
+
* @date 2020-01-03 support cognito-identity
|
|
10
|
+
* @date 2021-12-07 support SearchBody
|
|
11
|
+
*
|
|
12
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CORE_FIELDS = void 0;
|
|
16
|
+
//NOTE! - BE WARE TO USE `ts-transformer-keys` DUE TO MISSING `ttypescript`
|
|
17
|
+
// export const CORE_FIELDS: string[] = keys<CoreModel>().filter(_ => !_.startsWith('_'));
|
|
18
|
+
// _inf(NS, '! CORE_FIELDS =', CORE_FIELDS.join(', ')); // for debugging.
|
|
19
|
+
exports.CORE_FIELDS = 'ns,type,stereo,sid,uid,gid,lock,next,meta,createdAt,updatedAt,deletedAt'.split(',');
|
|
20
|
+
//# sourceMappingURL=core-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-storage.js","sourceRoot":"","sources":["../../src/types/core-storage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAgGH,2EAA2E;AAC3E,0FAA0F;AAC1F,yEAAyE;AAC5D,QAAA,WAAW,GAAa,yEAAyE,CAAC,KAAK,CAChH,GAAG,CACN,CAAC"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `core-types.ts`
|
|
3
|
+
* - common types for core service
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
7
|
+
* @date 2019-11-20 initial version
|
|
8
|
+
* @date 2020-01-03 support cognito-identity
|
|
9
|
+
* @date 2021-12-07 support SearchBody
|
|
10
|
+
*
|
|
11
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* class: `Incrementable`
|
|
15
|
+
* - properties to support atomic increments
|
|
16
|
+
*/
|
|
17
|
+
export interface Incrementable {
|
|
18
|
+
/**
|
|
19
|
+
* fields to increment
|
|
20
|
+
* - number: increment number field
|
|
21
|
+
* - (string | number)[]: append to list(array) field
|
|
22
|
+
*/
|
|
23
|
+
[key: string]: number | (string | number)[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* class: `GeneralItem`
|
|
27
|
+
* - general simple item model
|
|
28
|
+
*/
|
|
29
|
+
export interface GeneralItem {
|
|
30
|
+
/**
|
|
31
|
+
* only has simple string or number (and in arrays)
|
|
32
|
+
*/
|
|
33
|
+
[key: string]: string | string[] | number | number[];
|
|
34
|
+
}
|
|
35
|
+
/** ********************************************************************************************************************
|
|
36
|
+
* COMMON Interfaces
|
|
37
|
+
** ********************************************************************************************************************/
|
|
38
|
+
/**
|
|
39
|
+
* type: `NextMode`
|
|
40
|
+
* - compartible with REST API Method.
|
|
41
|
+
*/
|
|
42
|
+
export declare type NextMode = 'LIST' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
43
|
+
/**
|
|
44
|
+
* class: `NextIdentity`
|
|
45
|
+
* - the context parameter for each next-handler `fx(id, param, body, context)`
|
|
46
|
+
* - possible to query user's detail via OAuth Resource Server.
|
|
47
|
+
*/
|
|
48
|
+
export interface NextIdentity<T = any> {
|
|
49
|
+
/**
|
|
50
|
+
* site-id (like domain group)
|
|
51
|
+
*/
|
|
52
|
+
sid?: string;
|
|
53
|
+
/**
|
|
54
|
+
* user-id (user id)
|
|
55
|
+
*/
|
|
56
|
+
uid?: string;
|
|
57
|
+
/**
|
|
58
|
+
* group-id (group id)
|
|
59
|
+
*/
|
|
60
|
+
gid?: string;
|
|
61
|
+
/**
|
|
62
|
+
* roles (like `user`, `admin`, `super`)
|
|
63
|
+
*/
|
|
64
|
+
roles?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* prefered language (like 'ko')
|
|
67
|
+
* - use `x-lemon-language` header, or in `x-lemon-identity`
|
|
68
|
+
* @since ver2.2.3 2020/JUL/15
|
|
69
|
+
*/
|
|
70
|
+
lang?: string;
|
|
71
|
+
/**
|
|
72
|
+
* (optional) internal last-error message
|
|
73
|
+
* - if this is not empty, then DO NOT use this object.
|
|
74
|
+
* @since ver3.1.2 2022/MAY/15
|
|
75
|
+
*/
|
|
76
|
+
error?: string;
|
|
77
|
+
/**
|
|
78
|
+
* something unknown having the original data.
|
|
79
|
+
*/
|
|
80
|
+
meta?: T;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* class: `NextIdentityJwt`
|
|
84
|
+
* - JWT-Token based identity
|
|
85
|
+
*/
|
|
86
|
+
export interface NextIdentityJwt<T = any> extends NextIdentity<T> {
|
|
87
|
+
/**
|
|
88
|
+
* issuer of jwt
|
|
89
|
+
* - must be in format of `kms/<alias>`
|
|
90
|
+
*/
|
|
91
|
+
iss: string;
|
|
92
|
+
/**
|
|
93
|
+
* expired timestamp (sec)
|
|
94
|
+
*/
|
|
95
|
+
exp: number;
|
|
96
|
+
/**
|
|
97
|
+
* issued timestamp (sec)
|
|
98
|
+
*/
|
|
99
|
+
iat: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* class: `NextIdentityCognito`
|
|
103
|
+
* - extended information w/ cognito identity.
|
|
104
|
+
*/
|
|
105
|
+
export interface NextIdentityCognito<T = any> extends NextIdentity<T> {
|
|
106
|
+
/**
|
|
107
|
+
* account-id of AWS Credential
|
|
108
|
+
*/
|
|
109
|
+
accountId: string;
|
|
110
|
+
/**
|
|
111
|
+
* identity-id of cognito.
|
|
112
|
+
*/
|
|
113
|
+
identityId: string;
|
|
114
|
+
/**
|
|
115
|
+
* identity-pool-id of cognito
|
|
116
|
+
*/
|
|
117
|
+
identityPoolId: string;
|
|
118
|
+
/**
|
|
119
|
+
* authenticated provider of cognito like 'oauth.lemoncloud.io,oauth.lemoncloud.io:ap-northeast-2:618ce9d2-1234-2345-4567-e248ea51425e:kakao_00000'
|
|
120
|
+
*/
|
|
121
|
+
identityProvider?: string;
|
|
122
|
+
/**
|
|
123
|
+
* user-agent string like 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4)'
|
|
124
|
+
*/
|
|
125
|
+
userAgent?: string;
|
|
126
|
+
/**
|
|
127
|
+
* (optional) caller string like `AROXXXXXX:CognitoIdentityCredentials` from `APIGatewayEventIdentity`
|
|
128
|
+
* - available since `3.1.1`
|
|
129
|
+
*/
|
|
130
|
+
caller?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* class: `NextIdentityAcess`
|
|
134
|
+
* - extended information w/ site + account access information.
|
|
135
|
+
*/
|
|
136
|
+
export interface NextIdentityAccess<T = any> extends NextIdentity<T> {
|
|
137
|
+
/**
|
|
138
|
+
* site-information for domain
|
|
139
|
+
*/
|
|
140
|
+
Site?: {
|
|
141
|
+
stereo?: string;
|
|
142
|
+
name?: string;
|
|
143
|
+
domain?: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* domain-information for current-access
|
|
147
|
+
*/
|
|
148
|
+
Domain?: {
|
|
149
|
+
stereo?: string;
|
|
150
|
+
name?: string;
|
|
151
|
+
domain?: string;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* user-information for active user.
|
|
155
|
+
*/
|
|
156
|
+
User?: {
|
|
157
|
+
name?: string;
|
|
158
|
+
nick?: string;
|
|
159
|
+
email?: string;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* group-information for groups.
|
|
163
|
+
*/
|
|
164
|
+
Group?: {
|
|
165
|
+
name?: string;
|
|
166
|
+
roles?: string[];
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* login account-information.
|
|
170
|
+
*/
|
|
171
|
+
Account?: {
|
|
172
|
+
id?: string;
|
|
173
|
+
stereo?: string;
|
|
174
|
+
socialId?: string;
|
|
175
|
+
identityId?: string;
|
|
176
|
+
loginId?: string;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* class: `NextContext`
|
|
181
|
+
* - information of caller's context w/ `next-identity`.
|
|
182
|
+
*/
|
|
183
|
+
export interface NextContext<T extends NextIdentity = NextIdentity> {
|
|
184
|
+
/**
|
|
185
|
+
* user identity after authentication.
|
|
186
|
+
*/
|
|
187
|
+
identity?: T;
|
|
188
|
+
/**
|
|
189
|
+
* origin event source. can be 'express' if `npm run express.local`.
|
|
190
|
+
*/
|
|
191
|
+
source?: string;
|
|
192
|
+
/**
|
|
193
|
+
* ip-address of source client.
|
|
194
|
+
*/
|
|
195
|
+
clientIp?: string;
|
|
196
|
+
/**
|
|
197
|
+
* user-agent of source client.
|
|
198
|
+
*/
|
|
199
|
+
userAgent?: string;
|
|
200
|
+
/**
|
|
201
|
+
* id of request to keep track of timing infor w/ `metrics`
|
|
202
|
+
*/
|
|
203
|
+
requestId?: string;
|
|
204
|
+
/**
|
|
205
|
+
* id of aws account number from initial request. (ex: `085403634746` for lemon profile)
|
|
206
|
+
*/
|
|
207
|
+
accountId?: string;
|
|
208
|
+
/**
|
|
209
|
+
* domain name of request.
|
|
210
|
+
*/
|
|
211
|
+
domain?: string;
|
|
212
|
+
/**
|
|
213
|
+
* cookie string of origin request
|
|
214
|
+
*/
|
|
215
|
+
cookie?: {
|
|
216
|
+
[key: string]: string;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* calling depth for every handler. ( automatically increased from lambda-handler )
|
|
220
|
+
*/
|
|
221
|
+
depth?: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* type: `NextHandler`
|
|
225
|
+
* - basic form of next handler of contollers (as API)
|
|
226
|
+
* - RestAPI 요청을 처리하는 콘트롤 함수.
|
|
227
|
+
*/
|
|
228
|
+
export declare type NextHandler<TParam = any, TResult = any, TBody = any> = (
|
|
229
|
+
/**
|
|
230
|
+
* resouce id
|
|
231
|
+
*/
|
|
232
|
+
id?: string,
|
|
233
|
+
/**
|
|
234
|
+
* request's query-param
|
|
235
|
+
*/
|
|
236
|
+
param?: TParam,
|
|
237
|
+
/**
|
|
238
|
+
* request's post|put payload
|
|
239
|
+
*/
|
|
240
|
+
body?: TBody,
|
|
241
|
+
/**
|
|
242
|
+
* a context per each request.
|
|
243
|
+
*/
|
|
244
|
+
$ctx?: NextContext) => Promise<TResult>;
|
|
245
|
+
/**
|
|
246
|
+
* Decode `NextHandler` by mode + id + cmd (+ path)
|
|
247
|
+
*/
|
|
248
|
+
export declare type NextDecoder<TMode = NextMode> = (mode: TMode, id?: string, cmd?: string, path?: string) => NextHandler;
|
|
249
|
+
/** ********************************************************************************************************************
|
|
250
|
+
* Search Services
|
|
251
|
+
** ********************************************************************************************************************/
|
|
252
|
+
/**
|
|
253
|
+
* class: QueryResult
|
|
254
|
+
* - result information of query.
|
|
255
|
+
*/
|
|
256
|
+
export interface QueryResult<T> {
|
|
257
|
+
list: T[];
|
|
258
|
+
total?: number;
|
|
259
|
+
page?: number;
|
|
260
|
+
limit?: number;
|
|
261
|
+
aggregations?: any;
|
|
262
|
+
last?: any;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 쿼리의 각 항목의 값들
|
|
266
|
+
*/
|
|
267
|
+
export declare type QueryTerm = string | number | string[] | number[] | {
|
|
268
|
+
query: string | number | string[] | number[];
|
|
269
|
+
operator?: 'and' | 'or';
|
|
270
|
+
slop?: number;
|
|
271
|
+
} | {
|
|
272
|
+
query: {
|
|
273
|
+
query_string: {
|
|
274
|
+
default_field?: string;
|
|
275
|
+
query: string;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* 정렬(sort)에 쓰이는 항목.
|
|
281
|
+
*/
|
|
282
|
+
export declare type SortTerm = string | {
|
|
283
|
+
[key: string]: 'asc' | 'desc';
|
|
284
|
+
} | {
|
|
285
|
+
[key: string]: {
|
|
286
|
+
order?: 'asc' | 'desc';
|
|
287
|
+
missing?: '_last' | '_first';
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* 검색 쿼리 항목.
|
|
292
|
+
*/
|
|
293
|
+
export interface SearchQuery {
|
|
294
|
+
term?: {
|
|
295
|
+
[key: string]: QueryTerm;
|
|
296
|
+
};
|
|
297
|
+
terms?: {
|
|
298
|
+
[key: string]: QueryTerm;
|
|
299
|
+
};
|
|
300
|
+
match?: {
|
|
301
|
+
[key: string]: QueryTerm;
|
|
302
|
+
};
|
|
303
|
+
match_phrase?: {
|
|
304
|
+
[key: string]: QueryTerm;
|
|
305
|
+
};
|
|
306
|
+
prefix?: {
|
|
307
|
+
[key: string]: QueryTerm;
|
|
308
|
+
};
|
|
309
|
+
exists?: {
|
|
310
|
+
field: string;
|
|
311
|
+
};
|
|
312
|
+
range?: {
|
|
313
|
+
[key: string]: {
|
|
314
|
+
gt?: string | number;
|
|
315
|
+
gte?: string | number;
|
|
316
|
+
lt?: string | number;
|
|
317
|
+
lte?: string | number;
|
|
318
|
+
format?: string;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
bool?: {
|
|
322
|
+
filter?: SearchQuery | SearchQuery[];
|
|
323
|
+
must?: SearchQuery | SearchQuery[];
|
|
324
|
+
must_not?: SearchQuery | SearchQuery[];
|
|
325
|
+
should?: SearchQuery | SearchQuery[];
|
|
326
|
+
minimum_should_match?: number;
|
|
327
|
+
};
|
|
328
|
+
query_string?: {
|
|
329
|
+
query: string;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
export interface HighlightTerm {
|
|
333
|
+
fields?: {
|
|
334
|
+
[key: string]: {
|
|
335
|
+
type?: 'unified' | string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* type of search body
|
|
341
|
+
*/
|
|
342
|
+
export interface SearchBody {
|
|
343
|
+
size?: number;
|
|
344
|
+
from?: number;
|
|
345
|
+
search_after?: (string | number)[];
|
|
346
|
+
query?: SearchQuery;
|
|
347
|
+
highlight?: HighlightTerm;
|
|
348
|
+
sort?: SortTerm | SortTerm[];
|
|
349
|
+
_source?: string[];
|
|
350
|
+
aggs?: any;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* class: `SimpleSearchParam`
|
|
354
|
+
* - simplified search param with json object.
|
|
355
|
+
*/
|
|
356
|
+
export interface SimpleSearchParam extends GeneralItem {
|
|
357
|
+
$query?: string | any;
|
|
358
|
+
$limit?: number;
|
|
359
|
+
$page?: number;
|
|
360
|
+
$Q?: string | any;
|
|
361
|
+
$A?: string;
|
|
362
|
+
$O?: string;
|
|
363
|
+
$H?: string;
|
|
364
|
+
$source?: string;
|
|
365
|
+
$exist?: string;
|
|
366
|
+
$exists?: string;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* class: `AutocompleteSearchParam`
|
|
370
|
+
* - Search-as-You-Type
|
|
371
|
+
*/
|
|
372
|
+
export interface AutocompleteSearchParam {
|
|
373
|
+
/**
|
|
374
|
+
* query object. key as field to search and value as string to match
|
|
375
|
+
*/
|
|
376
|
+
$query: {
|
|
377
|
+
[field: string]: string;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* additional filter object.
|
|
381
|
+
*/
|
|
382
|
+
$filter?: {
|
|
383
|
+
[field: string]: string;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* maximum results in a page (default: 10)
|
|
387
|
+
*/
|
|
388
|
+
$limit?: number;
|
|
389
|
+
/**
|
|
390
|
+
* 0-indexed page number (default: 0)
|
|
391
|
+
*/
|
|
392
|
+
$page?: number;
|
|
393
|
+
/**
|
|
394
|
+
* highlighting
|
|
395
|
+
* - if boolean is given, turn on/off highlighting (default: false)
|
|
396
|
+
* - if string is given, replace default highlighting tags (default: 'em')
|
|
397
|
+
*/
|
|
398
|
+
$highlight?: boolean | string;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* feature: `DynamoSimpleQueriable`
|
|
402
|
+
* - simple query capable class.
|
|
403
|
+
*/
|
|
404
|
+
export interface Elastic6SimpleQueriable<T extends GeneralItem> {
|
|
405
|
+
/**
|
|
406
|
+
* simple range query by `partition-key` w/ limit.
|
|
407
|
+
*
|
|
408
|
+
* @param id value of id
|
|
409
|
+
*/
|
|
410
|
+
queryAll(id: string, limit?: number, isDesc?: boolean): Promise<QueryResult<T>>;
|
|
411
|
+
/**
|
|
412
|
+
* search in simplemode
|
|
413
|
+
*
|
|
414
|
+
* @param param SimpleSearchParam
|
|
415
|
+
*/
|
|
416
|
+
searchSimple(param: SimpleSearchParam): Promise<QueryResult<T>>;
|
|
417
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `core-types.ts`
|
|
4
|
+
* - common types for core service
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
8
|
+
* @date 2019-11-20 initial version
|
|
9
|
+
* @date 2020-01-03 support cognito-identity
|
|
10
|
+
* @date 2021-12-07 support SearchBody
|
|
11
|
+
*
|
|
12
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
//# sourceMappingURL=core-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-types.js","sourceRoot":"","sources":["../../src/types/core-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `index.ts`
|
|
3
|
+
* - main index
|
|
4
|
+
*
|
|
5
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
6
|
+
* @date 2019-08-09 initial commit
|
|
7
|
+
* @date 2019-11-26 cleanup and optimized for `lemon-core#v2`
|
|
8
|
+
*
|
|
9
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
export * from './core-types';
|
|
12
|
+
export * from './core-storage';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* `index.ts`
|
|
19
|
+
* - main index
|
|
20
|
+
*
|
|
21
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
22
|
+
* @date 2019-08-09 initial commit
|
|
23
|
+
* @date 2019-11-26 cleanup and optimized for `lemon-core#v2`
|
|
24
|
+
*
|
|
25
|
+
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
26
|
+
*/
|
|
27
|
+
__exportStar(require("./core-types"), exports);
|
|
28
|
+
__exportStar(require("./core-storage"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,+CAA6B;AAC7B,iDAA+B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lemon-model",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Common shared model definitions for Lemon Micro-Service Platform",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run build-ts",
|
|
9
|
+
"build-ts": "tsc -v && tsc",
|
|
10
|
+
"watch-ts": "tsc -w",
|
|
11
|
+
"doc": "npm run doc:html && open dist/docs/index.html",
|
|
12
|
+
"doc:html": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --out dist/docs",
|
|
13
|
+
"doc:publish": "npm run doc:html && gh-pages -m \"docs(gh-pages): publish gh-pages via typedoc\" -d dist/docs",
|
|
14
|
+
"lint": "tsc --noEmit && eslint '*/**/*.{js,ts,jsx,tsx}' --fix",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
16
|
+
"!test": "------- run self-test with jest -----",
|
|
17
|
+
"test": "jest --config=jest.config.json",
|
|
18
|
+
"test:watch": "jest --config=jest.config.json --watchAll",
|
|
19
|
+
"!publish": "------- publish into repository -----",
|
|
20
|
+
"prepare": "npm run build",
|
|
21
|
+
"!prepublishOnly": "npm test && npm run lint && npm run format",
|
|
22
|
+
"prepublishOnly": "npm test && npm run lint"
|
|
23
|
+
},
|
|
24
|
+
"husky": {
|
|
25
|
+
"hooks": {
|
|
26
|
+
"!pre-commit": "lint-staged"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"lint-staged": {
|
|
30
|
+
"src/**/*.{js,ts,tsx,jsx}": [
|
|
31
|
+
"npm run lint",
|
|
32
|
+
"git add"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/**/*"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=12.22.12"
|
|
40
|
+
},
|
|
41
|
+
"author": "Steve Jung <steve@lemoncloud.io>",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"dependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/async": "^3.2.3",
|
|
46
|
+
"@types/cookie-parser": "^1.4.2",
|
|
47
|
+
"@types/cors": "^2.8.7",
|
|
48
|
+
"@types/dotenv": "^6.1.1",
|
|
49
|
+
"@types/jest": "^27.4.1",
|
|
50
|
+
"@types/js-yaml": "^3.12.5",
|
|
51
|
+
"@types/mime-types": "^2.1.0",
|
|
52
|
+
"@types/supertest": "^2.0.10",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
55
|
+
"eslint": "^8.11.0",
|
|
56
|
+
"eslint-config-prettier": "^8.5.0",
|
|
57
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
58
|
+
"gh-pages": "^2.2.0",
|
|
59
|
+
"husky": "^2.2.0",
|
|
60
|
+
"jest": "^27.5.1",
|
|
61
|
+
"lint-staged": "^8.1.6",
|
|
62
|
+
"prettier": "^2.6.0",
|
|
63
|
+
"superagent": "^5.3.1",
|
|
64
|
+
"supertest": "^4.0.2",
|
|
65
|
+
"ts-jest": "^27.1.3",
|
|
66
|
+
"ts-node": "^8.10.2",
|
|
67
|
+
"ttypescript": "^1.5.13",
|
|
68
|
+
"typedoc": "^0.15.8",
|
|
69
|
+
"typescript": "^4.6.2"
|
|
70
|
+
},
|
|
71
|
+
"private": false,
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "git+ssh://git@github.com/lemoncloud-io/lemon-model.git"
|
|
75
|
+
},
|
|
76
|
+
"keywords": [
|
|
77
|
+
"lemoncloud",
|
|
78
|
+
"lemon-model",
|
|
79
|
+
"CoreModel"
|
|
80
|
+
],
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/lemoncloud-io/lemon-model/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/lemoncloud-io/lemon-model#readme"
|
|
85
|
+
}
|