Skip to content

Commit

Permalink
Rename context folder
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Jul 25, 2024
1 parent 1cf0c92 commit 65ef821
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 10 deletions.
158 changes: 158 additions & 0 deletions runner/src/context-builder/__snapshots__/context.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ContextBuilder unit tests Context object social api can fetch from the near social api 1`] = `
[
[
"https://api.near.social/index",
{
"body": "{"action":"post","key":"main","options":{"limit":1,"order":"desc"}}",
"headers": {
"Content-Type": "application/json",
},
"method": "POST",
},
],
]
`;

exports[`ContextBuilder unit tests ContextBuilder adds CRUD operations for table 1`] = `
{
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
}
`;

exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 1`] = `
{
"Posts": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
}
`;

exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 2`] = `
{
"Comments": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"PostLikes": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"Posts": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
}
`;

exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 3`] = `
{
"CommentsTable": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"Posts": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
}
`;

exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 4`] = `
{
"AnotherTable": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"Comments": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"ComposerQuest": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"ContractorQuest": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"CreatorQuest": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"MyTable1": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"PostLikes": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"Posts": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"ThirdTable": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
"YetAnotherTable": {
"delete": [Function],
"insert": [Function],
"select": [Function],
"update": [Function],
"upsert": [Function],
},
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type fetch from 'node-fetch';
import type DmlHandler from '../dml-handler';
import IndexerConfig from '../indexer-config';
import { LogLevel } from '../indexer-meta/log-entry';
import ContextBuilder from './context';
import ContextBuilder from './context-builder';

describe('ContextBuilder unit tests', () => {
const MOCK_CONFIG = {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions runner/src/context-builder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './context-builder';
export type { ContextObject } from './context-builder';
2 changes: 0 additions & 2 deletions runner/src/context/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions runner/src/indexer/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { LogLevel } from '../indexer-meta/log-entry';
import IndexerConfig from '../indexer-config/indexer-config';
import { IndexerStatus } from '../indexer-meta';
import type IndexerMeta from '../indexer-meta';
import ContextBuilder from '../context';
import { type ContextObject } from '../context';
import ContextBuilder from '../context-builder';
import { type ContextObject } from '../context-builder';

describe('Indexer unit tests', () => {
const SIMPLE_REDIS_STREAM = 'test:stream';
Expand Down
4 changes: 2 additions & 2 deletions runner/src/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LogEntry from '../indexer-meta/log-entry';
import type IndexerConfig from '../indexer-config';
import { IndexerStatus } from '../indexer-meta';
import { type IndexerMetaInterface } from '../indexer-meta/indexer-meta';
import type ContextBuilder from '../context';
import type ContextBuilder from '../context-builder';

interface Dependencies {
contextBuilder: ContextBuilder
Expand All @@ -28,7 +28,7 @@ export default class Indexer {
tracer = trace.getTracer('queryapi-runner-indexer');

private readonly logger: typeof logger;
private readonly deps: Required<Dependencies>;
readonly deps: Required<Dependencies>;
private currentStatus?: string;

constructor (
Expand Down
4 changes: 3 additions & 1 deletion runner/src/local-indexer/local-indexer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ContextBuilder from '../context-builder';
import InMemoryDmlHandler from '../dml-handler/in-memory-dml-handler';
import IndexerConfig from '../indexer-config';
import { type LocalIndexerConfig } from '../indexer-config/indexer-config';
Expand All @@ -20,8 +21,9 @@ export default class LocalIndexer {
logLevel: config.logLevel,
});
const dmlHandler = new InMemoryDmlHandler(config.schema);
const contextBuilder = new ContextBuilder(fullIndexerConfig, { dmlHandler });
const indexerMeta = new NoOpIndexerMeta(config);
this.indexer = new Indexer(fullIndexerConfig, { indexerMeta, dmlHandler });
this.indexer = new Indexer(fullIndexerConfig, { indexerMeta, contextBuilder });
this.lakeClient = new LakeClient();
}

Expand Down
2 changes: 1 addition & 1 deletion runner/src/stream-handler/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import parentLogger from '../logger';
import { wrapSpan } from '../utility';
import { type PostgresConnectionParams } from '../pg-client';
import DmlHandler from '../dml-handler/dml-handler';
import ContextBuilder from '../context';
import ContextBuilder from '../context-builder';

if (isMainThread) {
throw new Error('Worker should not be run on main thread');
Expand Down
2 changes: 1 addition & 1 deletion runner/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LogLevel } from '../src/indexer-meta/log-entry';
import IndexerConfig from '../src/indexer-config';
import IndexerMeta from '../src/indexer-meta/indexer-meta';
import DmlHandler from '../src/dml-handler/dml-handler';
import ContextBuilder from '../src/context';
import ContextBuilder from '../src/context-builder';

describe('Indexer integration', () => {
jest.setTimeout(300_000);
Expand Down

0 comments on commit 65ef821

Please sign in to comment.