@urga-panel/ur-panels-core 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/.eslintrc.js +13 -0
- package/dist/ServiceManager.d.ts +26 -0
- package/dist/ServiceManager.js +351 -0
- package/dist/TestRun.d.ts +1 -0
- package/dist/TestRun.js +14 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +22 -0
- package/dist/services/abstract/apiService/ApiService.d.ts +17 -0
- package/dist/services/abstract/apiService/ApiService.js +33 -0
- package/dist/services/abstract/authServices/AuthService.d.ts +75 -0
- package/dist/services/abstract/authServices/AuthService.js +275 -0
- package/dist/services/abstract/authServices/Authorization.d.ts +0 -0
- package/dist/services/abstract/authServices/Authorization.js +0 -0
- package/dist/services/abstract/extensionServices/ExtensionService.d.ts +25 -0
- package/dist/services/abstract/extensionServices/ExtensionService.js +21 -0
- package/dist/services/abstract/pageServices/LayoutPageService.d.ts +17 -0
- package/dist/services/abstract/pageServices/LayoutPageService.js +32 -0
- package/dist/services/abstract/pageServices/PageServices.d.ts +20 -0
- package/dist/services/abstract/pageServices/PageServices.js +23 -0
- package/dist/services/abstract/pageServices/controllers/NSPageControllerService.d.ts +10 -0
- package/dist/services/abstract/pageServices/controllers/NSPageControllerService.js +18 -0
- package/dist/services/abstract/pageServices/controllers/PageControllerService.d.ts +27 -0
- package/dist/services/abstract/pageServices/controllers/PageControllerService.js +24 -0
- package/dist/services/abstract/pageServices/controllers/SVPageControllerService.d.ts +34 -0
- package/dist/services/abstract/pageServices/controllers/SVPageControllerService.js +73 -0
- package/dist/services/abstract/pageServices/pages/NsPageService.d.ts +26 -0
- package/dist/services/abstract/pageServices/pages/NsPageService.js +66 -0
- package/dist/services/abstract/project/ProjectInfoService.d.ts +42 -0
- package/dist/services/abstract/project/ProjectInfoService.js +72 -0
- package/dist/services/abstract/webviewServices/WVBackService.d.ts +18 -0
- package/dist/services/abstract/webviewServices/WVBackService.js +22 -0
- package/dist/services/abstract/webviewServices/WVFrontService.d.ts +21 -0
- package/dist/services/abstract/webviewServices/WVFrontService.js +54 -0
- package/dist/services/abstract/webviewServices/nv.d.ts +26 -0
- package/dist/services/abstract/webviewServices/nv.js +99 -0
- package/dist/services/main/fetchServices/FetchBrowserService.d.ts +19 -0
- package/dist/services/main/fetchServices/FetchBrowserService.js +26 -0
- package/dist/services/main/httpServices/RequestHandlerService.d.ts +46 -0
- package/dist/services/main/httpServices/RequestHandlerService.js +165 -0
- package/dist/services/main/remoteApiControllerService/RemoteApiControllerService.d.ts +36 -0
- package/dist/services/main/remoteApiControllerService/RemoteApiControllerService.js +42 -0
- package/dist/services/main/testServices/TestService.d.ts +19 -0
- package/dist/services/main/testServices/TestService.js +22 -0
- package/dist/services/main/testServices/TestService2.d.ts +18 -0
- package/dist/services/main/testServices/TestService2.js +20 -0
- package/dist/types/RegisterServiceInfo.d.ts +13 -0
- package/dist/types/RegisterServiceInfo.js +1 -0
- package/dist/types/Service.d.ts +32 -0
- package/dist/types/Service.js +43 -0
- package/dist/types/ServiceConstructor.d.ts +5 -0
- package/dist/types/ServiceConstructor.js +1 -0
- package/dist/types/ServiceEntry.d.ts +6 -0
- package/dist/types/ServiceEntry.js +1 -0
- package/dist/types/ServiceOts.d.ts +12 -0
- package/dist/types/ServiceOts.js +1 -0
- package/dist/types/ServiceRegisterInfo.d.ts +29 -0
- package/dist/types/ServiceRegisterInfo.js +25 -0
- package/dist/types/ServiceResponse.d.ts +13 -0
- package/dist/types/ServiceResponse.js +1 -0
- package/dist/types/ServiceSetupOptions.d.ts +3 -0
- package/dist/types/ServiceSetupOptions.js +1 -0
- package/dist/types/ServiceStatus.d.ts +1 -0
- package/dist/types/ServiceStatus.js +1 -0
- package/dist/types/_ServiceError.d.ts +5 -0
- package/dist/types/_ServiceError.js +1 -0
- package/jest.config.js +5 -0
- package/package.json +35 -0
- package/src/ServiceManager.ts +403 -0
- package/src/TestRun.ts +17 -0
- package/src/index.ts +26 -0
- package/src/services/abstract/apiService/ApiService.ts +51 -0
- package/src/services/abstract/authServices/AuthService.ts +364 -0
- package/src/services/abstract/authServices/Authorization.ts +0 -0
- package/src/services/abstract/extensionServices/ExtensionService.ts +50 -0
- package/src/services/abstract/pageServices/LayoutPageService.ts +49 -0
- package/src/services/abstract/pageServices/PageServices.ts +37 -0
- package/src/services/abstract/pageServices/controllers/NSPageControllerService.ts +23 -0
- package/src/services/abstract/pageServices/controllers/PageControllerService.ts +56 -0
- package/src/services/abstract/pageServices/controllers/SVPageControllerService.ts +104 -0
- package/src/services/abstract/pageServices/pages/NSPageService.ts +82 -0
- package/src/services/abstract/project/ProjectInfoService.ts +108 -0
- package/src/services/abstract/webviewServices/WVBackService.ts +34 -0
- package/src/services/abstract/webviewServices/WVFrontService.ts +71 -0
- package/src/services/abstract/webviewServices/nv.js +112 -0
- package/src/services/abstract/webviewServices/nv.ts +125 -0
- package/src/services/main/fetchServices/FetchBrowserService.ts +40 -0
- package/src/services/main/httpServices/RequestHandlerService.ts +207 -0
- package/src/services/main/remoteApiControllerService/RemoteApiControllerService.ts +70 -0
- package/src/services/main/testServices/TestService.ts +36 -0
- package/src/services/main/testServices/TestService2.ts +34 -0
- package/src/types/RegisterServiceInfo.ts +19 -0
- package/src/types/Service.ts +61 -0
- package/src/types/ServiceConstructor.ts +6 -0
- package/src/types/ServiceEntry.ts +10 -0
- package/src/types/ServiceOts.ts +17 -0
- package/src/types/ServiceRegisterInfo.ts +48 -0
- package/src/types/ServiceResponse.ts +13 -0
- package/src/types/ServiceSetupOptions.ts +5 -0
- package/src/types/ServiceStatus.ts +2 -0
- package/src/types/_ServiceError.ts +5 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { Service } from "../../../types/Service.js";
|
|
2
|
+
import { RegisterServiceInfo } from "../../../types/ServiceRegisterInfo.js";
|
|
3
|
+
// import bcrypt from 'bcryptjs';
|
|
4
|
+
// import jwt from 'jsonwebtoken';
|
|
5
|
+
const JWT_SECRET = 'gizliAnahtar'; // .env dosyasına taşıman önerilir
|
|
6
|
+
const JWT_REFRESH_SECRET = 'gizliRefreshAnahtar'; // refresh için ayrı bir secret önerilir
|
|
7
|
+
export class AuthService extends Service {
|
|
8
|
+
ots;
|
|
9
|
+
static serviceInfo = {
|
|
10
|
+
name: "AuthService",
|
|
11
|
+
requiredServices: ["RequestHandlerService"],
|
|
12
|
+
};
|
|
13
|
+
async onSetup(options) {
|
|
14
|
+
return { status: "success", message: "setup complete" };
|
|
15
|
+
}
|
|
16
|
+
async onStart() {
|
|
17
|
+
// Object.keys(this.pages).forEach(async tag => {
|
|
18
|
+
// const service = this.ots.abilities.createChildService?.("ProjectPage-"+tag);
|
|
19
|
+
// await service.start();
|
|
20
|
+
// });
|
|
21
|
+
const requestHandlerService = this.ots.usedService.RequestHandlerService();
|
|
22
|
+
// requestHandlerService.addHandler("deneme",this.loginHandler.bind(this));
|
|
23
|
+
requestHandlerService.addHandler("login", this.loginRequest.bind(this));
|
|
24
|
+
requestHandlerService.addHandler("deneme", this.deneme.bind(this), {
|
|
25
|
+
auth: true,
|
|
26
|
+
role: "guest" // Örnek olarak admin rolü
|
|
27
|
+
});
|
|
28
|
+
requestHandlerService.addHandler("getUserInfo", this.getUserInfo_REQUEST.bind(this), {
|
|
29
|
+
auth: true,
|
|
30
|
+
role: "guest" // Örnek olarak admin rolü
|
|
31
|
+
});
|
|
32
|
+
// requestHandlerService.addHandler("deneme",this.loginHandler.bind(this));
|
|
33
|
+
return { status: "success", message: "started" };
|
|
34
|
+
}
|
|
35
|
+
async onStop() {
|
|
36
|
+
return { status: "success", message: "stopped" };
|
|
37
|
+
}
|
|
38
|
+
async onDestroy() {
|
|
39
|
+
return { status: "success", message: "destroyed" };
|
|
40
|
+
}
|
|
41
|
+
constructor(ots) {
|
|
42
|
+
super(ots);
|
|
43
|
+
this.ots = ots;
|
|
44
|
+
}
|
|
45
|
+
// protected abstract authenticateUser(username: string, password: string):
|
|
46
|
+
// Promise<{
|
|
47
|
+
// success: boolean; user?: {
|
|
48
|
+
// id: number;
|
|
49
|
+
// username: string;
|
|
50
|
+
// password: string; // Optional password field for internal use
|
|
51
|
+
// role?: string; // Optional role field
|
|
52
|
+
// };
|
|
53
|
+
// }>;
|
|
54
|
+
// Define methods specific to AuthService here
|
|
55
|
+
async loginRequest({ username, password, params, request, url }) {
|
|
56
|
+
//const { username, password } = params;
|
|
57
|
+
// Kullanıcı adı veya şifre eksikse
|
|
58
|
+
//debugger;
|
|
59
|
+
try {
|
|
60
|
+
// const formData = await request.formData();
|
|
61
|
+
// const username = formData.get('username');
|
|
62
|
+
// const password = formData.get('password');
|
|
63
|
+
//debugger;
|
|
64
|
+
if (!username || !password) {
|
|
65
|
+
return this.resposeHandler({ status: "fail", message: "Kullanıcı adı ve şifre gereklidir" });
|
|
66
|
+
}
|
|
67
|
+
const result = await this.getUserInfo({ userName: username });
|
|
68
|
+
if (result.success) {
|
|
69
|
+
let jwt;
|
|
70
|
+
if (typeof window === "undefined") {
|
|
71
|
+
jwt = (await import("jsonwebtoken")).default;
|
|
72
|
+
}
|
|
73
|
+
let bcrypt;
|
|
74
|
+
if (typeof window === "undefined") {
|
|
75
|
+
bcrypt = await import("bcryptjs");
|
|
76
|
+
}
|
|
77
|
+
console.log("User authenticated:", result.user);
|
|
78
|
+
const match = await bcrypt.compare(password, result.user.password);
|
|
79
|
+
if (!match) {
|
|
80
|
+
return this.resposeHandler({ success: false });
|
|
81
|
+
}
|
|
82
|
+
const accessToken = jwt.sign({
|
|
83
|
+
id: result.user.id,
|
|
84
|
+
username: result.user.username,
|
|
85
|
+
role: result.user.role,
|
|
86
|
+
databaseId: result.user.databaseId // databaseId eklendi
|
|
87
|
+
}, JWT_SECRET, { expiresIn: '15m' });
|
|
88
|
+
// 5. Refresh Token üret
|
|
89
|
+
const refreshToken = jwt.sign({
|
|
90
|
+
id: result.user.id,
|
|
91
|
+
username: result.user.username,
|
|
92
|
+
role: result.user.role,
|
|
93
|
+
databaseId: result.user.databaseId // databaseId eklendi
|
|
94
|
+
}, JWT_REFRESH_SECRET, { expiresIn: '7d' });
|
|
95
|
+
// return { status: "success", accessToken: accessToken,
|
|
96
|
+
// refreshToken: refreshToken };
|
|
97
|
+
// // ...tokenları ürettikten sonra...
|
|
98
|
+
return new Response(JSON.stringify({ status: "success", message: "valid credentials", data: { user: result.user } }), {
|
|
99
|
+
status: 200,
|
|
100
|
+
headers: {
|
|
101
|
+
"Set-Cookie": `accessToken=${accessToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=900, refreshToken=${refreshToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=604800`,
|
|
102
|
+
'Content-Type': 'application/json'
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return this.resposeHandler({ status: "fail", message: "Invalid credentials" });
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
this.log.ERROR("Error during login:", error);
|
|
110
|
+
return this.resposeHandler({ status: "error", message: "An error occurred during login" });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async checkToken({ accessToken, refreshToken, options }) {
|
|
114
|
+
this.log.OK("Access Token:", accessToken);
|
|
115
|
+
this.log.OK("Refresh Token:", refreshToken);
|
|
116
|
+
//debugger;
|
|
117
|
+
try {
|
|
118
|
+
// 1. Access token'ı doğrula
|
|
119
|
+
let jwt;
|
|
120
|
+
if (typeof window === "undefined") {
|
|
121
|
+
jwt = (await import("jsonwebtoken")).default;
|
|
122
|
+
}
|
|
123
|
+
const decoded = jwt.verify(accessToken, JWT_SECRET);
|
|
124
|
+
const res = await this.getUserInfo({
|
|
125
|
+
userId: decoded.id,
|
|
126
|
+
userName: decoded.username,
|
|
127
|
+
userRole: decoded.role || "user" // Varsayılan rol
|
|
128
|
+
});
|
|
129
|
+
//debugger;
|
|
130
|
+
if (!res.success) {
|
|
131
|
+
return { valid: false, user: res.user };
|
|
132
|
+
}
|
|
133
|
+
// Admin ise onay ver
|
|
134
|
+
if (options?.role && res.user?.role == 'admin') {
|
|
135
|
+
return { valid: true, user: res.user };
|
|
136
|
+
}
|
|
137
|
+
//Check role here
|
|
138
|
+
if (options?.role && res.user?.role !== options.role) {
|
|
139
|
+
return { valid: false };
|
|
140
|
+
}
|
|
141
|
+
return { valid: true, user: res.user };
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
// Access token geçersiz veya süresi dolmuşsa
|
|
145
|
+
try {
|
|
146
|
+
let jwt;
|
|
147
|
+
if (typeof window === "undefined") {
|
|
148
|
+
jwt = (await import("jsonwebtoken")).default;
|
|
149
|
+
}
|
|
150
|
+
// 2. Refresh token'ı doğrula
|
|
151
|
+
const decodedRefresh = jwt.verify(refreshToken, JWT_REFRESH_SECRET);
|
|
152
|
+
//debugger;
|
|
153
|
+
const res = await this.getUserInfo({
|
|
154
|
+
userId: decodedRefresh.id,
|
|
155
|
+
userName: decodedRefresh.username,
|
|
156
|
+
userRole: decodedRefresh.role || "user" // Varsayılan rol
|
|
157
|
+
});
|
|
158
|
+
if (!res.success) {
|
|
159
|
+
return { valid: false };
|
|
160
|
+
}
|
|
161
|
+
//Check role here
|
|
162
|
+
// Admin ise onay ver
|
|
163
|
+
// Admin ise devam etsin
|
|
164
|
+
if (options?.role && res.user?.role === 'admin') {
|
|
165
|
+
// admin ise role kontrolü atlanır, devam edilir
|
|
166
|
+
}
|
|
167
|
+
else if (options?.role && res.user?.role !== options.role) {
|
|
168
|
+
return { valid: false };
|
|
169
|
+
}
|
|
170
|
+
// Refresh token geçerli, yeni access token üret
|
|
171
|
+
const newAccessToken = jwt.sign({
|
|
172
|
+
id: decodedRefresh.id,
|
|
173
|
+
username: decodedRefresh.username,
|
|
174
|
+
role: decodedRefresh.role,
|
|
175
|
+
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
176
|
+
}, JWT_SECRET, { expiresIn: '15m' });
|
|
177
|
+
const newRefreshToken = jwt.sign({
|
|
178
|
+
id: decodedRefresh.id,
|
|
179
|
+
username: decodedRefresh.username,
|
|
180
|
+
role: decodedRefresh.role,
|
|
181
|
+
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
182
|
+
}, JWT_REFRESH_SECRET, { expiresIn: '7d' });
|
|
183
|
+
return { valid: true, newAccessToken, newRefreshToken, user: res.user };
|
|
184
|
+
}
|
|
185
|
+
catch (refreshErr) {
|
|
186
|
+
// Refresh token da geçersiz
|
|
187
|
+
return { valid: false };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// async checkToken(accessToken: string, refreshToken): Promise<boolean> {
|
|
192
|
+
// // try {
|
|
193
|
+
// // const decoded = jwt.verify(token, 'gizliAnahtar');
|
|
194
|
+
// // return !!decoded;
|
|
195
|
+
// // } catch (error) {
|
|
196
|
+
// // console.error('Token verification failed:', error);
|
|
197
|
+
// // return false;
|
|
198
|
+
// // }
|
|
199
|
+
// }
|
|
200
|
+
async deneme({ params, request, url }) {
|
|
201
|
+
this.log.OK("RequestHandlerService deneme", params);
|
|
202
|
+
const cookieHeader = request.headers.get('cookie');
|
|
203
|
+
const accessToken = this.getCookie(cookieHeader, 'accessToken');
|
|
204
|
+
const refreshToken = this.getCookie(cookieHeader, 'refreshToken');
|
|
205
|
+
this.log.OK("Access Token:", accessToken);
|
|
206
|
+
this.log.OK("Refresh Token:", refreshToken);
|
|
207
|
+
return this.resposeHandler({ status: "success", message: "Deneme successful" });
|
|
208
|
+
}
|
|
209
|
+
async getUserInfo_REQUEST({ params, request, url, user }) {
|
|
210
|
+
this.log.OK("RequestHandlerService deneme", params);
|
|
211
|
+
//debugger;
|
|
212
|
+
// const cookieHeader = request.headers.get('cookie');
|
|
213
|
+
// const accessToken = this.getCookie(cookieHeader, 'accessToken');
|
|
214
|
+
// const refreshToken = this.getCookie(cookieHeader, 'refreshToken');
|
|
215
|
+
// this.log.OK("Access Token:", accessToken);
|
|
216
|
+
// this.log.OK("Refresh Token:", refreshToken);
|
|
217
|
+
//const result = await this.getUserInfo({userName:username});
|
|
218
|
+
//debugger;
|
|
219
|
+
return this.resposeHandler({
|
|
220
|
+
status: "success",
|
|
221
|
+
message: "getUserInfo_REQUEST successful",
|
|
222
|
+
data: {
|
|
223
|
+
user: {
|
|
224
|
+
id: user?.id || null,
|
|
225
|
+
username: user?.username || null,
|
|
226
|
+
role: user?.role || null,
|
|
227
|
+
databaseId: user?.databaseId || null // databaseId eklendi
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
resposeHandler(response) {
|
|
233
|
+
if (response.status === "success") {
|
|
234
|
+
return new Response(JSON.stringify(response), {
|
|
235
|
+
status: 200,
|
|
236
|
+
headers: {
|
|
237
|
+
'Content-Type': 'application/json'
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return new Response(JSON.stringify(response), {
|
|
242
|
+
status: 400,
|
|
243
|
+
headers: {
|
|
244
|
+
'Content-Type': 'application/json'
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
getCookie(cookieHeader, name) {
|
|
249
|
+
if (!cookieHeader)
|
|
250
|
+
return undefined;
|
|
251
|
+
const cookies = cookieHeader.split(';').map(c => c.trim());
|
|
252
|
+
for (const cookie of cookies) {
|
|
253
|
+
const [key, ...val] = cookie.split('=');
|
|
254
|
+
if (key === name)
|
|
255
|
+
return val.join('=');
|
|
256
|
+
}
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
async logout() {
|
|
260
|
+
await this.clearToken();
|
|
261
|
+
}
|
|
262
|
+
async register(username, password) {
|
|
263
|
+
// Implement registration logic (platform-specific)
|
|
264
|
+
// You may want to add an abstract method for registration as well
|
|
265
|
+
return true; // Placeholder
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
export const registerServiceInfo = new RegisterServiceInfo({
|
|
269
|
+
serviceName: "RequestHandlerService",
|
|
270
|
+
tag: "RequestHandlerService",
|
|
271
|
+
dynamicTag: false,
|
|
272
|
+
requiredServices: [],
|
|
273
|
+
isAbstract: true,
|
|
274
|
+
abstractService: AuthService,
|
|
275
|
+
});
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Service } from "../../../types/Service.js";
|
|
2
|
+
import { ServiceOts } from "../../../types/ServiceOts.js";
|
|
3
|
+
import { ServiceResponse } from "../../../types/ServiceResponse.js";
|
|
4
|
+
import { ServiceSetupOptions } from "../../../types/ServiceSetupOptions.js";
|
|
5
|
+
export type ExtensionOts = ServiceOts & {
|
|
6
|
+
usedService: {};
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class ExtensionService extends Service {
|
|
9
|
+
constructor(ots: ExtensionOts);
|
|
10
|
+
abstract extensionInfo: {
|
|
11
|
+
showLeftMenu: boolean;
|
|
12
|
+
name: string;
|
|
13
|
+
showName: string;
|
|
14
|
+
icon: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
description: string;
|
|
17
|
+
version: string;
|
|
18
|
+
};
|
|
19
|
+
abstract svelteComponent: any;
|
|
20
|
+
protected abstract onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse>;
|
|
21
|
+
protected abstract onStart(): Promise<ServiceResponse>;
|
|
22
|
+
protected abstract onStop(): Promise<ServiceResponse>;
|
|
23
|
+
protected abstract onDestroy(): Promise<ServiceResponse>;
|
|
24
|
+
denemeYazi(): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Service } from "../../../types/Service.js";
|
|
2
|
+
export class ExtensionService extends Service {
|
|
3
|
+
constructor(ots) {
|
|
4
|
+
super({ ...ots });
|
|
5
|
+
}
|
|
6
|
+
// protected async onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse> {
|
|
7
|
+
// return { status: "success", message: "setup complete" };
|
|
8
|
+
// }
|
|
9
|
+
// protected async onStart(): Promise<ServiceResponse> {
|
|
10
|
+
// return { status: "success", message: "started" };
|
|
11
|
+
// }
|
|
12
|
+
// protected async onStop(): Promise<ServiceResponse> {
|
|
13
|
+
// return { status: "success", message: "stopped" };
|
|
14
|
+
// }
|
|
15
|
+
// protected async onDestroy(): Promise<ServiceResponse> {
|
|
16
|
+
// return { status: "success", message: "destroyed" };
|
|
17
|
+
// }
|
|
18
|
+
denemeYazi() {
|
|
19
|
+
return "deneme";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ServiceOts } from "../../../types/ServiceOts.js";
|
|
2
|
+
import { PageService } from "./PageServices.js";
|
|
3
|
+
export type RightMenuItem = {
|
|
4
|
+
icon: string;
|
|
5
|
+
label: string;
|
|
6
|
+
action: () => void;
|
|
7
|
+
};
|
|
8
|
+
export type LayoutOts = ServiceOts & {
|
|
9
|
+
usedService: {};
|
|
10
|
+
};
|
|
11
|
+
export declare class LayoutPageService extends PageService {
|
|
12
|
+
rightMenuItem: RightMenuItem[];
|
|
13
|
+
s_onMount?: () => Promise<void>;
|
|
14
|
+
s_onDestroy?: () => Promise<void>;
|
|
15
|
+
constructor(ots: LayoutOts);
|
|
16
|
+
denemeYazi(): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PageService } from "./PageServices.js";
|
|
2
|
+
export class LayoutPageService extends PageService {
|
|
3
|
+
rightMenuItem;
|
|
4
|
+
// svelte_onMount?: () => void;
|
|
5
|
+
// svelte_onDestroy?: () => void;
|
|
6
|
+
s_onMount;
|
|
7
|
+
s_onDestroy;
|
|
8
|
+
constructor(ots) {
|
|
9
|
+
super({ ...ots });
|
|
10
|
+
}
|
|
11
|
+
/*
|
|
12
|
+
protected async onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse> {
|
|
13
|
+
super.onSetup(options);
|
|
14
|
+
return { status: "success", message: "LayoutService setup complete" };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected async onStart(): Promise<ServiceResponse> {
|
|
18
|
+
super.onStart();
|
|
19
|
+
return { status: "success", message: "LayoutService started" };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected async onStop(): Promise<ServiceResponse> {
|
|
23
|
+
return { status: "success", message: "LayoutService stopped" };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async onDestroy(): Promise<ServiceResponse> {
|
|
27
|
+
return { status: "success", message: "LayoutService destroyed" };
|
|
28
|
+
}*/
|
|
29
|
+
denemeYazi() {
|
|
30
|
+
return "deneme";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Service } from "../../../types/Service.js";
|
|
2
|
+
import { ServiceOts } from "../../../types/ServiceOts.js";
|
|
3
|
+
import { ServiceResponse } from "../../../types/ServiceResponse.js";
|
|
4
|
+
import { ServiceSetupOptions } from "../../../types/ServiceSetupOptions.js";
|
|
5
|
+
export type PageOts = ServiceOts & {
|
|
6
|
+
usedService: {};
|
|
7
|
+
};
|
|
8
|
+
export declare class PageService extends Service {
|
|
9
|
+
serviceInfo: {
|
|
10
|
+
name: string;
|
|
11
|
+
requiredServices: string[];
|
|
12
|
+
};
|
|
13
|
+
svelteComponent: any;
|
|
14
|
+
constructor(ots: PageOts);
|
|
15
|
+
protected onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse>;
|
|
16
|
+
protected onStart(): Promise<ServiceResponse>;
|
|
17
|
+
protected onStop(): Promise<ServiceResponse>;
|
|
18
|
+
protected onDestroy(): Promise<ServiceResponse>;
|
|
19
|
+
denemeYazi(): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Service } from "../../../types/Service.js";
|
|
2
|
+
export class PageService extends Service {
|
|
3
|
+
serviceInfo;
|
|
4
|
+
svelteComponent; // Optional Svelte component reference
|
|
5
|
+
constructor(ots) {
|
|
6
|
+
super({ ...ots });
|
|
7
|
+
}
|
|
8
|
+
async onSetup(options) {
|
|
9
|
+
return { status: "success", message: "setup complete" };
|
|
10
|
+
}
|
|
11
|
+
async onStart() {
|
|
12
|
+
return { status: "success", message: "started" };
|
|
13
|
+
}
|
|
14
|
+
async onStop() {
|
|
15
|
+
return { status: "success", message: "stopped" };
|
|
16
|
+
}
|
|
17
|
+
async onDestroy() {
|
|
18
|
+
return { status: "success", message: "destroyed" };
|
|
19
|
+
}
|
|
20
|
+
denemeYazi() {
|
|
21
|
+
return "deneme";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NSPageService } from "../pages/NsPageService.js";
|
|
2
|
+
import { PageControllerService } from "./PageControllerService.js";
|
|
3
|
+
export declare class NSPageControllerService extends PageControllerService {
|
|
4
|
+
serviceInfo: {
|
|
5
|
+
name: string;
|
|
6
|
+
requiredServices: string[];
|
|
7
|
+
};
|
|
8
|
+
registerPage(tag: string, opt: object): NSPageService;
|
|
9
|
+
onLoaded(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PageControllerService } from "./PageControllerService.js";
|
|
2
|
+
export class NSPageControllerService extends PageControllerService {
|
|
3
|
+
serviceInfo;
|
|
4
|
+
registerPage(tag, opt) {
|
|
5
|
+
console.log(`Registering page with tag: ${tag}`);
|
|
6
|
+
const service = this.ots.abilities.createChildService?.(tag);
|
|
7
|
+
// await service.setup();
|
|
8
|
+
this.pages[tag] = {
|
|
9
|
+
status: "setup",
|
|
10
|
+
service: service
|
|
11
|
+
};
|
|
12
|
+
return service;
|
|
13
|
+
}
|
|
14
|
+
onLoaded() {
|
|
15
|
+
console.log("NSPageControllerService onLoaded called");
|
|
16
|
+
// Implement any additional logic needed when the page is loaded
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Service } from "../../../../types/Service.js";
|
|
2
|
+
import { ServiceOts } from "../../../../types/ServiceOts.js";
|
|
3
|
+
import { ServiceResponse } from "../../../../types/ServiceResponse.js";
|
|
4
|
+
import { ServiceSetupOptions } from "../../../../types/ServiceSetupOptions.js";
|
|
5
|
+
import { PageService } from "../PageServices.js";
|
|
6
|
+
export type PageControllerOts = ServiceOts & {
|
|
7
|
+
usedService: {};
|
|
8
|
+
abilities?: {
|
|
9
|
+
createChildService?: (tag: string) => any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class PageControllerService extends Service {
|
|
13
|
+
ots: PageControllerOts;
|
|
14
|
+
abstract registerPage(tag: string, opt: object): any;
|
|
15
|
+
pages: {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
service: PageService;
|
|
18
|
+
status: "setup" | "started" | "stopped" | "destroyed";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
constructor(ots: PageControllerOts);
|
|
22
|
+
protected onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse>;
|
|
23
|
+
protected onStart(): Promise<ServiceResponse>;
|
|
24
|
+
protected onStop(): Promise<ServiceResponse>;
|
|
25
|
+
protected onDestroy(): Promise<ServiceResponse>;
|
|
26
|
+
denemeYazi(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Service } from "../../../../types/Service.js";
|
|
2
|
+
export class PageControllerService extends Service {
|
|
3
|
+
ots;
|
|
4
|
+
pages = {};
|
|
5
|
+
constructor(ots) {
|
|
6
|
+
super({ ...ots });
|
|
7
|
+
this.ots = ots;
|
|
8
|
+
}
|
|
9
|
+
async onSetup(options) {
|
|
10
|
+
return { status: "success", message: "setup complete" };
|
|
11
|
+
}
|
|
12
|
+
async onStart() {
|
|
13
|
+
return { status: "success", message: "started" };
|
|
14
|
+
}
|
|
15
|
+
async onStop() {
|
|
16
|
+
return { status: "success", message: "stopped" };
|
|
17
|
+
}
|
|
18
|
+
async onDestroy() {
|
|
19
|
+
return { status: "success", message: "destroyed" };
|
|
20
|
+
}
|
|
21
|
+
denemeYazi() {
|
|
22
|
+
return "deneme";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PageControllerService } from "./PageControllerService.js";
|
|
2
|
+
import { PageService } from "../PageServices.js";
|
|
3
|
+
export type SveltePageProp = {
|
|
4
|
+
onMount: (callback: () => Promise<void>) => void;
|
|
5
|
+
onDestroy: (callback: () => Promise<void>) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare class SVPageControllerService extends PageControllerService {
|
|
8
|
+
ots: any;
|
|
9
|
+
serviceInfo: {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
requiredServices: any[];
|
|
13
|
+
description: string;
|
|
14
|
+
version: string;
|
|
15
|
+
};
|
|
16
|
+
registerPage(tag: string, opt: object): void;
|
|
17
|
+
pageServices: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
constructor(ots: any);
|
|
21
|
+
createPageService(tag: string, callback: (service: PageService, obj?: {
|
|
22
|
+
params: any;
|
|
23
|
+
url: any;
|
|
24
|
+
}) => Promise<any>, options?: {
|
|
25
|
+
slug?: boolean;
|
|
26
|
+
}): ({ params, url }: {
|
|
27
|
+
params: any;
|
|
28
|
+
url: any;
|
|
29
|
+
}) => Promise<any>;
|
|
30
|
+
mountPageService(tag: string, page: SveltePageProp, options?: {
|
|
31
|
+
onMount?: () => Promise<void>;
|
|
32
|
+
onDestroy?: () => Promise<void>;
|
|
33
|
+
}): PageService;
|
|
34
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PageControllerService } from "./PageControllerService.js";
|
|
2
|
+
export class SVPageControllerService extends PageControllerService {
|
|
3
|
+
ots;
|
|
4
|
+
serviceInfo = {
|
|
5
|
+
name: "SVPageControllerService",
|
|
6
|
+
type: "SVPageControllerService",
|
|
7
|
+
requiredServices: [],
|
|
8
|
+
description: "Service for handling Svelte page operations",
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
};
|
|
11
|
+
registerPage(tag, opt) {
|
|
12
|
+
throw new Error("Method not implemented.");
|
|
13
|
+
}
|
|
14
|
+
pageServices = {};
|
|
15
|
+
constructor(ots) {
|
|
16
|
+
super({ ...ots });
|
|
17
|
+
this.ots = ots;
|
|
18
|
+
}
|
|
19
|
+
createPageService(tag, callback, options) {
|
|
20
|
+
const $this = this;
|
|
21
|
+
return async ({ params, url }) => {
|
|
22
|
+
const slug = params.slug;
|
|
23
|
+
const device = params.device;
|
|
24
|
+
let tagWithSlug = tag;
|
|
25
|
+
if (options?.slug) {
|
|
26
|
+
tagWithSlug = `${tag}-${slug}`;
|
|
27
|
+
}
|
|
28
|
+
//console.warn("Slug:", slug,"tag:", tagWithSlug, "url:", url);
|
|
29
|
+
//console.warn('device:', device, 'params:', params);
|
|
30
|
+
let service = $this.pageServices[tagWithSlug];
|
|
31
|
+
if (service == undefined) {
|
|
32
|
+
service = this.ots.abilities.createChildService?.(tagWithSlug);
|
|
33
|
+
await service.setup();
|
|
34
|
+
}
|
|
35
|
+
$this.pageServices[tagWithSlug] = service;
|
|
36
|
+
//console.log("Available services:", Object.keys(this.pageServices));
|
|
37
|
+
const res = await callback(service, { params, url });
|
|
38
|
+
return {
|
|
39
|
+
...res,
|
|
40
|
+
device: device,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
mountPageService(tag, page, options) {
|
|
45
|
+
let key = tag;
|
|
46
|
+
const $this = this;
|
|
47
|
+
console.log("Available services:", Object.keys(this.pageServices));
|
|
48
|
+
const service = this.pageServices[key];
|
|
49
|
+
this.log.OK("Mounting page service for tag:", tag, "Service:", service);
|
|
50
|
+
page.onMount(async () => {
|
|
51
|
+
this.log.OK("PageService", "onMount", key);
|
|
52
|
+
console.log("Available services:", Object.keys($this.pageServices));
|
|
53
|
+
await service.start();
|
|
54
|
+
if (options?.onMount) {
|
|
55
|
+
await options.onMount();
|
|
56
|
+
}
|
|
57
|
+
// await service.start();
|
|
58
|
+
// if(options?.onMount){
|
|
59
|
+
// await options.onMount();
|
|
60
|
+
// }
|
|
61
|
+
// (this.pageServices["MainLayoutService"] as MainLayoutService).loading = false;
|
|
62
|
+
// (this.pageServices["MainLayoutService"] as MainLayoutService).mobileMenuOpen = false;
|
|
63
|
+
});
|
|
64
|
+
page.onDestroy(async () => {
|
|
65
|
+
this.log.OK("PageService", "onDestroy", key);
|
|
66
|
+
await service.stop();
|
|
67
|
+
if (options?.onDestroy) {
|
|
68
|
+
await options.onDestroy();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return service;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Service } from "../../../../types/Service.js";
|
|
2
|
+
import { ServiceOts } from "../../../../types/ServiceOts.js";
|
|
3
|
+
import { ServiceResponse } from "../../../../types/ServiceResponse.js";
|
|
4
|
+
import { ServiceSetupOptions } from "../../../../types/ServiceSetupOptions.js";
|
|
5
|
+
export type PageOts = ServiceOts & {
|
|
6
|
+
usedService: {};
|
|
7
|
+
};
|
|
8
|
+
export declare class NSPageService extends Service {
|
|
9
|
+
serviceInfo: {
|
|
10
|
+
name: string;
|
|
11
|
+
requiredServices: string[];
|
|
12
|
+
};
|
|
13
|
+
model: any;
|
|
14
|
+
page: any;
|
|
15
|
+
constructor(ots: PageOts);
|
|
16
|
+
protected onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse>;
|
|
17
|
+
protected onStart(): Promise<ServiceResponse>;
|
|
18
|
+
protected onStop(): Promise<ServiceResponse>;
|
|
19
|
+
protected onDestroy(): Promise<ServiceResponse>;
|
|
20
|
+
navigatingTo(callback: (args?: any) => void, model: any, args?: any): void;
|
|
21
|
+
navigatedTo(callback: (args?: any) => void, args?: any): void;
|
|
22
|
+
onLoaded(callback: (args?: any) => void, args?: any): void;
|
|
23
|
+
onUnloaded(callback: (args?: any) => void, args?: any): void;
|
|
24
|
+
navigatingFrom(callback: (args?: any) => void, args?: any): void;
|
|
25
|
+
navigatedFrom(callback: (args?: any) => void, args?: any): void;
|
|
26
|
+
}
|