Skip to content

Commit 2a36cae

Browse files
committed
Group common code
1 parent c81519b commit 2a36cae

File tree

108 files changed

+988
-3149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+988
-3149
lines changed

apps/client/src/core/constants.ts

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
export default {
2-
// any time we roll out backward incompatible redux structure changes, this number should be bumped. It causes
3-
// anyone's setup to automatically reset & forget any previous saved redux store structure so there aren't
4-
// incompatibility problems with the latest code
5-
APP_STATE_VERSION: 8,
6-
7-
NUM_DEFAULT_ROWS: 4,
8-
GITHUB_URL: 'https://github.com/benkeen/generatedata',
9-
CHANGELOG_URL: 'https://github.com/benkeen/generatedata/blob/master/CHANGELOG.md',
10-
11-
// these map to the GD_APP_TYPE env var. They're the different available configurations for this GD installation
12-
APP_TYPES: {
13-
LOGIN: 'login',
14-
SINGLE: 'single',
15-
OPEN: 'open',
16-
CLOSED: 'closed'
17-
},
18-
19-
THEMES: [
20-
{ value: 'ambiance', label: 'Ambiance' },
21-
{ value: 'bespin', label: 'Bespin' },
22-
{ value: 'cobalt', label: 'Cobalt' },
23-
{ value: 'darcula', label: 'Darcula' },
24-
{ value: 'lucario', label: 'Lucario' }
25-
],
26-
27-
MIN_PREVIEW_ROWS: 5,
28-
MAX_PREVIEW_ROWS: 20,
29-
HEADER_HEIGHT: 66,
30-
FOOTER_HEIGHT: 66,
31-
SMALL_SCREEN_WIDTH: 720,
32-
GENERATION_BATCH_SIZE: 50,
33-
SMALL_GENERATION_COUNT: 1000,
34-
SMALL_GENERATION_COUNT_WITH_GRAPH: 5000,
35-
36-
GRAPH_RANGES: {
37-
RANGE1: 5000,
38-
RANGE2: 10000,
39-
RANGE3: 100000
40-
},
41-
42-
GRID: {
43-
SMALL_BREAKPOINT: 650,
44-
MEDIUM_BREAKPOINT: 780
45-
},
46-
47-
ZINDEXES: {
48-
DRAWER: 1300,
49-
DIALOG: 5005
50-
},
51-
52-
DATA_TYPE_GROUPS: ['humanData', 'geo', 'text', 'numeric', 'other', 'financial', 'countrySpecific'],
53-
54-
EXPORT_TYPE_GROUPS: ['core', 'programmingLanguage'],
55-
56-
CONTINENTS: ['africa', 'asia', 'centralAmerica', 'europe', 'northAmerica', 'oceania', 'southAmerica'],
57-
58-
DATE_FORMAT: 'MMM d, y',
59-
DATETIME_FORMAT: 'MMM d, y h:mm a',
60-
TIME_FORMAT: 'h:mm a'
61-
};
1+
// export default {
2+
// // any time we roll out backward incompatible redux structure changes, this number should be bumped. It causes
3+
// // anyone's setup to automatically reset & forget any previous saved redux store structure so there aren't
4+
// // incompatibility problems with the latest code
5+
// APP_STATE_VERSION: 8,
6+
7+
// NUM_DEFAULT_ROWS: 4,
8+
// GITHUB_URL: 'https://github.com/benkeen/generatedata',
9+
// CHANGELOG_URL: 'https://github.com/benkeen/generatedata/blob/master/CHANGELOG.md',
10+
11+
// // these map to the GD_APP_TYPE env var. They're the different available configurations for this GD installation
12+
// APP_TYPES: {
13+
// LOGIN: 'login',
14+
// SINGLE: 'single',
15+
// OPEN: 'open',
16+
// CLOSED: 'closed'
17+
// },
18+
19+
// THEMES: [
20+
// { value: 'ambiance', label: 'Ambiance' },
21+
// { value: 'bespin', label: 'Bespin' },
22+
// { value: 'cobalt', label: 'Cobalt' },
23+
// { value: 'darcula', label: 'Darcula' },
24+
// { value: 'lucario', label: 'Lucario' }
25+
// ],
26+
27+
// MIN_PREVIEW_ROWS: 5,
28+
// MAX_PREVIEW_ROWS: 20,
29+
// HEADER_HEIGHT: 66,
30+
// FOOTER_HEIGHT: 66,
31+
// SMALL_SCREEN_WIDTH: 720,
32+
// GENERATION_BATCH_SIZE: 50,
33+
// SMALL_GENERATION_COUNT: 1000,
34+
// SMALL_GENERATION_COUNT_WITH_GRAPH: 5000,
35+
36+
// GRAPH_RANGES: {
37+
// RANGE1: 5000,
38+
// RANGE2: 10000,
39+
// RANGE3: 100000
40+
// },
41+
42+
// GRID: {
43+
// SMALL_BREAKPOINT: 650,
44+
// MEDIUM_BREAKPOINT: 780
45+
// },
46+
47+
// ZINDEXES: {
48+
// DRAWER: 1300,
49+
// DIALOG: 5005
50+
// },
51+
52+
// DATA_TYPE_GROUPS: ['humanData', 'geo', 'text', 'numeric', 'other', 'financial', 'countrySpecific'],
53+
54+
// EXPORT_TYPE_GROUPS: ['core', 'programmingLanguage'],
55+
56+
// CONTINENTS: ['africa', 'asia', 'centralAmerica', 'europe', 'northAmerica', 'oceania', 'southAmerica'],
57+
58+
// DATE_FORMAT: 'MMM d, y',
59+
// DATETIME_FORMAT: 'MMM d, y h:mm a',
60+
// TIME_FORMAT: 'h:mm a'
61+
// };

