Skip to content

Commit

Permalink
chore: generate types
Browse files Browse the repository at this point in the history
  • Loading branch information
konker committed Dec 19, 2023
1 parent 376b864 commit de04b0d
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schemas.maas.global/maas-backend/customers/personalDataCatalogue.json",
"description": "MaaS customer personal data catalogue schema",
"$id": "https://schemas.maas.global/maas-backend/customers/personalDataCatalog.json",
"description": "MaaS customer personal data catalog schema",
"definitions": {
"regionRestriction": {
"type": "array",
Expand All @@ -24,17 +24,18 @@
"type": "string"
}
}
}
},
"required": ["name"]
},
"personalDataCatalogueItem": {
"personalDataCatalogItem": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["string", "ISODate", "email", "phone", "locale"]
"enum": ["string", "ISODate", "ISODatetime", "ISOCountryAlpha2"]
},
"enum": {
"type": "array",
Expand All @@ -47,21 +48,17 @@
"type": "boolean",
"description": "True if the client should show the value in plain text. False if the value should be obfuscated."
},
"isReadOnly": {
"type": "boolean",
"description": "True if the item is read-only. False if the item can be edited."
},
"description": {
"type": "string"
},
"regionRestriction": {
"$ref": "#/definitions/regionRestriction"
},
"dependsOn": {
"$ref": "#/definitions/dependsOnRestriction"
"type": "array",
"items": {
"$ref": "#/definitions/dependsOnRestriction"
}
}
},
"required": ["name", "type", "canShowPlain", "isReadOnly"],
"required": ["name", "type", "canShowPlain"],
"additionalProperties": false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"customer": {
"$ref": "https://schemas.maas.global/maas-backend/customers/customer.json"
},
"personalDataCatalogue": {
"personalDataCatalog": {
"type": "array",
"items": {
"$ref": "https://schemas.maas.global/maas-backend/customers/personalDataCatalogue.json#/definitions/personalDataCatalogueItem"
"$ref": "https://schemas.maas.global/maas-backend/customers/personalDataCatalog.json#/definitions/personalDataCatalogItem"
}
}
},
"additionalProperties": false,
"required": ["customer", "personalDataCatalogue"]
"required": ["customer", "personalDataCatalog"]
}
1 change: 1 addition & 0 deletions maas-schemas/src/ajv/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const registry: mjsv.Registry = {
require('../../schemas/maas-backend/customers/personal-documents/update/request.json'),
require('../../schemas/maas-backend/customers/personal-documents/update/response.json'),
require('../../schemas/maas-backend/customers/personalData.json'),
require('../../schemas/maas-backend/customers/personalDataCatalog.json'),
require('../../schemas/maas-backend/customers/retrieve/request.json'),
require('../../schemas/maas-backend/customers/retrieve/response.json'),
require('../../schemas/maas-backend/customers/stats/request.json'),
Expand Down
14 changes: 14 additions & 0 deletions maas-schemas/src/io-ts/_translation.log
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,20 @@ INFO: missing description
in schemas/maas-backend/customers/personalData.json
INFO: missing description
in schemas/maas-backend/customers/personalData.json
INFO: primitive type "string" used outside top-level definitions
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: primitive type "string" used outside top-level definitions
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: primitive type "string" used outside top-level definitions
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: primitive type "string" used outside top-level definitions
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: primitive type "string" used outside top-level definitions
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: missing description
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: missing description
in schemas/maas-backend/customers/personalDataCatalog.json
INFO: primitive type "integer" used outside top-level definitions
in schemas/maas-backend/customers/stats/response.json
WARNING: minimum field not supported outside top-level definitions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
/*
undefined
MaaS customer personal data catalog schema
!!! AUTO GENERATED BY IOTSFJS REFRAIN FROM MANUAL EDITING !!!
See https://www.npmjs.com/package/io-ts-from-json-schema
*/

import * as t from 'io-ts';

import * as Region_ad49_ from '../../core/region';

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/maas-backend/customers/personalDataCatalog.json';

// RegionRestriction
// Restrict to the specified list of regions
export type RegionRestriction = t.Branded<
Array<Region_ad49_.RegionId>,
RegionRestrictionBrand
>;
export type RegionRestrictionC = t.BrandC<
t.ArrayC<typeof Region_ad49_.RegionId>,
RegionRestrictionBrand
>;
export const RegionRestriction: RegionRestrictionC = t.brand(
t.array(Region_ad49_.RegionId),
(x): x is t.Branded<Array<Region_ad49_.RegionId>, RegionRestrictionBrand> => true,
'RegionRestriction',
);
export type RegionRestrictionBrand = {
readonly RegionRestriction: unique symbol;
};

// DependsOnRestriction
// The purpose of this remains a mystery
export type DependsOnRestriction = t.Branded<
({
name?: string;
values?: Array<string>;
} & Record<string, unknown>) & {
name: Defined;
},
DependsOnRestrictionBrand
>;
export type DependsOnRestrictionC = t.BrandC<
t.IntersectionC<
[
t.IntersectionC<
[
t.PartialC<{
name: t.StringC;
values: t.ArrayC<t.StringC>;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>,
t.TypeC<{
name: typeof Defined;
}>,
]
>,
DependsOnRestrictionBrand
>;
export const DependsOnRestriction: DependsOnRestrictionC = t.brand(
t.intersection([
t.intersection([
t.partial({
name: t.string,
values: t.array(t.string),
}),
t.record(t.string, t.unknown),
]),
t.type({
name: Defined,
}),
]),
(
x,
): x is t.Branded<
({
name?: string;
values?: Array<string>;
} & Record<string, unknown>) & {
name: Defined;
},
DependsOnRestrictionBrand
> => true,
'DependsOnRestriction',
);
export type DependsOnRestrictionBrand = {
readonly DependsOnRestriction: unique symbol;
};

// PersonalDataCatalogItem
// The purpose of this remains a mystery
export type PersonalDataCatalogItem = t.Branded<
{
name?: string;
type?: string & ('string' | 'ISODate' | 'ISODatetime' | 'ISOCountryAlpha2');
enum?: Array<string>;
canShowPlain?: boolean;
regionRestriction?: RegionRestriction;
dependsOn?: Array<DependsOnRestriction>;
} & {
name: Defined;
type: Defined;
canShowPlain: Defined;
},
PersonalDataCatalogItemBrand
>;
export type PersonalDataCatalogItemC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
name: t.StringC;
type: t.IntersectionC<
[
t.StringC,
t.UnionC<
[
t.LiteralC<'string'>,
t.LiteralC<'ISODate'>,
t.LiteralC<'ISODatetime'>,
t.LiteralC<'ISOCountryAlpha2'>,
]
>,
]
>;
enum: t.ArrayC<t.StringC>;
canShowPlain: t.BooleanC;
regionRestriction: typeof RegionRestriction;
dependsOn: t.ArrayC<typeof DependsOnRestriction>;
}>,
t.TypeC<{
name: typeof Defined;
type: typeof Defined;
canShowPlain: typeof Defined;
}>,
]
>,
PersonalDataCatalogItemBrand
>;
export const PersonalDataCatalogItem: PersonalDataCatalogItemC = t.brand(
t.intersection([
t.partial({
name: t.string,
type: t.intersection([
t.string,
t.union([
t.literal('string'),
t.literal('ISODate'),
t.literal('ISODatetime'),
t.literal('ISOCountryAlpha2'),
]),
]),
enum: t.array(t.string),
canShowPlain: t.boolean,
regionRestriction: RegionRestriction,
dependsOn: t.array(DependsOnRestriction),
}),
t.type({
name: Defined,
type: Defined,
canShowPlain: Defined,
}),
]),
(
x,
): x is t.Branded<
{
name?: string;
type?: string & ('string' | 'ISODate' | 'ISODatetime' | 'ISOCountryAlpha2');
enum?: Array<string>;
canShowPlain?: boolean;
regionRestriction?: RegionRestriction;
dependsOn?: Array<DependsOnRestriction>;
} & {
name: Defined;
type: Defined;
canShowPlain: Defined;
},
PersonalDataCatalogItemBrand
> => true,
'PersonalDataCatalogItem',
);
export type PersonalDataCatalogItemBrand = {
readonly PersonalDataCatalogItem: unique symbol;
};

// PersonalDataCatalog
// The default export. More information at the top.
export type PersonalDataCatalog = t.Branded<unknown, PersonalDataCatalogBrand>;
export type PersonalDataCatalogC = t.BrandC<t.UnknownC, PersonalDataCatalogBrand>;
export const PersonalDataCatalog: PersonalDataCatalogC = t.brand(
t.unknown,
(x): x is t.Branded<unknown, PersonalDataCatalogBrand> => true,
'PersonalDataCatalog',
);
export type PersonalDataCatalogBrand = {
readonly PersonalDataCatalog: unique symbol;
};

export default PersonalDataCatalog;

// Success
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See https://www.npmjs.com/package/io-ts-from-json-schema
import * as t from 'io-ts';

import * as Customer_1cb6_ from '../customer';
import * as PersonalDataCatalog_96ca_ from '../personalDataCatalog';

export type Defined = {} | null;
export class DefinedType extends t.Type<Defined> {
Expand All @@ -35,8 +36,10 @@ export const schemaId =
export type Response = t.Branded<
{
customer?: Customer_1cb6_.Customer;
personalDataCatalog?: Array<PersonalDataCatalog_96ca_.PersonalDataCatalogItem>;
} & {
customer: Defined;
personalDataCatalog: Defined;
},
ResponseBrand
>;
Expand All @@ -45,9 +48,13 @@ export type ResponseC = t.BrandC<
[
t.PartialC<{
customer: typeof Customer_1cb6_.Customer;
personalDataCatalog: t.ArrayC<
typeof PersonalDataCatalog_96ca_.PersonalDataCatalogItem
>;
}>,
t.TypeC<{
customer: typeof Defined;
personalDataCatalog: typeof Defined;
}>,
]
>,
Expand All @@ -57,18 +64,22 @@ export const Response: ResponseC = t.brand(
t.intersection([
t.partial({
customer: Customer_1cb6_.Customer,
personalDataCatalog: t.array(PersonalDataCatalog_96ca_.PersonalDataCatalogItem),
}),
t.type({
customer: Defined,
personalDataCatalog: Defined,
}),
]),
(
x,
): x is t.Branded<
{
customer?: Customer_1cb6_.Customer;
personalDataCatalog?: Array<PersonalDataCatalog_96ca_.PersonalDataCatalogItem>;
} & {
customer: Defined;
personalDataCatalog: Defined;
},
ResponseBrand
> => true,
Expand Down
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/maas-backend/customers/personalDataCatalog';

0 comments on commit de04b0d

Please sign in to comment.