@instantdb/react 0.22.75-experimental.test-type-tests.19832950243.1 → 0.22.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/commonjs/Cursors.js +1 -1
  2. package/dist/commonjs/Cursors.js.map +1 -1
  3. package/dist/commonjs/InstantReactWebDatabase.d.ts +1 -1
  4. package/dist/commonjs/InstantReactWebDatabase.d.ts.map +1 -1
  5. package/dist/commonjs/InstantReactWebDatabase.js.map +1 -1
  6. package/dist/commonjs/init.d.ts +1 -3
  7. package/dist/commonjs/init.d.ts.map +1 -1
  8. package/dist/commonjs/init.js +2 -7
  9. package/dist/commonjs/init.js.map +1 -1
  10. package/dist/esm/Cursors.js +1 -1
  11. package/dist/esm/Cursors.js.map +1 -1
  12. package/dist/esm/InstantReactWebDatabase.d.ts +1 -1
  13. package/dist/esm/InstantReactWebDatabase.d.ts.map +1 -1
  14. package/dist/esm/InstantReactWebDatabase.js.map +1 -1
  15. package/dist/esm/init.d.ts +1 -3
  16. package/dist/esm/init.d.ts.map +1 -1
  17. package/dist/esm/init.js +2 -7
  18. package/dist/esm/init.js.map +1 -1
  19. package/dist/standalone/index.js +16 -26
  20. package/dist/standalone/index.umd.cjs +10 -10
  21. package/package.json +4 -6
  22. package/src/Cursors.tsx +2 -2
  23. package/src/InstantReactWebDatabase.ts +3 -4
  24. package/src/init.ts +8 -17
  25. package/tsconfig.json +2 -3
  26. package/dist/commonjs/__types__/typeUtils.d.ts +0 -20
  27. package/dist/commonjs/__types__/typeUtils.d.ts.map +0 -1
  28. package/dist/commonjs/__types__/typeUtils.js +0 -5
  29. package/dist/commonjs/__types__/typeUtils.js.map +0 -1
  30. package/dist/commonjs/__types__/typesTests.d.ts +0 -2
  31. package/dist/commonjs/__types__/typesTests.d.ts.map +0 -1
  32. package/dist/commonjs/__types__/typesTests.js +0 -53
  33. package/dist/commonjs/__types__/typesTests.js.map +0 -1
  34. package/dist/esm/__types__/typeUtils.d.ts +0 -20
  35. package/dist/esm/__types__/typeUtils.d.ts.map +0 -1
  36. package/dist/esm/__types__/typeUtils.js +0 -4
  37. package/dist/esm/__types__/typeUtils.js.map +0 -1
  38. package/dist/esm/__types__/typesTests.d.ts +0 -2
  39. package/dist/esm/__types__/typesTests.d.ts.map +0 -1
  40. package/dist/esm/__types__/typesTests.js +0 -51
  41. package/dist/esm/__types__/typesTests.js.map +0 -1
  42. package/src/__types__/typeUtils.ts +0 -39
  43. package/src/__types__/typesTests.ts +0 -86
  44. package/tsconfig.test.json +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/react",
3
- "version": "0.22.75-experimental.test-type-tests.19832950243.1",
3
+ "version": "0.22.75",
4
4
  "description": "Instant DB for React",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/react",
6
6
  "repository": {
@@ -54,14 +54,12 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "eventsource": "^4.0.0",
57
- "@instantdb/core": "0.22.75-experimental.test-type-tests.19832950243.1",
58
- "@instantdb/react-common": "0.22.75-experimental.test-type-tests.19832950243.1",
59
- "@instantdb/version": "0.22.75-experimental.test-type-tests.19832950243.1"
57
+ "@instantdb/core": "0.22.75",
58
+ "@instantdb/react-common": "0.22.75",
59
+ "@instantdb/version": "0.22.75"
60
60
  },
