@azure-net/kit 3.9.2 → 4.0.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.
@@ -2,8 +2,10 @@ type TransformationParams<SchemaData> = {
2
2
  validate?: boolean;
3
3
  onValidationError?: (errors: RequestErrors<SchemaData>) => void;
4
4
  };
5
- type DeepKeys<SchemaData> = SchemaData extends object ? {
6
- [K in keyof SchemaData & string]: SchemaData[K] extends object ? K | `${K}.${DeepKeys<SchemaData[K]>}` : K;
5
+ type AtomicObject = Date | File | Blob | FileList | FormData | URL | RegExp | ArrayBuffer | DataView | Promise<unknown>;
6
+ type IsAtomic<T> = T extends AtomicObject ? true : false;
7
+ type DeepKeys<SchemaData> = IsAtomic<SchemaData> extends true ? never : SchemaData extends object ? {
8
+ [K in keyof SchemaData & string]: IsAtomic<SchemaData[K]> extends true ? K : SchemaData[K] extends object ? K | `${K}.${DeepKeys<SchemaData[K]>}` : K;
7
9
  }[keyof SchemaData & string] : never;
8
10
  export type ValidationParams<SchemaData = unknown, CurrentValue = unknown, CurrentKey = string> = {
9
11
  val: CurrentValue;
@@ -19,7 +21,7 @@ export interface ValidationErrorsMap {
19
21
  }
20
22
  export type ValidationResult = ValidationMessage | ValidationErrorsMap | ValidationErrorsMap[] | undefined;
21
23
  export type ValidationRuleResult<CurrentValue, ListValues = unknown, CurrentKey = string> = (params: ValidationParams<CurrentValue, ListValues, CurrentKey>) => ValidationResult;
22
- type ValidationErrors<Errors> = Errors extends ReadonlyArray<infer U> ? ValidationErrors<U>[] : Errors extends object ? {
24
+ type ValidationErrors<Errors> = Errors extends ReadonlyArray<infer U> ? ValidationErrors<U>[] : IsAtomic<Errors> extends true ? ValidationMessage : Errors extends object ? {
23
25
  [K in keyof Errors]?: ValidationErrors<Errors[K]>;
24
26
  } : ValidationMessage;
25
27
  export type RequestErrors<SchemaData> = Partial<ValidationErrors<SchemaData>>;
@@ -1,4 +1,3 @@
1
- import { masks } from '../../../constants/masks.js';
2
1
  /**
3
2
  *
4
3
  * @param validationMessages - BaseValidationMessages
@@ -180,7 +179,6 @@ export const createRules = (validationMessages) => {
180
179
  * @returns ValidationRuleResult<T, D>
181
180
  * @description Checks if the value is a phone number and if it is valid.
182
181
  */
183
- const countryCodes = new Set(Object.values(masks).map((country) => country.cc)).add('8');
184
182
  const phone = (params) => {
185
183
  const { message } = { ...params, message: params?.message ?? validationMessages.phone };
186
184
  return ({ val }) => {
@@ -197,40 +195,13 @@ export const createRules = (validationMessages) => {
197
195
  return message();
198
196
  }
199
197
  let hasValidCountryCode = false;
200
- if (cleanedVal.startsWith('+')) {
201
- const sortedCodes = Array.from(countryCodes)
202
- .filter((code) => code.startsWith('+'))
203
- .sort((a, b) => b.length - a.length);
204
- for (const code of sortedCodes) {
205
- if (cleanedVal.startsWith(code)) {
206
- const remainingDigits = cleanedVal.slice(code.length);
207
- if (remainingDigits.length >= 4) {
208
- hasValidCountryCode = true;
209
- break;
210
- }
211
- }
212
- }
213
- }
214
- else if (cleanedVal.startsWith('8')) {
198
+ if (cleanedVal.startsWith('8')) {
215
199
  if (cleanedVal.length === 11) {
216
200
  hasValidCountryCode = true;
217
201
  }
218
202
  }
219
203
  else if (/^\d+$/.test(cleanedVal)) {
220
- const codesWithoutPlus = Array.from(countryCodes)
221
- .filter((code) => !code.startsWith('+') && code !== 'N/A')
222
- .map((code) => code.replace('+', ''))
223
- .sort((a, b) => b.length - a.length);
224
- for (const code of codesWithoutPlus) {
225
- if (cleanedVal.startsWith(code)) {
226
- const remainingDigits = cleanedVal.slice(code.length);
227
- if (remainingDigits.length >= 4) {
228
- hasValidCountryCode = true;
229
- break;
230
- }
231
- }
232
- }
233
- if (!hasValidCountryCode && cleanedVal.length >= 7 && cleanedVal.length <= 10) {
204
+ if (!hasValidCountryCode && cleanedVal.length >= 6 && cleanedVal.length <= 16) {
234
205
  hasValidCountryCode = true;
235
206
  }
236
207
  }
@@ -1,3 +1,4 @@
1
1
  export * from './Ru.js';
2
2
  export * from './En.js';
3
3
  export * from './WithI18n.js';
4
+ export * from './types.js';
@@ -1,3 +1,4 @@
1
1
  export * from './Ru.js';
2
2
  export * from './En.js';
3
3
  export * from './WithI18n.js';
4
+ export * from './types.js';
@@ -1,5 +1,5 @@
1
1
  export { createPresenter, createStore, createPresenterFactory, createStoreFactory, clearCache } from '../edges/index.js';
2
2
  export { createAsyncHelpers, type AsyncHelperRetry, type AsyncResourceSettings, type AsyncActionResponse } from './delivery/injectableDependencies/AsyncHelpers.js';
3
3
  export { createErrorHandler } from './delivery/injectableDependencies/ErrorHandler.js';
4
- export { createSchemaFactory, schema, type Schema, type RequestErrors, type ISchemaError, type ValidationResult, type ValidationRuleResult, type ValidationParams } from './delivery/schema/Schema.js';
5
- export { createRules, validationMessagesRu, validationMessagesI18n, validationMessagesEn, type ValidationRuleParams } from './delivery/schema/rules/index.js';
4
+ export { createSchemaFactory, schema, type Schema, type RequestErrors, type ISchemaError, type ValidationResult, type ValidationRuleResult, type ValidationParams, type ValidationMessage, type ValidationErrorsMap } from './delivery/schema/Schema.js';
5
+ export { createRules, validationMessagesRu, validationMessagesI18n, validationMessagesEn, type ValidationRuleParams, type BaseValidationMessages } from './delivery/schema/rules/index.js';
@@ -1,4 +1,3 @@
1
- export { event, stop, prevent, once, immediate, type EventHandler, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
1
  export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals, type AsyncSignalOptions, type AsyncSignalSvelte, type QueryController, type CreateQueryOptions, type AsyncSignalSource, type AsyncStatus } from './svelte/index.js';
3
2
  export { createMiddlewareManager, type IMiddleware } from './shared/middleware/index.js';
4
3
  export { ClassMirror } from './shared/classMirror/index.js';
@@ -1,4 +1,3 @@
1
- export { event, stop, prevent, once, immediate, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
1
  export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals } from './svelte/index.js';
3
2
  export { createMiddlewareManager } from './shared/middleware/index.js';
4
3
  export { ClassMirror } from './shared/classMirror/index.js';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './core/index.js';
2
- export * from './edges/index.js';
2
+ export { __withEdgesUniversalLoad } from './edges/index.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './core/index.js';
2
- export * from './edges/index.js';
2
+ export { __withEdgesUniversalLoad } from './edges/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "3.9.2",
3
+ "version": "4.0.0-0",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -17,10 +17,6 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "svelte": "./dist/index.js"
19
19
  },
20
- "./constants": {
21
- "types": "./dist/core/constants/index.d.ts",
22
- "svelte": "./dist/core/constants/index.js"
23
- },
24
20
  "./infra": {
25
21
  "types": "./dist/core/infra.d.ts",
26
22
  "svelte": "./dist/core/infra.js"
@@ -110,9 +106,9 @@
110
106
  "svelte"
111
107
  ],
112
108
  "dependencies": {
113
- "@azure-net/edges": "^1.2.0",
114
- "@azure-net/edges-translations": "^1.2.0",
115
- "@azure-net/tools": "^1.2.0"
109
+ "@azure-net/edges": "^1.2.2",
110
+ "@azure-net/edges-translations": "^1.2.2",
111
+ "@azure-net/tools": "^1.2.2"
116
112
  },
117
113
  "scripts": {
118
114
  "dev": "vite dev",
@@ -1 +0,0 @@
1
- export * from './masks.js';
@@ -1 +0,0 @@
1
- export * from './masks.js';