From c495c40e33447908a20e20d8ec6b73fee51a17c2 Mon Sep 17 00:00:00 2001
From: Grant Timmerman <744973+grant@users.noreply.github.com>
Date: Wed, 1 Dec 2021 16:15:01 -0800
Subject: [PATCH 1/5] Revert "Revert "refactor: use cesdk (#391)" (#399)"
This reverts commit ad756583eabc06b220af54d6e44734742be29785.
---
docs/generated/api.json | 288 +-----------------
docs/generated/api.md | 21 +-
package-lock.json | 28 +-
package.json | 1 +
src/cloud_event_types/cloud_events_context.ts | 63 ----
src/cloud_events.ts | 12 +-
src/function_wrappers.ts | 4 +-
src/functions.ts | 13 +-
test/function_wrappers.ts | 7 +-
test/integration/cloud_event.ts | 3 +-
10 files changed, 45 insertions(+), 395 deletions(-)
delete mode 100644 src/cloud_event_types/cloud_events_context.ts
diff --git a/docs/generated/api.json b/docs/generated/api.json
index 1d5bc428..4674aed7 100644
--- a/docs/generated/api.json
+++ b/docs/generated/api.json
@@ -223,8 +223,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
@@ -282,8 +282,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
@@ -333,282 +333,6 @@
],
"extendsTokenRanges": []
},
- {
- "kind": "Interface",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface",
- "docComment": "/**\n * The CloudEvents v1.0 context attributes. {@link https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#context-attributes}\n *\n * @public\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "export interface CloudEventsContext "
- }
- ],
- "releaseTag": "Public",
- "name": "CloudEventsContext",
- "members": [
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#data:member",
- "docComment": "/**\n * The event payload.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "data?: "
- },
- {
- "kind": "Content",
- "text": "any"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "data",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#datacontenttype:member",
- "docComment": "/**\n * Content type of the event data.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "datacontenttype?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "datacontenttype",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#dataschema:member",
- "docComment": "/**\n * A link to the schema that the event data adheres to.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "dataschema?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "dataschema",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#id:member",
- "docComment": "/**\n * ID of the event.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "id: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "id",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#source:member",
- "docComment": "/**\n * The event producer.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "source: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "source",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#specversion:member",
- "docComment": "/**\n * The version of the CloudEvents specification which the event uses.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "specversion: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "specversion",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#subject:member",
- "docComment": "/**\n * Describes the subject of the event in the context of the event producer.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "subject?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "subject",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#time:member",
- "docComment": "/**\n * Timestamp of when the event happened.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "time?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "time",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#traceparent:member",
- "docComment": "/**\n * The traceparent string, containing a trace version, trace ID, span ID, and trace options.\n *\n * @see\n *\n * https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "traceparent?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "traceparent",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#type:member",
- "docComment": "/**\n * Type of occurrence which has happened.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "type: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "type",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- }
- ],
- "extendsTokenRanges": []
- },
{
"kind": "Interface",
"canonicalReference": "@google-cloud/functions-framework!CloudFunctionsContext:interface",
@@ -749,8 +473,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
diff --git a/docs/generated/api.md b/docs/generated/api.md
index 62d90ee2..3b34f26c 100644
--- a/docs/generated/api.md
+++ b/docs/generated/api.md
@@ -6,6 +6,7 @@
///
+import { CloudEvent } from 'cloudevents';
import * as express from 'express';
// @public
@@ -14,27 +15,13 @@ export const cloudEvent: (functionName: string, handler: CloudEventFunction) =>
// @public
export interface CloudEventFunction {
// (undocumented)
- (cloudEvent: CloudEventsContext): any;
+ (cloudEvent: CloudEvent): any;
}
// @public
export interface CloudEventFunctionWithCallback {
// (undocumented)
- (cloudEvent: CloudEventsContext, callback: Function): any;
-}
-
-// @public
-export interface CloudEventsContext {
- data?: any;
- datacontenttype?: string;
- dataschema?: string;
- id: string;
- source: string;
- specversion: string;
- subject?: string;
- time?: string;
- traceparent?: string;
- type: string;
+ (cloudEvent: CloudEvent, callback: Function): any;
}
// @public
@@ -48,7 +35,7 @@ export interface CloudFunctionsContext {
}
// @public
-export type Context = CloudFunctionsContext | CloudEventsContext;
+export type Context = CloudFunctionsContext | CloudEvent;
// @public
export interface Data {
diff --git a/package-lock.json b/package-lock.json
index ba88c01c..add5e93f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -635,7 +635,6 @@
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
- "dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -1025,6 +1024,15 @@
"mimic-response": "^1.0.0"
}
},
+ "cloudevents": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/cloudevents/-/cloudevents-5.0.0.tgz",
+ "integrity": "sha512-ximOtbqCaOfSAqkkP0AwG5nIunNuCzNEADXVNW9FSmmOCDxab234NOpJsZovMx6j/COo2p3hwGDcbSS8LN/l1w==",
+ "requires": {
+ "ajv": "~6.12.3",
+ "uuid": "~8.3.0"
+ }
+ },
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@@ -1710,8 +1718,7 @@
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
- "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
- "dev": true
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"fast-diff": {
"version": "1.2.0",
@@ -1735,8 +1742,7 @@
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
- "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
- "dev": true
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"fast-levenshtein": {
"version": "2.0.6",
@@ -2483,8 +2489,7 @@
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
- "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
- "dev": true
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
},
"json-stable-stringify-without-jsonify": {
"version": "1.0.1",
@@ -3394,8 +3399,7 @@
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
- "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
- "dev": true
+ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"pupa": {
"version": "2.1.1",
@@ -4274,7 +4278,6 @@
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
- "dev": true,
"requires": {
"punycode": "^2.1.0"
}
@@ -4299,6 +4302,11 @@
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
+ "uuid": {
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
+ },
"v8-compile-cache": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
diff --git a/package.json b/package.json
index d894a696..09ad7fa6 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
},
"dependencies": {
"body-parser": "^1.18.3",
+ "cloudevents": "^5.0.0",
"express": "^4.16.4",
"minimist": "^1.2.5",
"on-finished": "^2.3.0",
diff --git a/src/cloud_event_types/cloud_events_context.ts b/src/cloud_event_types/cloud_events_context.ts
deleted file mode 100644
index 4685d1f1..00000000
--- a/src/cloud_event_types/cloud_events_context.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * The CloudEvents v1.0 context attributes.
- * {@link https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#context-attributes}
- * @public
- */
-export interface CloudEventsContext {
- /**
- * ID of the event.
- */
- id: string;
- /**
- * The event producer.
- */
- source: string;
- /**
- * The version of the CloudEvents specification which the event uses.
- */
- specversion: string;
- /**
- * Type of occurrence which has happened.
- */
- type: string;
- /**
- * Timestamp of when the event happened.
- */
- time?: string;
- /**
- * Describes the subject of the event in the context of the event producer.
- */
- subject?: string;
- /**
- * A link to the schema that the event data adheres to.
- */
- dataschema?: string;
- /**
- * Content type of the event data.
- */
- datacontenttype?: string;
- /**
- * The traceparent string, containing a trace version, trace ID, span ID, and trace options.
- * @see https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md
- */
- traceparent?: string;
- /**
- * The event payload.
- */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- data?: any;
-}
diff --git a/src/cloud_events.ts b/src/cloud_events.ts
index f94e6774..e5dfa496 100644
--- a/src/cloud_events.ts
+++ b/src/cloud_events.ts
@@ -13,7 +13,7 @@
// limitations under the License.
import * as express from 'express';
-import {CloudEventsContext} from './functions';
+import {CloudEvent} from 'cloudevents';
/**
* Custom exception class to represent errors durring event conversions.
@@ -56,15 +56,11 @@ export function isBinaryCloudEvent(req: express.Request): boolean {
* @param req Express request object.
* @return CloudEvents context.
*/
-export function getBinaryCloudEventContext(
- req: express.Request
-): CloudEventsContext {
- const context = {} as CloudEventsContext;
+export function getBinaryCloudEventContext(req: express.Request): CloudEvent {
+ const context = {} as CloudEvent;
for (const name in req.headers) {
if (name.startsWith('ce-')) {
- const attributeName = name.substr(
- 'ce-'.length
- ) as keyof CloudEventsContext;
+ const attributeName = name.substr('ce-'.length) as keyof CloudEvent;
context[attributeName] = req.header(name);
}
}
diff --git a/src/function_wrappers.ts b/src/function_wrappers.ts
index 20ccfacd..da2b0f22 100644
--- a/src/function_wrappers.ts
+++ b/src/function_wrappers.ts
@@ -25,9 +25,9 @@ import {
Context,
CloudEventFunction,
CloudEventFunctionWithCallback,
- CloudEventsContext,
HandlerFunction,
} from './functions';
+import {CloudEvent} from 'cloudevents';
import {SignatureType} from './types';
/**
@@ -60,7 +60,7 @@ const getOnDoneCallback = (res: Response): OnDoneCallback => {
* @param req an Express HTTP request
* @returns a CloudEvent parsed from the request
*/
-const parseCloudEventRequest = (req: Request): CloudEventsContext => {
+const parseCloudEventRequest = (req: Request): CloudEvent => {
let cloudEvent = req.body;
if (isBinaryCloudEvent(req)) {
cloudEvent = getBinaryCloudEventContext(req);
diff --git a/src/functions.ts b/src/functions.ts
index 6b0a1d6b..0688c8fd 100644
--- a/src/functions.ts
+++ b/src/functions.ts
@@ -17,12 +17,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as express from 'express';
-import {CloudEventsContext} from './cloud_event_types/cloud_events_context';
-
-/**
- * @public
- */
-export {CloudEventsContext};
+import {CloudEvent} from 'cloudevents';
/**
* @public
@@ -65,14 +60,14 @@ export interface EventFunctionWithCallback {
* @public
*/
export interface CloudEventFunction {
- (cloudEvent: CloudEventsContext): any;
+ (cloudEvent: CloudEvent): any;
}
/**
* A CloudEvent function handler with callback.
* @public
*/
export interface CloudEventFunctionWithCallback {
- (cloudEvent: CloudEventsContext, callback: Function): any;
+ (cloudEvent: CloudEvent, callback: Function): any;
}
/**
* A function handler.
@@ -136,4 +131,4 @@ export interface CloudFunctionsContext {
* The function's context.
* @public
*/
-export type Context = CloudFunctionsContext | CloudEventsContext;
+export type Context = CloudFunctionsContext | CloudEvent;
diff --git a/test/function_wrappers.ts b/test/function_wrappers.ts
index 2dda15b4..20800cd7 100644
--- a/test/function_wrappers.ts
+++ b/test/function_wrappers.ts
@@ -1,7 +1,8 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import {Request, Response} from 'express';
-import {CloudEventsContext, Context} from '../src/functions';
+import {Context} from '../src/functions';
+import {CloudEvent} from 'cloudevents';
import {wrapUserFunction} from '../src/function_wrappers';
describe('wrapUserFunction', () => {
@@ -77,7 +78,7 @@ describe('wrapUserFunction', () => {
it('correctly wraps an async CloudEvent function', done => {
const request = createRequest(CLOUD_EVENT);
const response = createResponse();
- const func = wrapUserFunction(async (cloudEvent: CloudEventsContext) => {
+ const func = wrapUserFunction(async (cloudEvent: CloudEvent) => {
assert.deepStrictEqual(cloudEvent, CLOUD_EVENT);
// await to make sure wrapper handles async code
await new Promise(resolve => setTimeout(resolve, 20));
@@ -90,7 +91,7 @@ describe('wrapUserFunction', () => {
const request = createRequest(CLOUD_EVENT);
const response = createResponse();
const func = wrapUserFunction(
- (cloudEvent: CloudEventsContext, callback: Function) => {
+ (cloudEvent: CloudEvent, callback: Function) => {
// timeout to make sure wrapper waits for callback
setTimeout(() => {
assert.deepStrictEqual(cloudEvent, CLOUD_EVENT);
diff --git a/test/integration/cloud_event.ts b/test/integration/cloud_event.ts
index 7a7a6da5..455d8fc2 100644
--- a/test/integration/cloud_event.ts
+++ b/test/integration/cloud_event.ts
@@ -17,6 +17,7 @@ import * as functions from '../../src/index';
import * as sinon from 'sinon';
import {getTestServer} from '../../src/testing';
import * as supertest from 'supertest';
+import {CloudEvent} from 'cloudevents';
// A structured CloudEvent
const TEST_CLOUD_EVENT = {
@@ -39,7 +40,7 @@ const TEST_EXTENSIONS = {
describe('CloudEvent Function', () => {
let clock: sinon.SinonFakeTimers;
- let receivedCloudEvent: functions.CloudEventsContext | null;
+ let receivedCloudEvent: CloudEvent | null;
before(() => {
functions.cloudEvent('testCloudEventFunction', ce => {
receivedCloudEvent = ce;
From 1a0a02f88795642134e0acca53d4ac2f22b1b23c Mon Sep 17 00:00:00 2001
From: Grant Timmerman
Date: Wed, 1 Dec 2021 21:37:51 -0800
Subject: [PATCH 2/5] ci: run doc generator
Signed-off-by: Grant Timmerman
---
docs/generated/api.json | 316 +++++++++++++++++++++++++++++++++++++---
docs/generated/api.md | 21 ++-
2 files changed, 313 insertions(+), 24 deletions(-)
diff --git a/docs/generated/api.json b/docs/generated/api.json
index 4674aed7..cd09291d 100644
--- a/docs/generated/api.json
+++ b/docs/generated/api.json
@@ -206,7 +206,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface CloudEventFunction "
+ "text": "export declare interface CloudEventFunction "
}
],
"releaseTag": "Public",
@@ -223,8 +223,8 @@
},
{
"kind": "Reference",
- "text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "text": "CloudEventsContext",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
},
{
"kind": "Content",
@@ -265,7 +265,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface CloudEventFunctionWithCallback "
+ "text": "export declare interface CloudEventFunctionWithCallback "
}
],
"releaseTag": "Public",
@@ -282,8 +282,8 @@
},
{
"kind": "Reference",
- "text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "text": "CloudEventsContext",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
},
{
"kind": "Content",
@@ -333,6 +333,282 @@
],
"extendsTokenRanges": []
},
+ {
+ "kind": "Interface",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface",
+ "docComment": "/**\n * The CloudEvents v1.0 context attributes. {@link https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#context-attributes}\n *\n * @public\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "export declare interface CloudEventsContext "
+ }
+ ],
+ "releaseTag": "Public",
+ "name": "CloudEventsContext",
+ "members": [
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#data:member",
+ "docComment": "/**\n * The event payload.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "data?: "
+ },
+ {
+ "kind": "Content",
+ "text": "any"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "data",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#datacontenttype:member",
+ "docComment": "/**\n * Content type of the event data.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "datacontenttype?: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "datacontenttype",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#dataschema:member",
+ "docComment": "/**\n * A link to the schema that the event data adheres to.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "dataschema?: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "dataschema",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#id:member",
+ "docComment": "/**\n * ID of the event.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "id: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": false,
+ "releaseTag": "Public",
+ "name": "id",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#source:member",
+ "docComment": "/**\n * The event producer.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "source: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": false,
+ "releaseTag": "Public",
+ "name": "source",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#specversion:member",
+ "docComment": "/**\n * The version of the CloudEvents specification which the event uses.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "specversion: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": false,
+ "releaseTag": "Public",
+ "name": "specversion",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#subject:member",
+ "docComment": "/**\n * Describes the subject of the event in the context of the event producer.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "subject?: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "subject",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#time:member",
+ "docComment": "/**\n * Timestamp of when the event happened.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "time?: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "time",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#traceparent:member",
+ "docComment": "/**\n * The traceparent string, containing a trace version, trace ID, span ID, and trace options.\n *\n * @see\n *\n * https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "traceparent?: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": true,
+ "releaseTag": "Public",
+ "name": "traceparent",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ },
+ {
+ "kind": "PropertySignature",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#type:member",
+ "docComment": "/**\n * Type of occurrence which has happened.\n */\n",
+ "excerptTokens": [
+ {
+ "kind": "Content",
+ "text": "type: "
+ },
+ {
+ "kind": "Content",
+ "text": "string"
+ },
+ {
+ "kind": "Content",
+ "text": ";"
+ }
+ ],
+ "isOptional": false,
+ "releaseTag": "Public",
+ "name": "type",
+ "propertyTypeTokenRange": {
+ "startIndex": 1,
+ "endIndex": 2
+ }
+ }
+ ],
+ "extendsTokenRanges": []
+ },
{
"kind": "Interface",
"canonicalReference": "@google-cloud/functions-framework!CloudFunctionsContext:interface",
@@ -340,7 +616,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface CloudFunctionsContext "
+ "text": "export declare interface CloudFunctionsContext "
}
],
"releaseTag": "Public",
@@ -473,8 +749,8 @@
},
{
"kind": "Reference",
- "text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "text": "CloudEventsContext",
+ "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
},
{
"kind": "Content",
@@ -495,7 +771,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface Data "
+ "text": "export declare interface Data "
}
],
"releaseTag": "Public",
@@ -537,7 +813,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface EventFunction "
+ "text": "export declare interface EventFunction "
}
],
"releaseTag": "Public",
@@ -611,7 +887,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface EventFunctionWithCallback "
+ "text": "export declare interface EventFunctionWithCallback "
}
],
"releaseTag": "Public",
@@ -793,7 +1069,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface HttpFunction "
+ "text": "export declare interface HttpFunction "
}
],
"releaseTag": "Public",
@@ -810,8 +1086,8 @@
},
{
"kind": "Reference",
- "text": "Request",
- "canonicalReference": "@google-cloud/functions-framework!Request:interface"
+ "text": "Request_2",
+ "canonicalReference": "@google-cloud/functions-framework!~Request_2:interface"
},
{
"kind": "Content",
@@ -819,8 +1095,8 @@
},
{
"kind": "Reference",
- "text": "Response",
- "canonicalReference": "@google-cloud/functions-framework!Response:type"
+ "text": "Response_2",
+ "canonicalReference": "@google-cloud/functions-framework!~Response_2:type"
},
{
"kind": "Content",
@@ -903,7 +1179,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface LegacyEvent "
+ "text": "export declare interface LegacyEvent "
}
],
"releaseTag": "Public",
@@ -972,7 +1248,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export interface Request extends "
+ "text": "declare interface Request_2 extends "
},
{
"kind": "Reference",
@@ -1029,7 +1305,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare type Response = "
+ "text": "declare type Response_2 = "
},
{
"kind": "Reference",
diff --git a/docs/generated/api.md b/docs/generated/api.md
index 3b34f26c..62d90ee2 100644
--- a/docs/generated/api.md
+++ b/docs/generated/api.md
@@ -6,7 +6,6 @@
///
-import { CloudEvent } from 'cloudevents';
import * as express from 'express';
// @public
@@ -15,13 +14,27 @@ export const cloudEvent: (functionName: string, handler: CloudEventFunction) =>
// @public
export interface CloudEventFunction {
// (undocumented)
- (cloudEvent: CloudEvent): any;
+ (cloudEvent: CloudEventsContext): any;
}
// @public
export interface CloudEventFunctionWithCallback {
// (undocumented)
- (cloudEvent: CloudEvent, callback: Function): any;
+ (cloudEvent: CloudEventsContext, callback: Function): any;
+}
+
+// @public
+export interface CloudEventsContext {
+ data?: any;
+ datacontenttype?: string;
+ dataschema?: string;
+ id: string;
+ source: string;
+ specversion: string;
+ subject?: string;
+ time?: string;
+ traceparent?: string;
+ type: string;
}
// @public
@@ -35,7 +48,7 @@ export interface CloudFunctionsContext {
}
// @public
-export type Context = CloudFunctionsContext | CloudEvent;
+export type Context = CloudFunctionsContext | CloudEventsContext;
// @public
export interface Data {
From 7738f78dde94d401372673bf1d64558f80c8fb6c Mon Sep 17 00:00:00 2001
From: Grant Timmerman
Date: Wed, 1 Dec 2021 21:39:54 -0800
Subject: [PATCH 3/5] ci: gen docs
Signed-off-by: Grant Timmerman
---
docs/generated/api.json | 288 +---------------------------------------
docs/generated/api.md | 21 +--
2 files changed, 10 insertions(+), 299 deletions(-)
diff --git a/docs/generated/api.json b/docs/generated/api.json
index cd09291d..988ea1ff 100644
--- a/docs/generated/api.json
+++ b/docs/generated/api.json
@@ -223,8 +223,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
@@ -282,8 +282,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
@@ -333,282 +333,6 @@
],
"extendsTokenRanges": []
},
- {
- "kind": "Interface",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface",
- "docComment": "/**\n * The CloudEvents v1.0 context attributes. {@link https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#context-attributes}\n *\n * @public\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "export declare interface CloudEventsContext "
- }
- ],
- "releaseTag": "Public",
- "name": "CloudEventsContext",
- "members": [
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#data:member",
- "docComment": "/**\n * The event payload.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "data?: "
- },
- {
- "kind": "Content",
- "text": "any"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "data",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#datacontenttype:member",
- "docComment": "/**\n * Content type of the event data.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "datacontenttype?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "datacontenttype",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#dataschema:member",
- "docComment": "/**\n * A link to the schema that the event data adheres to.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "dataschema?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "dataschema",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#id:member",
- "docComment": "/**\n * ID of the event.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "id: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "id",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#source:member",
- "docComment": "/**\n * The event producer.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "source: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "source",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#specversion:member",
- "docComment": "/**\n * The version of the CloudEvents specification which the event uses.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "specversion: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "specversion",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#subject:member",
- "docComment": "/**\n * Describes the subject of the event in the context of the event producer.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "subject?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "subject",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#time:member",
- "docComment": "/**\n * Timestamp of when the event happened.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "time?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "time",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#traceparent:member",
- "docComment": "/**\n * The traceparent string, containing a trace version, trace ID, span ID, and trace options.\n *\n * @see\n *\n * https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "traceparent?: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": true,
- "releaseTag": "Public",
- "name": "traceparent",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- },
- {
- "kind": "PropertySignature",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext#type:member",
- "docComment": "/**\n * Type of occurrence which has happened.\n */\n",
- "excerptTokens": [
- {
- "kind": "Content",
- "text": "type: "
- },
- {
- "kind": "Content",
- "text": "string"
- },
- {
- "kind": "Content",
- "text": ";"
- }
- ],
- "isOptional": false,
- "releaseTag": "Public",
- "name": "type",
- "propertyTypeTokenRange": {
- "startIndex": 1,
- "endIndex": 2
- }
- }
- ],
- "extendsTokenRanges": []
- },
{
"kind": "Interface",
"canonicalReference": "@google-cloud/functions-framework!CloudFunctionsContext:interface",
@@ -749,8 +473,8 @@
},
{
"kind": "Reference",
- "text": "CloudEventsContext",
- "canonicalReference": "@google-cloud/functions-framework!CloudEventsContext:interface"
+ "text": "CloudEvent",
+ "canonicalReference": "cloudevents!CloudEvent:class"
},
{
"kind": "Content",
diff --git a/docs/generated/api.md b/docs/generated/api.md
index 62d90ee2..3b34f26c 100644
--- a/docs/generated/api.md
+++ b/docs/generated/api.md
@@ -6,6 +6,7 @@
///
+import { CloudEvent } from 'cloudevents';
import * as express from 'express';
// @public
@@ -14,27 +15,13 @@ export const cloudEvent: (functionName: string, handler: CloudEventFunction) =>
// @public
export interface CloudEventFunction {
// (undocumented)
- (cloudEvent: CloudEventsContext): any;
+ (cloudEvent: CloudEvent): any;
}
// @public
export interface CloudEventFunctionWithCallback {
// (undocumented)
- (cloudEvent: CloudEventsContext, callback: Function): any;
-}
-
-// @public
-export interface CloudEventsContext {
- data?: any;
- datacontenttype?: string;
- dataschema?: string;
- id: string;
- source: string;
- specversion: string;
- subject?: string;
- time?: string;
- traceparent?: string;
- type: string;
+ (cloudEvent: CloudEvent, callback: Function): any;
}
// @public
@@ -48,7 +35,7 @@ export interface CloudFunctionsContext {
}
// @public
-export type Context = CloudFunctionsContext | CloudEventsContext;
+export type Context = CloudFunctionsContext | CloudEvent;
// @public
export interface Data {
From 741516de7df41e6e37fc55cc5ceebcda7be9fd80 Mon Sep 17 00:00:00 2001
From: Grant Timmerman
Date: Wed, 1 Dec 2021 22:03:16 -0800
Subject: [PATCH 4/5] refactor: minor import refactoring
Signed-off-by: Grant Timmerman
---
src/cloud_events.ts | 2 +-
src/function_wrappers.ts | 2 +-
src/functions.ts | 7 ++++++-
test/function_wrappers.ts | 3 +--
test/integration/cloud_event.ts | 3 +--
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/cloud_events.ts b/src/cloud_events.ts
index e5dfa496..b213f357 100644
--- a/src/cloud_events.ts
+++ b/src/cloud_events.ts
@@ -13,7 +13,7 @@
// limitations under the License.
import * as express from 'express';
-import {CloudEvent} from 'cloudevents';
+import {CloudEvent} from './functions';
/**
* Custom exception class to represent errors durring event conversions.
diff --git a/src/function_wrappers.ts b/src/function_wrappers.ts
index da2b0f22..36a607e1 100644
--- a/src/function_wrappers.ts
+++ b/src/function_wrappers.ts
@@ -27,7 +27,7 @@ import {
CloudEventFunctionWithCallback,
HandlerFunction,
} from './functions';
-import {CloudEvent} from 'cloudevents';
+import {CloudEvent} from './functions';
import {SignatureType} from './types';
/**
diff --git a/src/functions.ts b/src/functions.ts
index 0688c8fd..7d7f12bc 100644
--- a/src/functions.ts
+++ b/src/functions.ts
@@ -17,7 +17,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as express from 'express';
-import {CloudEvent} from 'cloudevents';
+import {CloudEventV1 as CloudEvent} from 'cloudevents';
+
+/**
+ * @public
+ */
+export {CloudEvent};
/**
* @public
diff --git a/test/function_wrappers.ts b/test/function_wrappers.ts
index 20800cd7..aa17664b 100644
--- a/test/function_wrappers.ts
+++ b/test/function_wrappers.ts
@@ -1,8 +1,7 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import {Request, Response} from 'express';
-import {Context} from '../src/functions';
-import {CloudEvent} from 'cloudevents';
+import {Context, CloudEvent} from '../src/functions';
import {wrapUserFunction} from '../src/function_wrappers';
describe('wrapUserFunction', () => {
diff --git a/test/integration/cloud_event.ts b/test/integration/cloud_event.ts
index 455d8fc2..32d45d9b 100644
--- a/test/integration/cloud_event.ts
+++ b/test/integration/cloud_event.ts
@@ -17,7 +17,6 @@ import * as functions from '../../src/index';
import * as sinon from 'sinon';
import {getTestServer} from '../../src/testing';
import * as supertest from 'supertest';
-import {CloudEvent} from 'cloudevents';
// A structured CloudEvent
const TEST_CLOUD_EVENT = {
@@ -40,7 +39,7 @@ const TEST_EXTENSIONS = {
describe('CloudEvent Function', () => {
let clock: sinon.SinonFakeTimers;
- let receivedCloudEvent: CloudEvent | null;
+ let receivedCloudEvent: functions.CloudEvent | null;
before(() => {
functions.cloudEvent('testCloudEventFunction', ce => {
receivedCloudEvent = ce;
From af829f9293dfbb3f82524683c9bc1e61ec7851ca Mon Sep 17 00:00:00 2001
From: Grant Timmerman
Date: Wed, 1 Dec 2021 22:07:49 -0800
Subject: [PATCH 5/5] ci: fix docs
Signed-off-by: Grant Timmerman
---
docs/generated/api.json | 34 +++++++++++++++++-----------------
docs/generated/api.md | 4 +++-
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/docs/generated/api.json b/docs/generated/api.json
index 988ea1ff..c851a664 100644
--- a/docs/generated/api.json
+++ b/docs/generated/api.json
@@ -206,7 +206,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface CloudEventFunction "
+ "text": "export interface CloudEventFunction "
}
],
"releaseTag": "Public",
@@ -224,7 +224,7 @@
{
"kind": "Reference",
"text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "canonicalReference": "cloudevents!CloudEventV1:interface"
},
{
"kind": "Content",
@@ -265,7 +265,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface CloudEventFunctionWithCallback "
+ "text": "export interface CloudEventFunctionWithCallback "
}
],
"releaseTag": "Public",
@@ -283,7 +283,7 @@
{
"kind": "Reference",
"text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "canonicalReference": "cloudevents!CloudEventV1:interface"
},
{
"kind": "Content",
@@ -340,7 +340,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface CloudFunctionsContext "
+ "text": "export interface CloudFunctionsContext "
}
],
"releaseTag": "Public",
@@ -474,7 +474,7 @@
{
"kind": "Reference",
"text": "CloudEvent",
- "canonicalReference": "cloudevents!CloudEvent:class"
+ "canonicalReference": "cloudevents!CloudEventV1:interface"
},
{
"kind": "Content",
@@ -495,7 +495,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface Data "
+ "text": "export interface Data "
}
],
"releaseTag": "Public",
@@ -537,7 +537,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface EventFunction "
+ "text": "export interface EventFunction "
}
],
"releaseTag": "Public",
@@ -611,7 +611,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface EventFunctionWithCallback "
+ "text": "export interface EventFunctionWithCallback "
}
],
"releaseTag": "Public",
@@ -793,7 +793,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface HttpFunction "
+ "text": "export interface HttpFunction "
}
],
"releaseTag": "Public",
@@ -810,8 +810,8 @@
},
{
"kind": "Reference",
- "text": "Request_2",
- "canonicalReference": "@google-cloud/functions-framework!~Request_2:interface"
+ "text": "Request",
+ "canonicalReference": "@google-cloud/functions-framework!Request:interface"
},
{
"kind": "Content",
@@ -819,8 +819,8 @@
},
{
"kind": "Reference",
- "text": "Response_2",
- "canonicalReference": "@google-cloud/functions-framework!~Response_2:type"
+ "text": "Response",
+ "canonicalReference": "@google-cloud/functions-framework!Response:type"
},
{
"kind": "Content",
@@ -903,7 +903,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "export declare interface LegacyEvent "
+ "text": "export interface LegacyEvent "
}
],
"releaseTag": "Public",
@@ -972,7 +972,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "declare interface Request_2 extends "
+ "text": "export interface Request extends "
},
{
"kind": "Reference",
@@ -1029,7 +1029,7 @@
"excerptTokens": [
{
"kind": "Content",
- "text": "declare type Response_2 = "
+ "text": "export declare type Response = "
},
{
"kind": "Reference",
diff --git a/docs/generated/api.md b/docs/generated/api.md
index 3b34f26c..461ab879 100644
--- a/docs/generated/api.md
+++ b/docs/generated/api.md
@@ -6,9 +6,11 @@
///
-import { CloudEvent } from 'cloudevents';
+import { CloudEventV1 as CloudEvent } from 'cloudevents';
import * as express from 'express';
+export { CloudEvent }
+
// @public
export const cloudEvent: (functionName: string, handler: CloudEventFunction) => void;