Skip to content

Commit

Permalink
ts-convert
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuunguyeen committed Dec 12, 2023
1 parent aa9f191 commit e6db6dc
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 0 deletions.
4 changes: 4 additions & 0 deletions maas-schemas/src/ajv/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ export const registry: mjsv.Registry = {
require('../../schemas/tsp/manage/response.json'),
require('../../schemas/tsp/package-create/request.json'),
require('../../schemas/tsp/package-create/response.json'),
require('../../schemas/tsp/payments-initiate/request.json'),
require('../../schemas/tsp/payments-initiate/response.json'),
require('../../schemas/tsp/payments-retrieve/request.json'),
require('../../schemas/tsp/payments-retrieve/response.json'),
require('../../schemas/tsp/post-kyc-verification-update/request.json'),
require('../../schemas/tsp/post-kyc-verification-update/response.json'),
require('../../schemas/tsp/stations-list/request.json'),
Expand Down
18 changes: 18 additions & 0 deletions maas-schemas/src/io-ts/_translation.log
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,24 @@ WARNING: missing $schema declaration
in schemas/tsp/package-create/request.json
WARNING: missing $schema declaration
in schemas/tsp/package-create/response.json
WARNING: missing $schema declaration
in schemas/tsp/payments-initiate/request.json
INFO: primitive type "number" used outside top-level definitions
in schemas/tsp/payments-initiate/request.json
WARNING: missing $schema declaration
in schemas/tsp/payments-initiate/response.json
INFO: primitive type "number" used outside top-level definitions
in schemas/tsp/payments-initiate/response.json
INFO: primitive type "string" used outside top-level definitions
in schemas/tsp/payments-initiate/response.json
WARNING: missing $schema declaration
in schemas/tsp/payments-retrieve/request.json
WARNING: missing $schema declaration
in schemas/tsp/payments-retrieve/response.json
INFO: primitive type "number" used outside top-level definitions
in schemas/tsp/payments-retrieve/response.json
INFO: primitive type "string" used outside top-level definitions
in schemas/tsp/payments-retrieve/response.json
WARNING: missing $schema declaration
in schemas/tsp/post-kyc-verification-update/request.json
INFO: primitive type "string" used outside top-level definitions
Expand Down
108 changes: 108 additions & 0 deletions maas-schemas/src/io-ts/_types/tsp/payments-initiate/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
undefined
Response schema for creating payment through TSP api
!!! AUTO GENERATED BY IOTSFJS REFRAIN FROM MANUAL EDITING !!!
See https://www.npmjs.com/package/io-ts-from-json-schema
*/

import { NonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
import * as t from 'io-ts';
import { nonEmptyArray } from 'io-ts-types/lib/nonEmptyArray';

import * as Booking_4353_ from '../../core/booking';

export type Defined = {} | null;
export class DefinedType extends t.Type<Defined> {
readonly _tag: 'DefinedType' = 'DefinedType';
constructor() {
super(
'defined',
(u): u is Defined => typeof u !== 'undefined',
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
t.identity,
);
}
}
export type DefinedC = {} & DefinedType;
export const Defined: DefinedC = new DefinedType();

export const schemaId = 'https://schemas.maas.global/tsp/payments-initiate/request.json';

// Response
// The default export. More information at the top.
export type Response = t.Branded<
{
tspId?: Booking_4353_.TspId;
amount?: number;
paymentStatus?: string;
} & {
tspId: Defined;
amount: Defined;
paymentStatus: Defined;
},
ResponseBrand
>;
export type ResponseC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
tspId: typeof Booking_4353_.TspId;
amount: t.NumberC;
paymentStatus: t.StringC;
}>,
t.TypeC<{
tspId: typeof Defined;
amount: typeof Defined;
paymentStatus: typeof Defined;
}>,
]
>,
ResponseBrand
>;
export const Response: ResponseC = t.brand(
t.intersection([
t.partial({
tspId: Booking_4353_.TspId,
amount: t.number,
paymentStatus: t.string,
}),
t.type({
tspId: Defined,
amount: Defined,
paymentStatus: Defined,
}),
]),
(
x,
): x is t.Branded<
{
tspId?: Booking_4353_.TspId;
amount?: number;
paymentStatus?: string;
} & {
tspId: Defined;
amount: Defined;
paymentStatus: Defined;
},
ResponseBrand
> => true,
'Response',
);
export type ResponseBrand = {
readonly Response: unique symbol;
};
/** require('io-ts-validator').validator(nonEmptyArray(Response)).decodeSync(examplesResponse) // => examplesResponse */
export const examplesResponse: NonEmptyArray<Response> = [
{
tspId: '00000000-cafe-cafe-cafe-cafecafecafe',
amount: 2405,
paymentStatus: 'CONFIRMED',
},
] as unknown as NonEmptyArray<Response>;

