Skip to content

Commit

Permalink
FIX build
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Oct 7, 2023
1 parent e39c4fe commit aa65abd
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 98 deletions.
21 changes: 8 additions & 13 deletions javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
"bdd"
],
"license": "MIT",
"exports": {
".": {
"import": "./dist/es/index.js",
"default": "./dist/lib/index.js"
}
"type": "module",
"exports": "./dist/src/index.js",
"engines": {
"node": ">=16"
},
"main": "./dist/lib/index.js",
"jsnext:main": "./dist/es/index.js",
"module": "./dist/es/index.js",
"types": "./dist/es/index.d.ts",
"types": "./dist/src/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -33,10 +29,9 @@
"prepublish": "npm run build",
"lint": "tslint --project .",
"lint:fix": "tslint --project . --fix",
"transpile": "tsc -p ./ --module commonjs && echo '# transpile es5 (require) sucess!'",
"transpile:es": "tsc -p ./ --outDir ./dist/es && echo '# transpile es (modules) sucess!'",
"transpile": "tsc -p ./ && echo '# transpile es (modules) sucess!'",
"transpile:removegen": "rimraf -r ./dist/lib/truth-table-generator && rimraf -r ./dist/es/truth-table-generator",
"build": "rimraf -r ./dist && npm run transpile && npm run transpile:es && npm run transpile:removegen",
"build": "rimraf -r ./dist && npm run transpile && npm run transpile:removegen",
"dry": "npm pack --dry-run",
"test": "mocha -r ts-node/register test/unit/index.test.ts --timeout 50000 --bail",
"dev": "mocha -r ts-node/register test/unit/index.test.ts --watch --watch-extensions ts",
Expand All @@ -59,7 +54,7 @@
"clone": "2.1.2",
"deep-equal": "2.2.2",
"faker": "5.5.3",
"minimongo": "6.8.3",
"minimongo": "6.15.1",
"mocha": "10.2.0",
"pouchdb-selector-core": "8.0.1",
"read-last-lines": "1.8.0",
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/truth-table-generator/binary-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function oppositeBinary(i: string): string {
}

export function stateSetToObject(stateSet: StateSet): any {
const ret = {};
const ret: any = {};
let i = 0;
orderedStateList.forEach(s => {
ret[s] = stateSet[i];
Expand Down
6 changes: 3 additions & 3 deletions javascript/src/truth-table-generator/data-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function randomHuman(partial?: Partial<Human>): Human {
};
if (partial) {
Object.entries(partial).forEach(([k, v]) => {
ret[k] = v;
(ret as any)[k] = v;
});
}

Expand All @@ -59,7 +59,7 @@ export function randomChangeHuman(input: Human): Human {
const cloned: Human = Object.assign({}, input);

const field = fakerDatatype.number({ min: 1, max: 3 });
keyToChangeFn[field](cloned);
(keyToChangeFn as any)[field](cloned);

return cloned;
}
Expand All @@ -84,7 +84,7 @@ export function randomChangeEvent(
const randomOp = randomOfArray(ops);

const operation = allDocs.length === 0 ? 'INSERT' : randomOp;
let ret;
let ret: any;
switch (operation) {
case 'INSERT':
const newDoc = randomHuman();
Expand Down
4 changes: 2 additions & 2 deletions javascript/src/truth-table-generator/minimongo-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
import {
compileDocumentSelector,
compileSort
} from 'minimongo/src/selector';
} from 'minimongo/lib/selector.js';
export {
compileDocumentSelector,
compileSort
} from 'minimongo/src/selector';
} from 'minimongo/lib/selector.js';
import {
randomString
} from 'async-test-util';
Expand Down
8 changes: 4 additions & 4 deletions javascript/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function tryToFillPreviousDoc<DocType>(
input.changeEvent.previous = doc;
}
} else {
const found = input.previousResults.find(item => item[primary] === id);
const found = input.previousResults.find(item => (item as any)[primary] === id);
if (found) {
input.changeEvent.previous = found;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export function getSortFieldsOfQuery(query: MongoQuery): string[] {
}
return query.sort.map(maybeArray => {
if (Array.isArray(maybeArray)) {
return maybeArray[0].map(field => normalizeSortField(field));
return maybeArray[0].map((field: any) => normalizeSortField(field));
} else {
return normalizeSortField(maybeArray);
}
Expand All @@ -85,7 +85,7 @@ export function replaceCharAt(str: string, index: number, replacement: string) {
export function mapToObject<K, V>(map: Map<K, V>): {
[k: string]: V
} {
const ret = {};
const ret: any = {};
map.forEach(
(value: V, key: K) => {
ret[key as any] = value;
Expand All @@ -105,7 +105,7 @@ export function objectToMap<K, V>(object: {
}

export function cloneMap<K, V>(map: Map<K, V>): Map<K, V> {
const ret = new Map();
const ret: any = new Map();
map.forEach(
(value: V, key: K) => {
ret[key as any] = value;
Expand Down
10 changes: 5 additions & 5 deletions javascript/test/helper/input.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
StateResolveFunctionInput,
QueryParams
} from '../../src/types';
import { Human } from '../../src/truth-table-generator/types';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper';
import { randomChangeEvent } from '../../src/truth-table-generator/data-generator';
} from '../../src/types/index.js';
import { Human } from '../../src/truth-table-generator/types.js';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper.js';
import { randomChangeEvent } from '../../src/truth-table-generator/data-generator.js';

export function getExampleStateResolveFunctionInput(): StateResolveFunctionInput<Human> {
const queryParams: QueryParams<Human> = getQueryParamsByMongoQuery({
Expand All @@ -17,4 +17,4 @@ export function getExampleStateResolveFunctionInput(): StateResolveFunctionInput
queryParams
};

}
}
16 changes: 8 additions & 8 deletions javascript/test/unit/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import * as assert from 'assert';
import {
orderedActionList,
actionFunctions
} from '../../src/actions';
} from '../../src/actions/index.js';
import {
ActionFunction,
ActionName,
ActionFunctionInput,
ResultKeyDocumentMap
} from '../../src/types';
import { randomChangeEvent, randomHuman, randomHumans } from '../../src/truth-table-generator/data-generator';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper';
import { Human } from '../../src/truth-table-generator/types';
import { insertFirst, insertLast, removeExisting, insertAtSortPosition } from '../../src/actions/action-functions';
} from '../../src/types/index.js';
import { randomChangeEvent, randomHuman, randomHumans } from '../../src/truth-table-generator/data-generator.js';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper.js';
import { Human } from '../../src/truth-table-generator/types.js';
import { insertFirst, insertLast, removeExisting, insertAtSortPosition } from '../../src/actions/action-functions.js';

export function docsToMap<DocType>(
primary: string,
docs: DocType[]
): ResultKeyDocumentMap<DocType> {
const map: ResultKeyDocumentMap<DocType> = new Map();
docs.forEach(doc => {
map.set(doc[primary], doc);
map.set((doc as any)[primary], doc);
});
return map;
}
Expand Down Expand Up @@ -48,7 +48,7 @@ export function runCheckedAction<DocType = any>(

// ensure correct all docs are also in key-doc-map
input.previousResults.forEach(doc => {
const mapDoc = (input.keyDocumentMap as ResultKeyDocumentMap<DocType>).get(doc[primary]);
const mapDoc = (input.keyDocumentMap as ResultKeyDocumentMap<DocType>).get((doc as any)[primary]);
assert.ok(mapDoc);
assert.deepStrictEqual(doc, mapDoc);
});
Expand Down
6 changes: 3 additions & 3 deletions javascript/test/unit/binary-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
decimalToPaddedBinary,
binaryToDecimal,
LAST_STATE_SET
} from '../../src/truth-table-generator/binary-state';
} from '../../src/truth-table-generator/binary-state.js';
import {
orderedStateList
} from '../../src/states';
import { StateSet } from '../../src/types';
} from '../../src/states/index.js';
import { StateSet } from '../../src/types/index.js';


describe('binary-state.test.ts', () => {
Expand Down
18 changes: 9 additions & 9 deletions javascript/test/unit/calculate-bdd-quality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import {
measurePerformanceOfStateFunctions,
countFunctionUsages,
getQualityOfBdd
} from '../../src/truth-table-generator/calculate-bdd-quality';
} from '../../src/truth-table-generator/calculate-bdd-quality.js';
import {
orderedStateList
} from '../../src/states';
import { StateActionIdMap } from '../../src/truth-table-generator/types';
import { OUTPUT_TRUTH_TABLE_PATH } from '../../src/truth-table-generator/config';
import { readJsonFile } from '../../src/truth-table-generator/util';
import { objectToMap } from '../../src';
import { orderedActionList } from '../../src/actions';
} from '../../src/states/index.js';
import { StateActionIdMap } from '../../src/truth-table-generator/types.js';
import { OUTPUT_TRUTH_TABLE_PATH } from '../../src/truth-table-generator/config.js';
import { readJsonFile } from '../../src/truth-table-generator/util.js';
import { objectToMap } from '../../src/index.js';
import { orderedActionList } from '../../src/actions/index.js';
import {
DEFAULT_EXAMPLE_QUERY
} from '../../src/truth-table-generator/queries';
} from '../../src/truth-table-generator/queries.js';
import {
insertFiveSorted
} from '../../src/truth-table-generator/procedures';
} from '../../src/truth-table-generator/procedures.js';

describe('calculate-bdd-quality.test.ts', () => {
const unknownValueActionId: number = 42;
Expand Down
6 changes: 3 additions & 3 deletions javascript/test/unit/fuzzing.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as assert from 'assert';

import { fuzzing } from '../../src/truth-table-generator/fuzzing';
import { orderedActionList } from '../../src/actions';
import { StateActionIdMap } from '../../src/truth-table-generator/types';
import { fuzzing } from '../../src/truth-table-generator/fuzzing.js';
import { orderedActionList } from '../../src/actions/index.js';
import { StateActionIdMap } from '../../src/truth-table-generator/types.js';

describe('fuzzing.test.ts', () => {

Expand Down
28 changes: 14 additions & 14 deletions javascript/test/unit/generated-stuff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ import {
import {
orderedStateList,
stateResolveFunctions
} from '../../src/states';
} from '../../src/states/index.js';
import {
objectToMap
} from '../../src/util';
} from '../../src/util.js';
import {
readJsonFile
} from '../../src/truth-table-generator/util';
import { OUTPUT_TRUTH_TABLE_PATH } from '../../src/truth-table-generator/config';
import { StateActionIdMap, Human } from '../../src/truth-table-generator/types';
import { getSimpleBdd } from '../../src/bdd/bdd.generated';
} from '../../src/truth-table-generator/util.js';
import { OUTPUT_TRUTH_TABLE_PATH } from '../../src/truth-table-generator/config.js';
import { StateActionIdMap, Human } from '../../src/truth-table-generator/types.js';
import { getSimpleBdd } from '../../src/bdd/bdd.generated.js';
import {
StateResolveFunctionInput,
QueryParams,
MongoQuery,
ChangeEvent
} from '../../src/types';
} from '../../src/types/index.js';
import {
getQueryParamsByMongoQuery,
getMinimongoCollection,
applyChangeEvent,
minimongoFind,
minimongoUpsert
} from '../../src/truth-table-generator/minimongo-helper';
import { randomHuman } from '../../src/truth-table-generator/data-generator';
import { calculateActionName, calculateActionFromMap, runAction } from '../../src/index';
import { getQueryVariations } from '../../src/truth-table-generator/queries';
import { getTestProcedures, oneThatWasCrashing } from '../../src/truth-table-generator/procedures';
} from '../../src/truth-table-generator/minimongo-helper.js';
import { randomHuman } from '../../src/truth-table-generator/data-generator.js';
import { calculateActionName, calculateActionFromMap, runAction } from '../../src/index.js';
import { getQueryVariations } from '../../src/truth-table-generator/queries.js';
import { getTestProcedures, oneThatWasCrashing } from '../../src/truth-table-generator/procedures.js';
import deepEqual = require('deep-equal');
import { orderedActionList } from '../../src/actions';
import { orderedActionList } from '../../src/actions/index.js';


describe('generated-stuff.test.ts', () => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('generated-stuff.test.ts', () => {
const sortedResolvers = {};
orderedStateList.forEach((stateName, index) => {
const fn = stateResolveFunctions[stateName];
sortedResolvers[index] = (i: any) => {
(sortedResolvers as any)[index] = (i: any) => {
const ret = fn(i);
// console.log('resolve: ' + index + ' returned ' + ret);
return ret;
Expand Down
18 changes: 9 additions & 9 deletions javascript/test/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
console.log('### starting unit-tests ###');
import './minimongo.test';
import './actions.test';
import './states.test';
import './binary-state.test';
import './queries.test';
import './fuzzing.test';
import './calculate-bdd-quality.test';
import './truth-table-generator.test';
import './minimongo.test.js';
import './actions.test.js';
import './states.test.js';
import './binary-state.test.js';
import './queries.test.js';
import './fuzzing.test.js';
import './calculate-bdd-quality.test.js';
import './truth-table-generator.test.js';

// should be last
import './generated-stuff.test';
import './generated-stuff.test.js';
6 changes: 3 additions & 3 deletions javascript/test/unit/minimongo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import * as assert from 'assert';

import {
randomHuman, randomHumans
} from '../../src/truth-table-generator/data-generator';
} from '../../src/truth-table-generator/data-generator.js';

import {
getMinimongoCollection,
minimongoUpsert,
minimongoFind,
compileSort
} from '../../src/truth-table-generator/minimongo-helper';
} from '../../src/truth-table-generator/minimongo-helper.js';
import { clone } from 'async-test-util';
import { MongoQuery } from '../../src';
import { MongoQuery } from '../../src/index.js';

/**
* sometimes we think stuff is wrong with minimongo
Expand Down
2 changes: 1 addition & 1 deletion javascript/test/unit/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SKIP_VARIATIONS,
LIMIT_VARIATIONS,
SORT_VARIATION
} from '../../src/truth-table-generator/queries';
} from '../../src/truth-table-generator/queries.js';

describe('queries-state.test.ts', () => {
it('should have all query variations', () => {
Expand Down
14 changes: 7 additions & 7 deletions javascript/test/unit/states.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
stateResolveFunctions,
getStateSet,
stateResolveFunctionByIndex
} from '../../src/states';
import { getExampleStateResolveFunctionInput } from '../helper/input';
import { StateResolveFunctionInput } from '../../src/types';
} from '../../src/states/index.js';
import { getExampleStateResolveFunctionInput } from '../helper/input.js';
import { StateResolveFunctionInput } from '../../src/types/index.js';
import { clone } from 'async-test-util';
import {
wasSortedAfterLast,
Expand All @@ -16,10 +16,10 @@ import {
wasLimitReached,
wasMatching,
isSortedBeforeFirst
} from '../../src/states/state-resolver';
import { randomHuman } from '../../src/truth-table-generator/data-generator';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper';
import { Human } from '../../src/truth-table-generator/types';
} from '../../src/states/state-resolver.js';
import { randomHuman } from '../../src/truth-table-generator/data-generator.js';
import { getQueryParamsByMongoQuery } from '../../src/truth-table-generator/minimongo-helper.js';
import { Human } from '../../src/truth-table-generator/types.js';

describe('states.test.ts', () => {
describe('basic', () => {
Expand Down
Loading

0 comments on commit aa65abd

Please sign in to comment.