Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
konker committed Aug 24, 2020
1 parent b032d93 commit 035ce7e
Show file tree
Hide file tree
Showing 9 changed files with 484 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.5.3",
"name": "@maasglobal/maas-schemas-ts",
"publishConfig": {
"registry": "https://npm.deployment.maas.global/repository/npm-maas/"
},
"version": "14.6.0-rc2",
"description": "TypeScript types and io-ts validators for maas-schemas",
"main": "index.js",
"files": [
Expand Down
158 changes: 158 additions & 0 deletions maas-schemas-ts/src/aws/s3/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
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 const S3Event = 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
71 changes: 71 additions & 0 deletions maas-schemas-ts/src/aws/sns/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
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 const SnsNotification = 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
14 changes: 14 additions & 0 deletions maas-schemas-ts/src/core/components/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ 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 const IsoDateTime = 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
54 changes: 54 additions & 0 deletions maas-schemas-ts/translation.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
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
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
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
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
WARNING: skipping examples handling for $ref object
in ../maas-schemas/schemas/core/booking.json
WARNING: skipping default value handling for $ref object
Expand Down
10 changes: 7 additions & 3 deletions maas-schemas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "maas-schemas",
"version": "14.5.3",
"name": "@maasglobal/maas-schemas",
"publishConfig": {
"registry": "https://npm.deployment.maas.global/repository/npm-maas/"
},
"version": "14.6.0-rc2",
"description": "Schemas for MaaS infrastructure",
"main": "index.js",
"engine": {
Expand All @@ -19,7 +22,8 @@
"contributors": [
"James Nguyen",
"Klaus Dahlen",
"Lauri Svan"
"Lauri Svan",
"Konrad Markus"
],
"license": "MIT",
"bugs": {
Expand Down
Loading

0 comments on commit 035ce7e

Please sign in to comment.