Skip to content

Commit

Permalink
Merge pull request #109 from mrjono1/update-example
Browse files Browse the repository at this point in the history
update example project to version 2
  • Loading branch information
mrjono1 authored Jun 20, 2021
2 parents c99538a + 93edcad commit fd10822
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 130 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"joi": "^17.3.0"
},
"devDependencies": {
"joi-to-typescript": "^1.12.0",
"joi-to-typescript": "^2.0.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
}
Expand Down
39 changes: 20 additions & 19 deletions example/scripts/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { convertFromDirectory } from 'joi-to-typescript';

async function types(): Promise<void> {
console.log('Running joi-to-typescript...');

// Configure your settings here
const result = await convertFromDirectory({
schemaDirectory: './src/schemas',
typeOutputDirectory: './src/interfaces'
});

if (result) {
console.log('Completed joi-to-typescript');
} else {
console.log('Failed to run joi-to-typescrip');
}
}

types();
import { convertFromDirectory } from 'joi-to-typescript';

async function types(): Promise<void> {
console.log('Running joi-to-typescript...');

// Configure your settings here
const result = await convertFromDirectory({
schemaDirectory: './src/schemas',
typeOutputDirectory: './src/interfaces',
debug: true
});

if (result) {
console.log('Completed joi-to-typescript');
} else {
console.log('Failed to run joi-to-typescrip');
}
}

types();
8 changes: 4 additions & 4 deletions example/src/schemas/OneSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import { PersonSchema } from './subDir/PersonSchema';

export const ZebraSchema = Joi.object({
name: Joi.string()
}).label('Zebra');
}).meta({ className: 'Zebra' });

export const ItemSchema = Joi.object({
name: Joi.string().required(),
maleZebra: ZebraSchema.description('Male Zebra'),
femaleZebra: ZebraSchema.description('Female Zebra')
}).label('Item');
}).meta({ className: 'Item' });

export const PeopleSchema = Joi.array()
.items(PersonSchema)
.required()
.label('People')
.meta({ className: 'People' })
.description('A list of People');

export const TestSchema = Joi.object({
name: Joi.string().optional(),
propertyName1: Joi.boolean().required(),
people: PeopleSchema.optional()
})
.label('Test')
.meta({ className: 'Test' })
.description('a test schema definition');
12 changes: 6 additions & 6 deletions example/src/schemas/subDir/AddressSchema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Joi from 'joi';

export const AddressSchema = Joi.object({
addressLineNumber1: Joi.string().required(),
Suburb: Joi.string().required()
}).label('Address');
import Joi from 'joi';

export const AddressSchema = Joi.object({
addressLineNumber1: Joi.string().required(),
Suburb: Joi.string().required()
}).meta({ className: 'Address' });
16 changes: 8 additions & 8 deletions example/src/schemas/subDir/PersonSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Joi from 'joi';
import { AddressSchema } from './AddressSchema';

export const PersonSchema = Joi.object({
firstName: Joi.string().required(),
lastName: Joi.string().required(),
address: AddressSchema.required()
}).label('Person');
import Joi from 'joi';
import { AddressSchema } from './AddressSchema';

export const PersonSchema = Joi.object({
firstName: Joi.string().required(),
lastName: Joi.string().required(),
address: AddressSchema.required()
}).meta({ className: 'Person' });
16 changes: 8 additions & 8 deletions example/src/schemas/subDir2/EmployeeSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Joi from 'joi';
import { PersonSchema } from '../subDir/PersonSchema';
import { ItemSchema } from '../OneSchema';

export const EmployeeSchema = Joi.object({
personalDetails: PersonSchema.required(),
pet: ItemSchema.required()
}).label('Employee');
import Joi from 'joi';
import { PersonSchema } from '../subDir/PersonSchema';
import { ItemSchema } from '../OneSchema';

export const EmployeeSchema = Joi.object({
personalDetails: PersonSchema.required(),
pet: ItemSchema.required()
}).meta({ className: 'Employee' });
168 changes: 84 additions & 84 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,113 @@


"@hapi/hoek@^9.0.0":
"integrity" "sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw=="
"resolved" "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.1.0.tgz"
"version" "9.1.0"
version "9.2.0"
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==

"@hapi/topo@^5.0.0":
"integrity" "sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw=="
"resolved" "https://registry.npmjs.org/@hapi/topo/-/topo-5.0.0.tgz"
"version" "5.0.0"
version "5.0.0"
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7"
integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==
dependencies:
"@hapi/hoek" "^9.0.0"

