generated from samhuk/ts-npm-package-template
-
-
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.
* initial commit of v5 * add relations, and very basic createTsPgOrm * complete bulk of data formats and relations. Begin stores. * Complete migration of get and getMany store functions * recursively expand but leaf node at Date objects * Complete bulk of v5. Remove all v4 code. Adapt integration tests. Remaining: unit tests. * Add temporary ts-ignore * Early unit test drive * Early unit test drive * Add create sql fns * Update README partially. Update record types. * version to 5.0.0. Etc.
- Loading branch information
Showing
85 changed files
with
2,393 additions
and
4,932 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
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,57 +1,89 @@ | ||
import { setObjPropDeep } from './obj' | ||
import { readObjPropDeep, setObjPropDeep } from './obj' | ||
|
||
describe('setObjPropDeep', () => { | ||
const fn = setObjPropDeep | ||
describe('common/obj', () => { | ||
describe('setObjPropDeep', () => { | ||
const fn = setObjPropDeep | ||
|
||
test('basic test', () => { | ||
const obj = { | ||
a: { | ||
b: { | ||
c: { | ||
test('basic test', () => { | ||
const obj = { | ||
a: { | ||
b: { | ||
c: { | ||
|
||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
const newObj = fn(obj, ['a', 'b', 'c', 'd'], 'new value') | ||
const newObj = fn(obj, ['a', 'b', 'c', 'd'], 'new value') | ||
|
||
expect(newObj).toEqual({ | ||
a: { | ||
b: { | ||
c: { | ||
d: 'new value', | ||
expect(newObj).toEqual({ | ||
a: { | ||
b: { | ||
c: { | ||
d: 'new value', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
|
||
test('basic test - createIfNotExists = true', () => { | ||
const obj = { | ||
a: { }, | ||
} | ||
test('basic test - createIfNotExists = true', () => { | ||
const obj = { | ||
a: { }, | ||
} | ||
|
||
const newObj = fn(obj, ['a', 'b', 'c', 'd'], 'new value', true) | ||
const newObj = fn(obj, ['a', 'b', 'c', 'd'], 'new value', true) | ||
|
||
expect(newObj).toEqual({ | ||
a: { | ||
b: { | ||
c: { | ||
d: 'new value', | ||
expect(newObj).toEqual({ | ||
a: { | ||
b: { | ||
c: { | ||
d: 'new value', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
test('basic test - single path segment', () => { | ||
const obj = {} | ||
|
||
const newObj = fn(obj, ['a'], 'new value', false) | ||
|
||
expect(newObj).toEqual({ | ||
a: 'new value', | ||
}) | ||
}) | ||
}) | ||
|
||
test('basic test - single path segment', () => { | ||
const obj = {} | ||
describe('readObjPropDeep', () => { | ||
const fn = readObjPropDeep | ||
|
||
test('basic test', () => { | ||
const obj = { | ||
a: { | ||
b: { | ||
c: { | ||
d: 'val', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
expect(fn(obj, ['a', 'b', 'c'])).toEqual({ d: 'val' }) | ||
expect(fn(obj, ['a', 'b', 'c', 'd'])).toEqual('val') | ||
}) | ||
|
||
test('basic test - single path segment', () => { | ||
const obj: any = {} | ||
expect(fn(obj, ['a'])).toEqual(undefined) | ||
|
||
const newObj = fn(obj, ['a'], 'new value', false) | ||
obj.a = null | ||
expect(fn(obj, ['a'])).toEqual(null) | ||
|
||
expect(newObj).toEqual({ | ||
a: 'new value', | ||
obj.a = 'val' | ||
expect(fn(obj, ['a'])).toEqual('val') | ||
}) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
import { DataType, NumSubType, StrSubType } from './types/dataType' | ||
import { FieldList } from './types/field' | ||
|
||
export const filterForCreateRecordField = (fieldList: FieldList) => ( | ||
fieldList.filter(f => !( | ||
(f.type === DataType.NUM && f.subType === NumSubType.SERIAL) | ||
|| (f.type === DataType.STR && f.subType === StrSubType.UUID_V4 && f.autoGenerate) | ||
|| (f.type === DataType.EPOCH && f.defaultToCurrentEpoch) | ||
)) | ||
) |
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,16 @@ | ||
import { camelCaseToSnakeCase, quote } from '../helpers/string' | ||
import { Field, FieldOptions, FieldsOptions } from './types/field' | ||
|
||
export const createCommonFields = <T extends FieldsOptions>(v: T): T => v | ||
|
||
export const createField = (fieldName: string, fieldOptions: FieldOptions): Field => { | ||
const unquotedColumnName = fieldOptions.columnName ?? camelCaseToSnakeCase(fieldName) | ||
return { | ||
...fieldOptions, | ||
name: fieldName, | ||
sql: { | ||
columnName: quote(unquotedColumnName), | ||
unquotedColumnName, | ||
}, | ||
} | ||
} |
Oops, something went wrong.