yuppi 1.2.4 → 1.2.6

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/README.md CHANGED
@@ -112,31 +112,21 @@ Yuppi
112
112
  │ ├── URI
113
113
  │ └── Username
114
114
 
115
- └── type Types
116
-
117
- ├── AnyObject
118
- ├── JSONSchema
119
- ├── Schema
120
- ├── ValidateOptions
121
- ├── ValidationError
122
- └── YuppiOptions
115
+ ├── type AnyObject
116
+ ├── type JSONSchema
117
+ ├── type Schema
118
+ ├── type ValidateOptions
119
+ ├── type ValidationError
120
+ └── type YuppiOptions
123
121
  ```
124
122
 
125
123
  ### Import
126
124
 
127
125
  Briefly as follows.
128
126
 
129
- > TypeScript
130
- >
131
- > ```typescript
132
- > import { Yuppi, Patterns, type Types as YuppiTypes } from "yuppi";
133
- > ```
134
- >
135
- > JavaScript
136
- >
137
- > ```javascript
138
- > import { Yuppi, Patterns } from "yuppi";
139
- > ```
127
+ ```typescript
128
+ import { Yuppi, Patterns } from 'yuppi';
129
+ ```
140
130
 
141
131
  ### Constructors
142
132
 
@@ -151,7 +141,7 @@ Yuppi schema builder.
151
141
  > Example:
152
142
  >
153
143
  > ```typescript
154
- > const Yupp: Yuppi = new Yuppi();
144
+ > const Yupp = new Yuppi();
155
145
  > ```
156
146
 
157
147
  ### Methods
@@ -170,9 +160,9 @@ Validate the properties with your Yuppi schema.
170
160
  > Example:
171
161
  >
172
162
  > ```typescript
