@azure-net/kit 0.8.1 → 0.8.7

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.
Files changed (90) hide show
  1. package/dist/core/delivery/index.d.ts +3 -0
  2. package/dist/core/delivery/index.js +3 -0
  3. package/dist/core/{provider/dependencies → delivery/injectableDependencies}/ErrorHandler.d.ts +1 -1
  4. package/dist/core/{provider/dependencies → delivery/injectableDependencies}/ErrorHandler.js +1 -1
  5. package/dist/core/delivery/schema/Schema.d.ts +33 -0
  6. package/dist/core/delivery/schema/Schema.js +78 -0
  7. package/dist/core/delivery/schema/index.d.ts +1 -0
  8. package/dist/core/delivery/schema/index.js +1 -0
  9. package/dist/core/delivery/schema/rules/Rules.d.ts +59 -0
  10. package/dist/core/delivery/schema/rules/Rules.js +285 -0
  11. package/dist/core/delivery/serverAction/CreateServerAction.d.ts +12 -0
  12. package/dist/core/delivery/serverAction/CreateServerAction.js +12 -0
  13. package/dist/core/delivery/serverAction/index.d.ts +1 -0
  14. package/dist/core/delivery/serverAction/index.js +1 -0
  15. package/dist/core/index.d.ts +7 -8
  16. package/dist/core/index.js +7 -8
  17. package/dist/core/infra/index.d.ts +5 -0
  18. package/dist/core/infra/index.js +5 -0
  19. package/dist/core/infra/response/BaseResponse.d.ts +1 -1
  20. package/dist/core/infra/response/BaseResponse.js +0 -1
  21. package/dist/core/{boundaryProvider → shared/boundaryProvider}/Provider.js +7 -7
  22. package/dist/core/shared/cookie/UniversalCookie.d.ts +69 -0
  23. package/dist/core/shared/cookie/UniversalCookie.js +157 -0
  24. package/dist/core/shared/cookie/index.d.ts +1 -0
  25. package/dist/core/shared/cookie/index.js +1 -0
  26. package/dist/core/{eventBus → shared/eventBus}/EventBus.d.ts +6 -10
  27. package/dist/core/{eventBus → shared/eventBus}/EventBus.js +12 -18
  28. package/dist/core/shared/middleware/Middleware.d.ts +16 -0
  29. package/dist/core/shared/middleware/Middleware.js +68 -0
  30. package/dist/core/shared/middleware/index.d.ts +1 -0
  31. package/dist/core/shared/middleware/index.js +1 -0
  32. package/dist/core/shared/request/rules/messages/En.d.ts +2 -0
  33. package/dist/core/shared/request/rules/messages/En.js +40 -0
  34. package/dist/core/shared/request/rules/messages/Ru.d.ts +2 -0
  35. package/dist/core/shared/request/rules/messages/Ru.js +40 -0
  36. package/dist/core/shared/request/rules/messages/WithI18n.d.ts +2 -0
  37. package/dist/core/shared/request/rules/messages/WithI18n.js +40 -0
  38. package/dist/core/shared/request/rules/messages/index.d.ts +3 -0
  39. package/dist/core/shared/request/rules/messages/index.js +3 -0
  40. package/dist/core/shared/request/rules/messages/types.d.ts +41 -0
  41. package/dist/core/shared/request/rules/messages/types.js +1 -0
  42. package/dist/{lib → core/ui}/onClickOutside/OnClickOutside.js +2 -2
  43. package/dist/edges/index.d.ts +1 -1
  44. package/dist/edges/index.js +1 -1
  45. package/dist/svelte/AsyncSignal/AsyncSignal.svelte.js +4 -4
  46. package/package.json +11 -19
  47. package/dist/core/provider/ActionsProvider.d.ts +0 -13
  48. package/dist/core/provider/ActionsProvider.js +0 -29
  49. package/dist/core/provider/index.d.ts +0 -2
  50. package/dist/core/provider/index.js +0 -2
  51. /package/dist/core/{provider/dependencies → delivery/injectableDependencies}/AsyncHelpers.d.ts +0 -0
  52. /package/dist/core/{provider/dependencies → delivery/injectableDependencies}/AsyncHelpers.js +0 -0
  53. /package/dist/core/{provider/dependencies → delivery/injectableDependencies}/index.d.ts +0 -0
  54. /package/dist/core/{provider/dependencies → delivery/injectableDependencies}/index.js +0 -0
  55. /package/dist/core/{request → delivery/schema}/rules/messages/En.d.ts +0 -0
  56. /package/dist/core/{request → delivery/schema}/rules/messages/En.js +0 -0
  57. /package/dist/core/{request → delivery/schema}/rules/messages/Ru.d.ts +0 -0
  58. /package/dist/core/{request → delivery/schema}/rules/messages/Ru.js +0 -0
  59. /package/dist/core/{request → delivery/schema}/rules/messages/WithI18n.d.ts +0 -0
  60. /package/dist/core/{request → delivery/schema}/rules/messages/WithI18n.js +0 -0
  61. /package/dist/core/{request → delivery/schema}/rules/messages/index.d.ts +0 -0
  62. /package/dist/core/{request → delivery/schema}/rules/messages/index.js +0 -0
  63. /package/dist/core/{request → delivery/schema}/rules/messages/types.d.ts +0 -0
  64. /package/dist/core/{request → delivery/schema}/rules/messages/types.js +0 -0
  65. /package/dist/core/{boundaryProvider → shared/boundaryProvider}/Provider.d.ts +0 -0
  66. /package/dist/core/{boundaryProvider → shared/boundaryProvider}/index.d.ts +0 -0
  67. /package/dist/core/{boundaryProvider → shared/boundaryProvider}/index.js +0 -0
  68. /package/dist/core/{classMirror → shared/classMirror}/ClassMirror.d.ts +0 -0
  69. /package/dist/core/{classMirror → shared/classMirror}/ClassMirror.js +0 -0
  70. /package/dist/core/{classMirror → shared/classMirror}/index.d.ts +0 -0
  71. /package/dist/core/{classMirror → shared/classMirror}/index.js +0 -0
  72. /package/dist/core/{eventBus → shared/eventBus}/index.d.ts +0 -0
  73. /package/dist/core/{eventBus → shared/eventBus}/index.js +0 -0
  74. /package/dist/core/{request → shared/request}/BaseRequest.d.ts +0 -0
  75. /package/dist/core/{request → shared/request}/BaseRequest.js +0 -0
  76. /package/dist/core/{request → shared/request}/index.d.ts +0 -0
  77. /package/dist/core/{request → shared/request}/index.js +0 -0
  78. /package/dist/core/{request → shared/request}/rules/Rules.d.ts +0 -0
  79. /package/dist/core/{request → shared/request}/rules/Rules.js +0 -0
  80. /package/dist/core/{request → shared/request}/rules/index.d.ts +0 -0
  81. /package/dist/core/{request → shared/request}/rules/index.js +0 -0
  82. /package/dist/{lib → core/ui}/eventModifiers/EventModifiers.d.ts +0 -0
  83. /package/dist/{lib → core/ui}/eventModifiers/EventModifiers.js +0 -0
  84. /package/dist/{lib → core/ui}/eventModifiers/index.d.ts +0 -0
  85. /package/dist/{lib → core/ui}/eventModifiers/index.js +0 -0
  86. /package/dist/{lib → core/ui}/index.d.ts +0 -0
  87. /package/dist/{lib → core/ui}/index.js +0 -0
  88. /package/dist/{lib → core/ui}/onClickOutside/OnClickOutside.d.ts +0 -0
  89. /package/dist/{lib → core/ui}/onClickOutside/index.d.ts +0 -0
  90. /package/dist/{lib → core/ui}/onClickOutside/index.js +0 -0
