onecore 0.6.6 → 0.6.8
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 +1631 -0
- package/package.json +1 -1
- package/src/db.ts +5 -2
- package/src/index.ts +3 -3
- package/src/job.ts +50 -71
- package/src/metadata.ts +2 -0
- package/src/service.ts +1 -1
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -20,6 +20,9 @@ export interface Executor {
|
|
|
20
20
|
execute(sql: string, args?: any[]): Promise<number>
|
|
21
21
|
executeBatch(statements: Statement[], requireFirstAffected?: boolean): Promise<number>
|
|
22
22
|
query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[]): Promise<T[]>
|
|
23
|
+
queryOne<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[]): Promise<T | null>
|
|
24
|
+
executeScalar<T>(sql: string, args?: any[]): Promise<T | null>
|
|
25
|
+
count(sql: string, args?: any[]): Promise<number>
|
|
23
26
|
}
|
|
24
27
|
export interface Transaction extends Executor {
|
|
25
28
|
commit(): Promise<void>
|
|
@@ -35,7 +38,7 @@ export interface ViewRepository<T, ID> {
|
|
|
35
38
|
load(id: ID, tx?: Transaction): Promise<T | null>;
|
|
36
39
|
}
|
|
37
40
|
export interface SearchRepository<T, F extends Filter> {
|
|
38
|
-
search(filter: F, limit: number,
|
|
41
|
+
search(filter: F, limit: number, page?: number, fields?: string[], tx?: Transaction): Promise<SearchResult<T>>;
|
|
39
42
|
}
|
|
40
43
|
export interface ViewSearchRepository<T, ID, F extends Filter>
|
|
41
44
|
extends ViewRepository<T, ID>, SearchRepository<T, F> {
|
|
@@ -72,7 +75,7 @@ export interface ViewPort<T, ID> {
|
|
|
72
75
|
load(id: ID, tx?: Transaction): Promise<T | null>;
|
|
73
76
|
}
|
|
74
77
|
export interface SearchPort<T, F extends Filter> {
|
|
75
|
-
search(s: F, limit: number,
|
|
78
|
+
search(s: F, limit: number, page?: number, fields?: string[], tx?: Transaction): Promise<SearchResult<T>>;
|
|
76
79
|
}
|
|
77
80
|
export interface ViewSearchPort<T, ID, F extends Filter>
|
|
78
81
|
extends ViewPort<T, ID>, SearchPort<T, F> {
|
package/src/index.ts
CHANGED
|
@@ -134,7 +134,7 @@ export class SearchUseCase<T, F extends Filter> {
|
|
|
134
134
|
constructor(protected repository: SearchRepository<T, F>) {
|
|
135
135
|
this.search = this.search.bind(this);
|
|
136
136
|
}
|
|
137
|
-
search(s: F, limit: number, page?: number
|
|
137
|
+
search(s: F, limit: number, page?: number, fields?: string[]): Promise<SearchResult<T>> {
|
|
138
138
|
return this.repository.search(s, limit, page, fields);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -164,7 +164,7 @@ export class Writer<T> {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
interface SearchWriterRepo<T, F extends Filter> {
|
|
167
|
-
search(s: F, limit: number, page?: number
|
|
167
|
+
search(s: F, limit: number, page?: number, fields?: string[]): Promise<SearchResult<T>>
|
|
168
168
|
create(obj: T, ctx?: Transaction): Promise<number>;
|
|
169
169
|
update(obj: T, ctx?: Transaction): Promise<number>;
|
|
170
170
|
patch(obj: Partial<T>, ctx?: Transaction): Promise<number>;
|
|
@@ -175,7 +175,7 @@ export class SearchWriter<T, F extends Filter> extends Writer<T> {
|
|
|
175
175
|
super(repository)
|
|
176
176
|
this.search = this.search.bind(this);
|
|
177
177
|
}
|
|
178
|
-
search(filter: F, limit: number, page?: number
|
|
178
|
+
search(filter: F, limit: number, page?: number, fields?: string[]): Promise<SearchResult<T>> {
|
|
179
179
|
return this.repository.search(filter, limit, page, fields);
|
|
180
180
|
}
|
|
181
181
|
}
|
package/src/job.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateRange, Filter,
|
|
1
|
+
import { DateRange, Filter, TimeRange } from "./model";
|
|
2
2
|
|
|
3
3
|
export interface Attachment {
|
|
4
4
|
originalFilename: string;
|
|
@@ -7,37 +7,6 @@ export interface Attachment {
|
|
|
7
7
|
size: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface Article {
|
|
11
|
-
id: string
|
|
12
|
-
slug: string
|
|
13
|
-
title: string
|
|
14
|
-
description?: string
|
|
15
|
-
publishedAt?: Date
|
|
16
|
-
tags?: string[]
|
|
17
|
-
thumbnail?: string
|
|
18
|
-
status?: string
|
|
19
|
-
createdAt?: Date
|
|
20
|
-
authorId?: string
|
|
21
|
-
savedAt?: Date
|
|
22
|
-
}
|
|
23
|
-
export interface ArticleFilter extends Filter {
|
|
24
|
-
id?: string
|
|
25
|
-
slug?: string
|
|
26
|
-
title?: string
|
|
27
|
-
description?: string
|
|
28
|
-
status?: string
|
|
29
|
-
publishedAt: TimeRange
|
|
30
|
-
tags?: string[]
|
|
31
|
-
authorId?: string
|
|
32
|
-
userId?: string
|
|
33
|
-
isSaved?: boolean
|
|
34
|
-
}
|
|
35
|
-
export interface ArticleRepository {
|
|
36
|
-
search(filter: ArticleFilter, limit: number, page?: number, fields?: string[]): Promise<SearchResult<Article>>
|
|
37
|
-
load(slug: string, userId?: string): Promise<Article | null>
|
|
38
|
-
getIdBySlug(slug: string): Promise<string>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
10
|
export interface Achievement {
|
|
42
11
|
subject: string;
|
|
43
12
|
description: string;
|
|
@@ -46,17 +15,7 @@ export interface Skill {
|
|
|
46
15
|
skill: string;
|
|
47
16
|
hirable: boolean;
|
|
48
17
|
}
|
|
49
|
-
|
|
50
|
-
userId?: string;
|
|
51
|
-
username?: string;
|
|
52
|
-
email?: string;
|
|
53
|
-
displayName?: string;
|
|
54
|
-
dateOfBirth?: DateRange;
|
|
55
|
-
status?: string[]|string;
|
|
56
|
-
interests?: string[];
|
|
57
|
-
skills?: Skill[];
|
|
58
|
-
achievements?: Achievement[];
|
|
59
|
-
}
|
|
18
|
+
|
|
60
19
|
export interface RoleFilter extends Filter {
|
|
61
20
|
roleId?: string;
|
|
62
21
|
roleName?: string;
|
|
@@ -91,35 +50,50 @@ export interface ReviewCommentFilter extends Filter {
|
|
|
91
50
|
time?: DateRange;
|
|
92
51
|
updatedAt?: DateRange;
|
|
93
52
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
rate: number
|
|
97
|
-
rate1: number
|
|
98
|
-
rate2: number
|
|
99
|
-
rate3: number
|
|
100
|
-
rate4: number
|
|
101
|
-
rate5: number
|
|
102
|
-
count: number;
|
|
103
|
-
score: number;
|
|
53
|
+
|
|
54
|
+
export interface Rate {
|
|
55
|
+
rate: number
|
|
56
|
+
rate1: number
|
|
57
|
+
rate2: number
|
|
58
|
+
rate3: number
|
|
59
|
+
rate4: number
|
|
60
|
+
rate5: number
|
|
104
61
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
count: number;
|
|
119
|
-
score: number;
|
|
62
|
+
|
|
63
|
+
export interface Article {
|
|
64
|
+
id: string
|
|
65
|
+
slug: string
|
|
66
|
+
title: string
|
|
67
|
+
description?: string
|
|
68
|
+
publishedAt?: Date
|
|
69
|
+
tags?: string[]
|
|
70
|
+
thumbnail?: string
|
|
71
|
+
status?: string
|
|
72
|
+
createdAt?: Date
|
|
73
|
+
authorId?: string
|
|
74
|
+
savedAt?: Date
|
|
120
75
|
}
|
|
121
|
-
|
|
122
|
-
|
|
76
|
+
|
|
77
|
+
export interface User {
|
|
78
|
+
id: string
|
|
79
|
+
username: string
|
|
80
|
+
email?: string
|
|
81
|
+
phone?: string
|
|
82
|
+
dateOfBirth?: Date
|
|
83
|
+
displayName?: string
|
|
84
|
+
status?: string
|
|
85
|
+
imageURL?: string
|
|
86
|
+
coverURL?: string
|
|
87
|
+
headline?: string
|
|
88
|
+
bio?: string
|
|
89
|
+
website?: string
|
|
90
|
+
occupation?: string
|
|
91
|
+
company?: string
|
|
92
|
+
location?: string
|
|
93
|
+
|
|
94
|
+
followedAt?: Date
|
|
95
|
+
followerCount?: number
|
|
96
|
+
followingCount?: number
|
|
123
97
|
}
|
|
124
98
|
|
|
125
99
|
export interface Company {
|
|
@@ -153,8 +127,11 @@ export interface Job {
|
|
|
153
127
|
skills?: string[]
|
|
154
128
|
minSalary?: number
|
|
155
129
|
maxSalary?: number
|
|
156
|
-
companyId?: string
|
|
157
130
|
status: string
|
|
131
|
+
companyId?: string
|
|
132
|
+
companyName?: string
|
|
133
|
+
logo?: string
|
|
134
|
+
savedAt?: Date
|
|
158
135
|
}
|
|
159
136
|
export interface JobFilter extends Filter {
|
|
160
137
|
id?: string
|
|
@@ -169,4 +146,6 @@ export interface JobFilter extends Filter {
|
|
|
169
146
|
applicantCount?: number
|
|
170
147
|
companyId?: string
|
|
171
148
|
status?: string
|
|
149
|
+
userId?: string
|
|
150
|
+
isSaved?: boolean
|
|
172
151
|
}
|
package/src/metadata.ts
CHANGED
package/src/service.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface ViewService<T, ID> {
|
|
|
9
9
|
|
|
10
10
|
export interface SearchService<T, F extends Filter> {
|
|
11
11
|
keys?(): string[];
|
|
12
|
-
search(filter: F, limit: number, page?: number
|
|
12
|
+
search(filter: F, limit: number, page?: number, fields?: string[]): Promise<SearchResult<T>>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface Query<T, ID, F extends Filter> extends SearchService<T, F> {
|