173
- > const schema: YuppiTypes.Schema = {
163
+ > const schema: Schema = {
174
164
  > display_name: {
175
- > type: "string",
165
+ > type: 'string',
176
166
  > min: 1,
177
167
  > max: 32,
178
168
  > nullable: false,
@@ -180,7 +170,7 @@ Validate the properties with your Yuppi schema.
180
170
  > },
181
171
  >
182
172
  > username: {
183
- > type: "string",
173
+ > type: 'string',
184
174
  > min: 3,
185
175
  > max: 16,
186
176
  > pattern: Patterns.Username,
@@ -189,7 +179,7 @@ Validate the properties with your Yuppi schema.
189
179
  > },
190
180
  >
191
181
  > email: {
192
- > type: "string",
182
+ > type: 'string',
193
183
  > pattern: Patterns.Email,
194
184
  > lowercase: true,
195
185
  > nullable: false,
@@ -197,10 +187,10 @@ Validate the properties with your Yuppi schema.
197
187
  > }
198
188
  > };
199
189
  >
200
- > const properties: YuppiTypes.AnyObject = {
201
- > display_name: "Fırat",
202
- > username: "fir4tozden",
203
- > email: "fir4tozden@gmail.com"
190
+ > const properties = {
191
+ > display_name: 'Fırat',
192
+ > username: 'fir4tozden',
193
+ > email: 'fir4tozden@gmail.com'
204
194
  > };
205
195
  >
206
196
  > try {
@@ -212,7 +202,7 @@ Validate the properties with your Yuppi schema.
212
202
  > email: "fir4tozden@gmail.com"
213
203
  > }
214
204
  > */
215
- > } catch((error: YuppiTypes.ValidationError)) {
205
+ > } catch (error) {
216
206
  > console.log(error.message); // "Field email must match the required pattern ^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$"
217
207
  > }
218
208
  > ```
@@ -232,9 +222,9 @@ Convert your Yuppi schema into Yup schema.
232
222
  > Example:
233
223
  >
234
224
  > ```typescript
235
- > const schema: YuppiTypes.Schema = {
225
+ > const schema: Schema = {
236
226
  > display_name: {
237
- > type: "string",
227
+ > type: 'string',
238
228
  > min: 1,
239
229
  > max: 32,
240
230
  > nullable: false,
@@ -242,7 +232,7 @@ Convert your Yuppi schema into Yup schema.
242
232
  > },
243
233
  >
244
234
  > username: {
245
- > type: "string",
235
+ > type: 'string',
246
236
  > min: 3,
247
237
  > max: 16,
248
238
  > pattern: Patterns.Username,
@@ -251,7 +241,7 @@ Convert your Yuppi schema into Yup schema.
251
241
  > },
252
242
  >
253
243
  > email: {
254
- > type: "string",
244
+ > type: 'string',
255
245
  > pattern: Patterns.Email,
256
246
  > lowercase: true,
257
247
  > nullable: false,
@@ -272,14 +262,14 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
272
262
  > | --------- | ------- | -------------------------- |
273
263
  > | schema | | [Schema]<br/>Yuppi schema. |
274
264
  >
275
- > returns [AnyObject]
265
+ > returns [JSONSchema]
276
266
  >
277
267
  > Example:
278
268
  >
279
269
  > ```typescript
280
- > const schema: YuppiTypes.Schema = {
270
+ > const schema: Schema = {
281
271
  > display_name: {
282
- > type: "string",
272
+ > type: 'string',
283
273
  > min: 1,
284
274
  > max: 32,
285
275
  > nullable: false,
@@ -287,7 +277,7 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
287
277
  > },
288
278
  >
289
279
  > username: {
290
- > type: "string",
280
+ > type: 'string',
291
281
  > min: 3,
292
282
  > max: 16,
293
283
  > pattern: Patterns.Username,
@@ -296,7 +286,7 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
296
286
  > },
297
287
  >
298
288
  > email: {
299
- > type: "string",
289
+ > type: 'string',
300
290
  > pattern: Patterns.Email,
301
291
  > lowercase: true,
302
292
  > nullable: false,
@@ -1,16 +1,23 @@
1
+ import * as yup from 'yup';
1
2
  import { AnyObject } from './types/AnyObject.type.mjs';
2
3
  import { JSONSchema } from './types/JSONSchema.type.mjs';
3
4
  import { Schema } from './types/Schema.type.mjs';
4
5
  import { YuppiOptions } from './types/YuppiOptions.type.mjs';
5
- import 'yup';
6
6
  import '@sinclair/typebox';
7
7
  import './types/ValidateOptions.type.mjs';
8
8
 
9
9
  declare class Yuppi {
10
10
  private readonly options;
11
11
  constructor(options?: YuppiOptions);
12
- validate(schema: Schema, properties: AnyObject): AnyObject;
13
- convertToYup(schema: Schema): AnyObject;
12
+ validate(schema: Schema, properties: AnyObject): {
13
+ [x: string]: any;
14
+ [x: number]: any;
15
+ };
16
+ convertToYup(schema: Schema): yup.ObjectSchema<{
17
+ [x: string]: any;
18
+ }, yup.AnyObject, {
19
+ [x: string]: any;
20
+ }, "">;
14
21
  convertToJSONSchema(schema: Schema): JSONSchema;
15
22
  }
16
23
 
@@ -1,16 +1,23 @@
1
+ import * as yup from 'yup';
1
2
  import { AnyObject } from './types/AnyObject.type.js';
2
3
  import { JSONSchema } from './types/JSONSchema.type.js';
3
4
  import { Schema } from './types/Schema.type.js';
4
5
  import { YuppiOptions } from './types/YuppiOptions.type.js';
5
- import 'yup';
6
6
  import '@sinclair/typebox';
7
7
  import './types/ValidateOptions.type.js';
8
8
 
9
9
  declare class Yuppi {
10
10
  private readonly options;
11
11
  constructor(options?: YuppiOptions);
12
- validate(schema: Schema, properties: AnyObject): AnyObject;
13
- convertToYup(schema: Schema): AnyObject;
12
+ validate(schema: Schema, properties: AnyObject): {
13
+ [x: string]: any;
14
+ [x: number]: any;
15
+ };
16
+ convertToYup(schema: Schema): yup.ObjectSchema<{
17
+ [x: string]: any;
18
+ }, yup.AnyObject, {
19
+ [x: string]: any;
20
+ }, "">;
14
21
  convertToJSONSchema(schema: Schema): JSONSchema;
15
22
  }
16
23
 
package/dist/main.d.mts CHANGED
@@ -1,13 +1,12 @@
1
1
  export { Yuppi } from './Yuppi.class.mjs';
2
2
  export { P as Patterns } from './Patterns.barrel-D-k3IHDq.mjs';
3
- export { T as Types } from './Types.barrel--XGUUjIp.mjs';
4
- import './types/AnyObject.type.mjs';
3
+ export { AnyObject } from './types/AnyObject.type.mjs';
4
+ export { JSONSchema } from './types/JSONSchema.type.mjs';
5
+ export { Schema } from './types/Schema.type.mjs';
6
+ export { ValidateOptions } from './types/ValidateOptions.type.mjs';
7
+ export { ValidationError } from './types/ValidationError.type.mjs';
8
+ export { YuppiOptions } from './types/YuppiOptions.type.mjs';
5
9
  import 'yup';
6
- import './types/JSONSchema.type.mjs';
7
- import '@sinclair/typebox';
8
- import './types/Schema.type.mjs';
9
- import './types/YuppiOptions.type.mjs';
10
- import './types/ValidateOptions.type.mjs';
11
10
  import './patterns/Any.pattern.mjs';
12
11
  import './patterns/Domain.pattern.mjs';
13
12
  import './patterns/Email.pattern.mjs';
@@ -15,4 +14,4 @@ import './patterns/HTTP.pattern.mjs';
15
14
  import './patterns/PhoneNumber.pattern.mjs';
16
15
  import './patterns/URI.pattern.mjs';
17
16
  import './patterns/Username.pattern.mjs';
18
- import './types/ValidationError.type.mjs';
17
+ import '@sinclair/typebox';
package/dist/main.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  export { Yuppi } from './Yuppi.class.js';
2
2
  export { P as Patterns } from './Patterns.barrel-JdN3lL2Q.js';
3
- export { T as Types } from './Types.barrel-wzQq8e9v.js';
4
- import './types/AnyObject.type.js';
3
+ export { AnyObject } from './types/AnyObject.type.js';
4
+ export { JSONSchema } from './types/JSONSchema.type.js';
5
+ export { Schema } from './types/Schema.type.js';
6
+ export { ValidateOptions } from './types/ValidateOptions.type.js';
7
+ export { ValidationError } from './types/ValidationError.type.js';
8
+ export { YuppiOptions } from './types/YuppiOptions.type.js';
5
9
  import 'yup';
6
- import './types/JSONSchema.type.js';
7
- import '@sinclair/typebox';
8
- import './types/Schema.type.js';
9
- import './types/YuppiOptions.type.js';
10
- import './types/ValidateOptions.type.js';
11
10
  import './patterns/Any.pattern.js';
12
11
  import './patterns/Domain.pattern.js';
13
12
  import './patterns/Email.pattern.js';
@@ -15,4 +14,4 @@ import './patterns/HTTP.pattern.js';
15
14
  import './patterns/PhoneNumber.pattern.js';
16
15
  import './patterns/URI.pattern.js';
17
16
  import './patterns/Username.pattern.js';
18
- import './types/ValidationError.type.js';
17
+ import '@sinclair/typebox';
@@ -5,7 +5,7 @@ type Base = {
5
5
  required: boolean;
6
6
  };
7
7
  type String = Base & {
8
- type: "string";
8
+ type: 'string';
9
9
  enum?: string[];
10
10
  min?: number;
11
11
  max?: number;
@@ -13,7 +13,7 @@ type String = Base & {
13
13
  uppercase?: boolean;
14
14
  };
15
15
  type Number = Base & {
16
- type: "number";
16
+ type: 'number';
17
17
  enum?: number[];
18
18
  min?: number;
19
19
  max?: number;
@@ -22,26 +22,24 @@ type Number = Base & {
22
22
  negative?: boolean;
23
23
  };
24
24
  type Boolean = Base & {
25
- type: "boolean";
25
+ type: 'boolean';
26
26
  };
27
27
  type Date = Base & {
28
- type: "date";
28
+ type: 'date';
29
29
  min?: string;
30
30
  max?: string;
31
31
  };
32
32
  type Object$1 = Base & {
33
- type: "object";
33
+ type: 'object';
34
34
  properties: Schema;
35
35
  };
36
36
  type Array = Base & {
37
- type: "array";
37
+ type: 'array';
38
38
  min?: number;
39
39
  max?: number;
40
40
  items: Types;
41
41
  };
42
42
  type Types = String | Number | Boolean | Date | Object$1 | Array;
43
- type Schema = {
44
- [key: string]: Types;
45
- };
43
+ type Schema = Record<string, Types>;
46
44
 
47
45
  export type { Array, Base, Boolean, Date, Number, Object$1 as Object, Schema, String, Types };
@@ -5,7 +5,7 @@ type Base = {
5
5
  required: boolean;
6
6
  };
7
7
  type String = Base & {
8
- type: "string";
8
+ type: 'string';
9
9
  enum?: string[];
10
10
  min?: number;
11
11
  max?: number;
@@ -13,7 +13,7 @@ type String = Base & {
13
13
  uppercase?: boolean;
14
14
  };
15
15
  type Number = Base & {
16
- type: "number";
16
+ type: 'number';
17
17
  enum?: number[];
18
18
  min?: number;
19
19
  max?: number;
@@ -22,26 +22,24 @@ type Number = Base & {
22
22
  negative?: boolean;
23
23
  };
24
24
  type Boolean = Base & {
25
- type: "boolean";
25
+ type: 'boolean';
26
26
  };
27
27
  type Date = Base & {
28
- type: "date";
28
+ type: 'date';
29
29
  min?: string;
30
30
  max?: string;
31
31
  };
32
32
  type Object$1 = Base & {
33
- type: "object";
33
+ type: 'object';
34
34
  properties: Schema;
35
35
  };
36
36
  type Array = Base & {
37
- type: "array";
37
+ type: 'array';
38
38
  min?: number;
39
39
  max?: number;
40
40
  items: Types;
41
41
  };
42
42
  type Types = String | Number | Boolean | Date | Object$1 | Array;
43
- type Schema = {
44
- [key: string]: Types;
45
- };
43
+ type Schema = Record<string, Types>;
46
44
 
47
45
  export type { Array, Base, Boolean, Date, Number, Object$1 as Object, Schema, String, Types };
@@ -1,6 +1,7 @@
1
+ import * as yup from 'yup';
1
2
  import { TObject } from '@sinclair/typebox';
2
3
  import { Schema } from '../types/Schema.type.mjs';
3
4
 
4
- declare const convertToJSONSchema: (schema: Schema) => TObject;
5
+ declare const convertToJSONSchema: (schema: Schema) => TObject<yup.AnyObject>;
5
6
 
6
7
  export { convertToJSONSchema };
@@ -1,6 +1,7 @@
1
+ import * as yup from 'yup';
1
2
  import { TObject } from '@sinclair/typebox';
2
3
  import { Schema } from '../types/Schema.type.js';
3
4
 
4
- declare const convertToJSONSchema: (schema: Schema) => TObject;
5
+ declare const convertToJSONSchema: (schema: Schema) => TObject<yup.AnyObject>;
5
6
 
6
7
  export { convertToJSONSchema };
@@ -1,9 +1,12 @@
1
- import { AnyObject } from '../types/AnyObject.type.mjs';
1
+ import * as yup from 'yup';
2
2
  import { Schema } from '../types/Schema.type.mjs';
3
3
  import { YuppiOptions } from '../types/YuppiOptions.type.mjs';
4
- import 'yup';
5
4
  import '../types/ValidateOptions.type.mjs';
6
5
 
7
- declare const convertToYup: (schema: Schema, error_messages: YuppiOptions["error_messages"]) => AnyObject;
6
+ declare const convertToYup: (schema: Schema, error_messages: YuppiOptions["error_messages"]) => yup.ObjectSchema<{
7
+ [x: string]: any;
8
+ }, yup.AnyObject, {
9
+ [x: string]: any;
10
+ }, "">;
8
11
 
9
12
  export { convertToYup };
@@ -1,9 +1,12 @@
1
- import { AnyObject } from '../types/AnyObject.type.js';
1
+ import * as yup from 'yup';
2
2
  import { Schema } from '../types/Schema.type.js';
3
3
  import { YuppiOptions } from '../types/YuppiOptions.type.js';
4
- import 'yup';
5
4
  import '../types/ValidateOptions.type.js';
6
5
 
7
- declare const convertToYup: (schema: Schema, error_messages: YuppiOptions["error_messages"]) => AnyObject;
6
+ declare const convertToYup: (schema: Schema, error_messages: YuppiOptions["error_messages"]) => yup.ObjectSchema<{
7
+ [x: string]: any;
8
+ }, yup.AnyObject, {
9
+ [x: string]: any;
10
+ }, "">;
8
11
 
9
12
  export { convertToYup };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuppi",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Schemas that can be converted to Yup and JSON Schema.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/keift/yuppi",
@@ -10,8 +10,8 @@
10
10
  "types": "./dist/main.d.ts",
11
11
  "scripts": {
12
12
  "tests": "bun run lint && bun test",
13
- "prettier": "prettier --write ./",
14
13
  "build": "tsup",
14
+ "prettier": "prettier --write ./",
15
15
  "lint": "eslint ./"
16
16
  },
17
17
  "dependencies": {
@@ -21,7 +21,7 @@
21
21
  "yup": "^1.7.0"
22
22
  },
23
23
  "devDependencies": {
24
- "neatlint": "^1.0.0",
24
+ "neatlint": "^1.1.6",
25
25
  "prettier": "^3.6.2",
26
26
  "tsup": "^8.5.0"
27
27
  },
@@ -1,18 +0,0 @@
1
- import { AnyObject } from './types/AnyObject.type.mjs';
2
- import { JSONSchema } from './types/JSONSchema.type.mjs';
3
- import { Schema } from './types/Schema.type.mjs';
4
- import { ValidateOptions } from './types/ValidateOptions.type.mjs';
5
- import { ValidationError } from './types/ValidationError.type.mjs';
6
- import { YuppiOptions } from './types/YuppiOptions.type.mjs';
7
-
8
- declare const Types_barrel_AnyObject: typeof AnyObject;
9
- declare const Types_barrel_JSONSchema: typeof JSONSchema;
10
- declare const Types_barrel_Schema: typeof Schema;
11
- declare const Types_barrel_ValidateOptions: typeof ValidateOptions;
12
- declare const Types_barrel_ValidationError: typeof ValidationError;
13
- declare const Types_barrel_YuppiOptions: typeof YuppiOptions;
14
- declare namespace Types_barrel {
15
- export { Types_barrel_AnyObject as AnyObject, Types_barrel_JSONSchema as JSONSchema, Types_barrel_Schema as Schema, Types_barrel_ValidateOptions as ValidateOptions, Types_barrel_ValidationError as ValidationError, Types_barrel_YuppiOptions as YuppiOptions };
16
- }
17
-
18
- export { Types_barrel as T };
@@ -1,18 +0,0 @@
1
- import { AnyObject } from './types/AnyObject.type.js';
2
- import { JSONSchema } from './types/JSONSchema.type.js';
3
- import { Schema } from './types/Schema.type.js';
4
- import { ValidateOptions } from './types/ValidateOptions.type.js';
5
- import { ValidationError } from './types/ValidationError.type.js';
6
- import { YuppiOptions } from './types/YuppiOptions.type.js';
7
-
8
- declare const Types_barrel_AnyObject: typeof AnyObject;
9
- declare const Types_barrel_JSONSchema: typeof JSONSchema;
10
- declare const Types_barrel_Schema: typeof Schema;
11
- declare const Types_barrel_ValidateOptions: typeof ValidateOptions;
12
- declare const Types_barrel_ValidationError: typeof ValidationError;
13
- declare const Types_barrel_YuppiOptions: typeof YuppiOptions;
14
- declare namespace Types_barrel {
15
- export { Types_barrel_AnyObject as AnyObject, Types_barrel_JSONSchema as JSONSchema, Types_barrel_Schema as Schema, Types_barrel_ValidateOptions as ValidateOptions, Types_barrel_ValidationError as ValidationError, Types_barrel_YuppiOptions as YuppiOptions };
16
- }
17
-
18
- export { Types_barrel as T };