import type { Equal, Expect, IsAny, NotAny } from './typeUtils.ts'; import { i, init } from '../index.ts'; const schema = i.schema({ entities: { tbl: i.entity({ d: i.date().indexed(), dOptional: i.date().optional(), }), }, }); async function _testUseDatesTest() { const db = init({ schema, appId: '123', useDateObjects: true, }); const data = await db.query({ tbl: {} }); const item = data?.tbl[0]; if (item) { type t = typeof item.d; type _cases = [Expect>, Expect>]; type tOpt = typeof item.dOptional; type _cases_2 = [ Expect>, Expect>, ]; } } async function _testUseDatesFalseTest() { const db = init({ schema, appId: '123', useDateObjects: false, }); const data = await db.query({ tbl: {} }); const item = data?.tbl[0]; if (item) { type t = typeof item.d; type _cases = [Expect>, Expect>]; type tOpt = typeof item.dOptional; type _cases_2 = [ Expect>, Expect>, ]; } } async function _testUseDatesUndefinedTest() { const db = init({ schema, appId: '123', }); const data = await db.query({ tbl: {} }); const item = data?.tbl[0]; if (item) { type t = typeof item.d; type _cases = [Expect>, Expect>]; type tOpt = typeof item.dOptional; type _cases_2 = [ Expect>, Expect>, ]; } } async function _testDataNoSchema() { const db = init({ appId: '123', }); const data = await db.query({ tbl: {} }); const item = data?.tbl[0]; if (item) { type t = typeof item.d; type _cases = [Expect>, Expect>]; } } async function _testSubscribe() { // No useDateObjects init({ appId: '123', schema, }).subscribeQuery({ tbl: {} }, (payload) => { if (payload.type === 'ok') { const item = payload.data.tbl[0]; if (item) { type _cases = [ Expect>, Expect>, Expect>, ]; } } }); // UseDateObjects init({ appId: '123', schema, useDateObjects: true, }).subscribeQuery({ tbl: {} }, (payload) => { if (payload.type === 'ok') { const item = payload.data.tbl[0]; if (item) { type _cases = [ Expect>, Expect>, Expect>, ]; } } }); // No schema init({ appId: '123', }).subscribeQuery({ tbl: {} }, (payload) => { if (payload.type === 'ok') { const item = payload.data.tbl[0]; if (item) { type _cases = [ Expect>, Expect>, Expect>, ]; } } }); }