Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(data-warehouse): rename streams to tables in custom REST source (#64395)

Marcus Hoff3dd39a43317
diff --git a/products/data_warehouse/frontend/shared/components/forms/CustomSourceManifestBuilder.tsx b/products/data_warehouse/frontend/shared/components/forms/CustomSourceManifestBuilder.tsx
index 9706e2d447e0..8a93152c7e63 100644
--- a/products/data_warehouse/frontend/shared/components/forms/CustomSourceManifestBuilder.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/CustomSourceManifestBuilder.tsx
@@ -13,7 +13,7 @@ import {
type AuthType,
CURSOR_TYPES,
type CursorType,
- eligibleParentStreams,
+ eligibleParentTables,
EMPTY_PARENT_FIELDS,
type HeaderEntry,
type ManifestState,
@@ -23,7 +23,7 @@ import {
type PaginatorType,
SORT_MODES,
type SortMode,
- type StreamForm,
+ type TableForm,
} from './customSourceManifest'
import {
customSourceManifestBuilderLogic,
@@ -88,10 +88,10 @@ export function CustomSourceManifestBuilder({
const { manifestState, manifestJson, manifestPreviewOpen } = useValues(logic)
const {
updateState,
- updateStream,
+ updateTable,
updatePaginator,
- addStream,
- removeStream,
+ addTable,
+ removeTable,
addHeader,
removeHeader,
updateHeader,
@@ -123,25 +123,25 @@ export function CustomSourceManifestBuilder({
<div className="space-y-4">
<div className="flex items-center justify-between">
<div>
- <h4 className="mb-0">Streams</h4>
+ <h4 className="mb-0">Tables</h4>
<p className="m-0 text-xs text-secondary">
- Each stream becomes a table. PostHog fetches the endpoint, paginates, and writes rows.
+ Each table maps to one endpoint. PostHog fetches it, paginates, and writes the rows.
</p>
</div>
- <LemonButton type="secondary" icon={<IconPlus />} onClick={addStream}>
- Add stream
+ <LemonButton type="secondary" icon={<IconPlus />} onClick={addTable}>
+ Add table
</LemonButton>
</div>
- {manifestState.streams.map((stream, index) => (
- <StreamCard
- key={stream.id}
+ {manifestState.tables.map((table, index) => (
+ <TableCard
+ key={table.id}
index={index}
- stream={stream}
- canRemove={manifestState.streams.length > 1}
- parentOptions={eligibleParentStreams(manifestState.streams, index)}
- onUpdate={(patch) => updateStream(index, patch)}
+ table={table}
+ canRemove={manifestState.tables.length > 1}
+ parentOptions={eligibleParentTables(manifestState.tables, index)}
+ onUpdate={(patch) => updateTable(index, patch)}
onUpdatePaginator={(paginator) => updatePaginator(index, paginator)}
- onRemove={() => removeStream(index)}
+ onRemove={() => removeTable(index)}
/>
))}
</div>
@@ -294,9 +294,9 @@ function HeadersSection({
)
}
-function StreamCard({
+function TableCard({
index,
- stream,
+ table,
canRemove,
parentOptions,
onUpdate,
@@ -304,17 +304,17 @@ function StreamCard({
onRemove,
}: {
index: number
- stream: StreamForm
+ table: TableForm
canRemove: boolean
parentOptions: string[]
- onUpdate: (patch: Partial<StreamForm>) => void
+ onUpdate: (patch: Partial<TableForm>) => void
onUpdatePaginator: (paginator: Paginator) => void
onRemove: () => void
}): JSX.Element {
return (
<div className="rounded border border-border p-3 space-y-3">
<div className="flex items-center justify-between">
- <h5 className="mb-0">Stream {index + 1}</h5>
+ <h5 className="mb-0">Table {index + 1}</h5>
{canRemove && (
<LemonButton type="tertiary" size="small" icon={<IconTrash />} onClick={onRemove}>
Remove
@@ -322,17 +322,17 @@ function StreamCard({
)}
</div>
<div className="grid grid-cols-2 gap-2">
- <LemonField.Pure label="Stream name">
+ <LemonField.Pure label="Table name">
<LemonInput
placeholder="users"
- value={stream.name}
+ value={table.name}
onChange={(value) => onUpdate({ name: value })}
/>
</LemonField.Pure>
<LemonField.Pure label="Primary key">
<LemonInput
placeholder="id"
- value={stream.primary_key}
+ value={table.primary_key}
onChange={(value) => onUpdate({ primary_key: value })}
/>
</LemonField.Pure>
@@ -341,13 +341,13 @@ function StreamCard({
<LemonField.Pure label="Path">
<LemonInput
placeholder="/v1/users"
- value={stream.path}
+ value={table.path}
onChange={(value) => onUpdate({ path: value })}
/>
</LemonField.Pure>
<LemonField.Pure label="HTTP method">
<LemonSelect
- value={stream.method}
+ value={table.method}
onChange={(value) => onUpdate({ method: value as 'GET' | 'POST' })}
options={[
{ value: 'GET', label: 'GET' },
@@ -359,7 +359,7 @@ function StreamCard({
<LemonField.Pure label="Records JSONPath">
<LemonInput
placeholder="data"
- value={stream.data_selector}
+ value={table.data_selector}
onChange={(value) => onUpdate({ data_selector: value })}
/>
<p className="m-0 mt-1 text-xs text-secondary">
@@ -369,46 +369,46 @@ function StreamCard({
</LemonField.Pure>
{/* Only show the dependency section when there's an eligible parent to
pick, or an existing dependency to edit / warn about (a stale parent
- from raw-authored JSON still needs its warning). A single-stream
+ from raw-authored JSON still needs its warning). A single-table
manifest has neither, so the section would just be an inert box. */}
- {(parentOptions.length > 0 || stream.parent_stream.trim().length > 0) && (
- <ParentSection stream={stream} parentOptions={parentOptions} onUpdate={onUpdate} />
+ {(parentOptions.length > 0 || table.parent_table.trim().length > 0) && (
+ <ParentSection table={table} parentOptions={parentOptions} onUpdate={onUpdate} />
)}
- <PaginatorSection paginator={stream.paginator} onUpdate={onUpdatePaginator} />
- <IncrementalSection stream={stream} onUpdate={onUpdate} />
+ <PaginatorSection paginator={table.paginator} onUpdate={onUpdatePaginator} />
+ <IncrementalSection table={table} onUpdate={onUpdate} />
</div>
)
}
function ParentSection({
- stream,
+ table,
parentOptions,
onUpdate,
}: {
- stream: StreamForm
+ table: TableForm
parentOptions: string[]
- onUpdate: (patch: Partial<StreamForm>) => void
+ onUpdate: (patch: Partial<TableForm>) => void
}): JSX.Element {
- const hasParent = stream.parent_stream.trim().length > 0
- const pathParam = stream.parent_path_param.trim()
- const parentField = stream.parent_resolve_field.trim()
+ const hasParent = table.parent_table.trim().length > 0
+ const pathParam = table.parent_path_param.trim()
+ const parentField = table.parent_resolve_field.trim()
// A parent name can go stale when the manifest was authored elsewhere (raw
// JSON) — the select would render the raw value with no visible error, and
// saving fails with an engine message that doesn't point here.
- const parentMissing = hasParent && !parentOptions.includes(stream.parent_stream)
+ const parentMissing = hasParent && !parentOptions.includes(table.parent_table)
// The REST engine can only inject a resolved value into the URL path, so the
// path must contain the placeholder — warn early instead of failing at sync.
- const pathMissingPlaceholder = hasParent && pathParam.length > 0 && !stream.path.includes(`{${pathParam}}`)
+ const pathMissingPlaceholder = hasParent && pathParam.length > 0 && !table.path.includes(`{${pathParam}}`)
return (
<div className="rounded border border-border p-3 space-y-2">
- <LemonField.Pure label="Depends on parent stream">
+ <LemonField.Pure label="Depends on parent table">
<LemonSelect
- value={hasParent ? stream.parent_stream : ''}
+ value={hasParent ? table.parent_table : ''}
onChange={(value) =>
- value ? onUpdate({ parent_stream: value }) : onUpdate({ ...EMPTY_PARENT_FIELDS })
+ value ? onUpdate({ parent_table: value }) : onUpdate({ ...EMPTY_PARENT_FIELDS })
}
options={[
- { value: '', label: 'None (top-level stream)' },
+ { value: '', label: 'None (top-level table)' },
...parentOptions.map((name) => ({ value: name, label: name })),
]}
/>
@@ -416,22 +416,22 @@ function ParentSection({
{hasParent && (
<>
<p className="m-0 text-xs text-secondary">
- PostHog fetches the parent stream first, then calls this stream once per parent row — binding
- the chosen parent field into the path placeholder (e.g.{' '}
- <code>/forms/{'{form_id}'}/responses</code>).
+ PostHog fetches the parent table first, then calls this table once per parent row — binding the
+ chosen parent field into the path placeholder (e.g. <code>/forms/{'{form_id}'}/responses</code>
+ ).
</p>
<div className="grid grid-cols-2 gap-2">
<LemonField.Pure label="Parent field">
<LemonInput
placeholder="id"
- value={stream.parent_resolve_field}
+ value={table.parent_resolve_field}
onChange={(value) => onUpdate({ parent_resolve_field: value })}
/>
</LemonField.Pure>
<LemonField.Pure label="Path placeholder">
<LemonInput
placeholder="form_id"
- value={stream.parent_path_param}
+ value={table.parent_path_param}
onChange={(value) => onUpdate({ parent_path_param: value })}
/>
</LemonField.Pure>
@@ -439,12 +439,12 @@ function ParentSection({
<LemonField.Pure label="Include parent fields">
<LemonInput
placeholder="id, name"
- value={stream.include_from_parent}
+ value={table.include_from_parent}
onChange={(value) => onUpdate({ include_from_parent: value })}
/>
<p className="m-0 mt-1 text-xs text-secondary">
Optional comma-separated parent fields copied onto each row, as{' '}
- <code>_{stream.parent_stream || 'parent'}_&lt;field&gt;</code>.
+ <code>_{table.parent_table || 'parent'}_&lt;field&gt;</code>.
</p>
</LemonField.Pure>
</>
@@ -457,7 +457,7 @@ function ParentSection({
<div aria-live="polite" className="empty:hidden space-y-2">
{parentMissing && (
<p className="m-0 text-xs text-danger">
- Stream <code>{stream.parent_stream}</code> doesn't exist or can't be this stream's parent — pick
+ Table <code>{table.parent_table}</code> doesn't exist or can't be this table's parent — pick
another parent or set to none.
</p>
)}
@@ -609,59 +609,59 @@ function PaginatorSection({
}
function IncrementalSection({
- stream,
+ table,
onUpdate,
}: {
- stream: StreamForm
- onUpdate: (patch: Partial<StreamForm>) => void
+ table: TableForm
+ onUpdate: (patch: Partial<TableForm>) => void
}): JSX.Element {
return (
<div className="rounded border border-border p-3 space-y-2">
<LemonCheckbox
- checked={stream.incremental_enabled}
+ checked={table.incremental_enabled}
onChange={(checked) => onUpdate({ incremental_enabled: checked })}
label="Enable incremental sync"
/>
- {stream.incremental_enabled && (
+ {table.incremental_enabled && (
<>
<div className="grid grid-cols-2 gap-2">
<LemonField.Pure label="Cursor JSONPath">
<LemonInput
placeholder="updated_at"
- value={stream.cursor_path}
+ value={table.cursor_path}
onChange={(value) => onUpdate({ cursor_path: value })}
/>
</LemonField.Pure>
<LemonField.Pure label="Cursor query param">
<LemonInput
placeholder="since"
- value={stream.start_param}
+ value={table.start_param}
onChange={(value) => onUpdate({ start_param: value })}
/>
</LemonField.Pure>
</div>
- {!stream.cursor_path.trim() && (
+ {!table.cursor_path.trim() && (
<p className="m-0 text-xs text-danger">
- Set a cursor JSONPath — otherwise incremental sync is ignored and the stream does a full
+ Set a cursor JSONPath — otherwise incremental sync is ignored and the table does a full
refresh every run.
</p>
)}
<div className="grid grid-cols-2 gap-2">
<LemonField.Pure label="Cursor type">
<LemonSelect
- value={stream.cursor_type}
+ value={table.cursor_type}
onChange={(value) => onUpdate({ cursor_type: value as CursorType })}
options={CURSOR_TYPE_OPTIONS}
/>
</LemonField.Pure>
<LemonField.Pure label="Upstream row order">
<LemonSelect
- value={stream.sort_mode}
+ value={table.sort_mode}
onChange={(value) => onUpdate({ sort_mode: value as SortMode })}
options={SORT_MODE_OPTIONS}
disabledReason={
- stream.parent_stream.trim()
- ? 'Streams with a parent always defer the incremental cursor commit to the end of the run — rows arrive grouped by parent, not in cursor order.'
+ table.parent_table.trim()
+ ? 'Tables with a parent always defer the incremental cursor commit to the end of the run — rows arrive grouped by parent, not in cursor order.'
: undefined
}
/>
@@ -671,11 +671,11 @@ function IncrementalSection({
Pick "Descending" when the API returns newest rows first — otherwise a resumed sync may skip
rows.
</p>
- {DATE_LIKE_CURSOR_TYPES.includes(stream.cursor_type) && (
+ {DATE_LIKE_CURSOR_TYPES.includes(table.cursor_type) && (
<LemonField.Pure label="Datetime format">
<LemonInput
placeholder="%Y-%m-%dT%H:%M:%SZ"
- value={stream.datetime_format}
+ value={table.datetime_format}
onChange={(value) => onUpdate({ datetime_format: value })}
/>
<p className="m-0 mt-1 text-xs text-secondary">
diff --git a/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifest.test.ts b/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifest.test.ts
index 3672164868f7..451d127f2ce5 100644
--- a/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifest.test.ts
+++ b/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifest.test.ts
@@ -1,12 +1,12 @@
import {
buildManifest,
- eligibleParentStreams,
+ eligibleParentTables,
extractAuthSecrets,
ManifestState,
parseManifestIntoState,
- removeStreamFromList,
- StreamForm,
- updateStreamInList,
+ removeTableFromList,
+ TableForm,
+ updateTableInList,
} from '../customSourceManifest'
const baseState = (): ManifestState => ({
@@ -19,9 +19,9 @@ const baseState = (): ManifestState => ({
auth_username: '',
auth_password: '',
headers: [],
- streams: [
+ tables: [
{
- id: 'stream-base',
+ id: 'table-base',
name: 'users',
path: '/v1/users',
method: 'GET',
@@ -34,7 +34,7 @@ const baseState = (): ManifestState => ({
cursor_type: 'datetime',
start_param: '',
datetime_format: '',
- parent_stream: '',
+ parent_table: '',
parent_resolve_field: '',
parent_path_param: '',
include_from_parent: '',
@@ -106,7 +106,7 @@ describe('buildManifest', () => {
it('splits a comma-separated primary_key into a list when multi-column', () => {
const state = baseState()
- state.streams[0].primary_key = 'user_id, page_url, day'
+ state.tables[0].primary_key = 'user_id, page_url, day'
const manifest = buildManifest(state) as any
expect(manifest.resources[0].primary_key).toEqual(['user_id', 'page_url', 'day'])
})
@@ -118,24 +118,24 @@ describe('buildManifest', () => {
it.each(['', ' ', ' , '])('falls back to id when primary_key is cleared (%p)', (cleared) => {
const state = baseState()
- state.streams[0].primary_key = cleared
+ state.tables[0].primary_key = cleared
const manifest = buildManifest(state) as any
expect(manifest.resources[0].primary_key).toEqual('id')
})
- it("only sets endpoint.method when the stream isn't GET", () => {
+ it("only sets endpoint.method when the table isn't GET", () => {
const get = buildManifest(baseState()) as any
expect('method' in get.resources[0].endpoint).toBe(false)
const state = baseState()
- state.streams[0].method = 'POST'
+ state.tables[0].method = 'POST'
const post = buildManifest(state) as any
expect(post.resources[0].endpoint.method).toBe('POST')
})
it('serializes paginator-specific fields per paginator type', () => {
const offsetState = baseState()
- offsetState.streams[0].paginator = { type: 'offset', limit: 50, offset_param: 'o', limit_param: 'l' }
+ offsetState.tables[0].paginator = { type: 'offset', limit: 50, offset_param: 'o', limit_param: 'l' }
const offsetManifest = buildManifest(offsetState) as any
expect(offsetManifest.resources[0].endpoint.paginator).toEqual({
type: 'offset',
@@ -145,7 +145,7 @@ describe('buildManifest', () => {
})
const pageState = baseState()
- pageState.streams[0].paginator = { type: 'page_number', page_param: 'p', base_page: 0 }
+ pageState.tables[0].paginator = { type: 'page_number', page_param: 'p', base_page: 0 }
const pageManifest = buildManifest(pageState) as any
expect(pageManifest.resources[0].endpoint.paginator).toEqual({
type: 'page_number',
@@ -156,7 +156,7 @@ describe('buildManifest', () => {
it('fills paginator defaults when fields are left blank', () => {
const state = baseState()
- state.streams[0].paginator = { type: 'cursor' }
+ state.tables[0].paginator = { type: 'cursor' }
const manifest = buildManifest(state) as any
expect(manifest.resources[0].endpoint.paginator).toEqual({
type: 'cursor',
@@ -167,14 +167,14 @@ describe('buildManifest', () => {
it('serializes json_response with an explicit and a default next_url_path', () => {
const explicit = baseState()
- explicit.streams[0].paginator = { type: 'json_response', next_url_path: 'paging.next' }
+ explicit.tables[0].paginator = { type: 'json_response', next_url_path: 'paging.next' }
expect((buildManifest(explicit) as any).resources[0].endpoint.paginator).toEqual({
type: 'json_response',
next_url_path: 'paging.next',
})
const blank = baseState()
- blank.streams[0].paginator = { type: 'json_response' }
+ blank.tables[0].paginator = { type: 'json_response' }
expect((buildManifest(blank) as any).resources[0].endpoint.paginator).toEqual({
type: 'json_response',
next_url_path: 'links.next',
@@ -183,14 +183,14 @@ describe('buildManifest', () => {
it('serializes header_link with an explicit and a default links_next_key', () => {
const explicit = baseState()
- explicit.streams[0].paginator = { type: 'header_link', links_next_key: 'successor' }
+ explicit.tables[0].paginator = { type: 'header_link', links_next_key: 'successor' }
expect((buildManifest(explicit) as any).resources[0].endpoint.paginator).toEqual({
type: 'header_link',
links_next_key: 'successor',
})
const blank = baseState()
- blank.streams[0].paginator = { type: 'header_link' }
+ blank.tables[0].paginator = { type: 'header_link' }
expect((buildManifest(blank) as any).resources[0].endpoint.paginator).toEqual({
type: 'header_link',
links_next_key: 'next',
@@ -199,36 +199,36 @@ describe('buildManifest', () => {
it('emits endpoint.incremental only when enabled AND cursor_path is set', () => {
const state = baseState()
- state.streams[0].incremental_enabled = true
- state.streams[0].cursor_path = 'updated_at'
+ state.tables[0].incremental_enabled = true
+ state.tables[0].cursor_path = 'updated_at'
const manifest = buildManifest(state) as any
expect(manifest.resources[0].endpoint.incremental).toEqual({
cursor_path: 'updated_at',
start_param: 'updated_at',
})
- state.streams[0].start_param = 'since'
+ state.tables[0].start_param = 'since'
const overriddenStart = buildManifest(state) as any
expect(overriddenStart.resources[0].endpoint.incremental.start_param).toBe('since')
- state.streams[0].cursor_path = ''
+ state.tables[0].cursor_path = ''
const noCursor = buildManifest(state) as any
expect('incremental' in noCursor.resources[0].endpoint).toBe(false)
})
it('omits cursor_type when it equals the backend default (datetime)', () => {
const state = baseState()
- state.streams[0].incremental_enabled = true
- state.streams[0].cursor_path = 'updated_at'
+ state.tables[0].incremental_enabled = true
+ state.tables[0].cursor_path = 'updated_at'
const manifest = buildManifest(state) as any
expect('cursor_type' in manifest.resources[0].endpoint.incremental).toBe(false)
})
it.each(['date', 'timestamp', 'integer'] as const)('emits cursor_type=%s when non-default', (cursorType) => {
const state = baseState()
- state.streams[0].incremental_enabled = true
- state.streams[0].cursor_path = 'updated_at'
- state.streams[0].cursor_type = cursorType
+ state.tables[0].incremental_enabled = true
+ state.tables[0].cursor_path = 'updated_at'
+ state.tables[0].cursor_type = cursorType
const manifest = buildManifest(state) as any
expect(manifest.resources[0].endpoint.incremental.cursor_type).toBe(cursorType)
})
@@ -238,7 +238,7 @@ describe('buildManifest', () => {
expect('sort_mode' in asc.resources[0]).toBe(false)
const descState = baseState()
- descState.streams[0].sort_mode = 'desc'
+ descState.tables[0].sort_mode = 'desc'
const desc = buildManifest(descState) as any
expect(desc.resources[0].sort_mode).toBe('desc')
})
@@ -249,20 +249,20 @@ describe('parseManifestIntoState', () => {
const state = parseManifestIntoState(undefined)
expect(state.base_url).toBe('')
expect(state.auth_type).toBe('bearer')
- expect(state.streams).toHaveLength(1)
+ expect(state.tables).toHaveLength(1)
})
it('returns defaults for invalid JSON', () => {
const state = parseManifestIntoState('{not json}')
- expect(state.streams).toHaveLength(1)
+ expect(state.tables).toHaveLength(1)
})
it('round-trips a manifest through build → parse → build without drift', () => {
const original = baseState()
original.headers = [{ id: 'h1', key: 'X-Workspace', value: 'acme' }]
- original.streams = [
+ original.tables = [
{
- id: 'stream-orders',
+ id: 'table-orders',
name: 'orders',
path: '/orders',
method: 'POST',
@@ -275,7 +275,7 @@ describe('parseManifestIntoState', () => {
cursor_type: 'datetime',
start_param: 'since',
datetime_format: '',
- parent_stream: '',
+ parent_table: '',
parent_resolve_field: '',
parent_path_param: '',
include_from_parent: '',
@@ -296,7 +296,7 @@ describe('parseManifestIntoState', () => {
['header_link', { type: 'header_link', links_next_key: 'successor' }],
] as const)('round-trips the %s paginator without drift', (_name, paginator) => {
const original = baseState()
- original.streams[0].paginator = { ...paginator }
+ original.tables[0].paginator = { ...paginator }
const firstJson = JSON.stringify(buildManifest(original))
const secondJson = JSON.stringify(buildManifest(parseManifestIntoState(firstJson)))
expect(secondJson).toBe(firstJson)
@@ -308,7 +308,7 @@ describe('parseManifestIntoState', () => {
resources: [{ name: 'r', primary_key: ['id'], endpoint: { path: '/r' } }],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].primary_key).toBe('id')
+ expect(state.tables[0].primary_key).toBe('id')
})
it('falls back to single_page paginator when type is unknown', () => {
@@ -317,7 +317,7 @@ describe('parseManifestIntoState', () => {
resources: [{ name: 'r', endpoint: { path: '/r', paginator: { type: 'wat' } } }],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].paginator.type).toBe('single_page')
+ expect(state.tables[0].paginator.type).toBe('single_page')
})
it("recognizes 'none' auth when type isn't one of the supported set", () => {
@@ -358,7 +358,7 @@ describe('parseManifestIntoState', () => {
resources: [{ name: 'r', endpoint: { path: '/r', paginator: { type: 'auto' } } }],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].paginator.type).toBe('single_page')
+ expect(state.tables[0].paginator.type).toBe('single_page')
})
it.each(['date', 'timestamp', 'integer'] as const)(
@@ -374,7 +374,7 @@ describe('parseManifestIntoState', () => {
],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].cursor_type).toBe(cursorType)
+ expect(state.tables[0].cursor_type).toBe(cursorType)
}
)
@@ -389,7 +389,7 @@ describe('parseManifestIntoState', () => {
],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].cursor_type).toBe('datetime')
+ expect(state.tables[0].cursor_type).toBe('datetime')
})
it.each(['asc', 'desc'] as const)('parses sort_mode=%s from the resource', (mode) => {
@@ -398,7 +398,7 @@ describe('parseManifestIntoState', () => {
resources: [{ name: 'r', endpoint: { path: '/r' }, sort_mode: mode }],
})
const state = parseManifestIntoState(manifestJson)
- expect(state.streams[0].sort_mode).toBe(mode)
+ expect(state.tables[0].sort_mode).toBe(mode)
})
it('round-trips all new fields without drift', () => {
@@ -406,9 +406,9 @@ describe('parseManifestIntoState', () => {
original.auth_type = 'api_key'
original.auth_api_key_name = 'X-Key'
original.auth_api_key_location = 'query'
- original.streams = [
+ original.tables = [
{
- id: 'stream-events',
+ id: 'table-events',
name: 'events',
path: '/events',
method: 'GET',
@@ -421,7 +421,7 @@ describe('parseManifestIntoState', () => {
cursor_type: 'timestamp',
start_param: 'since',
datetime_format: '',
- parent_stream: '',
+ parent_table: '',
parent_resolve_field: '',
parent_path_param: '',
include_from_parent: '',
@@ -435,30 +435,30 @@ describe('parseManifestIntoState', () => {
})
})
-// Spreads the base stream so new StreamForm fields only need a default in
+// Spreads the base table so new TableForm fields only need a default in
// baseState(), not in every fixture.
-const makeStream = (overrides: Partial<StreamForm>): StreamForm => ({
- ...baseState().streams[0],
+const makeTable = (overrides: Partial<TableForm>): TableForm => ({
+ ...baseState().tables[0],
...overrides,
})
describe('fan-out (parent/child)', () => {
const childState = (): ManifestState => {
const state = baseState()
- state.streams = [
- makeStream({
- id: 'stream-forms',
+ state.tables = [
+ makeTable({
+ id: 'table-forms',
name: 'forms',
path: '/forms',
data_selector: 'items',
}),
- makeStream({
- id: 'stream-responses',
+ makeTable({
+ id: 'table-responses',
name: 'responses',
path: '/forms/{form_id}/responses',
data_selector: 'items',
primary_key: 'token',
- parent_stream: 'forms',
+ parent_table: 'forms',
parent_resolve_field: 'id',
parent_path_param: 'form_id',
include_from_parent: 'id, title',
@@ -480,10 +480,10 @@ describe('fan-out (parent/child)', () => {
})
it('still emits the resolve param when the dependency is half-filled, so the backend rejects it loudly', () => {
- // Silently dropping a half-filled dependency would sync the stream as an
+ // Silently dropping a half-filled dependency would sync the table as an
// unrelated top-level endpoint — wrong data with no error anywhere.
const state = childState()
- state.streams[1].parent_path_param = '' // missing placeholder name
+ state.tables[1].parent_path_param = '' // missing placeholder name
const manifest = buildManifest(state) as any
expect(manifest.resources[1].endpoint.params).toEqual({
'': { type: 'resolve', resource: 'forms', field: 'id' },
@@ -492,62 +492,62 @@ describe('fan-out (parent/child)', () => {
it('omits include_from_parent when no parent fields are listed', () => {
const state = childState()
- state.streams[1].include_from_parent = ''
+ state.tables[1].include_from_parent = ''
const manifest = buildManifest(state) as any
expect('params' in manifest.resources[1].endpoint).toBe(true)
expect('include_from_parent' in manifest.resources[1]).toBe(false)
})
- it('keeps the top-level parent stream free of a resolve param', () => {
+ it('keeps the top-level parent table free of a resolve param', () => {
const manifest = buildManifest(childState()) as any
expect('params' in manifest.resources[0].endpoint).toBe(false)
})
- it('offers only top-level streams as parents — one level of nesting, no cycles', () => {
+ it('offers only top-level tables as parents — one level of nesting, no cycles', () => {
const state = childState()
- state.streams.push({
- ...state.streams[0],
- id: 'stream-users',
+ state.tables.push({
+ ...state.tables[0],
+ id: 'table-users',
name: 'users',
path: '/users',
})
- // The child stream may pick either top-level stream, but not itself.
- expect(eligibleParentStreams(state.streams, 1)).toEqual(['forms', 'users'])
- // A top-level stream can't pick the child (it has a parent) — so mutual
+ // The child table may pick either top-level table, but not itself.
+ expect(eligibleParentTables(state.tables, 1)).toEqual(['forms', 'users'])
+ // A top-level table can't pick the child (it has a parent) — so mutual
// cycles and grandchildren are unbuildable.
- expect(eligibleParentStreams(state.streams, 0)).toEqual(['users'])
- expect(eligibleParentStreams(state.streams, 2)).toEqual(['forms'])
+ expect(eligibleParentTables(state.tables, 0)).toEqual(['users'])
+ expect(eligibleParentTables(state.tables, 2)).toEqual(['forms'])
})
- it('renaming a parent stream follows through to its children', () => {
- const streams = updateStreamInList(childState().streams, 0, { name: 'surveys' })
- expect(streams[0].name).toBe('surveys')
- expect(streams[1].parent_stream).toBe('surveys')
+ it('renaming a parent table follows through to its children', () => {
+ const tables = updateTableInList(childState().tables, 0, { name: 'surveys' })
+ expect(tables[0].name).toBe('surveys')
+ expect(tables[1].parent_table).toBe('surveys')
})
- it('removing a parent stream clears its children back to top-level', () => {
- const streams = removeStreamFromList(childState().streams, 0)
- expect(streams).toHaveLength(1)
- expect(streams[0].parent_stream).toBe('')
- expect(streams[0].parent_resolve_field).toBe('')
- expect(streams[0].parent_path_param).toBe('')
- expect(streams[0].include_from_parent).toBe('')
+ it('removing a parent table clears its children back to top-level', () => {
+ const tables = removeTableFromList(childState().tables, 0)
+ expect(tables).toHaveLength(1)
+ expect(tables[0].parent_table).toBe('')
+ expect(tables[0].parent_resolve_field).toBe('')
+ expect(tables[0].parent_path_param).toBe('')
+ expect(tables[0].include_from_parent).toBe('')
})
- it('keeps children attached when a duplicate-named stream is removed', () => {
+ it('keeps children attached when a duplicate-named table is removed', () => {
// A sibling still carries the removed name, so the child's parent
// reference remains satisfiable and must not be cleared.
const state = childState()
- state.streams.push(makeStream({ id: 'stream-forms-2', name: 'forms', path: '/forms-v2' }))
- const streams = removeStreamFromList(state.streams, 0)
- expect(streams.find((s) => s.name === 'responses')?.parent_stream).toBe('forms')
+ state.tables.push(makeTable({ id: 'table-forms-2', name: 'forms', path: '/forms-v2' }))
+ const tables = removeTableFromList(state.tables, 0)
+ expect(tables.find((table) => table.name === 'responses')?.parent_table).toBe('forms')
})
it('rename to a colliding name still cascades — the backend rejects the duplicate at save', () => {
const state = childState()
- state.streams.push(makeStream({ id: 'stream-surveys', name: 'surveys', path: '/surveys' }))
- const streams = updateStreamInList(state.streams, 0, { name: 'surveys' })
- expect(streams[1].parent_stream).toBe('surveys')
+ state.tables.push(makeTable({ id: 'table-surveys', name: 'surveys', path: '/surveys' }))
+ const tables = updateTableInList(state.tables, 0, { name: 'surveys' })
+ expect(tables[1].parent_table).toBe('surveys')
})
it('keeps the first resolve param as the dependency when a manifest carries two', () => {
@@ -557,13 +557,13 @@ describe('fan-out (parent/child)', () => {
// builder edit re-emits (and the backend re-rejects) them honestly.
const manifest = buildManifest(childState()) as any
manifest.resources[1].endpoint.params.other_id = { type: 'resolve', resource: 'forms', field: 'id' }
- const child = parseManifestIntoState(JSON.stringify(manifest)).streams[1]
+ const child = parseManifestIntoState(JSON.stringify(manifest)).tables[1]
expect(child.parent_path_param).toBe('form_id')
expect(child.passthrough_params).toEqual({ other_id: { type: 'resolve', resource: 'forms', field: 'id' } })
})
it('preserves raw-authored static params through a builder round-trip', () => {
- // The builder has no UI for static query params, but editing a stream
+ // The builder has no UI for static query params, but editing a table
// must not silently drop ones authored in raw JSON.
const manifest = buildManifest(childState()) as any
manifest.resources[1].endpoint.params.status = 'active'
@@ -574,7 +574,7 @@ describe('fan-out (parent/child)', () => {
})
})
- it('preserves a top-level stream’s static params even with no parent dependency', () => {
+ it('preserves a top-level table’s static params even with no parent dependency', () => {
const manifest = buildManifest(childState()) as any
manifest.resources[0].endpoint.params = { limit: 100 }
const rebuilt = buildManifest(parseManifestIntoState(JSON.stringify(manifest))) as any
@@ -583,8 +583,8 @@ describe('fan-out (parent/child)', () => {
it('hydrates the parent dependency back out on parse', () => {
const state = parseManifestIntoState(JSON.stringify(buildManifest(childState())))
- const child = state.streams[1]
- expect(child.parent_stream).toBe('forms')
+ const child = state.tables[1]
+ expect(child.parent_table).toBe('forms')
expect(child.parent_resolve_field).toBe('id')
expect(child.parent_path_param).toBe('form_id')
expect(child.include_from_parent).toBe('id, title')
@@ -600,9 +600,9 @@ describe('fan-out (parent/child)', () => {
describe('datetime_format (incremental cursor)', () => {
const incrementalState = (datetimeFormat: string): ManifestState => {
const state = baseState()
- state.streams[0].incremental_enabled = true
- state.streams[0].cursor_path = 'updated_at'
- state.streams[0].datetime_format = datetimeFormat
+ state.tables[0].incremental_enabled = true
+ state.tables[0].cursor_path = 'updated_at'
+ state.tables[0].datetime_format = datetimeFormat
return state
}
@@ -618,7 +618,7 @@ describe('datetime_format (incremental cursor)', () => {
it('hydrates datetime_format on parse and round-trips without drift', () => {
const firstJson = JSON.stringify(buildManifest(incrementalState('%Y-%m-%dT%H:%M:%SZ')))
- expect(parseManifestIntoState(firstJson).streams[0].datetime_format).toBe('%Y-%m-%dT%H:%M:%SZ')
+ expect(parseManifestIntoState(firstJson).tables[0].datetime_format).toBe('%Y-%m-%dT%H:%M:%SZ')
expect(JSON.stringify(buildManifest(parseManifestIntoState(firstJson)))).toBe(firstJson)
})
})
diff --git a/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifestBuilderLogic.test.ts b/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifestBuilderLogic.test.ts
index 6fc542c60135..4e0565700f8b 100644
--- a/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifestBuilderLogic.test.ts
+++ b/products/data_warehouse/frontend/shared/components/forms/__tests__/customSourceManifestBuilderLogic.test.ts
@@ -79,7 +79,7 @@ describe('customSourceManifestBuilderLogic', () => {
it('parses the saved manifest into form state on mount', () => {
expect(logic.values.hasContent).toBe(true)
expect(logic.values.manifestState.base_url).toBe('https://saved.example.com')
- expect(logic.values.manifestState.streams[0].name).toBe('users')
+ expect(logic.values.manifestState.tables[0].name).toBe('users')
})
it('mirrors the saved manifest into the outer form on mount', () => {
@@ -125,37 +125,37 @@ describe('customSourceManifestBuilderLogic', () => {
})
})
- describe('stream and header mutations', () => {
+ describe('table and header mutations', () => {
beforeEach(() => {
logic = customSourceManifestBuilderLogic({ setValue })
logic.mount()
})
- it('adds and removes streams', () => {
- expect(logic.values.manifestState.streams).toHaveLength(1)
- logic.actions.addStream()
- expect(logic.values.manifestState.streams).toHaveLength(2)
- logic.actions.removeStream(0)
- expect(logic.values.manifestState.streams).toHaveLength(1)
+ it('adds and removes tables', () => {
+ expect(logic.values.manifestState.tables).toHaveLength(1)
+ logic.actions.addTable()
+ expect(logic.values.manifestState.tables).toHaveLength(2)
+ logic.actions.removeTable(0)
+ expect(logic.values.manifestState.tables).toHaveLength(1)
})
- it('cascades a parent rename to dependent streams through the reducer', () => {
+ it('cascades a parent rename to dependent tables through the reducer', () => {
// The cascade behavior itself is unit-tested on the pure helpers;
// this pins that the reducer is actually wired to them.
- logic.actions.updateStream(0, { name: 'forms' })
- logic.actions.addStream()
- logic.actions.updateStream(1, { name: 'responses', parent_stream: 'forms' })
+ logic.actions.updateTable(0, { name: 'forms' })
+ logic.actions.addTable()
+ logic.actions.updateTable(1, { name: 'responses', parent_table: 'forms' })
- logic.actions.updateStream(0, { name: 'surveys' })
- expect(logic.values.manifestState.streams[1].parent_stream).toBe('surveys')
+ logic.actions.updateTable(0, { name: 'surveys' })
+ expect(logic.values.manifestState.tables[1].parent_table).toBe('surveys')
- logic.actions.removeStream(0)
- expect(logic.values.manifestState.streams[0].parent_stream).toBe('')
+ logic.actions.removeTable(0)
+ expect(logic.values.manifestState.tables[0].parent_table).toBe('')
})
- it('updates a stream paginator by index', () => {
+ it('updates a table paginator by index', () => {
logic.actions.updatePaginator(0, { type: 'cursor', cursor_path: 'meta.next', cursor_param: 'after' })
- expect(logic.values.manifestState.streams[0].paginator).toEqual({
+ expect(logic.values.manifestState.tables[0].paginator).toEqual({
type: 'cursor',
cursor_path: 'meta.next',
cursor_param: 'after',
diff --git a/products/data_warehouse/frontend/shared/components/forms/customSourceManifest.ts b/products/data_warehouse/frontend/shared/components/forms/customSourceManifest.ts
index 59907c53dc61..341a0c03ced6 100644
--- a/products/data_warehouse/frontend/shared/components/forms/customSourceManifest.ts
+++ b/products/data_warehouse/frontend/shared/components/forms/customSourceManifest.ts
@@ -58,10 +58,10 @@ function isMember<T extends string>(values: readonly T[], value: string): value
// Stable client-only ids so React lists keep input/focus state attached to the
// right row across mid-list removals. Never serialized into the manifest.
-let streamIdSeq = 0
+let tableIdSeq = 0
let headerIdSeq = 0
-export function nextStreamId(): string {
- return `stream-${streamIdSeq++}`
+export function nextTableId(): string {
+ return `table-${tableIdSeq++}`
}
export function nextHeaderId(): string {
return `header-${headerIdSeq++}`
@@ -73,7 +73,7 @@ export interface HeaderEntry {
value: string
}
-export interface StreamForm {
+export interface TableForm {
id: string
name: string
path: string
@@ -88,18 +88,18 @@ export interface StreamForm {
start_param: string
// strftime pattern for the outgoing watermark; empty → ISO-8601 default
datetime_format: string
- // Fan-out (parent/child): when `parent_stream` is set, PostHog fetches that
- // stream first and calls this one once per parent row, injecting
+ // Fan-out (parent/child): when `parent_table` is set, PostHog fetches that
+ // table first and calls this one once per parent row, injecting
// `parent_resolve_field` into the `{parent_path_param}` placeholder in the
// path. `include_from_parent` lists parent fields copied onto each child row.
- // Empty `parent_stream` means a top-level stream.
- parent_stream: string
+ // Empty `parent_table` means a top-level table.
+ parent_table: string
parent_resolve_field: string
parent_path_param: string
include_from_parent: string
// Raw-authored `endpoint.params` entries the builder has no UI for (static
// query params, the engine's incremental specs, extra resolve params).
- // Carried verbatim through parse → build so editing a stream in the builder
+ // Carried verbatim through parse → build so editing a table in the builder
// never silently drops a query param the manifest author wrote by hand.
passthrough_params: Record<string, unknown>
}
@@ -114,7 +114,7 @@ export interface ManifestState {
auth_username: string
auth_password: string
headers: HeaderEntry[]
- streams: StreamForm[]
+ tables: TableForm[]
}
export interface AuthSecrets {
@@ -128,19 +128,19 @@ export function emptyHeader(): HeaderEntry {
}
// The cleared (top-level) state of every parent-dependency field. Single
-// source for the three places that reset a dependency — emptyStream, removing
-// a parent stream, and the builder's "None" selection — so a new parent field
+// source for the three places that reset a dependency — emptyTable, removing
+// a parent table, and the builder's "None" selection — so a new parent field
// only needs a default here.
export const EMPTY_PARENT_FIELDS = {
- parent_stream: '',
+ parent_table: '',
parent_resolve_field: '',
parent_path_param: '',
include_from_parent: '',
-} satisfies Partial<StreamForm>
+} satisfies Partial<TableForm>
-export function emptyStream(): StreamForm {
+export function emptyTable(): TableForm {
return {
- id: nextStreamId(),
+ id: nextTableId(),
name: '',
path: '',
method: 'GET',
@@ -166,51 +166,49 @@ function splitCsv(value: string): string[] {
}
/**
- * Names of the streams that `streams[index]` may depend on: named, not itself,
- * and top-level — nesting is capped at one level (a stream that already has a
+ * Names of the tables that `tables[index]` may depend on: named, not itself,
+ * and top-level — nesting is capped at one level (a table that already has a
* parent can't be a parent itself), mirroring the backend validation. This also
* makes cycles structurally impossible to build in the UI.
*/
-export function eligibleParentStreams(streams: StreamForm[], index: number): string[] {
- return streams
+export function eligibleParentTables(tables: TableForm[], index: number): string[] {
+ return tables
.filter(
(other, otherIndex) =>
- otherIndex !== index && other.name.trim().length > 0 && other.parent_stream.trim().length === 0
+ otherIndex !== index && other.name.trim().length > 0 && other.parent_table.trim().length === 0
)
.map((other) => other.name)
}
/**
- * Applies a patch to one stream. Renaming a stream follows through to children
- * that reference it via `parent_stream` — otherwise their dependency would
+ * Applies a patch to one table. Renaming a table follows through to children
+ * that reference it via `parent_table` — otherwise their dependency would
* dangle silently and only fail at save time.
*/
-export function updateStreamInList(streams: StreamForm[], index: number, patch: Partial<StreamForm>): StreamForm[] {
- const oldName = streams[index]?.name
- const updated = streams.map((stream, i) => (i === index ? { ...stream, ...patch } : stream))
+export function updateTableInList(tables: TableForm[], index: number, patch: Partial<TableForm>): TableForm[] {
+ const oldName = tables[index]?.name
+ const updated = tables.map((table, i) => (i === index ? { ...table, ...patch } : table))
const newName = patch.name
if (newName === undefined || !oldName || newName === oldName) {
return updated
}
- return updated.map((stream, i) =>
- i !== index && stream.parent_stream === oldName ? { ...stream, parent_stream: newName } : stream
+ return updated.map((table, i) =>
+ i !== index && table.parent_table === oldName ? { ...table, parent_table: newName } : table
)
}
/**
- * Removes a stream. Children that depended on it have the parent dependency
- * cleared (back to top-level) so they don't reference a stream that no longer
+ * Removes a table. Children that depended on it have the parent dependency
+ * cleared (back to top-level) so they don't reference a table that no longer
* exists.
*/
-export function removeStreamFromList(streams: StreamForm[], index: number): StreamForm[] {
- const removedName = streams[index]?.name
- const remaining = streams.filter((_, i) => i !== index)
- if (!removedName || remaining.some((stream) => stream.name === removedName)) {
+export function removeTableFromList(tables: TableForm[], index: number): TableForm[] {
+ const removedName = tables[index]?.name
+ const remaining = tables.filter((_, i) => i !== index)
+ if (!removedName || remaining.some((table) => table.name === removedName)) {
return remaining
}
- return remaining.map((stream) =>
- stream.parent_stream === removedName ? { ...stream, ...EMPTY_PARENT_FIELDS } : stream
- )
+ return remaining.map((table) => (table.parent_table === removedName ? { ...table, ...EMPTY_PARENT_FIELDS } : table))
}
export function defaultState(): ManifestState {
@@ -224,7 +222,7 @@ export function defaultState(): ManifestState {
auth_username: '',
auth_password: '',
headers: [],
- streams: [emptyStream()],
+ tables: [emptyTable()],
}
}
@@ -263,29 +261,29 @@ export function buildManifest(state: ManifestState): Record<string, unknown> {
client.headers = headerMap
}
- const resources = state.streams.map((stream) => {
+ const resources = state.tables.map((table) => {
const endpoint: Record<string, unknown> = {
- path: stream.path,
- data_selector: stream.data_selector || 'data',
+ path: table.path,
+ data_selector: table.data_selector || 'data',
}
- if (stream.method !== 'GET') {
- endpoint.method = stream.method
+ if (table.method !== 'GET') {
+ endpoint.method = table.method
}
- endpoint.paginator = serializePaginator(stream.paginator)
- if (stream.incremental_enabled && stream.cursor_path.trim()) {
+ endpoint.paginator = serializePaginator(table.paginator)
+ if (table.incremental_enabled && table.cursor_path.trim()) {
const incremental: Record<string, unknown> = {
- cursor_path: stream.cursor_path.trim(),
- start_param: stream.start_param.trim() || stream.cursor_path.trim(),
+ cursor_path: table.cursor_path.trim(),
+ start_param: table.start_param.trim() || table.cursor_path.trim(),
}
// Only emit cursor_type when it differs from the backend default
// (datetime) — keeps round-tripped manifests minimal. The Custom
// source reads it for incremental-field typing and strips it before
// the REST engine builds its Incremental tracker.
- if (stream.cursor_type !== 'datetime') {
- incremental.cursor_type = stream.cursor_type
+ if (table.cursor_type !== 'datetime') {
+ incremental.cursor_type = table.cursor_type
}
- if (stream.datetime_format.trim()) {
- incremental.datetime_format = stream.datetime_format.trim()
+ if (table.datetime_format.trim()) {
+ incremental.datetime_format = table.datetime_format.trim()
}
endpoint.incremental = incremental
}
@@ -294,35 +292,35 @@ export function buildManifest(state: ManifestState): Record<string, unknown> {
// no UI for. The dependency is emitted whenever a parent is selected,
// even half-filled: an incomplete dependency must fail backend validation
// loudly (the builder UI flags the missing pieces inline) rather than be
- // silently dropped — that would sync this stream as an unrelated
+ // silently dropped — that would sync this table as an unrelated
// top-level endpoint.
- const parentStream = stream.parent_stream.trim()
- const params: Record<string, unknown> = { ...stream.passthrough_params }
- if (parentStream) {
- params[stream.parent_path_param.trim()] = {
+ const parentTable = table.parent_table.trim()
+ const params: Record<string, unknown> = { ...table.passthrough_params }
+ if (parentTable) {
+ params[table.parent_path_param.trim()] = {
type: 'resolve',
- resource: parentStream,
- field: stream.parent_resolve_field.trim(),
+ resource: parentTable,
+ field: table.parent_resolve_field.trim(),
}
}
if (Object.keys(params).length > 0) {
endpoint.params = params
}
- const primaryKeys = splitCsv(stream.primary_key)
+ const primaryKeys = splitCsv(table.primary_key)
const resource: Record<string, unknown> = {
- name: stream.name,
+ name: table.name,
// Fall back to 'id' when the field is cleared — an empty primary_key
// array produces a broken resource downstream.
primary_key: primaryKeys.length === 0 ? 'id' : primaryKeys.length === 1 ? primaryKeys[0] : primaryKeys,
endpoint,
}
- const includeFromParent = splitCsv(stream.include_from_parent)
- if (parentStream && includeFromParent.length > 0) {
+ const includeFromParent = splitCsv(table.include_from_parent)
+ if (parentTable && includeFromParent.length > 0) {
resource.include_from_parent = includeFromParent
}
// sort_mode only affects incremental resume safety. Emit only when the
// user explicitly opts into descending order — backend default is asc.
- if (stream.sort_mode === 'desc') {
+ if (table.sort_mode === 'desc') {
resource.sort_mode = 'desc'
}
return resource
@@ -425,7 +423,7 @@ export function parseManifestIntoState(rawJson: string | undefined): ManifestSta
value: String(value),
}))
const resources: unknown[] = Array.isArray(manifest.resources) ? manifest.resources : []
- const streams: StreamForm[] = resources.length > 0 ? resources.map(parseStream) : [emptyStream()]
+ const tables: TableForm[] = resources.length > 0 ? resources.map(parseTable) : [emptyTable()]
return {
base_url: asString(client.base_url),
auth_type: authType,
@@ -436,11 +434,11 @@ export function parseManifestIntoState(rawJson: string | undefined): ManifestSta
auth_username: asString(auth.username),
auth_password: asString(auth.password),
headers,
- streams,
+ tables,
}
}
-function parseStream(resource: unknown): StreamForm {
+function parseTable(resource: unknown): TableForm {
const r = asObject(resource)
const endpoint = asObject(r.endpoint)
const paginatorRaw = asObject(endpoint.paginator)
@@ -453,12 +451,12 @@ function parseStream(resource: unknown): StreamForm {
const cursorType: CursorType = isMember(CURSOR_TYPES, cursorTypeRaw) ? cursorTypeRaw : 'datetime'
const primaryKey = r.primary_key
// Recover a fan-out dependency from the first `resolve` param: its key is the
- // path placeholder, and it names the parent stream + the parent field bound in.
+ // path placeholder, and it names the parent table + the parent field bound in.
// Every other params entry (static query params, incremental specs, extra
// resolve params on a malformed manifest) is preserved verbatim so a builder
// edit can't silently drop it.
const params = asObject(endpoint.params)
- let parentStream = ''
+ let parentTable = ''
let parentResolveField = ''
let parentPathParam = ''
const passthroughParams: Record<string, unknown> = {}
@@ -466,7 +464,7 @@ function parseStream(resource: unknown): StreamForm {
const spec = asObject(value)
if (spec.type === 'resolve' && !parentPathParam) {
parentPathParam = key
- parentStream = asString(spec.resource)
+ parentTable = asString(spec.resource)
parentResolveField = asString(spec.field)
} else {
passthroughParams[key] = value
@@ -476,7 +474,7 @@ function parseStream(resource: unknown): StreamForm {
? (r.include_from_parent as unknown[]).map((field) => String(field)).join(', ')
: ''
return {
- id: nextStreamId(),
+ id: nextTableId(),
name: asString(r.name),
path: asString(endpoint.path),
method: asString(endpoint.method) === 'POST' ? 'POST' : 'GET',
@@ -489,7 +487,7 @@ function parseStream(resource: unknown): StreamForm {
cursor_type: cursorType,
start_param: asString(incremental.start_param),
datetime_format: asString(incremental.datetime_format),
- parent_stream: parentStream,
+ parent_table: parentTable,
parent_resolve_field: parentResolveField,
parent_path_param: parentPathParam,
include_from_parent: includeFromParent,
diff --git a/products/data_warehouse/frontend/shared/components/forms/customSourceManifestBuilderLogic.ts b/products/data_warehouse/frontend/shared/components/forms/customSourceManifestBuilderLogic.ts
index 9a4a1207ba20..ef6db239b70e 100644
--- a/products/data_warehouse/frontend/shared/components/forms/customSourceManifestBuilderLogic.ts
+++ b/products/data_warehouse/frontend/shared/components/forms/customSourceManifestBuilderLogic.ts
@@ -15,15 +15,15 @@ import type { FieldName } from 'kea-forms'
import {
buildManifest,
emptyHeader,
- emptyStream,
+ emptyTable,
extractAuthSecrets,
type HeaderEntry,
type ManifestState,
type Paginator,
parseManifestIntoState,
- removeStreamFromList,
- type StreamForm,
- updateStreamInList,
+ removeTableFromList,
+ type TableForm,
+ updateTableInList,
} from './customSourceManifest'
import type { customSourceManifestBuilderLogicType } from './customSourceManifestBuilderLogicType'
@@ -41,7 +41,7 @@ export interface CustomSourceManifestBuilderLogicProps {
/**
* Owns the Custom REST source's manifest-builder form state (base URL, auth,
- * headers, streams) and mirrors it into the outer source form as
+ * headers, tables) and mirrors it into the outer source form as
* `payload.manifest_json` (the non-secret RESTAPIConfig structure) plus separate
* `payload.auth_*` secret fields for the credentials.
*
@@ -62,10 +62,10 @@ export const customSourceManifestBuilderLogic = kea<customSourceManifestBuilderL
actions({
setManifestState: (state: ManifestState) => ({ state }),
updateState: (patch: Partial<ManifestState>) => ({ patch }),
- updateStream: (index: number, patch: Partial<StreamForm>) => ({ index, patch }),
+ updateTable: (index: number, patch: Partial<TableForm>) => ({ index, patch }),
updatePaginator: (index: number, paginator: Paginator) => ({ index, paginator }),
- addStream: true,
- removeStream: (index: number) => ({ index }),
+ addTable: true,
+ removeTable: (index: number) => ({ index }),
addHeader: true,
removeHeader: (index: number) => ({ index }),
updateHeader: (index: number, patch: Partial<HeaderEntry>) => ({ index, patch }),
@@ -82,20 +82,20 @@ export const customSourceManifestBuilderLogic = kea<customSourceManifestBuilderL
{
setManifestState: (_, { state }) => state,
updateState: (state, { patch }) => ({ ...state, ...patch }),
- // Rename/remove cascade to dependent child streams lives in the
+ // Rename/remove cascade to dependent child tables lives in the
// pure helpers so it stays unit-testable.
- updateStream: (state, { index, patch }) => ({
+ updateTable: (state, { index, patch }) => ({
...state,
- streams: updateStreamInList(state.streams, index, patch),
+ tables: updateTableInList(state.tables, index, patch),
}),
updatePaginator: (state, { index, paginator }) => ({
...state,
- streams: state.streams.map((stream, i) => (i === index ? { ...stream, paginator } : stream)),
+ tables: state.tables.map((table, i) => (i === index ? { ...table, paginator } : table)),
}),
- addStream: (state) => ({ ...state, streams: [...state.streams, emptyStream()] }),
- removeStream: (state, { index }) => ({
+ addTable: (state) => ({ ...state, tables: [...state.tables, emptyTable()] }),
+ removeTable: (state, { index }) => ({
...state,
- streams: removeStreamFromList(state.streams, index),
+ tables: removeTableFromList(state.tables, index),
}),
addHeader: (state) => ({ ...state, headers: [...state.headers, emptyHeader()] }),
removeHeader: (state, { index }) => ({
@@ -117,10 +117,10 @@ export const customSourceManifestBuilderLogic = kea<customSourceManifestBuilderL
{
setManifestState: () => true,
updateState: () => true,
- updateStream: () => true,
+ updateTable: () => true,
updatePaginator: () => true,
- addStream: () => true,
- removeStream: () => true,
+ addTable: () => true,
+ removeTable: () => true,
addHeader: () => true,
removeHeader: () => true,
updateHeader: () => true,
@@ -134,10 +134,10 @@ export const customSourceManifestBuilderLogic = kea<customSourceManifestBuilderL
false,
{
updateState: () => true,
- updateStream: () => true,
+ updateTable: () => true,
updatePaginator: () => true,
- addStream: () => true,
- removeStream: () => true,
+ addTable: () => true,
+ removeTable: () => true,
addHeader: () => true,
removeHeader: () => true,
updateHeader: () => true,
@@ -172,10 +172,10 @@ export const customSourceManifestBuilderLogic = kea<customSourceManifestBuilderL
listeners(({ sharedListeners }) => ({
setManifestState: sharedListeners.pushManifestToOuterForm,
updateState: sharedListeners.pushManifestToOuterForm,
- updateStream: sharedListeners.pushManifestToOuterForm,
+ updateTable: sharedListeners.pushManifestToOuterForm,
updatePaginator: sharedListeners.pushManifestToOuterForm,
- addStream: sharedListeners.pushManifestToOuterForm,
- removeStream: sharedListeners.pushManifestToOuterForm,
+ addTable: sharedListeners.pushManifestToOuterForm,
+ removeTable: sharedListeners.pushManifestToOuterForm,
addHeader: sharedListeners.pushManifestToOuterForm,
removeHeader: sharedListeners.pushManifestToOuterForm,
updateHeader: sharedListeners.pushManifestToOuterForm,