create-entity-server 0.0.15 → 0.0.23
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/bin/create.js +15 -7
- package/package.json +1 -1
- package/template/.env.example +8 -7
- package/template/configs/database.json +173 -10
- package/template/entities/Account/account_audit.json +4 -5
- package/template/entities/System/system_audit_log.json +14 -8
- package/template/samples/README.md +28 -22
- package/template/samples/browser/entity-server-client.js +453 -0
- package/template/samples/browser/example.html +498 -0
- package/template/samples/entities/02_types_and_defaults.json +15 -16
- package/template/samples/entities/04_fk_and_composite_unique.json +0 -2
- package/template/samples/entities/05_cache.json +9 -8
- package/template/samples/entities/06_history_and_hard_delete.json +27 -9
- package/template/samples/entities/07_license_scope.json +40 -31
- package/template/samples/entities/09_hook_entity.json +0 -6
- package/template/samples/entities/10_hook_submit_delete.json +5 -2
- package/template/samples/entities/11_hook_webhook.json +9 -7
- package/template/samples/entities/12_hook_push.json +3 -3
- package/template/samples/entities/13_read_only.json +13 -10
- package/template/samples/entities/15_reset_defaults.json +0 -1
- package/template/samples/entities/16_isolated_license.json +62 -0
- package/template/samples/entities/README.md +36 -39
- package/template/samples/flutter/lib/entity_server_client.dart +170 -48
- package/template/samples/java/EntityServerClient.java +208 -61
- package/template/samples/java/EntityServerExample.java +4 -3
- package/template/samples/kotlin/EntityServerClient.kt +175 -45
- package/template/samples/node/src/EntityServerClient.js +232 -59
- package/template/samples/node/src/example.js +9 -9
- package/template/samples/php/ci4/Config/EntityServer.php +0 -1
- package/template/samples/php/ci4/Libraries/EntityServer.php +206 -53
- package/template/samples/php/laravel/Services/EntityServerService.php +190 -41
- package/template/samples/python/entity_server.py +181 -68
- package/template/samples/python/example.py +7 -6
- package/template/samples/react/src/example.tsx +41 -25
- package/template/samples/swift/EntityServerClient.swift +143 -37
- package/template/scripts/run.ps1 +12 -3
- package/template/scripts/run.sh +12 -8
- package/template/scripts/update-server.ps1 +68 -2
- package/template/scripts/update-server.sh +59 -2
- package/template/samples/entities/order_notification.json +0 -51
- package/template/samples/react/src/api/entityServerClient.ts +0 -413
- package/template/samples/react/src/hooks/useEntity.ts +0 -173
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Entity Server React 훅
|
|
3
|
-
*
|
|
4
|
-
* @tanstack/react-query 기반
|
|
5
|
-
* 설치: npm install @tanstack/react-query
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
9
|
-
import type {
|
|
10
|
-
EntityListParams,
|
|
11
|
-
EntityQueryFilter,
|
|
12
|
-
} from "../api/entityServerClient";
|
|
13
|
-
import { entityServer } from "../api/entityServerClient";
|
|
14
|
-
|
|
15
|
-
// ─── 조회 훅 ─────────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
|
-
/** 단건 조회 */
|
|
18
|
-
export function useEntityGet<T = unknown>(entity: string, seq: number | null) {
|
|
19
|
-
return useQuery({
|
|
20
|
-
queryKey: ["entity", entity, seq],
|
|
21
|
-
queryFn: () => entityServer.get<T>(entity, seq!),
|
|
22
|
-
enabled: seq != null,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** 목록 조회 */
|
|
27
|
-
export function useEntityList<T = unknown>(
|
|
28
|
-
entity: string,
|
|
29
|
-
params: EntityListParams = {},
|
|
30
|
-
) {
|
|
31
|
-
return useQuery({
|
|
32
|
-
queryKey: ["entity", entity, "list", params],
|
|
33
|
-
queryFn: () => entityServer.list<T>(entity, params),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** 건수 조회 */
|
|
38
|
-
export function useEntityCount(entity: string) {
|
|
39
|
-
return useQuery({
|
|
40
|
-
queryKey: ["entity", entity, "count"],
|
|
41
|
-
queryFn: () => entityServer.count(entity),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** 필터 검색 */
|
|
46
|
-
export function useEntityQuery<T = unknown>(
|
|
47
|
-
entity: string,
|
|
48
|
-
filter: EntityQueryFilter[],
|
|
49
|
-
params: EntityListParams = {},
|
|
50
|
-
) {
|
|
51
|
-
return useQuery({
|
|
52
|
-
queryKey: ["entity", entity, "query", filter, params],
|
|
53
|
-
queryFn: () => entityServer.query<T>(entity, filter, params),
|
|
54
|
-
enabled: filter.length > 0,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** 변경 이력 조회 */
|
|
59
|
-
export function useEntityHistory<T = unknown>(
|
|
60
|
-
entity: string,
|
|
61
|
-
seq: number | null,
|
|
62
|
-
) {
|
|
63
|
-
return useQuery({
|
|
64
|
-
queryKey: ["entity", entity, seq, "history"],
|
|
65
|
-
queryFn: () => entityServer.history<T>(entity, seq!),
|
|
66
|
-
enabled: seq != null,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ─── 뮤테이션 훅 ─────────────────────────────────────────────────────────────
|
|
71
|
-
|
|
72
|
-
/** 생성 또는 수정 */
|
|
73
|
-
export function useEntitySubmit(entity: string) {
|
|
74
|
-
const qc = useQueryClient();
|
|
75
|
-
return useMutation({
|
|
76
|
-
mutationFn: (data: Record<string, unknown>) =>
|
|
77
|
-
entityServer.submit(entity, data),
|
|
78
|
-
onSuccess: () => {
|
|
79
|
-
qc.invalidateQueries({ queryKey: ["entity", entity] });
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** 삭제 */
|
|
85
|
-
export function useEntityDelete(entity: string) {
|
|
86
|
-
const qc = useQueryClient();
|
|
87
|
-
return useMutation({
|
|
88
|
-
mutationFn: (seq: number) => entityServer.delete(entity, seq),
|
|
89
|
-
onSuccess: () => {
|
|
90
|
-
qc.invalidateQueries({ queryKey: ["entity", entity] });
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** 롤백 */
|
|
96
|
-
export function useEntityRollback(entity: string) {
|
|
97
|
-
const qc = useQueryClient();
|
|
98
|
-
return useMutation({
|
|
99
|
-
mutationFn: (historySeq: number) =>
|
|
100
|
-
entityServer.rollback(entity, historySeq),
|
|
101
|
-
onSuccess: () => {
|
|
102
|
-
qc.invalidateQueries({ queryKey: ["entity", entity] });
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** 푸시 디바이스 등록/갱신 */
|
|
108
|
-
export function useRegisterPushDevice() {
|
|
109
|
-
const qc = useQueryClient();
|
|
110
|
-
return useMutation({
|
|
111
|
-
mutationFn: (args: {
|
|
112
|
-
accountSeq: number;
|
|
113
|
-
deviceId: string;
|
|
114
|
-
pushToken: string;
|
|
115
|
-
platform?: string;
|
|
116
|
-
deviceType?: string;
|
|
117
|
-
browser?: string;
|
|
118
|
-
browserVersion?: string;
|
|
119
|
-
pushEnabled?: boolean;
|
|
120
|
-
transactionId?: string;
|
|
121
|
-
}) =>
|
|
122
|
-
entityServer.registerPushDevice(
|
|
123
|
-
args.accountSeq,
|
|
124
|
-
args.deviceId,
|
|
125
|
-
args.pushToken,
|
|
126
|
-
{
|
|
127
|
-
platform: args.platform,
|
|
128
|
-
deviceType: args.deviceType,
|
|
129
|
-
browser: args.browser,
|
|
130
|
-
browserVersion: args.browserVersion,
|
|
131
|
-
pushEnabled: args.pushEnabled,
|
|
132
|
-
transactionId: args.transactionId,
|
|
133
|
-
},
|
|
134
|
-
),
|
|
135
|
-
onSuccess: () => {
|
|
136
|
-
qc.invalidateQueries({ queryKey: ["entity", "account_device"] });
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** 푸시 디바이스 토큰 갱신 */
|
|
142
|
-
export function useUpdatePushDeviceToken() {
|
|
143
|
-
const qc = useQueryClient();
|
|
144
|
-
return useMutation({
|
|
145
|
-
mutationFn: (args: {
|
|
146
|
-
deviceSeq: number;
|
|
147
|
-
pushToken: string;
|
|
148
|
-
pushEnabled?: boolean;
|
|
149
|
-
transactionId?: string;
|
|
150
|
-
}) =>
|
|
151
|
-
entityServer.updatePushDeviceToken(args.deviceSeq, args.pushToken, {
|
|
152
|
-
pushEnabled: args.pushEnabled,
|
|
153
|
-
transactionId: args.transactionId,
|
|
154
|
-
}),
|
|
155
|
-
onSuccess: () => {
|
|
156
|
-
qc.invalidateQueries({ queryKey: ["entity", "account_device"] });
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** 푸시 디바이스 비활성화 */
|
|
162
|
-
export function useDisablePushDevice() {
|
|
163
|
-
const qc = useQueryClient();
|
|
164
|
-
return useMutation({
|
|
165
|
-
mutationFn: (args: { deviceSeq: number; transactionId?: string }) =>
|
|
166
|
-
entityServer.disablePushDevice(args.deviceSeq, {
|
|
167
|
-
transactionId: args.transactionId,
|
|
168
|
-
}),
|
|
169
|
-
onSuccess: () => {
|
|
170
|
-
qc.invalidateQueries({ queryKey: ["entity", "account_device"] });
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
}
|