Skip to content

Commit 5151b11

Browse files
committed
cleanup
1 parent fb81f43 commit 5151b11

11 files changed

+47
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
".esm-wrapper.mjs"
3434
],
3535
"scripts": {
36-
"test": "nyc mocha --timeout 5000 --colors -r ts-node/register test/*.ts",
36+
"test": "nyc mocha --timeout 5000 --colors -r ts-node/register test/*.ts src/**/*.test.ts",
3737
"test-example-parse-from-file": "ts-node examples/parse-from-file.ts",
3838
"test-example-parse-schema": "ts-node examples/parse-schema.ts",
3939
"test-time": "ts-node ./test/time-testing.ts",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
SimplifiedSchema
1919
} from './schema-analyzer';
2020
import * as schemaStats from './stats';
21-
import { AnyIterable, StandardJSONSchema, MongoDBJSONSchema, ExtendedJSONSchema } from './types';
21+
import { AnyIterable, StandardJSONSchema, MongoDBJSONSchema, ExpandedJSONSchema } from './types';
2222

2323
/**
2424
* Analyze documents - schema can be retrieved in different formats.
@@ -77,7 +77,7 @@ export type {
7777
SimplifiedSchema,
7878
StandardJSONSchema,
7979
MongoDBJSONSchema,
80-
ExtendedJSONSchema
80+
ExpandedJSONSchema
8181
};
8282

8383
export {

src/schema-accessor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Schema as InternalSchema } from './schema-analyzer';
22
import convertors from './schema-convertors';
3-
import { ExtendedJSONSchema, MongoDBJSONSchema, StandardJSONSchema } from './types';
3+
import { ExpandedJSONSchema, MongoDBJSONSchema, StandardJSONSchema } from './types';
44

55
export interface SchemaAccessor {
66
getStandardJsonSchema: () => Promise<StandardJSONSchema>;
77
getMongoDBJsonSchema: () => Promise<MongoDBJSONSchema>;
8-
getExtendedJsonSchema: () => Promise<ExtendedJSONSchema>;
8+
getExpandedJSONSchema: () => Promise<ExpandedJSONSchema>;
99
getInternalSchema: () => Promise<InternalSchema>;
1010
}
1111

@@ -23,7 +23,7 @@ export class InternalSchemaBasedAccessor implements SchemaAccessor {
2323
private internalSchema: InternalSchema;
2424
private standardJSONSchema?: StandardJSONSchema;
2525
private mongodbJSONSchema?: MongoDBJSONSchema;
26-
private extendedJSONSchema?: ExtendedJSONSchema;
26+
private ExpandedJSONSchema?: ExpandedJSONSchema;
2727

2828
constructor(internalSchema: InternalSchema) {
2929
this.internalSchema = internalSchema;
@@ -41,7 +41,7 @@ export class InternalSchemaBasedAccessor implements SchemaAccessor {
4141
return this.mongodbJSONSchema ??= await convertors.internalSchemaToMongoDB(this.internalSchema, options);
4242
}
4343

44-
async getExtendedJsonSchema(options: Options = {}): Promise<ExtendedJSONSchema> {
45-
return this.extendedJSONSchema ??= await convertors.internalSchemaToExtended(this.internalSchema, options);
44+
async getExpandedJSONSchema(options: Options = {}): Promise<ExpandedJSONSchema> {
45+
return this.ExpandedJSONSchema ??= await convertors.internalSchemaToExpanded(this.internalSchema, options);
4646
}
4747
}

src/schema-convertors.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/schema-convertors/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import internalSchemaToExpanded from './internalToExpanded';
2+
import internalSchemaToMongoDB from './internalToMongoDB';
3+
import internalSchemaToStandard from './internalToStandard';
4+
5+
export default {
6+
internalSchemaToStandard,
7+
internalSchemaToMongoDB,
8+
internalSchemaToExpanded
9+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { InternalSchema } from '..';
2+
import { ExpandedJSONSchema } from '../types';
3+
4+
export default function internalSchemaToExpanded(
5+
internalSchema: InternalSchema,
6+
options: {
7+
signal?: AbortSignal
8+
}): ExpandedJSONSchema {
9+
// TODO: COMPASS-8702
10+
return {} as ExpandedJSONSchema;
11+
}

src/schema-convertors/internalToMongoDB.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert';
22
import internalSchemaToStandard from './internalToMongoDB';
33

4-
describe.only('internalSchemaToStandard', function() {
4+
describe('internalSchemaToStandard', function() {
55
describe('Converts: ', function() {
66
it('get me analyzed thing', async function() {
77
const internal = {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { InternalSchema } from '..';
2+
import { StandardJSONSchema } from '../types';
3+
4+
export default function internalSchemaToStandard(
5+
internalSchema: InternalSchema,
6+
options: {
7+
signal?: AbortSignal
8+
}): StandardJSONSchema {
9+
// TODO: COMPASS-8700
10+
return {} as StandardJSONSchema;
11+
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type MongoDBJSONSchema = Pick<StandardJSONSchema, 'title' | 'required' |
99
anyOf?: MongoDBJSONSchema[];
1010
}
1111

12-
export type ExtendedJSONSchema = StandardJSONSchema & {
12+
export type ExpandedJSONSchema = StandardJSONSchema & {
1313
['x-bsonType']: string;
1414
['x-metadata']: {
1515
hasDuplicates: boolean;

test/analyze-documents.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ describe('analyzeDocuments', function() {
1515
});
1616

1717
it('Only converts the same format once', async function() {
18-
const convertSpy = sinon.spy(convertors, 'internalSchemaToExtended');
18+
const convertSpy = sinon.spy(convertors, 'internalSchemaToExpanded');
1919
const analyzeResults = await analyzeDocuments(docs);
20-
await analyzeResults.getExtendedJsonSchema();
21-
await analyzeResults.getExtendedJsonSchema();
22-
await analyzeResults.getExtendedJsonSchema();
20+
await analyzeResults.getExpandedJSONSchema();
21+
await analyzeResults.getExpandedJSONSchema();
22+
await analyzeResults.getExpandedJSONSchema();
2323
assert.strictEqual(convertSpy.calledOnce, true);
2424
});
2525
});

0 commit comments

Comments
 (0)