@@ -0,0 +1,69 @@
1
+ export type CookieOptions = {
2
+ expires?: Date | number;
3
+ maxAge?: number;
4
+ path?: string;
5
+ domain?: string;
6
+ secure?: boolean;
7
+ sameSite?: 'Strict' | 'Lax' | 'None';
8
+ httpOnly?: boolean;
9
+ priority?: 'low' | 'medium' | 'high' | undefined;
10
+ partitioned?: boolean | undefined;
11
+ };
12
+ /**
13
+ * Utility class for managing cookies in svelte ssr (browser and server).
14
+ * Supports setting, getting, deleting, checking, and clearing cookies.
15
+ * All methods are static and operate without creating instances.
16
+ */
17
+ export declare class UniversalCookie {
18
+ /**
19
+ * Sets a cookie with the specified key, value, and options.
20
+ * Serializes non-string values as JSON.
21
+ *
22
+ * @template T
23
+ * @param {string} name - The cookie key (alphanumeric, dash, underscore only).
24
+ * @param {T} value - The value to store in the cookie.
25
+ * @param {CookieOptions} [options] - Optional cookie attributes.
26
+ * @returns {void}
27
+ */
28
+ static set<T>(name: string, value: T, options?: CookieOptions): void;
29
+ /**
30
+ * Retrieves the value of a cookie by key.
31
+ * Attempts to parse JSON if possible.
32
+ *
33
+ * @template T
34
+ * @param {string} name - The cookie key to retrieve.
35
+ * @returns {T | undefined} The cookie value, parsed as type T or null if not found.
36
+ */
37
+ static get<T = string>(name: string): T | undefined;
38
+ /**
39
+ * Retrieves all cookies as a key-value record.
40
+ * Attempts to parse JSON values.
41
+ *
42
+ * @template T
43
+ * @returns {T | undefined} An object with all cookie keys and their values.
44
+ */
45
+ static getAll<T = Record<string, unknown>>(): T | undefined;
46
+ /**
47
+ * Checks if a cookie with the given key exists.
48
+ *
49
+ * @param {string} name - The cookie key to check.
50
+ * @returns {boolean} True if cookie exists, false otherwise.
51
+ */
52
+ static has(name: string): boolean;
53
+ /**
54
+ * Deletes a cookie by key.
55
+ *
56
+ * @param {string} name - The cookie key to delete.
57
+ * @param {CookieOptions} [options] - Optional cookie attributes.
58
+ * @returns {void}
59
+ */
60
+ static delete(name: string, options?: CookieOptions): void;
61
+ /**
62
+ * Deletes all cookies with default domain and path.
63
+ * It's recommended to specify path and domain in options for full cleanup.
64
+ *
65
+ * @param {CookieOptions} [options] - Optional cookie attributes.
66
+ * @returns {void}
67
+ */
68
+ static clear(options?: CookieOptions): void;
69
+ }
@@ -0,0 +1,157 @@
1
+ import { Cookies, EnvironmentUtil } from 'azure-net-tools';
2
+ import { RequestContext } from 'edges-svelte/context';
3
+ /**
4
+ * Utility class for managing cookies in svelte ssr (browser and server).
5
+ * Supports setting, getting, deleting, checking, and clearing cookies.
6
+ * All methods are static and operate without creating instances.
7
+ */
8
+ export class UniversalCookie {
9
+ /**
10
+ * Sets a cookie with the specified key, value, and options.
11
+ * Serializes non-string values as JSON.
12
+ *
13
+ * @template T
14
+ * @param {string} name - The cookie key (alphanumeric, dash, underscore only).
15
+ * @param {T} value - The value to store in the cookie.
16
+ * @param {CookieOptions} [options] - Optional cookie attributes.
17
+ * @returns {void}
18
+ */
19
+ static set(name, value, options) {
20
+ if (EnvironmentUtil.isBrowser) {
21
+ Cookies.set(name, value, options);
22
+ return;
23
+ }
24
+ if (EnvironmentUtil.isServer) {
25
+ const event = RequestContext.current().event;
26
+ if (event) {
27
+ const encodedKey = encodeURIComponent(name);
28
+ let serializedValue;
29
+ if (typeof value === 'string') {
30
+ serializedValue = encodeURIComponent(value);
31
+ }
32
+ else {
33
+ serializedValue = encodeURIComponent(JSON.stringify(value));
34
+ }
35
+ let expires;
36
+ if (options?.expires !== undefined) {
37
+ if (typeof options.expires === 'number') {
38
+ const date = new Date();
39
+ date.setTime(date.getTime() + options.expires * 86400 * 1000);
40
+ expires = date;
41
+ }
42
+ else {
43
+ expires = options.expires;
44
+ }
45
+ }
46
+ event.cookies.set(encodedKey, serializedValue, {
47
+ ...options,
48
+ path: options?.path ?? '/',
49
+ httpOnly: options?.httpOnly ?? false,
50
+ sameSite: options?.sameSite?.toLowerCase(),
51
+ expires
52
+ });
53
+ return;
54
+ }
55
+ }
56
+ throw new Error('Could not detect current environment');
57
+ }
58
+ /**
59
+ * Retrieves the value of a cookie by key.
60
+ * Attempts to parse JSON if possible.
61
+ *
62
+ * @template T
63
+ * @param {string} name - The cookie key to retrieve.
64
+ * @returns {T | undefined} The cookie value, parsed as type T or null if not found.
65
+ */
66
+ static get(name) {
67
+ if (EnvironmentUtil.isBrowser) {
68
+ return Cookies.get(name) ?? undefined;
69
+ }
70
+ if (EnvironmentUtil.isServer) {
71
+ const event = RequestContext.current().event;
72
+ if (event) {
73
+ const encodedKey = encodeURIComponent(name);
74
+ const cookieValue = event.cookies.get(encodedKey);
75
+ if (cookieValue) {
76
+ const decodedValue = decodeURIComponent(cookieValue);
77
+ try {
78
+ return JSON.parse(decodedValue);
79
+ }
80
+ catch {
81
+ return decodedValue;
82
+ }
83
+ }
84
+ return undefined;
85
+ }
86
+ return undefined;
87
+ }
88
+ return undefined;
89
+ }
90
+ /**
91
+ * Retrieves all cookies as a key-value record.
92
+ * Attempts to parse JSON values.
93
+ *
94
+ * @template T
95
+ * @returns {T | undefined} An object with all cookie keys and their values.
96
+ */
97
+ static getAll() {
98
+ if (EnvironmentUtil.isBrowser) {
99
+ return Cookies.getAll();
100
+ }
101
+ if (EnvironmentUtil.isServer) {
102
+ const event = RequestContext.current().event;
103
+ const result = {};
104
+ if (event) {
105
+ const allCookies = event.cookies.getAll();
106
+ for (const singleCookie of allCookies) {
107
+ try {
108
+ result[singleCookie.name] = JSON.parse(singleCookie.value);
109
+ }
110
+ catch {
111
+ result[singleCookie.name] = singleCookie.value;
112
+ }
113
+ }
114
+ }
115
+ return result;
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Checks if a cookie with the given key exists.
121
+ *
122
+ * @param {string} name - The cookie key to check.
123
+ * @returns {boolean} True if cookie exists, false otherwise.
124
+ */
125
+ static has(name) {
126
+ return this.get(name) !== undefined;
127
+ }
128
+ /**
129
+ * Deletes a cookie by key.
130
+ *
131
+ * @param {string} name - The cookie key to delete.
132
+ * @param {CookieOptions} [options] - Optional cookie attributes.
133
+ * @returns {void}
134
+ */
135
+ static delete(name, options) {
136
+ this.set(name, '', {
137
+ ...options,
138
+ expires: new Date(0),
139
+ maxAge: 0
140
+ });
141
+ }
142
+ /**
143
+ * Deletes all cookies with default domain and path.
144
+ * It's recommended to specify path and domain in options for full cleanup.
145
+ *
146
+ * @param {CookieOptions} [options] - Optional cookie attributes.
147
+ * @returns {void}
148
+ */
149
+ static clear(options) {
150
+ const allCookies = this.getAll();
151
+ if (allCookies) {
152
+ for (const key in allCookies) {
153
+ this.delete(key, options);
154
+ }
155
+ }
156
+ }
157
+ }
@@ -0,0 +1 @@
1
+ export * from './UniversalCookie.js';
@@ -0,0 +1 @@
1
+ export * from './UniversalCookie.js';
@@ -1,15 +1,10 @@
1
- export declare enum EventBusLayers {
2
- DOMAIN = "domain",
3
- APPLICATION = "application",
4
- PRESENTATION = "presentation"
5
- }
6
1
  export interface IEvent<T = unknown> {
7
2
  aggregateId: string;
8
3
  eventType: string;
9
4
  eventVersion: number;
10
5
  occurredAt: Date;
11
6
  metadata: IEventMetadata;
12
- eventLayer: EventBusLayers;
7
+ busName?: string;
13
8
  payload: T;
14
9
  }
15
10
  export interface IEventMetadata {
@@ -34,9 +29,9 @@ export declare class EventBus<TEventMap extends object> {
34
29
  private priorities;
35
30
  private readonly debug;
36
31
  private readonly maxHistorySize;
37
- private readonly layer;
32
+ private readonly busName?;
38
33
  constructor(options?: {
39
- layer?: EventBusLayers;
34
+ busName?: string;
40
35
  enableHistory?: boolean;
41
36
  maxHistorySize?: number;
42
37
  enableAsyncProcessing?: boolean;
@@ -70,12 +65,13 @@ export declare class EventBus<TEventMap extends object> {
70
65
  private generateCorrelationId;
71
66
  }
72
67
  export declare const loggingMiddleware: (event: IEvent, next: () => Promise<void>) => Promise<void>;
73
- export declare const createEventBus: <TEventMap extends object>(layer: EventBusLayers, opts: {
68
+ export declare const createEventBus: <TEventMap extends object>(opts: {
74
69
  history?: boolean;
75
70
  asyncProcessing?: boolean;
76
71
  historySize?: number;
77
72
  middlewares?: (<T = unknown>(event: IEvent<T>, next: () => Promise<void>) => Promise<void>)[];
78
73
  debug?: boolean;
74
+ busName?: string;
79
75
  }) => {
80
76
  eventBus: EventBus<TEventMap>;
81
77
  CreateEvent: <K extends keyof TEventMap>(eventName: K, data: TEventMap[K]) => void;
@@ -87,5 +83,5 @@ export declare const createEventBus: <TEventMap extends object>(layer: EventBusL
87
83
  CreateSubscriber: <K extends keyof TEventMap>(eventType: K, handler: DomainEventHandler<TEventMap[K]>, options?: {
88
84
  priority?: number;
89
85
  }) => IEventSubscription;
90
- createSubscribers: <K extends keyof TEventMap>(eventTypes: K[], handler: DomainEventHandler<TEventMap[K]>) => IEventSubscription;
86
+ CreateSubscribers: <K extends keyof TEventMap>(eventTypes: K[], handler: DomainEventHandler<TEventMap[K]>) => IEventSubscription;
91
87
  };
@@ -1,9 +1,3 @@
1
- export var EventBusLayers;
2
- (function (EventBusLayers) {
3
- EventBusLayers["DOMAIN"] = "domain";
4
- EventBusLayers["APPLICATION"] = "application";
5
- EventBusLayers["PRESENTATION"] = "presentation";
6
- })(EventBusLayers || (EventBusLayers = {}));
7
1
  export class EventBus {
8
2
  options;
9
3
  handlers = new Map();
@@ -15,10 +9,10 @@ export class EventBus {
15
9
  priorities = new Map();
16
10
  debug = false;
17
11
  maxHistorySize = 1000;
18
- layer;
19
- constructor(options = { layer: EventBusLayers.PRESENTATION, debug: false }) {
12
+ busName;
13
+ constructor(options = { debug: false }) {
20
14
  this.options = options;
21
- this.layer = options.layer ?? EventBusLayers.PRESENTATION;
15
+ this.busName = options.busName ?? undefined;
22
16
  this.debug = options.debug ?? false;
23
17
  if (options.maxHistorySize) {
24
18
  this.maxHistorySize = options.maxHistorySize;
@@ -34,7 +28,7 @@ export class EventBus {
34
28
  correlationId: this.generateCorrelationId(),
35
29
  ...metadata
36
30
  },
37
- eventLayer: this.layer,
31
+ busName: this.busName,
38
32
  payload
39
33
  };
40
34
  void this.processEvent(event);
@@ -45,7 +39,7 @@ export class EventBus {
45
39
  eventType: type,
46
40
  eventVersion: 1,
47
41
  occurredAt: new Date(),
48
- eventLayer: this.layer,
42
+ busName: this.busName,
49
43
  metadata: {
50
44
  correlationId: this.generateCorrelationId(),
51
45
  ...metadata
@@ -198,17 +192,17 @@ export class EventBus {
198
192
  }
199
193
  }
200
194
  export const loggingMiddleware = async (event, next) => {
201
- console.log(`[${event.eventLayer.toUpperCase()}Event] ${event.eventType} at ${event.occurredAt.toISOString()}`);
202
- console.log(`[${event.eventLayer.toUpperCase()}Event] data:`, event);
195
+ console.log(`[${event.busName ?? ''}Event] ${event.eventType} at ${event.occurredAt.toISOString()}`);
196
+ console.log(`[${event.busName ?? ''}Event] data:`, event);
203
197
  const start = performance.now();
204
198
  await next();
205
199
  const duration = performance.now() - start;
206
- console.log(`[${event.eventLayer.toUpperCase()}Event] ${event.eventType} processed in ${duration.toFixed(2)}ms`);
200
+ console.log(`[${event.busName ?? ''}Event] ${event.eventType} processed in ${duration.toFixed(2)}ms`);
207
201
  };
208
- export const createEventBus = (layer, opts) => {
202
+ export const createEventBus = (opts) => {
209
203
  const { history = true, asyncProcessing = true, historySize = 1000, middlewares = [], debug = false } = opts;
210
204
  const eventBus = new EventBus({
211
- layer,
205
+ busName: opts.busName,
212
206
  enableHistory: history,
213
207
  enableAsyncProcessing: asyncProcessing,
214
208
  maxHistorySize: historySize,
@@ -226,8 +220,8 @@ export const createEventBus = (layer, opts) => {
226
220
  const CreateSubscriber = (eventType, handler, options) => {
227
221
  return eventBus.subscribe(eventType, handler, options);
228
222
  };
229
- const createSubscribers = (eventTypes, handler) => {
223
+ const CreateSubscribers = (eventTypes, handler) => {
230
224
  return eventBus.subscribeMany(eventTypes, handler);
231
225
  };
232
- return { eventBus, CreateEvent, CreateBatch, CreateSubscriber, createSubscribers };
226
+ return { eventBus, CreateEvent, CreateBatch, CreateSubscriber, CreateSubscribers };
233
227
  };
@@ -0,0 +1,16 @@
1
+ import { error, type Page, type RequestEvent } from '@sveltejs/kit';
2
+ import { UniversalCookie } from '../cookie/index.js';
3
+ export type IMiddleware = (middlewareData: {
4
+ to: RequestEvent['url'] | Page['url'];
5
+ from?: RequestEvent['url'] | Page['url'];
6
+ error: typeof error;
7
+ next: (location?: string | URL, status?: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | number) => void;
8
+ isServer: boolean;
9
+ cookies: UniversalCookie;
10
+ event?: RequestEvent;
11
+ page: Page;
12
+ }) => Promise<void> | void;
13
+ export declare const createMiddlewareManager: (middlewares: IMiddleware[]) => {
14
+ serverMiddleware: () => Promise<void>;
15
+ clientMiddleware: () => void;
16
+ };
@@ -0,0 +1,68 @@
1
+ import { error, redirect } from '@sveltejs/kit';
2
+ import { RequestContext } from 'edges-svelte/context';
3
+ import { beforeNavigate, goto } from '$app/navigation';
4
+ import { page } from '$app/state';
5
+ import { EnvironmentUtil } from 'azure-net-tools';
6
+ import { UniversalCookie } from '../cookie/index.js';
7
+ const universalRedirect = (location, status = 301, navigation) => {
8
+ if (EnvironmentUtil.isBrowser && navigation) {
9
+ navigation?.cancel();
10
+ return goto(location);
11
+ }
12
+ else {
13
+ return redirect(status, location);
14
+ }
15
+ };
16
+ export const createMiddlewareManager = (middlewares) => {
17
+ const executeMiddlewares = async (navigation) => {
18
+ let event;
19
+ let from = undefined;
20
+ if (EnvironmentUtil.isServer) {
21
+ event = RequestContext.current().event;
22
+ const referer = event?.request.headers.get('referer');
23
+ from = referer ? new URL(referer) : undefined;
24
+ }
25
+ else {
26
+ from = navigation?.from?.url ?? undefined;
27
+ }
28
+ const to = (EnvironmentUtil.isBrowser ? (navigation?.to?.url ?? page?.url) : event?.url);
29
+ for (const middleware of middlewares) {
30
+ let shouldContinue = false;
31
+ const next = (location, status = 301) => {
32
+ shouldContinue = true;
33
+ if (location) {
34
+ return universalRedirect(location, status, navigation);
35
+ }
36
+ };
37
+ await middleware({
38
+ event,
39
+ page,
40
+ cookies: UniversalCookie,
41
+ isServer: EnvironmentUtil.isServer,
42
+ to,
43
+ from,
44
+ error,
45
+ next
46
+ });
47
+ if (!shouldContinue) {
48
+ if (EnvironmentUtil.isBrowser) {
49
+ navigation?.cancel();
50
+ if (from) {
51
+ void goto(from.pathname);
52
+ console.warn('Navigation blocked: middleware chain stopped (next() not called).');
53
+ }
54
+ }
55
+ else {
56
+ error(403, 'Navigation blocked: middleware chain stopped (next() not called).');
57
+ }
58
+ }
59
+ }
60
+ };
61
+ const serverMiddleware = async () => await executeMiddlewares();
62
+ const clientMiddleware = () => {
63
+ beforeNavigate(async (navigation) => {
64
+ await executeMiddlewares(navigation);
65
+ });
66
+ };
67
+ return { serverMiddleware, clientMiddleware };
68
+ };
@@ -0,0 +1 @@
1
+ export * from './Middleware.js';
@@ -0,0 +1 @@
1
+ export * from './Middleware.js';
@@ -0,0 +1,2 @@
1
+ import type { BaseValidationMessages } from './types.js';
2
+ export declare const validationMessagesEn: BaseValidationMessages;
@@ -0,0 +1,40 @@
1
+ export const validationMessagesEn = {
2
+ phone: () => 'Invalid phone number format',
3
+ email: () => 'Invalid email address',
4
+ required: () => 'This field is required',
5
+ lettersOnly: (whiteSpaces) => `This field may contain letters only${whiteSpaces ? '' : ' and must not contain spaces'}`,
6
+ allowedOnly: (value) => value && value.length ? `This field may contain only one of the following values: ${value}` : 'This field has no allowed values',
7
+ sameAs: (value) => `This field must match the ${value} field`,
8
+ notSameAs: (value) => `This field must not match the ${value} field`,
9
+ boolean: {
10
+ base: () => 'This field must be a boolean value',
11
+ expected: (value) => `Expected value: ${value}`
12
+ },
13
+ finite: {
14
+ base: () => 'This field must be a number',
15
+ min: (value) => `The number must be at least ${value}`,
16
+ max: (value) => `The number must be at most ${value}`,
17
+ maxDigitsAfterDot: (value) => `Number of digits after the decimal point must not exceed ${value}`
18
+ },
19
+ number: {
20
+ base: () => 'This field must be an integer',
21
+ min: (value) => `The number must be at least ${value}`,
22
+ max: (value) => `The number must be at most ${value}`
23
+ },
24
+ string: {
25
+ base: () => 'This field must be a string',
26
+ min: (value) => `Minimum string length is ${value}`,
27
+ max: (value) => `Maximum string length is ${value}`
28
+ },
29
+ array: {
30
+ base: () => 'This field must be an array',
31
+ min: (value) => `Minimum array length is ${value}`,
32
+ max: (value) => `Maximum array length is ${value}`
33
+ },
34
+ password: {
35
+ length: (value) => `Minimum password length is ${value}`,
36
+ specialChars: (value) => `Password must contain at least ${value} special character(s)`,
37
+ lowerUpperCasePattern: () => 'Password must contain both uppercase and lowercase letters',
38
+ numbers: (value) => `Password must contain at least ${value} number(s)`
39
+ }
40
+ };
@@ -0,0 +1,2 @@
1
+ import type { BaseValidationMessages } from './types.js';
2
+ export declare const validationMessagesRu: BaseValidationMessages;
@@ -0,0 +1,40 @@
1
+ export const validationMessagesRu = {
2
+ phone: () => 'Неверный формат номера телефона',
3
+ email: () => 'Невалидный email',
4
+ required: () => 'Поле обязательно к заполнению',
5
+ lettersOnly: (whiteSpaces) => `Поле может содержать только буквы ${whiteSpaces ? '' : 'и не должно содержать пробелы'}`,
6
+ allowedOnly: (value) => value && value.length ? `Поле может содержать только одно из следующих значений:: ${value}` : 'Поле не имеет допустимых значений',
7
+ sameAs: (value) => `Поле должно совпадать с полем ${value}`,
8
+ notSameAs: (value) => `Поле не должно совпадать с полем ${value}`,
9
+ boolean: {
10
+ base: () => 'Поле должно содержать значение типа boolean',
11
+ expected: (value) => `Ожидаемое значение поля - ${value}`
12
+ },
13
+ finite: {
14
+ base: () => 'Поле должно быть числом',
15
+ min: (value) => `Число должно быть не менее ${value}`,
16
+ max: (value) => `Число должно быть не более ${value}`,
17
+ maxDigitsAfterDot: (value) => `Количество символов после точки не более ${value}`
18
+ },
19
+ number: {
20
+ base: () => 'Поле должно быть целым числом',
21
+ min: (value) => `Число должно быть не менее ${value}`,
22
+ max: (value) => `Число должно быть не более ${value}`
23
+ },
24
+ string: {
25
+ base: () => 'Поле должно быть строкой',
26
+ min: (value) => `Минимальная длина строки - ${value}`,
27
+ max: (value) => `Максимальная длина строки - ${value}`
28
+ },
29
+ array: {
30
+ base: () => 'Поле должно быть массивом',
31
+ min: (value) => `Минимальная длина массива - ${value}`,
32
+ max: (value) => `Максимальная длина массива - ${value}`
33
+ },
34
+ password: {
35
+ length: (value) => `Минимальная длина пароля - ${value}`,
36
+ specialChars: (value) => `В пароле должно быть спецсимволы в количестве не менее ${value}`,
37
+ lowerUpperCasePattern: () => 'В пароле должны быть буквы верхнего и нижнего регистра',
38
+ numbers: (value) => `В пароле должно быть цифры в количестве не менее ${value}`
39
+ }
40
+ };
@@ -0,0 +1,2 @@
1
+ import type { BaseValidationMessages } from './types.js';
2
+ export declare const validationMessagesI18n: BaseValidationMessages;
@@ -0,0 +1,40 @@
1
+ export const validationMessagesI18n = {
2
+ phone: () => 'validation.phone',
3
+ email: () => 'validation.email',
4
+ required: () => 'validation.required',
5
+ lettersOnly: (whiteSpaces) => (whiteSpaces ? 'validation.lettersOnlyWithWhiteSpaces' : 'validation.lettersOnly'),
6
+ allowedOnly: (value) => ({ key: value && value.length ? 'validation.allowedOnly.base' : 'validation.allowedOnly.nothing', vars: { value } }),
7
+ sameAs: (value) => ({ key: 'validation.sameAs', vars: { value } }),
8
+ notSameAs: (value) => ({ key: 'validation.notSameAs', vars: { value } }),
9
+ boolean: {
10
+ base: () => 'validation.boolean.base',
11
+ expected: (value) => ({ key: 'validation.boolean.expected', vars: { value } })
12
+ },
13
+ finite: {
14
+ base: () => 'validation.finite.base',
15
+ min: (value) => ({ key: 'validation.finite.minLength', vars: { value } }),
16
+ max: (value) => ({ key: 'validation.finite.maxLength', vars: { value } }),
17
+ maxDigitsAfterDot: (value) => ({ key: 'validation.finite.maxDigitsAfterDot', vars: { value } })
18
+ },
19
+ number: {
20
+ base: () => 'validation.number.base',
21
+ min: (value) => ({ key: 'validation.number.minLength', vars: { value } }),
22
+ max: (value) => ({ key: 'validation.number.maxLength', vars: { value } })
23
+ },
24
+ string: {
25
+ base: () => 'validation.string.base',
26
+ min: (value) => ({ key: 'validation.string.minLength', vars: { value } }),
27
+ max: (value) => ({ key: 'validation.string.maxLength', vars: { value } })
28
+ },
29
+ array: {
30
+ base: () => 'validation.array.base',
31
+ min: (value) => ({ key: 'validation.array.minLength', vars: { value } }),
32
+ max: (value) => ({ key: 'validation.array.maxLength', vars: { value } })
33
+ },
34
+ password: {
35
+ length: (value) => ({ key: 'validation.password.length', vars: { value } }),
36
+ specialChars: (value) => ({ key: 'validation.password.specialChars', vars: { value } }),
37
+ lowerUpperCasePattern: () => ({ key: 'validation.password.lowerUpperCasePattern' }),
38
+ numbers: (value) => ({ key: 'validation.password.numbers', vars: { value } })
39
+ }
40
+ };
@@ -0,0 +1,3 @@
1
+ export * from './Ru.js';
2
+ export * from './En.js';
3
+ export * from './WithI18n.js';
@@ -0,0 +1,3 @@
1
+ export * from './Ru.js';
2
+ export * from './En.js';
3
+ export * from './WithI18n.js';
@@ -0,0 +1,41 @@
1
+ import type { ValidationMessage } from '../../index.js';
2
+ export type BaseValidationMessages = {
3
+ phone: () => ValidationMessage;
4
+ email: () => ValidationMessage;
5
+ required: () => ValidationMessage;
6
+ lettersOnly: (whiteSpaces: boolean) => ValidationMessage;
7
+ allowedOnly: (allowed: string) => ValidationMessage;
8
+ sameAs: (value: string) => ValidationMessage;
9
+ notSameAs: (value: string) => ValidationMessage;
10
+ boolean: {
11
+ base: () => ValidationMessage;
12
+ expected: (value: string) => ValidationMessage;
13
+ };
14
+ finite: {
15
+ base: () => ValidationMessage;
16
+ min: (value: number) => ValidationMessage;
17
+ max: (value: number) => ValidationMessage;
18
+ maxDigitsAfterDot: (value: number) => ValidationMessage;
19
+ };
20
+ number: {
21
+ base: () => ValidationMessage;
22
+ min: (value: number) => ValidationMessage;
23
+ max: (value: number) => ValidationMessage;
24
+ };
25
+ string: {
26
+ base: () => ValidationMessage;
27
+ min: (value: number) => ValidationMessage;
28
+ max: (value: number) => ValidationMessage;
29
+ };
30
+ array: {
31
+ base: () => ValidationMessage;
32
+ min: (value: number) => ValidationMessage;
33
+ max: (value: number) => ValidationMessage;
34
+ };
35
+ password: {
36
+ length: (value: number) => ValidationMessage;
37
+ specialChars: (value: number) => ValidationMessage;
38
+ lowerUpperCasePattern: () => ValidationMessage;
39
+ numbers: (value: number) => ValidationMessage;
40
+ };
41
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { browser } from '$app/environment';
1
+ import { EnvironmentUtil } from 'azure-net-tools';
2
2
  export const onClickOutside = (node, initiator) => {
3
- if (!browser)
3
+ if (EnvironmentUtil.isServer)
4
4
  return { destroy: () => { } };
5
5
  const handleClick = (event) => {
6
6
  if (event.target instanceof HTMLElement) {
@@ -1 +1 @@
1
- export { createProvider, createProviderFactory } from 'edges-svelte';
1
+ export { createPresenter, createPresenterFactory, createStore, createStoreFactory } from 'edges-svelte';
@@ -1 +1 @@
1
- export { createProvider, createProviderFactory } from 'edges-svelte';
1
+ export { createPresenter, createPresenterFactory, createStore, createStoreFactory } from 'edges-svelte';