FirelordJS

🔥High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience

MIT License

Downloads
1.2K
Stars
84
Committers
5
FirelordJS - 2.8.18 Latest Release

Published by tylim88 6 months ago

Firelord React Native

  1. fixed some field values being exported as object instead of function

Firelord Admin

  1. simplify internal field values type

Firelord Web

  1. no changes
FirelordJS - 2.8.15

Published by tylim88 6 months ago

remove document path trailing slash, it used to be 'a/b/c/d/', now it is 'a/b/c'

the trailing slash apparently causes random fail in tests(?)

FirelordJS - 2.8.7

Published by tylim88 7 months ago

fix nested object in mapped type is not partial in update


type DU = MetaTypeCreator<Record<string, { k: Record<`${1 | 2 | 3}`, number> }>, 'abc'>
const du = getFirelord<DU>(getFirestore(), 'abc')
const docRef = du.doc('123')

updateDoc(docRef, { x: { k: { '1': 1 } } }) // unexpected error requires all properties to present, now is fixed
FirelordJS - 2.8.6

Published by tylim88 7 months ago

fix value of where clause top level field from discriminated unions being never

import {
	MetaTypeCreator,
	query,
	where,
} from 'firelordjs'

type DU = MetaTypeCreator<
	{ c: false } | { c: true; v: 0 },
	'abc'
>
const du = getFirelord<DU>(getFirestore(), 'abc')

query(du.collection(), where('v', '==', 0)) //should be ok but error
FirelordJS - 2.8.5

Published by tylim88 7 months ago

  1. export ArrayUnionOrRemove type

  2. fix discriminated union value is inferred as never in where clause

import {
	MetaTypeCreator,
	query,
	where,
} from 'firelordjs'

type DU = MetaTypeCreator<
	{ a: { b: 1; c: 2 } | { b: 'a'; d: 'b' } },
	'abc'
>
const du = getFirelord<DU>(getFirestore(), 'abc')

query(du.collection(), where('a.b', '==', 2)) // previously no error but is expected to error 
FirelordJS - 2.8.2

Published by tylim88 8 months ago

solved where clause unable to get all keys of object unions type

FirelordJS - 2.8.0

Published by tylim88 8 months ago

now require typescript 5.4.2 and above

also please change your vscode TS version to 5.4.2, guide: https://firelordjs.com/change_ts_version

FirelordJS - 2.7.0

Published by tylim88 12 months ago

no longer support full flattened path if the key is string

given this type:

{
  a: Record<string,{ b: number, c: { d: string } }>
}

previously firelord generates the flattened path that look like:

{
  a: Record<string,{ b: number, c: { d: string } }>
  [x : `a.${string}`]: { b: number, c: { d: string } }
  [x : `a.${string}.b`]: number
  [x : `a.${string}.c`]: { d: string }
  [x : `a.${string}.c.d`]: string
}

the problem is: a.${string}.b, a.${string}.c and a.${string}.c.d will collapsed into a.${string}

to address this issue, firelord now generates:

{
  a: Record<string, { b: number, c: { d: string }, `c.d`: string }>
}

firelord will not attempt to flatten mapped type, but will still continue to flatten any nested object literal type, in this case it is the c.d

affected operation: all update operations

Remove JSON type

JSON type is now available by accessing meta type instead: Example['readJSON']

FirelordJS - 2.6.29

Published by tylim88 about 1 year ago