export default Response;

// Success
108 changes: 108 additions & 0 deletions maas-schemas/src/io-ts/_types/tsp/payments-retrieve/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
undefined
Response schema for retrieving a TSP payment from TSP api
!!! AUTO GENERATED BY IOTSFJS REFRAIN FROM MANUAL EDITING !!!
See https://www.npmjs.com/package/io-ts-from-json-schema
*/

import { NonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
import * as t from 'io-ts';
import { nonEmptyArray } from 'io-ts-types/lib/nonEmptyArray';

import * as Booking_4353_ from '../../core/booking';

export type Defined = {} | null;
export class DefinedType extends t.Type<Defined> {
readonly _tag: 'DefinedType' = 'DefinedType';
constructor() {
super(
'defined',
(u): u is Defined => typeof u !== 'undefined',
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
t.identity,
);
}
}
export type DefinedC = {} & DefinedType;
export const Defined: DefinedC = new DefinedType();

export const schemaId = 'https://schemas.maas.global/tsp/payments-retrieve/request.json';

// Response
// The default export. More information at the top.
export type Response = t.Branded<
{
tspId?: Booking_4353_.TspId;
amount?: number;
paymentStatus?: string;
} & {
tspId: Defined;
amount: Defined;
paymentStatus: Defined;
},
ResponseBrand
>;
export type ResponseC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
tspId: typeof Booking_4353_.TspId;
amount: t.NumberC;
paymentStatus: t.StringC;
}>,
t.TypeC<{
tspId: typeof Defined;
amount: typeof Defined;
paymentStatus: typeof Defined;
}>,
]
>,
ResponseBrand
>;
export const Response: ResponseC = t.brand(
t.intersection([
t.partial({
tspId: Booking_4353_.TspId,
amount: t.number,
paymentStatus: t.string,
}),
t.type({
tspId: Defined,
amount: Defined,
paymentStatus: Defined,
}),
]),
(
x,
): x is t.Branded<
{
tspId?: Booking_4353_.TspId;
amount?: number;
paymentStatus?: string;
} & {
tspId: Defined;
amount: Defined;
paymentStatus: Defined;
},
ResponseBrand
> => true,
'Response',
);
export type ResponseBrand = {
readonly Response: unique symbol;
};
/** require('io-ts-validator').validator(nonEmptyArray(Response)).decodeSync(examplesResponse) // => examplesResponse */
export const examplesResponse: NonEmptyArray<Response> = [
{
tspId: '00000000-cafe-cafe-cafe-cafecafecafe',
amount: 2405,
paymentStatus: 'PENDING',
},
] as unknown as NonEmptyArray<Response>;

export default Response;

// Success
3 changes: 3 additions & 0 deletions maas-schemas/src/io-ts/tsp/payments-initiate/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Generated by update-index.ts Do not edit!

export * from '../../_types/tsp/payments-initiate/request';
3 changes: 3 additions & 0 deletions maas-schemas/src/io-ts/tsp/payments-retrieve/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Generated by update-index.ts Do not edit!

export * from '../../_types/tsp/payments-retrieve/request';

0 comments on commit e6db6dc

Please sign in to comment.