Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
konker committed Jan 8, 2021
1 parent aa2a93b commit a8d182e
Show file tree
Hide file tree
Showing 9 changed files with 550 additions and 5 deletions.
7 changes: 5 additions & 2 deletions maas-schemas-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "maas-schemas-ts",
"version": "14.11.6",
"name": "@maasglobal/maas-schemas-ts",
"publishConfig": {
"registry": "https://npm.deployment.maas.global/repository/npm-maas/"
},
"version": "14.12.0-rc1",
"description": "TypeScript types and io-ts validators for maas-schemas",
"main": "index.js",
"files": [
Expand Down
202 changes: 202 additions & 0 deletions maas-schemas-ts/src/aws/s3/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/*
undefined
AWS S3 Event JSON Payload
!!! 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 Units_ from '../../core/components/units';

export const schemaId = 'http://maasglobal.com/aws/s3/event.json';

// S3Event
// The default export. More information at the top.
export type S3Event = t.Branded<
{
eventVersion?: number;
eventSource?: string & 'aws:s3';
awsRegion?: string;
eventTime?: Units_.IsoDateTime;
eventName?: unknown;
userIdentity?: {
principalId?: string;
};
requestParameters?: {
sourceIPAddress?: string;
};
responseElements?: {
'x-amz-request-id'?: string;
'x-amz-id-2'?: string;
};
s3?: {
s3SchemaVersion?: number;
configurationId?: string;
bucket?: {
name?: string;
ownerIdentity?: {
principalId?: string;
};
arn?: Units_.Arn;
};
object?: {
key?: string;
size?: number;
eTag?: string;
versionId?: string;
sequencer?: string;
};
};
glacierEventData?: {
restoreEventData?: {
lifecycleRestorationExpiryTime?: Units_.IsoDateTime;
lifecycleRestoreStorageClass?: string;
};
};
},
S3EventBrand
>;
export type S3EventC = t.BrandC<
t.PartialC<{
eventVersion: t.NumberC;
eventSource: t.IntersectionC<[t.StringC, t.LiteralC<'aws:s3'>]>;
awsRegion: t.StringC;
eventTime: typeof Units_.IsoDateTime;
eventName: t.UnknownC;
userIdentity: t.PartialC<{
principalId: t.StringC;
}>;
requestParameters: t.PartialC<{
sourceIPAddress: t.StringC;
}>;
responseElements: t.PartialC<{
'x-amz-request-id': t.StringC;
'x-amz-id-2': t.StringC;
}>;
s3: t.PartialC<{
s3SchemaVersion: t.NumberC;
configurationId: t.StringC;
bucket: t.PartialC<{
name: t.StringC;
ownerIdentity: t.PartialC<{
principalId: t.StringC;
}>;
arn: typeof Units_.Arn;
}>;
object: t.PartialC<{
key: t.StringC;
size: t.NumberC;
eTag: t.StringC;
versionId: t.StringC;
sequencer: t.StringC;
}>;
}>;
glacierEventData: t.PartialC<{
restoreEventData: t.PartialC<{
lifecycleRestorationExpiryTime: typeof Units_.IsoDateTime;
lifecycleRestoreStorageClass: t.StringC;
}>;
}>;
}>,
S3EventBrand
>;
export const S3Event: S3EventC = t.brand(
t.partial({
eventVersion: t.number,
eventSource: t.intersection([t.string, t.literal('aws:s3')]),
awsRegion: t.string,
eventTime: Units_.IsoDateTime,
eventName: t.unknown,
userIdentity: t.partial({
principalId: t.string,
}),
requestParameters: t.partial({
sourceIPAddress: t.string,
}),
responseElements: t.partial({
'x-amz-request-id': t.string,
'x-amz-id-2': t.string,
}),
s3: t.partial({
s3SchemaVersion: t.number,
configurationId: t.string,
bucket: t.partial({
name: t.string,
ownerIdentity: t.partial({
principalId: t.string,
}),
arn: Units_.Arn,
}),
object: t.partial({
key: t.string,
size: t.number,
eTag: t.string,
versionId: t.string,
sequencer: t.string,
}),
}),
glacierEventData: t.partial({
restoreEventData: t.partial({
lifecycleRestorationExpiryTime: Units_.IsoDateTime,
lifecycleRestoreStorageClass: t.string,
}),
}),
}),
(
x,
): x is t.Branded<
{
eventVersion?: number;
eventSource?: string & 'aws:s3';
awsRegion?: string;
eventTime?: Units_.IsoDateTime;
eventName?: unknown;
userIdentity?: {
principalId?: string;
};
requestParameters?: {
sourceIPAddress?: string;
};
responseElements?: {
'x-amz-request-id'?: string;
'x-amz-id-2'?: string;
};
s3?: {
s3SchemaVersion?: number;
configurationId?: string;
bucket?: {
name?: string;
ownerIdentity?: {
principalId?: string;
};
arn?: Units_.Arn;
};
object?: {
key?: string;
size?: number;
eTag?: string;
versionId?: string;
sequencer?: string;
};
};
glacierEventData?: {
restoreEventData?: {
lifecycleRestorationExpiryTime?: Units_.IsoDateTime;
lifecycleRestoreStorageClass?: string;
};
};
},
S3EventBrand
> => true,
'S3Event',
);
export interface S3EventBrand {
readonly S3Event: unique symbol;
}

export default S3Event;

// Success
86 changes: 86 additions & 0 deletions maas-schemas-ts/src/aws/sns/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
undefined
AWS SNS Notification JSON Payload
!!! 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 Units_ from '../../core/components/units';

export const schemaId = 'http://maasglobal.com/aws/sns/notification.json';

// SnsNotification
// The default export. More information at the top.
export type SnsNotification = t.Branded<
{
Type?: string & 'Notification';
MessageId?: Units_.Uuid;
TopicArn?: Units_.Arn;
Subject?: string;
Message?: string;
Timestamp?: Units_.IsoDateTime;
SignatureVersion?: number;
Signature?: string;
SigningCertURL?: Units_.Url;
UnsubscribeURL?: Units_.Url;
},
SnsNotificationBrand
>;
export type SnsNotificationC = t.BrandC<
t.PartialC<{
Type: t.IntersectionC<[t.StringC, t.LiteralC<'Notification'>]>;
MessageId: typeof Units_.Uuid;
TopicArn: typeof Units_.Arn;
Subject: t.StringC;
Message: t.StringC;
Timestamp: typeof Units_.IsoDateTime;
SignatureVersion: t.NumberC;
Signature: t.StringC;
SigningCertURL: typeof Units_.Url;
UnsubscribeURL: typeof Units_.Url;
}>,
SnsNotificationBrand
>;
export const SnsNotification: SnsNotificationC = t.brand(
t.partial({
Type: t.intersection([t.string, t.literal('Notification')]),
MessageId: Units_.Uuid,
TopicArn: Units_.Arn,
Subject: t.string,
Message: t.string,
Timestamp: Units_.IsoDateTime,
SignatureVersion: t.number,
Signature: t.string,
SigningCertURL: Units_.Url,
UnsubscribeURL: Units_.Url,
}),
(
x,
): x is t.Branded<
{
Type?: string & 'Notification';
MessageId?: Units_.Uuid;
TopicArn?: Units_.Arn;
Subject?: string;
Message?: string;
Timestamp?: Units_.IsoDateTime;
SignatureVersion?: number;
Signature?: string;
SigningCertURL?: Units_.Url;
UnsubscribeURL?: Units_.Url;
},
SnsNotificationBrand
> => true,
'SnsNotification',
);
export interface SnsNotificationBrand {
readonly SnsNotification: unique symbol;
}

export default SnsNotification;

// Success
15 changes: 15 additions & 0 deletions maas-schemas-ts/src/core/components/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ export interface IsoDateBrand {
readonly IsoDate: unique symbol;
}

// IsoDateTime
// A date in the form YYYY-MM-DDTHH:MM:SS.mmmZ
export type IsoDateTime = t.Branded<string, IsoDateTimeBrand>;
export type IsoDateTimeC = t.BrandC<t.StringC, IsoDateTimeBrand>;
export const IsoDateTime: IsoDateTimeC = t.brand(
t.string,
(x): x is t.Branded<string, IsoDateTimeBrand> =>
typeof x !== 'string' ||
x.match(RegExp('^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z')) !== null,
'IsoDateTime',
);
export interface IsoDateTimeBrand {
readonly IsoDateTime: unique symbol;
}

// Units
// The default export. More information at the top.
export type Units = t.Branded<unknown, UnitsBrand>;
Expand Down
60 changes: 60 additions & 0 deletions maas-schemas-ts/translation.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
INFO: primitive type "number" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: pattern field not supported outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: unexpected key in a $ref object
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: pattern field not supported outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "number" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: pattern field not supported outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: pattern field not supported outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: unexpected key in a $ref object
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "number" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
WARNING: unexpected key in a $ref object
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/s3/s3-event.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
INFO: primitive type "integer" used outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
WARNING: minimum field not supported outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/aws/sns/sns-notification.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/core/booking-option.json
WARNING: minLength field not supported outside top-level definitions
Expand Down
Loading

0 comments on commit a8d182e

Please sign in to comment.