From a86cedcafa2408a9af23d96cbbdc521635a591d2 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Mon, 27 Jul 2020 14:06:33 -0400 Subject: [PATCH] lib: remove unused event creation functions (#277) This commit removes two functions that are not used. Signed-off-by: Lance Ball --- src/event/spec.ts | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/event/spec.ts b/src/event/spec.ts index 6317130f..afa75681 100644 --- a/src/event/spec.ts +++ b/src/event/spec.ts @@ -1,9 +1,7 @@ import Ajv from "ajv"; -import { v4 as uuidv4 } from "uuid"; import { ValidationError, isBase64 } from "./validation"; -import { CloudEvent } from "./cloudevent"; -import { CloudEventV1, CloudEventV1Attributes, CloudEventV03, CloudEventV03Attributes } from "./interfaces"; +import { CloudEventV1, CloudEventV03 } from "./interfaces"; import { schemaV03, schemaV1 } from "./schemas"; import CONSTANTS from "../constants"; @@ -11,16 +9,6 @@ const ajv = new Ajv({ extendRefs: true }); const isValidAgainstSchemaV1 = ajv.compile(schemaV1); const isValidAgainstSchemaV03 = ajv.compile(schemaV03); -export function createV1(attributes: CloudEventV1Attributes): CloudEventV1 { - const event: CloudEventV1 = { - specversion: schemaV1.definitions.specversion.const, - id: uuidv4(), - time: new Date().toISOString(), - ...attributes, - }; - return new CloudEvent(event); -} - export function validateV1(event: CloudEventV1): boolean { if (!isValidAgainstSchemaV1(event)) { throw new ValidationError("invalid payload", isValidAgainstSchemaV1.errors); @@ -28,16 +16,6 @@ export function validateV1(event: CloudEventV1): boolean { return true; } -export function createV03(attributes: CloudEventV03Attributes): CloudEventV03 { - const event: CloudEventV03 = { - specversion: schemaV03.definitions.specversion.const, - id: uuidv4(), - time: new Date().toISOString(), - ...attributes, - }; - return new CloudEvent(event); -} - export function validateV03(event: CloudEventV03): boolean { if (!isValidAgainstSchemaV03(event)) { throw new ValidationError("invalid payload", isValidAgainstSchemaV03.errors);