"@sideway/address@^4.1.0":
"integrity" "sha512-wAH/JYRXeIFQRsxerIuLjgUu2Xszam+O5xKeatJ4oudShOOirfmsQ1D6LL54XOU2tizpCYku+s1wmU0SYdpoSA=="
"resolved" "https://registry.npmjs.org/@sideway/address/-/address-4.1.0.tgz"
"version" "4.1.0"
version "4.1.2"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1"
integrity sha512-idTz8ibqWFrPU8kMirL0CoPH/A29XOzzAzpyN3zQ4kAWnzmNfFmRaoMNN6VI8ske5M73HZyhIaW4OuSFIdM4oA==
dependencies:
"@hapi/hoek" "^9.0.0"

"@sideway/formula@^3.0.0":
"integrity" "sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg=="
"resolved" "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.0.tgz"
"version" "3.0.0"
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==

"@sideway/pinpoint@^2.0.0":
"integrity" "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ=="
"resolved" "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz"
"version" "2.0.0"
version "2.0.0"
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==

"@types/node@^14.14.14":
"integrity" "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
"resolved" "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz"
"version" "14.14.14"

"arg@^4.1.0":
"integrity" "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
"resolved" "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz"
"version" "4.1.3"

"buffer-from@^1.0.0":
"integrity" "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
"resolved" "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz"
"version" "1.1.1"

"create-require@^1.1.0":
"integrity" "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
"resolved" "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
"version" "1.1.1"

"diff@^4.0.1":
"integrity" "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A=="
"resolved" "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz"
"version" "4.0.2"

"joi-to-typescript@^1.12.0":
"integrity" "sha512-XY1lrjHIs8KrZJJtHrP7T1ukN6Itvizd7RnNNATjdlK0M4C+MiMmsrrfePORATp1+qhsf4GeqvPnKKoozaR9Yg=="
"resolved" "https://registry.npmjs.org/joi-to-typescript/-/joi-to-typescript-1.12.0.tgz"
"version" "1.12.0"
version "14.17.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.3.tgz#6d327abaa4be34a74e421ed6409a0ae2f47f4c3d"
integrity sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw==

arg@^4.1.0:
version "4.1.3"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==

buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

create-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==

diff@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==

joi-to-typescript@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/joi-to-typescript/-/joi-to-typescript-2.0.1.tgz#d638f45f9fb6f02da301aea66d46d62f6a12c61c"
integrity sha512-U9ZmJeiFYztzFk42MYwtw/Fwof/vyhP2npq4gl9pLYT/Gam/4a734pKxqENUe1H7kS5iT+k63gWbXAuj6QjVrQ==
dependencies:
"joi" "^17.3.0"
joi "^17.4.0"

"joi@^17.3.0":
"integrity" "sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg=="
"resolved" "https://registry.npmjs.org/joi/-/joi-17.3.0.tgz"
"version" "17.3.0"
joi@^17.3.0, joi@^17.4.0:
version "17.4.0"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.0.tgz#b5c2277c8519e016316e49ababd41a1908d9ef20"
integrity sha512-F4WiW2xaV6wc1jxete70Rw4V/VuMd6IN+a5ilZsxG4uYtUXWu2kq9W5P2dz30e7Gmw8RCbY/u/uk+dMPma9tAg==
dependencies:
"@hapi/hoek" "^9.0.0"
"@hapi/topo" "^5.0.0"
"@sideway/address" "^4.1.0"
"@sideway/formula" "^3.0.0"
"@sideway/pinpoint" "^2.0.0"

"make-error@^1.1.1":
"integrity" "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
"resolved" "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz"
"version" "1.3.6"
make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==

"source-map-support@^0.5.17":
"integrity" "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw=="
"resolved" "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz"
"version" "0.5.19"
source-map-support@^0.5.17:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
dependencies:
"buffer-from" "^1.0.0"
"source-map" "^0.6.0"

"source-map@^0.6.0":
"integrity" "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
"version" "0.6.1"

"ts-node@^9.1.1":
"integrity" "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg=="
"resolved" "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz"
"version" "9.1.1"
buffer-from "^1.0.0"
source-map "^0.6.0"

source-map@^0.6.0:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

ts-node@^9.1.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d"
integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==
dependencies:
"arg" "^4.1.0"
"create-require" "^1.1.0"
"diff" "^4.0.1"
"make-error" "^1.1.1"
"source-map-support" "^0.5.17"
"yn" "3.1.1"

"typescript@^4.1.3", "typescript@>=2.7":
"integrity" "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg=="
"resolved" "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz"
"version" "4.1.3"

"[email protected]":
"integrity" "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q=="
"resolved" "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz"
"version" "3.1.1"
arg "^4.1.0"
create-require "^1.1.0"
diff "^4.0.1"
make-error "^1.1.1"
source-map-support "^0.5.17"
yn "3.1.1"

typescript@^4.1.3:
version "4.3.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==

[email protected]:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

0 comments on commit fd10822

Please sign in to comment.