@guren/server 2.1.0 → 2.2.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/dist/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +3 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
- package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-EARA7JM4.js → chunk-PZKUDFMW.js} +11 -8
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +19 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +187 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +51 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +22 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +38 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +332 -152
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +144 -0
- package/dist/mcp/endpoint.d.ts +29 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +5 -2
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +1 -1
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +3 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-D60YF2ZO.d.ts +0 -329
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { ValidationRule, FileValidationOptions, ImageValidationOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in validation rules.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Required rule - value must be present and not empty.
|
|
7
|
+
*/
|
|
8
|
+
export declare function required(): ValidationRule;
|
|
9
|
+
/**
|
|
10
|
+
* Nullable rule - allows null values (removes other validation if null).
|
|
11
|
+
*/
|
|
12
|
+
export declare function nullable(): ValidationRule;
|
|
13
|
+
/**
|
|
14
|
+
* Required if another field equals a value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function requiredIf(field: string, value: unknown): ValidationRule;
|
|
17
|
+
/**
|
|
18
|
+
* Required unless another field equals a value.
|
|
19
|
+
*/
|
|
20
|
+
export declare function requiredUnless(field: string, value: unknown): ValidationRule;
|
|
21
|
+
/**
|
|
22
|
+
* Required with - field is required if any of the other fields are present.
|
|
23
|
+
*/
|
|
24
|
+
export declare function requiredWith(...fields: string[]): ValidationRule;
|
|
25
|
+
/**
|
|
26
|
+
* Required without - field is required if any of the other fields are not present.
|
|
27
|
+
*/
|
|
28
|
+
export declare function requiredWithout(...fields: string[]): ValidationRule;
|
|
29
|
+
/**
|
|
30
|
+
* String rule - value must be a string.
|
|
31
|
+
*/
|
|
32
|
+
export declare function string(): ValidationRule;
|
|
33
|
+
/**
|
|
34
|
+
* Numeric rule - value must be a number.
|
|
35
|
+
*/
|
|
36
|
+
export declare function numeric(): ValidationRule;
|
|
37
|
+
/**
|
|
38
|
+
* Integer rule - value must be an integer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function integer(): ValidationRule;
|
|
41
|
+
/**
|
|
42
|
+
* Boolean rule - value must be a boolean.
|
|
43
|
+
*/
|
|
44
|
+
export declare function boolean(): ValidationRule;
|
|
45
|
+
/**
|
|
46
|
+
* Array rule - value must be an array.
|
|
47
|
+
*/
|
|
48
|
+
export declare function array(): ValidationRule;
|
|
49
|
+
/**
|
|
50
|
+
* Object rule - value must be an object.
|
|
51
|
+
*/
|
|
52
|
+
export declare function object(): ValidationRule;
|
|
53
|
+
/**
|
|
54
|
+
* Email rule - value must be a valid email.
|
|
55
|
+
*/
|
|
56
|
+
export declare function email(): ValidationRule;
|
|
57
|
+
/**
|
|
58
|
+
* URL rule - value must be a valid URL.
|
|
59
|
+
*/
|
|
60
|
+
export declare function url(): ValidationRule;
|
|
61
|
+
/**
|
|
62
|
+
* UUID rule - value must be a valid UUID.
|
|
63
|
+
*/
|
|
64
|
+
export declare function uuid(): ValidationRule;
|
|
65
|
+
/**
|
|
66
|
+
* Minimum rule - value must be at least min.
|
|
67
|
+
*/
|
|
68
|
+
export declare function min(minValue: number): ValidationRule;
|
|
69
|
+
/**
|
|
70
|
+
* Maximum rule - value must be at most max.
|
|
71
|
+
*/
|
|
72
|
+
export declare function max(maxValue: number): ValidationRule;
|
|
73
|
+
/**
|
|
74
|
+
* Between rule - value must be between min and max.
|
|
75
|
+
*/
|
|
76
|
+
export declare function between(minValue: number, maxValue: number): ValidationRule;
|
|
77
|
+
/**
|
|
78
|
+
* Size rule - value must be exactly size.
|
|
79
|
+
*/
|
|
80
|
+
export declare function size(exactSize: number): ValidationRule;
|
|
81
|
+
/**
|
|
82
|
+
* In rule - value must be in the given array.
|
|
83
|
+
*/
|
|
84
|
+
export declare function inValues(values: unknown[]): ValidationRule;
|
|
85
|
+
/**
|
|
86
|
+
* Not in rule - value must not be in the given array.
|
|
87
|
+
*/
|
|
88
|
+
export declare function notIn(values: unknown[]): ValidationRule;
|
|
89
|
+
/**
|
|
90
|
+
* Regex rule - value must match the regex.
|
|
91
|
+
*/
|
|
92
|
+
export declare function regex(pattern: RegExp): ValidationRule;
|
|
93
|
+
/**
|
|
94
|
+
* Confirmed rule - field must have a matching field_confirmation.
|
|
95
|
+
*/
|
|
96
|
+
export declare function confirmed(): ValidationRule;
|
|
97
|
+
/**
|
|
98
|
+
* Same rule - field must match another field.
|
|
99
|
+
*/
|
|
100
|
+
export declare function same(otherField: string): ValidationRule;
|
|
101
|
+
/**
|
|
102
|
+
* Different rule - field must be different from another field.
|
|
103
|
+
*/
|
|
104
|
+
export declare function different(otherField: string): ValidationRule;
|
|
105
|
+
/**
|
|
106
|
+
* After rule - date must be after another date.
|
|
107
|
+
*/
|
|
108
|
+
export declare function after(date: string | Date): ValidationRule;
|
|
109
|
+
/**
|
|
110
|
+
* After or equal rule - date must be after or equal to another date.
|
|
111
|
+
*/
|
|
112
|
+
export declare function afterOrEqual(date: string | Date): ValidationRule;
|
|
113
|
+
/**
|
|
114
|
+
* Before rule - date must be before another date.
|
|
115
|
+
*/
|
|
116
|
+
export declare function before(date: string | Date): ValidationRule;
|
|
117
|
+
/**
|
|
118
|
+
* Before or equal rule - date must be before or equal to another date.
|
|
119
|
+
*/
|
|
120
|
+
export declare function beforeOrEqual(date: string | Date): ValidationRule;
|
|
121
|
+
/**
|
|
122
|
+
* Date rule - value must be a valid date.
|
|
123
|
+
*/
|
|
124
|
+
export declare function date(): ValidationRule;
|
|
125
|
+
/**
|
|
126
|
+
* Date format rule - value must match the given format.
|
|
127
|
+
*/
|
|
128
|
+
export declare function dateFormat(format: string): ValidationRule;
|
|
129
|
+
/**
|
|
130
|
+
* Alpha rule - value must only contain letters.
|
|
131
|
+
*/
|
|
132
|
+
export declare function alpha(): ValidationRule;
|
|
133
|
+
/**
|
|
134
|
+
* Alpha numeric rule - value must only contain letters and numbers.
|
|
135
|
+
*/
|
|
136
|
+
export declare function alphaNum(): ValidationRule;
|
|
137
|
+
/**
|
|
138
|
+
* Alpha dash rule - value must only contain letters, numbers, dashes, and underscores.
|
|
139
|
+
*/
|
|
140
|
+
export declare function alphaDash(): ValidationRule;
|
|
141
|
+
/**
|
|
142
|
+
* Starts with rule - value must start with one of the given prefixes.
|
|
143
|
+
*/
|
|
144
|
+
export declare function startsWith(...prefixes: string[]): ValidationRule;
|
|
145
|
+
/**
|
|
146
|
+
* Ends with rule - value must end with one of the given suffixes.
|
|
147
|
+
*/
|
|
148
|
+
export declare function endsWith(...suffixes: string[]): ValidationRule;
|
|
149
|
+
/**
|
|
150
|
+
* JSON rule - value must be a valid JSON string.
|
|
151
|
+
*/
|
|
152
|
+
export declare function json(): ValidationRule;
|
|
153
|
+
/**
|
|
154
|
+
* IP rule - value must be a valid IP address.
|
|
155
|
+
*/
|
|
156
|
+
export declare function ip(): ValidationRule;
|
|
157
|
+
/**
|
|
158
|
+
* IPv4 rule - value must be a valid IPv4 address.
|
|
159
|
+
*/
|
|
160
|
+
export declare function ipv4(): ValidationRule;
|
|
161
|
+
/**
|
|
162
|
+
* IPv6 rule - value must be a valid IPv6 address.
|
|
163
|
+
*/
|
|
164
|
+
export declare function ipv6(): ValidationRule;
|
|
165
|
+
/**
|
|
166
|
+
* File rule - validates a file object.
|
|
167
|
+
*/
|
|
168
|
+
export declare function file(options?: FileValidationOptions): ValidationRule;
|
|
169
|
+
/**
|
|
170
|
+
* Image rule - validates an image file.
|
|
171
|
+
*/
|
|
172
|
+
export declare function image(options?: ImageValidationOptions): ValidationRule;
|
|
173
|
+
/**
|
|
174
|
+
* Mimes rule - validates file MIME types.
|
|
175
|
+
*/
|
|
176
|
+
export declare function mimes(...mimeTypes: string[]): ValidationRule;
|
|
177
|
+
/**
|
|
178
|
+
* Max file size rule.
|
|
179
|
+
*/
|
|
180
|
+
export declare function maxFileSize(bytes: number): ValidationRule;
|
|
181
|
+
/**
|
|
182
|
+
* Min file size rule.
|
|
183
|
+
*/
|
|
184
|
+
export declare function minFileSize(bytes: number): ValidationRule;
|
|
185
|
+
/**
|
|
186
|
+
* Custom rule - create a custom validation rule.
|
|
187
|
+
*/
|
|
188
|
+
export declare function custom(validate: (value: unknown, field: string, data: Record<string, unknown>) => boolean | string | Promise<boolean | string>, message?: string): ValidationRule;
|
|
189
|
+
/**
|
|
190
|
+
* Unique rule (async) - checks uniqueness via callback.
|
|
191
|
+
*/
|
|
192
|
+
export declare function unique(callback: (value: unknown, field: string) => Promise<boolean>): ValidationRule;
|
|
193
|
+
/**
|
|
194
|
+
* Exists rule (async) - checks existence via callback.
|
|
195
|
+
*/
|
|
196
|
+
export declare function exists(callback: (value: unknown, field: string) => Promise<boolean>): ValidationRule;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation rule function type.
|
|
3
|
+
*/
|
|
4
|
+
export type ValidationRule<T = unknown> = (value: T, field: string, data: Record<string, unknown>) => true | string | Promise<true | string>;
|
|
5
|
+
/**
|
|
6
|
+
* Validation rule definition.
|
|
7
|
+
*/
|
|
8
|
+
export interface RuleDefinition {
|
|
9
|
+
name: string;
|
|
10
|
+
validate: ValidationRule;
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validation result.
|
|
15
|
+
*/
|
|
16
|
+
export interface ValidationResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
data?: Record<string, unknown>;
|
|
19
|
+
errors?: Record<string, string[]>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* File validation options.
|
|
23
|
+
*/
|
|
24
|
+
export interface FileValidationOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Maximum file size in bytes.
|
|
27
|
+
*/
|
|
28
|
+
maxSize?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Allowed MIME types.
|
|
31
|
+
*/
|
|
32
|
+
mimes?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Allowed file extensions.
|
|
35
|
+
*/
|
|
36
|
+
extensions?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Minimum file size in bytes.
|
|
39
|
+
*/
|
|
40
|
+
minSize?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Image validation options.
|
|
44
|
+
*/
|
|
45
|
+
export interface ImageValidationOptions extends FileValidationOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Maximum width in pixels.
|
|
48
|
+
*/
|
|
49
|
+
maxWidth?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Maximum height in pixels.
|
|
52
|
+
*/
|
|
53
|
+
maxHeight?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Minimum width in pixels.
|
|
56
|
+
*/
|
|
57
|
+
minWidth?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Minimum height in pixels.
|
|
60
|
+
*/
|
|
61
|
+
minHeight?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Required aspect ratio (width/height).
|
|
64
|
+
*/
|
|
65
|
+
ratio?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Allowed aspect ratio tolerance.
|
|
68
|
+
*/
|
|
69
|
+
ratioTolerance?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validator options.
|
|
73
|
+
*/
|
|
74
|
+
export interface ValidatorOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Stop on first error for each field.
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
stopOnFirstError?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Custom error messages.
|
|
82
|
+
*/
|
|
83
|
+
messages?: Record<string, string>;
|
|
84
|
+
/**
|
|
85
|
+
* Custom attribute names for error messages.
|
|
86
|
+
*/
|
|
87
|
+
attributes?: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* File-like interface for validation.
|
|
91
|
+
*/
|
|
92
|
+
export interface FileLike {
|
|
93
|
+
name: string;
|
|
94
|
+
size: number;
|
|
95
|
+
type: string;
|
|
96
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InlineConfig, ViteDevServer } from 'vite';
|
|
2
|
+
export interface StartViteDevServerOptions {
|
|
3
|
+
root?: string;
|
|
4
|
+
config?: InlineConfig;
|
|
5
|
+
/**
|
|
6
|
+
* What the dev server binds to. Left unset it follows Vite's own
|
|
7
|
+
* localhost-only default, which is the safe choice: the dev server serves
|
|
8
|
+
* every file under the project root, including the default SQLite database,
|
|
9
|
+
* with no authentication. Pass `true` to expose it on the network.
|
|
10
|
+
*/
|
|
11
|
+
host?: boolean | string;
|
|
12
|
+
port?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface StartedViteDevServer {
|
|
15
|
+
server: ViteDevServer;
|
|
16
|
+
localUrl: string;
|
|
17
|
+
networkUrls: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build the inline config the managed dev server starts with.
|
|
21
|
+
*
|
|
22
|
+
* `server.host` is only set when the caller asked for one. Left undefined it
|
|
23
|
+
* is dropped during Vite's config merge, so the project's own `vite.config.ts`
|
|
24
|
+
* decides, falling back to Vite's localhost-only default.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveViteDevServerConfig(options?: StartViteDevServerOptions): InlineConfig;
|
|
27
|
+
export declare function startViteDevServer(options?: StartViteDevServerOptions): Promise<StartedViteDevServer>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { TranslationMessages, TranslationLoader, I18nConfig, ReplacementValues } from './types.js';
|
|
2
|
+
import { Translator } from './Translator.js';
|
|
3
|
+
/**
|
|
4
|
+
* I18n manager for handling multiple locales and translators.
|
|
5
|
+
*/
|
|
6
|
+
export declare class I18nManager {
|
|
7
|
+
private config;
|
|
8
|
+
private translator;
|
|
9
|
+
private loader;
|
|
10
|
+
private loadedLocales;
|
|
11
|
+
constructor(config: I18nConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Translate a key.
|
|
14
|
+
*/
|
|
15
|
+
t(key: string, replacements?: ReplacementValues): string;
|
|
16
|
+
/**
|
|
17
|
+
* Translate a key with count for pluralization.
|
|
18
|
+
*/
|
|
19
|
+
tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a translation exists.
|
|
22
|
+
*/
|
|
23
|
+
has(key: string, locale?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get the current locale.
|
|
26
|
+
*/
|
|
27
|
+
getLocale(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Set the current locale.
|
|
30
|
+
*/
|
|
31
|
+
setLocale(locale: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the fallback locale.
|
|
34
|
+
*/
|
|
35
|
+
getFallbackLocale(): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Set the fallback locale.
|
|
38
|
+
*/
|
|
39
|
+
setFallbackLocale(locale: string | undefined): void;
|
|
40
|
+
/**
|
|
41
|
+
* Load translations for a locale.
|
|
42
|
+
*/
|
|
43
|
+
loadLocale(locale: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Load translations for multiple locales.
|
|
46
|
+
*/
|
|
47
|
+
loadLocales(locales: string[]): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Load a specific namespace for a locale.
|
|
50
|
+
*/
|
|
51
|
+
loadNamespace(locale: string, namespace: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Add messages for a locale.
|
|
54
|
+
*/
|
|
55
|
+
addMessages(locale: string, messages: TranslationMessages): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get all messages for a locale.
|
|
58
|
+
*/
|
|
59
|
+
getMessages(locale?: string): TranslationMessages;
|
|
60
|
+
/**
|
|
61
|
+
* Get available locales.
|
|
62
|
+
*/
|
|
63
|
+
getAvailableLocales(): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Get available locales from loader.
|
|
66
|
+
*/
|
|
67
|
+
getLoaderLocales(): Promise<string[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a locale is loaded.
|
|
70
|
+
*/
|
|
71
|
+
isLocaleLoaded(locale: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Get the underlying translator.
|
|
74
|
+
*/
|
|
75
|
+
getTranslator(): Translator;
|
|
76
|
+
/**
|
|
77
|
+
* Set a custom loader.
|
|
78
|
+
*/
|
|
79
|
+
setLoader(loader: TranslationLoader): void;
|
|
80
|
+
/**
|
|
81
|
+
* Create a scoped translator for a specific locale.
|
|
82
|
+
*/
|
|
83
|
+
forLocale(locale: string): Translator;
|
|
84
|
+
/**
|
|
85
|
+
* The message catalogs that accompany a locale: the fallback locale's
|
|
86
|
+
* (when it differs) plus the locale's own, in that order — so consumers
|
|
87
|
+
* that flatten the record let the active locale win on key collisions.
|
|
88
|
+
*/
|
|
89
|
+
messagesForLocale(locale: string): Record<string, TranslationMessages>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a new I18n manager.
|
|
93
|
+
*/
|
|
94
|
+
export declare function createI18n(config: I18nConfig): I18nManager;
|
|
95
|
+
/**
|
|
96
|
+
* Set the global I18n manager.
|
|
97
|
+
*/
|
|
98
|
+
export declare function setI18n(i18n: I18nManager): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get the global I18n manager.
|
|
101
|
+
*/
|
|
102
|
+
export declare function getI18n(): I18nManager;
|
|
103
|
+
/**
|
|
104
|
+
* Get the global I18n manager, or `undefined` when none was registered.
|
|
105
|
+
*/
|
|
106
|
+
export declare function tryGetI18n(): I18nManager | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Translate a key using the global I18n manager.
|
|
109
|
+
*/
|
|
110
|
+
export declare function t(key: string, replacements?: ReplacementValues): string;
|
|
111
|
+
/**
|
|
112
|
+
* Translate a key with count using the global I18n manager.
|
|
113
|
+
*/
|
|
114
|
+
export declare function tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { TranslationMessages, ReplacementValues, TranslatorOptions, PluralizationRule } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Translator class for handling translations.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Translator {
|
|
6
|
+
private locale;
|
|
7
|
+
private fallbackLocale;
|
|
8
|
+
private messages;
|
|
9
|
+
private pluralizationRules;
|
|
10
|
+
private onMissingKey?;
|
|
11
|
+
constructor(options: TranslatorOptions);
|
|
12
|
+
/**
|
|
13
|
+
* Translate a key.
|
|
14
|
+
*/
|
|
15
|
+
t(key: string, replacements?: ReplacementValues): string;
|
|
16
|
+
/**
|
|
17
|
+
* Translate a key with count for pluralization.
|
|
18
|
+
*/
|
|
19
|
+
tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a translation exists.
|
|
22
|
+
*/
|
|
23
|
+
has(key: string, locale?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get the current locale.
|
|
26
|
+
*/
|
|
27
|
+
getLocale(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Set the current locale.
|
|
30
|
+
*/
|
|
31
|
+
setLocale(locale: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the fallback locale.
|
|
34
|
+
*/
|
|
35
|
+
getFallbackLocale(): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Set the fallback locale.
|
|
38
|
+
*/
|
|
39
|
+
setFallbackLocale(locale: string | undefined): void;
|
|
40
|
+
/**
|
|
41
|
+
* Add messages for a locale.
|
|
42
|
+
*/
|
|
43
|
+
addMessages(locale: string, messages: TranslationMessages): void;
|
|
44
|
+
/**
|
|
45
|
+
* Set messages for a locale (replaces existing).
|
|
46
|
+
*/
|
|
47
|
+
setMessages(locale: string, messages: TranslationMessages): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get all messages for a locale.
|
|
50
|
+
*/
|
|
51
|
+
getMessages(locale?: string): TranslationMessages;
|
|
52
|
+
/**
|
|
53
|
+
* Get available locales.
|
|
54
|
+
*/
|
|
55
|
+
getAvailableLocales(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Set a custom pluralization rule.
|
|
58
|
+
*/
|
|
59
|
+
setPluralizationRule(locale: string, rule: PluralizationRule): void;
|
|
60
|
+
/**
|
|
61
|
+
* Internal translate method.
|
|
62
|
+
*/
|
|
63
|
+
private translate;
|
|
64
|
+
/**
|
|
65
|
+
* Get raw translation without replacements.
|
|
66
|
+
*/
|
|
67
|
+
private getRawTranslation;
|
|
68
|
+
/**
|
|
69
|
+
* Apply replacements to a translation string.
|
|
70
|
+
*/
|
|
71
|
+
private applyReplacements;
|
|
72
|
+
/**
|
|
73
|
+
* Handle missing translation key.
|
|
74
|
+
*/
|
|
75
|
+
private handleMissingKey;
|
|
76
|
+
/**
|
|
77
|
+
* Deep merge messages.
|
|
78
|
+
*/
|
|
79
|
+
private mergeMessages;
|
|
80
|
+
}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Returns the index of the plural form to use.
|
|
8
|
-
* Most languages use: 0 = one, 1 = other
|
|
9
|
-
* Some languages have more complex rules.
|
|
10
|
-
*/
|
|
11
|
-
declare const pluralizationRules: Record<string, PluralizationRule>;
|
|
12
|
-
/**
|
|
13
|
-
* Get pluralization rule for a locale.
|
|
14
|
-
*/
|
|
15
|
-
declare function getPluralizationRule(locale: string): PluralizationRule;
|
|
16
|
-
/**
|
|
17
|
-
* Select the appropriate plural form from a translation.
|
|
18
|
-
*
|
|
19
|
-
* Translation format: "singular|plural" or "one|few|many"
|
|
20
|
-
*/
|
|
21
|
-
declare function selectPluralForm(translation: string, count: number, rule: PluralizationRule): string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* JSON file-based translation loader.
|
|
25
|
-
*
|
|
26
|
-
* Expected directory structure:
|
|
27
|
-
* path/
|
|
28
|
-
* en/
|
|
29
|
-
* messages.json
|
|
30
|
-
* validation.json
|
|
31
|
-
* ja/
|
|
32
|
-
* messages.json
|
|
33
|
-
* validation.json
|
|
34
|
-
*/
|
|
35
|
-
declare class JsonLoader implements TranslationLoader {
|
|
36
|
-
private basePath;
|
|
37
|
-
private cache;
|
|
38
|
-
private useCache;
|
|
39
|
-
constructor(basePath: string, options?: {
|
|
40
|
-
cache?: boolean;
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Load all translations for a locale.
|
|
44
|
-
*/
|
|
45
|
-
load(locale: string): Promise<TranslationMessages>;
|
|
46
|
-
/**
|
|
47
|
-
* Load translations for a specific namespace.
|
|
48
|
-
*/
|
|
49
|
-
loadNamespace(locale: string, namespace: string): Promise<TranslationMessages>;
|
|
50
|
-
/**
|
|
51
|
-
* Get available locales.
|
|
52
|
-
*/
|
|
53
|
-
getAvailableLocales(): Promise<string[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Clear the cache.
|
|
56
|
-
*/
|
|
57
|
-
clearCache(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Enable or disable caching.
|
|
60
|
-
*/
|
|
61
|
-
setCaching(enabled: boolean): void;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* In-memory translation loader.
|
|
66
|
-
* Useful for testing or when translations are bundled with the application.
|
|
67
|
-
*/
|
|
68
|
-
declare class MemoryLoader implements TranslationLoader {
|
|
69
|
-
private messages;
|
|
70
|
-
constructor(messages?: Record<string, TranslationMessages>);
|
|
71
|
-
/**
|
|
72
|
-
* Load all translations for a locale.
|
|
73
|
-
*/
|
|
74
|
-
load(locale: string): Promise<TranslationMessages>;
|
|
75
|
-
/**
|
|
76
|
-
* Load translations for a specific namespace.
|
|
77
|
-
*/
|
|
78
|
-
loadNamespace(locale: string, namespace: string): Promise<TranslationMessages>;
|
|
79
|
-
/**
|
|
80
|
-
* Get available locales.
|
|
81
|
-
*/
|
|
82
|
-
getAvailableLocales(): Promise<string[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Add messages for a locale.
|
|
85
|
-
*/
|
|
86
|
-
addMessages(locale: string, messages: TranslationMessages): void;
|
|
87
|
-
/**
|
|
88
|
-
* Set messages for a locale (replaces existing).
|
|
89
|
-
*/
|
|
90
|
-
setMessages(locale: string, messages: TranslationMessages): void;
|
|
91
|
-
/**
|
|
92
|
-
* Remove messages for a locale.
|
|
93
|
-
*/
|
|
94
|
-
removeLocale(locale: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* Clear all messages.
|
|
97
|
-
*/
|
|
98
|
-
clear(): void;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { JsonLoader, MemoryLoader, PluralizationRule, TranslationLoader, TranslationMessages, getPluralizationRule, pluralizationRules, selectPluralForm };
|
|
1
|
+
export type { TranslationMessages, ReplacementValues, GurenTranslationKeys, RegisteredTranslationKey, PluralizationRule, TranslationLoader, TranslatorOptions, I18nConfig, TranslationLoaderFactory, } from './types.js';
|
|
2
|
+
export { pluralizationRules, getPluralizationRule, selectPluralForm, } from './pluralization.js';
|
|
3
|
+
export { Translator } from './Translator.js';
|
|
4
|
+
export { I18nManager, createI18n, setI18n, getI18n, tryGetI18n, t, tc, } from './I18nManager.js';
|
|
5
|
+
export { JsonLoader } from './loaders/JsonLoader.js';
|
|
6
|
+
export { MemoryLoader } from './loaders/MemoryLoader.js';
|
package/dist/i18n/index.js
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
selectPluralForm,
|
|
11
11
|
setI18n,
|
|
12
12
|
t,
|
|
13
|
-
tc
|
|
14
|
-
|
|
13
|
+
tc,
|
|
14
|
+
tryGetI18n
|
|
15
|
+
} from "../chunk-HR2KZ3WL.js";
|
|
15
16
|
export {
|
|
16
17
|
I18nManager,
|
|
17
18
|
JsonLoader,
|
|
@@ -24,5 +25,6 @@ export {
|
|
|
24
25
|
selectPluralForm,
|
|
25
26
|
setI18n,
|
|
26
27
|
t,
|
|
27
|
-
tc
|
|
28
|
+
tc,
|
|
29
|
+
tryGetI18n
|
|
28
30
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TranslationLoader, TranslationMessages } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* JSON file-based translation loader.
|
|
4
|
+
*
|
|
5
|
+
* Expected directory structure:
|
|
6
|
+
* path/
|
|
7
|
+
* en/
|
|
8
|
+
* messages.json
|
|
9
|
+
* validation.json
|
|
10
|
+
* ja/
|
|
11
|
+
* messages.json
|
|
12
|
+
* validation.json
|
|
13
|
+
*
|
|
14
|
+
* This layout (locale subdirectories, namespace = file name) is a contract
|
|
15
|
+
* shared with the CLI: `guren codegen` (packages/cli/src/i18n-types.ts) and
|
|
16
|
+
* `guren check --i18n` (packages/cli/src/i18n-check.ts) re-implement the
|
|
17
|
+
* same walk statically. Changing the layout or parse tolerance here strands
|
|
18
|
+
* them on the old contract — update both together.
|
|
19
|
+
*/
|
|
20
|
+
export declare class JsonLoader implements TranslationLoader {
|
|
21
|
+
private basePath;
|
|
22
|
+
private cache;
|
|
23
|
+
private useCache;
|
|
24
|
+
constructor(basePath: string, options?: {
|
|
25
|
+
cache?: boolean;
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Load all translations for a locale.
|
|
29
|
+
*/
|
|
30
|
+
load(locale: string): Promise<TranslationMessages>;
|
|
31
|
+
/**
|
|
32
|
+
* Load translations for a specific namespace.
|
|
33
|
+
*/
|
|
34
|
+
loadNamespace(locale: string, namespace: string): Promise<TranslationMessages>;
|
|
35
|
+
/**
|
|
36
|
+
* Get available locales.
|
|
37
|
+
*/
|
|
38
|
+
getAvailableLocales(): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Clear the cache.
|
|
41
|
+
*/
|
|
42
|
+
clearCache(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Enable or disable caching.
|
|
45
|
+
*/
|
|
46
|
+
setCaching(enabled: boolean): void;
|
|
47
|
+
}
|