solved discriminated union not working correctly when using it with ternary

	type DU = MetaTypeCreator<
		| { a: { b: 1; c: 2 } | { b: 'a'; d: 'b' } }
		| { x: { y: 1; z: 2; u: 3 } | { y: 'a'; w: 'b'; v: 'c' } | false },
		'abc'
	>

	const du = getFirelord<DU>(getFirestore(), 'abc')

	const docRef = du.doc('123')

	const v = false as boolean

	const x = v
		? {
				y: 1 as const,
		  }
		: {
				w: 'b' as const,
		  }

	// ok as expected
	updateDoc(docRef, {
		x,
	})

	// should be ok but error
	// this error is unrelated to const assertion because of const modifier on type parameters
	updateDoc(docRef, {
		x: v
			? {
					y: 1,
					z: 2,
			  }
			: {
					w: 'b',
					v: 'c',
			  },
	})

	const data = {
		x: v
			? {
					y: 1,
					z: 2,
					u: 3,
			  }
			: {
					y: 'a',
					w: 'b',
					v: 'c',
			  },
	}
	// should be error because no const assertion but ok
	updateDoc(docRef, data)

image

2.6.29 fixed these issues

FirelordJS - 2.6.28

Published by tylim88 about 1 year ago

fix discriminated unions not working in update operations (result in false error)

FirelordJS - 2.6.27

Published by tylim88 about 1 year ago

set operation throw false type error when working with mapped type where the key type is string

example meta type

type A = MetatypeCreator<{
   a: Record<string, number>
},'id'>

this will throw type error even though it should be correct

const b:string = "zzz"

setDoc(ref, { a: { [b]: "yyy" } })

this is because keyof type { [x: string]: unknown } is string | number while keyof Record<string, number> is string

2.6.27 fixed this issue

FirelordJS - 2.6.23

Published by tylim88 about 1 year ago

fix update operation missing autocomplete if the data is an empty object

FirelordJS - 2.6.20

Published by tylim88 about 1 year ago

add toTimestamp to convert JSONTimeStamp to Firestore Timestamp:

import { toTimestamp } from 'firelordjs'

const firestoreTimestamp = toTimestamp(someJSONTimestamp)

https://firelordjs.com/highlights/transformative_types#json-types

FirelordJS - 2.6.17

Published by tylim88 about 1 year ago

  1. allow updateDocNoFlatten to receive empty object as argument on nested level
updateDocNoFlatten(docRef, { } ) // this will still throw type error
updateDocNoFlatten(docRef, { a: { } } )  // this will not throw type error. It will delete all members of object 'a' (default behavior of firestore update operation)
  1. previously by design the library sacrificed autocomplete for smarter type checking in update operations. Now autocomplete is possible in all update operations without sacrificing type checking

image

  1. fixed

The type of dynamic object key is not working properly if the type is mapped type, e.g. updateDoc(ref, { a:{ [b]:1 } }) where the type is { a:Record<string,number> }.

  1. transaction and batch operation ref no longer return undefined
FirelordJS - 2.6.15

Published by tylim88 about 1 year ago

fix updateDoc does not error on nested unknown key

example, given this type {a: { b:2 } }

updateDoc(ref, {a: { c:2 }}) // will not error, it is wrongly expecting {c?: unknown}, this is a false positive

2.6.15 fixed this issue

this is a very old bug

FirelordJS - 2.6.13

Published by tylim88 about 1 year ago

fix updateDoc object literal types are not optional if union with non-object literal type

example, given this type {a: false | {b:2, c:3} }

updateDoc(ref, {a: { b:2 }}) // will error, it is wrongly expecting {b:2, c:3}, this is a false error

2.6.13 fixed this issue

FirelordJS - 2.6.12

Published by tylim88 about 1 year ago

expand json type, example

old:
image

new:
image

FirelordJS - 2.6.8

Published by tylim88 about 1 year ago

rename Serial types to JSON types for easier understanding https://firelordjs.com/highlights/transformative_types/#json-types

image

FirelordJS - 2.6.7

Published by tylim88 about 1 year ago

Introduce serial types

image

FirelordJS - 2.6.6

Published by tylim88 about 1 year ago

  1. all onSnapshot callback return types now are void | Promise<void> because popular eslint rule no-misused-promises throw error if you try to use async callback
  2. some housekeeping
Package Rankings
Top 6.7% on Proxy.golang.org
Top 5.58% on Npmjs.org
Related Projects