packages/common/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist/*

packages/utils/package.json renamed to packages/common/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
2-
"name": "@generatedata/utils",
3-
"description": "Shared utility methods",
2+
"name": "@generatedata/common",
3+
"description": "Shared utility methods, constants",
44
"module": "./dist/index.js",
55
"scripts": {
66
"build": "tsc"
77
},
88
"devDependencies": {
9+
"@date-io/date-fns": "^1.3.13",
910
"@generatedata/types": "workspace:*",
1011
"@testing-library/react": "^10.4.7",
1112
"@types/jest": "^26.0.15",
13+
"date-fns": "^2.17.0",
1214
"jest": "^29.4.3",
1315
"typescript": "^5.7.3"
1416
}

packages/common/src/constants.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
export default {
2+
// any time we roll out backward incompatible redux structure changes, this number should be bumped. It causes
3+
// anyone's setup to automatically reset & forget any previous saved redux store structure so there aren't
4+
// incompatibility problems with the latest code
5+
APP_STATE_VERSION: 8,
6+
7+
NUM_DEFAULT_ROWS: 4,
8+
GITHUB_URL: 'https://github.com/benkeen/generatedata',
9+
CHANGELOG_URL: 'https://github.com/benkeen/generatedata/blob/master/CHANGELOG.md',
10+
11+
// these map to the GD_APP_TYPE env var. They're the different available configurations for this GD installation
12+
APP_TYPES: {
13+
LOGIN: 'login',
14+
SINGLE: 'single',
15+
OPEN: 'open',
16+
CLOSED: 'closed'
17+
},
18+
19+
THEMES: [
20+
{ value: 'ambiance', label: 'Ambiance' },
21+
{ value: 'bespin', label: 'Bespin' },
22+
{ value: 'cobalt', label: 'Cobalt' },
23+
{ value: 'darcula', label: 'Darcula' },
24+
{ value: 'lucario', label: 'Lucario' }
25+
],
26+
27+
MIN_PREVIEW_ROWS: 5,
28+
MAX_PREVIEW_ROWS: 20,
29+
HEADER_HEIGHT: 66,
30+
FOOTER_HEIGHT: 66,
31+
SMALL_SCREEN_WIDTH: 720,
32+
GENERATION_BATCH_SIZE: 50,
33+
SMALL_GENERATION_COUNT: 1000,
34+
SMALL_GENERATION_COUNT_WITH_GRAPH: 5000,
35+
36+
GRAPH_RANGES: {
37+
RANGE1: 5000,
38+
RANGE2: 10000,
39+
RANGE3: 100000
40+
},
41+
42+
GRID: {
43+
SMALL_BREAKPOINT: 650,
44+
MEDIUM_BREAKPOINT: 780
45+
},
46+
47+
ZINDEXES: {
48+
DRAWER: 1300,
49+
DIALOG: 5005
50+
},
51+
52+
DATA_TYPE_GROUPS: ['humanData', 'geo', 'text', 'numeric', 'other', 'financial', 'countrySpecific'],
53+
54+
EXPORT_TYPE_GROUPS: ['core', 'programmingLanguage'],
55+
56+
CONTINENTS: ['africa', 'asia', 'centralAmerica', 'europe', 'northAmerica', 'oceania', 'southAmerica'],
57+
58+
DATE_FORMAT: 'MMM d, y',
59+
DATETIME_FORMAT: 'MMM d, y h:mm a',
60+
TIME_FORMAT: 'h:mm a'
61+
};

packages/common/src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as constants from './constants';
2+
import * as arrayUtils from './utils/arrayUtils';
3+
import * as countryUtils from './utils/countryUtils';
4+
import * as generalUtils from './utils/generalUtils';
5+
import * as randomUtils from './utils/randomUtils';
6+
import * as stringUtils from './utils/stringUtils';
7+
import * as numberUtils from './utils/numberUtils';
8+
9+
export default {
10+
arrayUtils: { ...arrayUtils },
11+
countryUtils: { ...countryUtils },
12+
generalUtils: { ...generalUtils },
13+
randomUtils: { ...randomUtils },
14+
stringUtils: { ...stringUtils },
15+
numberUtils: { ...numberUtils }
16+
};
17+
18+
export { constants };
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import * as arrayUtils from '../arrayUtils';
2+
3+
describe('getUnique', () => {
4+
it('generates expected characters', () => {
5+
expect(arrayUtils.getUnique([1, 1, 1, 2])).toEqual([1, 2]);
6+
expect(arrayUtils.getUnique([])).toEqual([]);
7+
});
8+
});
9+
10+
describe('getArrayOfSize', () => {
11+
it('generated iterable array of specific size', () => {
12+
const arr = arrayUtils.getArrayOfSize(10);
13+
const newArray = arr.map((i, index) => index);
14+
15+
expect(arr.length).toEqual(10);
16+
expect(newArray).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
17+
});
18+
});
19+
20+
describe('removeItem', () => {
21+
it('removes an item from an array', () => {
22+
expect(arrayUtils.removeItem([1, 2, 3], 1)).toEqual([2, 3]);
23+
});
24+
25+
it('removes an item from an array', () => {
26+
expect(arrayUtils.removeItem([1, 2, 3], 1)).toEqual([2, 3]);
27+
});
28+
29+
it('uses strict comparison check for comparison', () => {
30+
expect(arrayUtils.removeItem(['1', '2', '3'], 1)).toEqual(['1', '2', '3']);
31+
});
32+
33+
it('removes all items with the value', () => {
34+
expect(arrayUtils.removeItem([5, 11, 2, 29, 2, 22, 2], 2)).toEqual([5, 11, 29, 22]);
35+
});
36+
37+
it('bounds checking', () => {
38+
expect(arrayUtils.removeItem([], 1)).toEqual([]);
39+
expect(arrayUtils.removeItem([1], 1)).toEqual([]);
40+
expect(arrayUtils.removeItem([1, 1, 1, 1, 1], 1)).toEqual([]);
41+
});
42+
});

0 commit comments

Comments
 (0)