61
61
  "scripts": {
62
62
  "test": "vitest",
63
- "test:types": "tsc -p tsconfig.test.json --noEmit",
64
- "test:ci": "pnpm run test:types",
65
63
  "check-exports": "attw --pack .",
66
64
  "dev": "tsc --watch --preserveWatchOutput -p tsconfig.dev.json",
67
65
  "clean": "rm -rf dist",
package/src/Cursors.tsx CHANGED
@@ -41,7 +41,7 @@ export function Cursors<
41
41
  _spaceId || `cursors-space-default--${String(room.type)}-${room.id}`;
42
42
 
43
43
  const cursorsPresence = room.usePresence({
44
- keys: [spaceId] as (keyof RoomSchema[RoomType]['presence'])[],
44
+ keys: [spaceId],
45
45
  });
46
46
 
47
47
  const fullPresence = room._core._reactor.getPresence(room.type, room.id);
@@ -142,7 +142,7 @@ export function Cursors<
142
142
  {renderCursor ? (
143
143
  renderCursor({
144
144
  color: cursor.color,
145
- presence: fullPresence?.peers[id],
145
+ presence: fullPresence.peers[id],
146
146
  })
147
147
  ) : (
148
148
  <Cursor {...cursor} />
@@ -4,11 +4,10 @@ import { EventSource } from 'eventsource';
4
4
 
5
5
  export default class InstantReactWebDatabase<
6
6
  Schema extends InstantSchemaDef<any, any, any>,
7
- UseDates extends boolean = false,
8
- Config extends InstantConfig<Schema, UseDates> = InstantConfig<
7
+ Config extends InstantConfig<Schema, boolean> = InstantConfig<
9
8
  Schema,
10
- UseDates
9
+ boolean
11
10
  >,
12
- > extends InstantReactAbstractDatabase<Schema, UseDates, Config> {
11
+ > extends InstantReactAbstractDatabase<Schema, Config> {
13
12
  static EventSourceImpl = EventSource;
14
13
  }
package/src/init.ts CHANGED
@@ -31,23 +31,14 @@ export function init<
31
31
  Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,
32
32
  UseDates extends boolean = false,
33
33
  >(
34
- // Allows config with missing `useDateObjects`, but keeps `UseDates`
35
- // as a non-nullable in the InstantConfig type.
36
- config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
37
- useDateObjects?: UseDates;
38
- },
39
- ): InstantReactWebDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {
40
- const configStrict = {
41
- ...config,
42
- useDateObjects: (config.useDateObjects ?? false) as UseDates,
43
- };
44
- return new InstantReactWebDatabase<
45
- Schema,
46
- UseDates,
47
- InstantConfig<Schema, UseDates>
48
- >(configStrict, {
49
- '@instantdb/react': version,
50
- });
34
+ config: InstantConfig<Schema, UseDates>,
35
+ ): InstantReactWebDatabase<Schema, InstantConfig<Schema, UseDates>> {
36
+ return new InstantReactWebDatabase<Schema, InstantConfig<Schema, UseDates>>(
37
+ config,
38
+ {
39
+ '@instantdb/react': version,
40
+ },
41
+ );
51
42
  }
52
43
 
53
44
  /**
package/tsconfig.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "include": ["src"],
4
- "exclude": ["node_modules", "dist", "src/__types__"],
4
+ "exclude": ["node_modules", "dist"],
5
5
  "compilerOptions": {
6
6
  "outDir": "dist/tsc",
7
7
  "rewriteRelativeImportExtensions": true,
8
8
  "rootDir": "src",
9
- "jsx": "react-jsx",
10
- "strictNullChecks": true
9
+ "jsx": "react-jsx"
11
10
  }
12
11
  }
@@ -1,20 +0,0 @@
1
- export type Expect<T extends true> = T;
2
- export type ExpectTrue<T extends true> = T;
3
- export type ExpectFalse<T extends false> = T;
4
- export type IsTrue<T extends true> = T;
5
- export type IsFalse<T extends false> = T;
6
- export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
7
- export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
8
- export type IsAny<T> = 0 extends 1 & T ? true : false;
9
- export type NotAny<T> = true extends IsAny<T> ? false : true;
10
- export type Debug<T> = {
11
- [K in keyof T]: T[K];
12
- };
13
- export type MergeInsertions<T> = T extends object ? {
14
- [K in keyof T]: MergeInsertions<T[K]>;
15
- } : T;
16
- export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
17
- export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : false;
18
- export type ExpectValidArgs<FUNC extends (...args: any[]) => any, ARGS extends any[]> = ARGS extends Parameters<FUNC> ? true : false;
19
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
20
- //# sourceMappingURL=typeUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../../src/__types__/typeUtils.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAC3C,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAC7C,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IACpB,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAC/D,IAAI,GACJ,KAAK,CAAC;AACZ,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;AAGrE,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AACtD,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;AAE7D,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAChD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC7C;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACzC,CAAC,CAAC;AAEN,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,QAAQ,IAAI,QAAQ,SAAS,KAAK,GAC/D,IAAI,GACJ,KAAK,CAAC;AACV,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACpC,IAAI,SAAS,GAAG,EAAE,IAChB,IAAI,SAAS,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjD,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAC1B,CAAC,GACD,KAAK,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // Type testing utils from
3
- // https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- //# sourceMappingURL=typeUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../../../src/__types__/typeUtils.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,gFAAgF","sourcesContent":["// Type testing utils from\n// https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts\n\nexport type Expect<T extends true> = T;\nexport type ExpectTrue<T extends true> = T;\nexport type ExpectFalse<T extends false> = T;\nexport type IsTrue<T extends true> = T;\nexport type IsFalse<T extends false> = T;\n\nexport type Equal<X, Y> =\n (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2\n ? true\n : false;\nexport type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;\n\n// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type NotAny<T> = true extends IsAny<T> ? false : true;\n\nexport type Debug<T> = { [K in keyof T]: T[K] };\nexport type MergeInsertions<T> = T extends object\n ? { [K in keyof T]: MergeInsertions<T[K]> }\n : T;\n\nexport type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;\n\nexport type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE\n ? true\n : false;\nexport type ExpectValidArgs<\n FUNC extends (...args: any[]) => any,\n ARGS extends any[],\n> = ARGS extends Parameters<FUNC> ? true : false;\n\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => void\n ? I\n : never;\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=typesTests.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typesTests.d.ts","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":""}
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_ts_1 = require("../index.js");
4
- const schema = index_ts_1.i.schema({
5
- entities: {
6
- tbl: index_ts_1.i.entity({
7
- d: index_ts_1.i.date().indexed(),
8
- dOptional: index_ts_1.i.date().optional(),
9
- }),
10
- },
11
- });
12
- function _testUseDatesTest() {
13
- const db = (0, index_ts_1.init)({
14
- schema,
15
- appId: '123',
16
- useDateObjects: true,
17
- });
18
- const { data } = db.useQuery({ tbl: {} });
19
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
20
- if (item) {
21
- }
22
- }
23
- function _testUseDatesFalseTest() {
24
- const db = (0, index_ts_1.init)({
25
- schema,
26
- appId: '123',
27
- useDateObjects: false,
28
- });
29
- const { data } = db.useQuery({ tbl: {} });
30
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
31
- if (item) {
32
- }
33
- }
34
- function _testUseDatesUndefinedTest() {
35
- const db = (0, index_ts_1.init)({
36
- schema,
37
- appId: '123',
38
- });
39
- const { data } = db.useQuery({ tbl: {} });
40
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
41
- if (item) {
42
- }
43
- }
44
- function _testDataNoSchema() {
45
- const db = (0, index_ts_1.init)({
46
- appId: '123',
47
- });
48
- const { data } = db.useQuery({ tbl: {} });
49
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
50
- if (item) {
51
- }
52
- }
53
- //# sourceMappingURL=typesTests.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typesTests.js","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":";;AACA,0CAAsC;AAEtC,MAAM,MAAM,GAAG,YAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE;QACR,GAAG,EAAE,YAAC,CAAC,MAAM,CAAC;YACZ,CAAC,EAAE,YAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,YAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;SAC/B,CAAC;KACH;CACF,CAAC,CAAC;AAEH,SAAS,iBAAiB;IACxB,MAAM,EAAE,GAAG,IAAA,eAAI,EAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,IAAI;KACrB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,EAAE,GAAG,IAAA,eAAI,EAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,KAAK;KACtB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,MAAM,EAAE,GAAG,IAAA,eAAI,EAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB;IACxB,MAAM,EAAE,GAAG,IAAA,eAAI,EAAC;QACd,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IAGX,CAAC;AACH,CAAC","sourcesContent":["import type { Equal, Expect, IsAny, NotAny } from './typeUtils.ts';\nimport { i, init } from '../index.ts';\n\nconst schema = i.schema({\n entities: {\n tbl: i.entity({\n d: i.date().indexed(),\n dOptional: i.date().optional(),\n }),\n },\n});\n\nfunction _testUseDatesTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: true,\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, Date | undefined>>,\n ];\n }\n}\n\nfunction _testUseDatesFalseTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: false,\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nfunction _testUseDatesUndefinedTest() {\n const db = init({\n schema,\n appId: '123',\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nfunction _testDataNoSchema() {\n const db = init({\n appId: '123',\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];\n }\n}\n"]}
@@ -1,20 +0,0 @@
1
- export type Expect<T extends true> = T;
2
- export type ExpectTrue<T extends true> = T;
3
- export type ExpectFalse<T extends false> = T;
4
- export type IsTrue<T extends true> = T;
5
- export type IsFalse<T extends false> = T;
6
- export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
7
- export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
8
- export type IsAny<T> = 0 extends 1 & T ? true : false;
9
- export type NotAny<T> = true extends IsAny<T> ? false : true;
10
- export type Debug<T> = {
11
- [K in keyof T]: T[K];
12
- };
13
- export type MergeInsertions<T> = T extends object ? {
14
- [K in keyof T]: MergeInsertions<T[K]>;
15
- } : T;
16
- export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
17
- export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : false;
18
- export type ExpectValidArgs<FUNC extends (...args: any[]) => any, ARGS extends any[]> = ARGS extends Parameters<FUNC> ? true : false;
19
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
20
- //# sourceMappingURL=typeUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../../src/__types__/typeUtils.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAC3C,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAC7C,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IACpB,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAC/D,IAAI,GACJ,KAAK,CAAC;AACZ,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;AAGrE,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AACtD,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;AAE7D,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAChD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC7C;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACzC,CAAC,CAAC;AAEN,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,QAAQ,IAAI,QAAQ,SAAS,KAAK,GAC/D,IAAI,GACJ,KAAK,CAAC;AACV,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACpC,IAAI,SAAS,GAAG,EAAE,IAChB,IAAI,SAAS,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjD,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAC1B,CAAC,GACD,KAAK,CAAC"}
@@ -1,4 +0,0 @@
1
- // Type testing utils from
2
- // https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
3
- export {};
4
- //# sourceMappingURL=typeUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../../../src/__types__/typeUtils.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,gFAAgF","sourcesContent":["// Type testing utils from\n// https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts\n\nexport type Expect<T extends true> = T;\nexport type ExpectTrue<T extends true> = T;\nexport type ExpectFalse<T extends false> = T;\nexport type IsTrue<T extends true> = T;\nexport type IsFalse<T extends false> = T;\n\nexport type Equal<X, Y> =\n (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2\n ? true\n : false;\nexport type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;\n\n// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type NotAny<T> = true extends IsAny<T> ? false : true;\n\nexport type Debug<T> = { [K in keyof T]: T[K] };\nexport type MergeInsertions<T> = T extends object\n ? { [K in keyof T]: MergeInsertions<T[K]> }\n : T;\n\nexport type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;\n\nexport type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE\n ? true\n : false;\nexport type ExpectValidArgs<\n FUNC extends (...args: any[]) => any,\n ARGS extends any[],\n> = ARGS extends Parameters<FUNC> ? true : false;\n\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => void\n ? I\n : never;\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=typesTests.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typesTests.d.ts","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":""}
@@ -1,51 +0,0 @@
1
- import { i, init } from "../index.js";
2
- const schema = i.schema({
3
- entities: {
4
- tbl: i.entity({
5
- d: i.date().indexed(),
6
- dOptional: i.date().optional(),
7
- }),
8
- },
9
- });
10
- function _testUseDatesTest() {
11
- const db = init({
12
- schema,
13
- appId: '123',
14
- useDateObjects: true,
15
- });
16
- const { data } = db.useQuery({ tbl: {} });
17
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
18
- if (item) {
19
- }
20
- }
21
- function _testUseDatesFalseTest() {
22
- const db = init({
23
- schema,
24
- appId: '123',
25
- useDateObjects: false,
26
- });
27
- const { data } = db.useQuery({ tbl: {} });
28
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
29
- if (item) {
30
- }
31
- }
32
- function _testUseDatesUndefinedTest() {
33
- const db = init({
34
- schema,
35
- appId: '123',
36
- });
37
- const { data } = db.useQuery({ tbl: {} });
38
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
39
- if (item) {
40
- }
41
- }
42
- function _testDataNoSchema() {
43
- const db = init({
44
- appId: '123',
45
- });
46
- const { data } = db.useQuery({ tbl: {} });
47
- const item = data === null || data === void 0 ? void 0 : data.tbl[0];
48
- if (item) {
49
- }
50
- }
51
- //# sourceMappingURL=typesTests.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typesTests.js","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE;QACR,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;YACZ,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;SAC/B,CAAC;KACH;CACF,CAAC,CAAC;AAEH,SAAS,iBAAiB;IACxB,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,IAAI;KACrB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,KAAK;KACtB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,MAAM;QACN,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IASX,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB;IACxB,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;IAGX,CAAC;AACH,CAAC","sourcesContent":["import type { Equal, Expect, IsAny, NotAny } from './typeUtils.ts';\nimport { i, init } from '../index.ts';\n\nconst schema = i.schema({\n entities: {\n tbl: i.entity({\n d: i.date().indexed(),\n dOptional: i.date().optional(),\n }),\n },\n});\n\nfunction _testUseDatesTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: true,\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, Date | undefined>>,\n ];\n }\n}\n\nfunction _testUseDatesFalseTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: false,\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nfunction _testUseDatesUndefinedTest() {\n const db = init({\n schema,\n appId: '123',\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nfunction _testDataNoSchema() {\n const db = init({\n appId: '123',\n });\n\n const { data } = db.useQuery({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];\n }\n}\n"]}
@@ -1,39 +0,0 @@
1
- // Type testing utils from
2
- // https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
3
-
4
- export type Expect<T extends true> = T;
5
- export type ExpectTrue<T extends true> = T;
6
- export type ExpectFalse<T extends false> = T;
7
- export type IsTrue<T extends true> = T;
8
- export type IsFalse<T extends false> = T;
9
-
10
- export type Equal<X, Y> =
11
- (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
12
- ? true
13
- : false;
14
- export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
15
-
16
- // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
17
- export type IsAny<T> = 0 extends 1 & T ? true : false;
18
- export type NotAny<T> = true extends IsAny<T> ? false : true;
19
-
20
- export type Debug<T> = { [K in keyof T]: T[K] };
21
- export type MergeInsertions<T> = T extends object
22
- ? { [K in keyof T]: MergeInsertions<T[K]> }
23
- : T;
24
-
25
- export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
26
-
27
- export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE
28
- ? true
29
- : false;
30
- export type ExpectValidArgs<
31
- FUNC extends (...args: any[]) => any,
32
- ARGS extends any[],
33
- > = ARGS extends Parameters<FUNC> ? true : false;
34
-
35
- export type UnionToIntersection<U> = (
36
- U extends any ? (k: U) => void : never
37
- ) extends (k: infer I) => void
38
- ? I
39
- : never;
@@ -1,86 +0,0 @@
1
- import type { Equal, Expect, IsAny, NotAny } from './typeUtils.ts';
2
- import { i, init } from '../index.ts';
3
-
4
- const schema = i.schema({
5
- entities: {
6
- tbl: i.entity({
7
- d: i.date().indexed(),
8
- dOptional: i.date().optional(),
9
- }),
10
- },
11
- });
12
-
13
- function _testUseDatesTest() {
14
- const db = init({
15
- schema,
16
- appId: '123',
17
- useDateObjects: true,
18
- });
19
-
20
- const { data } = db.useQuery({ tbl: {} });
21
- const item = data?.tbl[0];
22
- if (item) {
23
- type t = typeof item.d;
24
- type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];
25
-
26
- type tOpt = typeof item.dOptional;
27
- type _cases_2 = [
28
- Expect<NotAny<tOpt>>,
29
- Expect<Equal<tOpt, Date | undefined>>,
30
- ];
31
- }
32
- }
33
-
34
- function _testUseDatesFalseTest() {
35
- const db = init({
36
- schema,
37
- appId: '123',
38
- useDateObjects: false,
39
- });
40
-
41
- const { data } = db.useQuery({ tbl: {} });
42
- const item = data?.tbl[0];
43
- if (item) {
44
- type t = typeof item.d;
45
- type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
46
-
47
- type tOpt = typeof item.dOptional;
48
- type _cases_2 = [
49
- Expect<NotAny<tOpt>>,
50
- Expect<Equal<tOpt, string | number | undefined>>,
51
- ];
52
- }
53
- }
54
-
55
- function _testUseDatesUndefinedTest() {
56
- const db = init({
57
- schema,
58
- appId: '123',
59
- });
60
-
61
- const { data } = db.useQuery({ tbl: {} });
62
- const item = data?.tbl[0];
63
- if (item) {
64
- type t = typeof item.d;
65
- type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
66
-
67
- type tOpt = typeof item.dOptional;
68
- type _cases_2 = [
69
- Expect<NotAny<tOpt>>,
70
- Expect<Equal<tOpt, string | number | undefined>>,
71
- ];
72
- }
73
- }
74
-
75
- function _testDataNoSchema() {
76
- const db = init({
77
- appId: '123',
78
- });
79
-
80
- const { data } = db.useQuery({ tbl: {} });
81
- const item = data?.tbl[0];
82
- if (item) {
83
- type t = typeof item.d;
84
- type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];
85
- }
86
- }
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["src", "src/__types__"],
4
- "exclude": ["node_modules", "dist"]
5
- }