Skip to content

Commit 584ee82

Browse files
committed
lib: be explicit about what gets exported from ./src/index.ts
Signed-off-by: Lance Ball <lball@redhat.com>
1 parent 26d457a commit 584ee82

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

src/index.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
export * from "./event";
2-
export * from "./transport";
3-
export * from "./event/v1";
4-
export * from "./event/v03";
1+
import {
2+
CloudEvent,
3+
CloudEventV03,
4+
CloudEventV03Attributes,
5+
CloudEventV1,
6+
CloudEventV1Attributes,
7+
ValidationError,
8+
Version,
9+
} from "./event";
10+
11+
import { Emitter, Receiver, Mode, Protocol, TransportOptions } from "./transport";
12+
import { Headers, headersFor } from "./transport/http/headers";
13+
14+
export {
15+
// From event
16+
CloudEvent,
17+
CloudEventV03,
18+
CloudEventV03Attributes,
19+
CloudEventV1,
20+
CloudEventV1Attributes,
21+
Version,
22+
ValidationError,
23+
// From transport
24+
Emitter,
25+
Receiver,
26+
Mode,
27+
Protocol,
28+
TransportOptions,
29+
Headers,
30+
headersFor,
31+
};

test/http_emitter_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CONSTANTS from "../src/constants";
55

66
const DEFAULT_CE_CONTENT_TYPE = CONSTANTS.DEFAULT_CE_CONTENT_TYPE;
77

8-
import { CloudEvent, Version, Emitter, Protocol, http } from "../src";
8+
import { CloudEvent, Version, Emitter, Protocol, headersFor } from "../src";
99
import { AxiosResponse } from "axios";
1010

1111
const receiver = "https://cloudevents.io/";
@@ -64,7 +64,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
6464
});
6565

6666
it("Provides the HTTP headers for a binary event", () => {
67-
const headers = http.headersFor(event);
67+
const headers = headersFor(event);
6868
expect(headers[CONSTANTS.CE_HEADERS.TYPE]).to.equal(event.type);
6969
expect(headers[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(event.specversion);
7070
expect(headers[CONSTANTS.CE_HEADERS.SOURCE]).to.equal(event.source);
@@ -161,7 +161,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
161161
});
162162

163163
it("Provides the HTTP headers for a binary event", () => {
164-
const headers = http.headersFor(event);
164+
const headers = headersFor(event);
165165
expect(headers[CONSTANTS.CE_HEADERS.TYPE]).to.equal(event.type);
166166
expect(headers[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(event.specversion);
167167
expect(headers[CONSTANTS.CE_HEADERS.SOURCE]).to.equal(event.source);

test/receiver_binary_1_tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import "mocha";
22
import { expect } from "chai";
33

4-
import { CloudEvent, ValidationError, Version, asBase64 } from "../src";
4+
import { CloudEvent, ValidationError, Version } from "../src";
5+
import { asBase64 } from "../src/event/validation";
56
import { BinaryHTTPReceiver } from "../src/transport/http/binary_receiver";
67
import CONSTANTS from "../src/constants";
78

test/receiver_structured_1_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import "mocha";
22
import { expect } from "chai";
33

4-
import { CloudEvent, ValidationError, Version, asBase64 } from "../src";
4+
import { CloudEvent, ValidationError, Version } from "../src";
5+
import { asBase64 } from "../src/event/validation";
56
import { StructuredHTTPReceiver } from "../src/transport/http/structured_receiver";
67

78
const receiver = new StructuredHTTPReceiver(Version.V1);

test/spec_1_tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "mocha";
22
import { expect } from "chai";
3-
import { CloudEvent, Version, ValidationError, asBase64 } from "../src";
3+
import { CloudEvent, Version, ValidationError } from "../src";
4+
import { asBase64 } from "../src/event/validation";
45
import Constants from "../src/constants";
56

67
const id = "97699ec2-a8d9-47c1-bfa0-ff7aa526f838";

0 commit comments

Comments
 (0)