Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,15 @@ The SDK provides commands for ingesting events into Flowcore event types.

> **Important**: Ingestion operations require API key authentication.

Create an API-key client before running either ingestion command. The SDK sends the raw key in the `Authorization` header and keeps it out of the webhook URL. Load the key from a secret store; do not put it in a query string.

```typescript
const client = new FlowcoreClient({
apiKeyId: process.env.FLOWCORE_API_KEY_ID!,
apiKey: process.env.FLOWCORE_API_KEY!,
})
```

#### Ingest a Single Event

```typescript
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/fetch.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface MockedRequest {
path: string
headers: Record<string, string> | null
searchParams: Record<string, string | string[]> | null
noSearchParams: boolean
body: string | Record<string, unknown> | Array<unknown> | null
status: number
response: string | Record<string, unknown> | Array<unknown> | null
Expand Down Expand Up @@ -160,6 +161,10 @@ export class FetchMockBuilder {
}
}

if (mockedRequest.noSearchParams && Object.keys(searchParams).length > 0) {
return false
}

if (mockedRequest.headers) {
try {
assertObjectMatch(mockedRequest.headers, headers)
Expand Down Expand Up @@ -213,6 +218,7 @@ class FetchMockBuilderPath {
private path: string
private headers: Record<string, string> | null = null
private searchParams: Record<string, string | string[]> | null = null
private noSearchParams = false
private body: string | Record<string, unknown> | Array<unknown> | null = null
private status = 200
private response: string | Record<string, unknown> | Array<unknown> | null = null
Expand All @@ -230,6 +236,11 @@ class FetchMockBuilderPath {
return this
}

public withoutSearchParams() {
this.noSearchParams = true
return this
}

public matchBody(body: string | Record<string, unknown> | Array<unknown>) {
this.body = body
return this
Expand Down Expand Up @@ -261,6 +272,7 @@ class FetchMockBuilderPath {
path: this.path,
headers: this.headers,
searchParams: this.searchParams,
noSearchParams: this.noSearchParams,
body: this.body,
status: this.status,
response: this.response,
Expand Down
2 changes: 2 additions & 0 deletions test/tests/commands/ingestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("Ingestion", () => {
const fetchMockerBuilder = fetchMocker.mock(mockWebhookUrl)

fetchMockerBuilder.post(`/event/${tenantName}/${dataCoreId}/${flowTypeName}/${eventTypeName}`)
.withoutSearchParams()
.matchBody(eventData)
.matchHeaders({
"Content-Type": "application/json",
Expand Down Expand Up @@ -233,6 +234,7 @@ describe("Ingestion", () => {
const fetchMockerBuilder = fetchMocker.mock(mockWebhookUrl)

fetchMockerBuilder.post(`/events/${tenantName}/${dataCoreId}/${flowTypeName}/${eventTypeName}`)
.withoutSearchParams()
.matchBody(events)
.matchHeaders({
"Content-Type": "application/json",
Expand Down
Loading