-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from guardian/aa/data
feat: Add a simple table, with dummy data
- Loading branch information
Showing
5 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
node_modules | ||
dist | ||
|
||
# CloudQuery cache directory | ||
.cq | ||
|
||
# Output directory for CloudQuery | ||
data | ||
|
||
# CloudQuery log file | ||
cloudquery.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
kind: source | ||
spec: | ||
name: "ns1" | ||
registry: "grpc" | ||
path: "localhost:7777" | ||
tables: ['*'] | ||
destinations: ['file'] | ||
--- | ||
kind: destination | ||
spec: | ||
name: "file" | ||
path: "cloudquery/file" | ||
version: "v3.4.6" | ||
spec: | ||
path: "data/{{TABLE}}/{{UUID}}.{{FORMAT}}" | ||
format: "csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,50 @@ | ||
import type { Table } from '@cloudquery/plugin-sdk-javascript/schema/table'; | ||
import type { Writable } from 'stream'; | ||
import { Utf8 } from '@cloudquery/plugin-sdk-javascript/arrow'; | ||
import { createColumn } from '@cloudquery/plugin-sdk-javascript/schema/column'; | ||
import { pathResolver } from '@cloudquery/plugin-sdk-javascript/schema/resolvers'; | ||
import { createTable } from '@cloudquery/plugin-sdk-javascript/schema/table'; | ||
import type { | ||
Table, | ||
TableResolver, | ||
} from '@cloudquery/plugin-sdk-javascript/schema/table'; | ||
import type { Logger } from 'winston'; | ||
import type { Spec } from './spec.js'; | ||
|
||
export const getTables = async ( | ||
logger: Logger, | ||
spec: Spec, | ||
): Promise<Table[]> => { | ||
// TOD add tables | ||
return Promise.resolve([]); | ||
const resolver: TableResolver = async ( | ||
clientMeta: unknown, | ||
parent: unknown, | ||
stream: Writable, | ||
) => { | ||
await new Promise((_) => setTimeout(_, 500)); | ||
|
||
const data = new Array(10).fill(undefined); | ||
data.forEach((_, index) => { | ||
stream.write({ id: [index], name: [`hello ${index}`] }); | ||
}); | ||
return; | ||
}; | ||
|
||
const table = createTable({ | ||
name: 'test', | ||
columns: [ | ||
createColumn({ | ||
name: 'id', | ||
type: new Utf8(), | ||
resolver: pathResolver('id'), | ||
}), | ||
createColumn({ | ||
name: 'name', | ||
type: new Utf8(), | ||
resolver: pathResolver('name'), | ||
}), | ||
], | ||
description: 'testing', | ||
resolver, | ||
}); | ||
|
||
return Promise.resolve([table]); | ||
}; |