@urga-panel/ur-panels-core 1.0.28 → 1.0.30

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.
@@ -84,11 +84,23 @@ export class _ServiceManager {
84
84
  createChildService: (tag, PageCtor) => {
85
85
  //console.log("createChildService called for ---", tag);
86
86
  const ServiceClass = PageCtor ?? PageService;
87
+ // usedService'i requiredServices'e göre doldur
88
+ const usedService = {};
89
+ if (logService)
90
+ usedService["LogService"] = () => logService;
91
+ // PageService'in requiredServices'ine bak
92
+ const reqServices = ServiceClass.serviceInfo?.requiredServices;
93
+ if (Array.isArray(reqServices)) {
94
+ for (const reqName of reqServices) {
95
+ usedService[reqName] = () => this.getService(reqName);
96
+ }
97
+ }
87
98
  const _pageService = this.setKey(tag, {
88
99
  serviceSelf: new ServiceClass({
89
- usedService: logService ? { "LogService": () => logService } : {},
100
+ usedService,
90
101
  tag: tag,
91
102
  type: type,
103
+ ServiceManager: this,
92
104
  }),
93
105
  status: "waitSetup",
94
106
  });
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export { RequestHandlerService } from "./services/main/httpServices/RequestHandl
15
15
  export { AuthService } from "./services/abstract/authServices/AuthService.js";
16
16
  export { LogService, ConsoleTransport, DatabaseTransport, parseLogConfigFromEnv, getDatabaseTransportConfigFromEnv } from "./services/main/logService/index.js";
17
17
  export type { ILogEntry, ILogTransport, LogServiceConfig, DatabaseTransportOptions, EnvLogConfig } from "./services/main/logService/index.js";
18
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "./utils/turkishSearch.js";
package/dist/index.js CHANGED
@@ -17,6 +17,8 @@ export { RequestHandlerService } from "./services/main/httpServices/RequestHandl
17
17
  export { AuthService } from "./services/abstract/authServices/AuthService.js";
18
18
  // LogService exports
19
19
  export { LogService, ConsoleTransport, DatabaseTransport, parseLogConfigFromEnv, getDatabaseTransportConfigFromEnv } from "./services/main/logService/index.js";
20
+ // Turkish search utilities (browser-safe, no Node.js dependencies)
21
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "./utils/turkishSearch.js";
20
22
  // export { PageControllerService } from "./services/pageServices/controller/PageControllerService.js";
21
23
  // export { ExtensionService } from "./services/extensionServices/controller/ExtensionService.js";
22
24
  // export { Test2Service } from "./testServices/TestService2";
@@ -1,5 +1,6 @@
1
1
  import { Service } from "../../../types/Service.js";
2
2
  import { ServiceResponse } from "../../../types/ServiceResponse.js";
3
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "../../../utils/turkishSearch.js";
3
4
  export declare abstract class ApiService extends Service {
4
5
  ots: any;
5
6
  apis: {
@@ -13,5 +14,14 @@ export declare abstract class ApiService extends Service {
13
14
  };
14
15
  protected onStart(): Promise<ServiceResponse>;
15
16
  constructor(ots: any);
17
+ /**
18
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
19
+ * Usage: const searchRegex = this.createTurkishSearchRegex(search.trim());
20
+ */
21
+ protected createTurkishSearchRegex(searchTerm: string): RegExp;
22
+ /**
23
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
24
+ */
25
+ protected createTurkishSearchPattern(searchTerm: string): string;
16
26
  resposeHandler(response: any): Response;
17
27
  }
@@ -1,4 +1,7 @@
1
1
  import { Service } from "../../../types/Service.js";
2
+ import { createTurkishSearchRegex, createTurkishSearchPattern } from "../../../utils/turkishSearch.js";
3
+ // Re-export for backward compatibility (index.ts also exports from turkishSearch directly)
4
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "../../../utils/turkishSearch.js";
2
5
  export class ApiService extends Service {
3
6
  ots;
4
7
  apis = {};
@@ -19,6 +22,19 @@ export class ApiService extends Service {
19
22
  this.ots = ots;
20
23
  this.apis = {};
21
24
  }
25
+ /**
26
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
27
+ * Usage: const searchRegex = this.createTurkishSearchRegex(search.trim());
28
+ */
29
+ createTurkishSearchRegex(searchTerm) {
30
+ return createTurkishSearchRegex(searchTerm);
31
+ }
32
+ /**
33
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
34
+ */
35
+ createTurkishSearchPattern(searchTerm) {
36
+ return createTurkishSearchPattern(searchTerm);
37
+ }
22
38
  resposeHandler(response) {
23
39
  if (response.status === "success") {
24
40
  return new Response(JSON.stringify(response), {
@@ -3,7 +3,10 @@ import { ServiceOts } from "../../../types/ServiceOts.js";
3
3
  import { ServiceResponse } from "../../../types/ServiceResponse.js";
4
4
  import { ServiceSetupOptions } from "../../../types/ServiceSetupOptions.js";
5
5
  export type PageOts = ServiceOts & {
6
- usedService: {};
6
+ usedService: {
7
+ [key: string]: () => Service;
8
+ };
9
+ ServiceManager?: any;
7
10
  };
8
11
  export declare class PageService extends Service {
9
12
  serviceInfo: {
@@ -11,7 +14,26 @@ export declare class PageService extends Service {
11
14
  requiredServices: string[];
12
15
  };
13
16
  svelteComponent: any;
17
+ ServiceManager: any;
18
+ protected usedService: {
19
+ [key: string]: () => Service;
20
+ };
14
21
  constructor(ots: PageOts);
22
+ /**
23
+ * ApiFront servisine kolay erişim
24
+ * Kullanım: this.apiFront.apis.branchesService.getAllBranches()
25
+ */
26
+ protected get apiFront(): any;
27
+ /**
28
+ * RouteService'e kolay erişim
29
+ * Kullanım: this.routeService.goto("/path")
30
+ */
31
+ protected get routeService(): any;
32
+ /**
33
+ * MainLayoutService'e kolay erişim
34
+ * Kullanım: this.mainLayout.loadingChildren = false
35
+ */
36
+ protected get mainLayout(): any;
15
37
  protected onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse>;
16
38
  protected onStart(): Promise<ServiceResponse>;
17
39
  protected onStop(): Promise<ServiceResponse>;
@@ -2,8 +2,36 @@ import { Service } from "../../../types/Service.js";
2
2
  export class PageService extends Service {
3
3
  serviceInfo;
4
4
  svelteComponent; // Optional Svelte component reference
5
+ ServiceManager;
6
+ usedService;
5
7
  constructor(ots) {
6
8
  super({ ...ots });
9
+ this.ServiceManager = ots.ServiceManager;
10
+ this.usedService = ots.usedService || {};
11
+ }
12
+ // ═══════════════════════════════════════════════════
13
+ // 🎯 Otomatik getter'lar - Tüm PageService'ler için
14
+ // ═══════════════════════════════════════════════════
15
+ /**
16
+ * ApiFront servisine kolay erişim
17
+ * Kullanım: this.apiFront.apis.branchesService.getAllBranches()
18
+ */
19
+ get apiFront() {
20
+ return this.usedService["ApiFront"]?.() ?? this.ServiceManager?.getService("ApiFront");
21
+ }
22
+ /**
23
+ * RouteService'e kolay erişim
24
+ * Kullanım: this.routeService.goto("/path")
25
+ */
26
+ get routeService() {
27
+ return this.usedService["RouteService"]?.() ?? this.ServiceManager?.getService("RouteService");
28
+ }
29
+ /**
30
+ * MainLayoutService'e kolay erişim
31
+ * Kullanım: this.mainLayout.loadingChildren = false
32
+ */
33
+ get mainLayout() {
34
+ return this.usedService["MainLayoutService"]?.() ?? this.ServiceManager?.getService("MainLayoutService");
7
35
  }
8
36
  async onSetup(options) {
9
37
  return { status: "success", message: "setup complete" };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Turkish locale-aware search utilities.
3
+ *
4
+ * This file has NO Node.js dependencies and is safe to import in frontend (browser) code.
5
+ * Import path: '@urga-panel/ur-panels-core/dist/utils/turkishSearch'
6
+ */
7
+ /**
8
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
9
+ * Handles İ↔i, I↔ı, Ğ↔ğ, Ü↔ü, Ş↔ş, Ö↔ö, Ç↔ç mappings.
10
+ */
11
+ export declare function createTurkishSearchRegex(searchTerm: string): RegExp;
12
+ /**
13
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
14
+ */
15
+ export declare function createTurkishSearchPattern(searchTerm: string): string;
16
+ /**
17
+ * Turkish locale-aware lowercase conversion.
18
+ * Correctly handles İ→i, I→ı (unlike standard toLowerCase which does I→i).
19
+ */
20
+ export declare function turkishLowerCase(str: string): string;
21
+ /**
22
+ * Turkish locale-aware case-insensitive includes check.
23
+ * Use for frontend filtering where MongoDB regex is not available.
24
+ */
25
+ export declare function turkishIncludes(text: string, term: string): boolean;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Turkish locale-aware search utilities.
3
+ *
4
+ * This file has NO Node.js dependencies and is safe to import in frontend (browser) code.
5
+ * Import path: '@urga-panel/ur-panels-core/dist/utils/turkishSearch'
6
+ */
7
+ // Turkish character mappings for case-insensitive search
8
+ const TURKISH_CHAR_MAP = {
9
+ 'i': '[iİ]',
10
+ 'İ': '[iİ]',
11
+ 'ı': '[ıI]',
12
+ 'I': '[ıI]',
13
+ 'ğ': '[ğĞ]',
14
+ 'Ğ': '[ğĞ]',
15
+ 'ü': '[üÜ]',
16
+ 'Ü': '[üÜ]',
17
+ 'ş': '[şŞ]',
18
+ 'Ş': '[şŞ]',
19
+ 'ö': '[öÖ]',
20
+ 'Ö': '[öÖ]',
21
+ 'ç': '[çÇ]',
22
+ 'Ç': '[çÇ]',
23
+ };
24
+ /**
25
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
26
+ * Handles İ↔i, I↔ı, Ğ↔ğ, Ü↔ü, Ş↔ş, Ö↔ö, Ç↔ç mappings.
27
+ */
28
+ export function createTurkishSearchRegex(searchTerm) {
29
+ const regexPattern = searchTerm
30
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
31
+ .split('')
32
+ .map(char => TURKISH_CHAR_MAP[char] || char)
33
+ .join('');
34
+ return new RegExp(regexPattern, 'i');
35
+ }
36
+ /**
37
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
38
+ */
39
+ export function createTurkishSearchPattern(searchTerm) {
40
+ return searchTerm
41
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
42
+ .split('')
43
+ .map(char => TURKISH_CHAR_MAP[char] || char)
44
+ .join('');
45
+ }
46
+ /**
47
+ * Turkish locale-aware lowercase conversion.
48
+ * Correctly handles İ→i, I→ı (unlike standard toLowerCase which does I→i).
49
+ */
50
+ export function turkishLowerCase(str) {
51
+ return str.toLocaleLowerCase('tr-TR');
52
+ }
53
+ /**
54
+ * Turkish locale-aware case-insensitive includes check.
55
+ * Use for frontend filtering where MongoDB regex is not available.
56
+ */
57
+ export function turkishIncludes(text, term) {
58
+ return text.toLocaleLowerCase('tr-TR').includes(term.toLocaleLowerCase('tr-TR'));
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urga-panel/ur-panels-core",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -103,11 +103,25 @@ export class _ServiceManager {
103
103
  createChildService: (tag: string, PageCtor?: ServiceConstructor<Service>) => {
104
104
  //console.log("createChildService called for ---", tag);
105
105
  const ServiceClass = PageCtor ?? PageService;
106
+
107
+ // usedService'i requiredServices'e göre doldur
108
+ const usedService: { [key: string]: () => Service } = {};
109
+ if (logService) usedService["LogService"] = () => logService!;
110
+
111
+ // PageService'in requiredServices'ine bak
112
+ const reqServices = (ServiceClass as any).serviceInfo?.requiredServices;
113
+ if (Array.isArray(reqServices)) {
114
+ for (const reqName of reqServices) {
115
+ usedService[reqName] = () => this.getService(reqName);
116
+ }
117
+ }
118
+
106
119
  const _pageService = this.setKey(tag, {
107
120
  serviceSelf: new ServiceClass({
108
- usedService: logService ? { "LogService": () => logService! } : {},
121
+ usedService,
109
122
  tag: tag,
110
123
  type: type,
124
+ ServiceManager: this,
111
125
  }),
112
126
  status: "waitSetup",
113
127
  });
package/src/index.ts CHANGED
@@ -21,6 +21,9 @@ export { AuthService } from "./services/abstract/authServices/AuthService.js";
21
21
  export { LogService, ConsoleTransport, DatabaseTransport, parseLogConfigFromEnv, getDatabaseTransportConfigFromEnv } from "./services/main/logService/index.js";
22
22
  export type { ILogEntry, ILogTransport, LogServiceConfig, DatabaseTransportOptions, EnvLogConfig } from "./services/main/logService/index.js";
23
23
 
24
+ // Turkish search utilities (browser-safe, no Node.js dependencies)
25
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "./utils/turkishSearch.js";
26
+
24
27
 
25
28
  // export { PageControllerService } from "./services/pageServices/controller/PageControllerService.js";
26
29
  // export { ExtensionService } from "./services/extensionServices/controller/ExtensionService.js";
@@ -1,7 +1,10 @@
1
1
  import { Service } from "../../../types/Service";
2
2
  import { ServiceResponse } from "../../../types/ServiceResponse";
3
3
  import { RequestHandlerService } from "../../main/httpServices/RequestHandlerService";
4
+ import { createTurkishSearchRegex, createTurkishSearchPattern } from "../../../utils/turkishSearch";
4
5
 
6
+ // Re-export for backward compatibility (index.ts also exports from turkishSearch directly)
7
+ export { createTurkishSearchRegex, createTurkishSearchPattern, turkishLowerCase, turkishIncludes } from "../../../utils/turkishSearch";
5
8
 
6
9
  export abstract class ApiService extends Service {
7
10
 
@@ -36,6 +39,21 @@ export abstract class ApiService extends Service {
36
39
  this.apis = {};
37
40
  }
38
41
 
42
+ /**
43
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
44
+ * Usage: const searchRegex = this.createTurkishSearchRegex(search.trim());
45
+ */
46
+ protected createTurkishSearchRegex(searchTerm: string): RegExp {
47
+ return createTurkishSearchRegex(searchTerm);
48
+ }
49
+
50
+ /**
51
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
52
+ */
53
+ protected createTurkishSearchPattern(searchTerm: string): string {
54
+ return createTurkishSearchPattern(searchTerm);
55
+ }
56
+
39
57
  resposeHandler(response: any): Response {
40
58
  if (response.status === "success") {
41
59
  return new Response(JSON.stringify(response), {
@@ -5,14 +5,49 @@ import { ServiceSetupOptions } from "../../../types/ServiceSetupOptions";
5
5
 
6
6
  export type PageOts = ServiceOts & {
7
7
  usedService: {
8
+ [key: string]: () => Service;
8
9
  }
10
+ ServiceManager?: any;
9
11
  }
10
12
 
11
13
  export class PageService extends Service {
12
14
  serviceInfo: { name: string; requiredServices: string[]; };
13
15
  public svelteComponent: any; // Optional Svelte component reference
14
- constructor(ots:PageOts) {
16
+ public ServiceManager: any;
17
+ protected usedService: { [key: string]: () => Service };
18
+
19
+ constructor(ots: PageOts) {
15
20
  super({...ots});
21
+ this.ServiceManager = (ots as any).ServiceManager;
22
+ this.usedService = ots.usedService || {};
23
+ }
24
+
25
+ // ═══════════════════════════════════════════════════
26
+ // 🎯 Otomatik getter'lar - Tüm PageService'ler için
27
+ // ═══════════════════════════════════════════════════
28
+
29
+ /**
30
+ * ApiFront servisine kolay erişim
31
+ * Kullanım: this.apiFront.apis.branchesService.getAllBranches()
32
+ */
33
+ protected get apiFront(): any {
34
+ return this.usedService["ApiFront"]?.() ?? this.ServiceManager?.getService("ApiFront");
35
+ }
36
+
37
+ /**
38
+ * RouteService'e kolay erişim
39
+ * Kullanım: this.routeService.goto("/path")
40
+ */
41
+ protected get routeService(): any {
42
+ return this.usedService["RouteService"]?.() ?? this.ServiceManager?.getService("RouteService");
43
+ }
44
+
45
+ /**
46
+ * MainLayoutService'e kolay erişim
47
+ * Kullanım: this.mainLayout.loadingChildren = false
48
+ */
49
+ protected get mainLayout(): any {
50
+ return this.usedService["MainLayoutService"]?.() ?? this.ServiceManager?.getService("MainLayoutService");
16
51
  }
17
52
 
18
53
  protected async onSetup(options?: ServiceSetupOptions): Promise<ServiceResponse> {
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Turkish locale-aware search utilities.
3
+ *
4
+ * This file has NO Node.js dependencies and is safe to import in frontend (browser) code.
5
+ * Import path: '@urga-panel/ur-panels-core/dist/utils/turkishSearch'
6
+ */
7
+
8
+ // Turkish character mappings for case-insensitive search
9
+ const TURKISH_CHAR_MAP: { [key: string]: string } = {
10
+ 'i': '[iİ]',
11
+ 'İ': '[iİ]',
12
+ 'ı': '[ıI]',
13
+ 'I': '[ıI]',
14
+ 'ğ': '[ğĞ]',
15
+ 'Ğ': '[ğĞ]',
16
+ 'ü': '[üÜ]',
17
+ 'Ü': '[üÜ]',
18
+ 'ş': '[şŞ]',
19
+ 'Ş': '[şŞ]',
20
+ 'ö': '[öÖ]',
21
+ 'Ö': '[öÖ]',
22
+ 'ç': '[çÇ]',
23
+ 'Ç': '[çÇ]',
24
+ };
25
+
26
+ /**
27
+ * Creates a Turkish-aware case-insensitive RegExp for MongoDB $regex queries.
28
+ * Handles İ↔i, I↔ı, Ğ↔ğ, Ü↔ü, Ş↔ş, Ö↔ö, Ç↔ç mappings.
29
+ */
30
+ export function createTurkishSearchRegex(searchTerm: string): RegExp {
31
+ const regexPattern = searchTerm
32
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
33
+ .split('')
34
+ .map(char => TURKISH_CHAR_MAP[char] || char)
35
+ .join('');
36
+ return new RegExp(regexPattern, 'i');
37
+ }
38
+
39
+ /**
40
+ * Creates a Turkish-aware regex pattern string for MongoDB $regexMatch in aggregation pipelines.
41
+ */
42
+ export function createTurkishSearchPattern(searchTerm: string): string {
43
+ return searchTerm
44
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
45
+ .split('')
46
+ .map(char => TURKISH_CHAR_MAP[char] || char)
47
+ .join('');
48
+ }
49
+
50
+ /**
51
+ * Turkish locale-aware lowercase conversion.
52
+ * Correctly handles İ→i, I→ı (unlike standard toLowerCase which does I→i).
53
+ */
54
+ export function turkishLowerCase(str: string): string {
55
+ return str.toLocaleLowerCase('tr-TR');
56
+ }
57
+
58
+ /**
59
+ * Turkish locale-aware case-insensitive includes check.
60
+ * Use for frontend filtering where MongoDB regex is not available.
61
+ */
62
+ export function turkishIncludes(text: string, term: string): boolean {
63
+ return text.toLocaleLowerCase('tr-TR').includes(term.toLocaleLowerCase('tr-TR'));
64
+ }