@instantdb/core 0.22.75 → 0.22.76

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 (85) hide show
  1. package/dist/commonjs/Connection.d.ts +2 -1
  2. package/dist/commonjs/Connection.d.ts.map +1 -1
  3. package/dist/commonjs/Connection.js +26 -16
  4. package/dist/commonjs/Connection.js.map +1 -1
  5. package/dist/commonjs/Reactor.d.ts.map +1 -1
  6. package/dist/commonjs/Reactor.js +8 -1
  7. package/dist/commonjs/Reactor.js.map +1 -1
  8. package/dist/commonjs/SyncTable.d.ts +10 -10
  9. package/dist/commonjs/SyncTable.d.ts.map +1 -1
  10. package/dist/commonjs/SyncTable.js.map +1 -1
  11. package/dist/commonjs/__types__/fieldsTypeTest.d.ts +2 -0
  12. package/dist/commonjs/__types__/fieldsTypeTest.d.ts.map +1 -0
  13. package/dist/commonjs/__types__/fieldsTypeTest.js +74 -0
  14. package/dist/commonjs/__types__/fieldsTypeTest.js.map +1 -0
  15. package/dist/commonjs/__types__/typeUtils.d.ts +20 -0
  16. package/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
  17. package/dist/commonjs/__types__/typeUtils.js +5 -0
  18. package/dist/commonjs/__types__/typeUtils.js.map +1 -0
  19. package/dist/commonjs/__types__/useDatesTypeTest.d.ts +2 -0
  20. package/dist/commonjs/__types__/useDatesTypeTest.d.ts.map +1 -0
  21. package/dist/commonjs/__types__/useDatesTypeTest.js +55 -0
  22. package/dist/commonjs/__types__/useDatesTypeTest.js.map +1 -0
  23. package/dist/commonjs/clientTypes.d.ts +1 -1
  24. package/dist/commonjs/clientTypes.d.ts.map +1 -1
  25. package/dist/commonjs/clientTypes.js.map +1 -1
  26. package/dist/commonjs/index.d.ts +15 -8
  27. package/dist/commonjs/index.d.ts.map +1 -1
  28. package/dist/commonjs/index.js +12 -7
  29. package/dist/commonjs/index.js.map +1 -1
  30. package/dist/commonjs/queryTypes.d.ts +4 -4
  31. package/dist/commonjs/queryTypes.d.ts.map +1 -1
  32. package/dist/commonjs/queryTypes.js.map +1 -1
  33. package/dist/commonjs/schemaTypes.d.ts +2 -2
  34. package/dist/commonjs/schemaTypes.d.ts.map +1 -1
  35. package/dist/commonjs/schemaTypes.js.map +1 -1
  36. package/dist/esm/Connection.d.ts +2 -1
  37. package/dist/esm/Connection.d.ts.map +1 -1
  38. package/dist/esm/Connection.js +26 -16
  39. package/dist/esm/Connection.js.map +1 -1
  40. package/dist/esm/Reactor.d.ts.map +1 -1
  41. package/dist/esm/Reactor.js +8 -1
  42. package/dist/esm/Reactor.js.map +1 -1
  43. package/dist/esm/SyncTable.d.ts +10 -10
  44. package/dist/esm/SyncTable.d.ts.map +1 -1
  45. package/dist/esm/SyncTable.js.map +1 -1
  46. package/dist/esm/__types__/fieldsTypeTest.d.ts +2 -0
  47. package/dist/esm/__types__/fieldsTypeTest.d.ts.map +1 -0
  48. package/dist/esm/__types__/fieldsTypeTest.js +72 -0
  49. package/dist/esm/__types__/fieldsTypeTest.js.map +1 -0
  50. package/dist/esm/__types__/typeUtils.d.ts +20 -0
  51. package/dist/esm/__types__/typeUtils.d.ts.map +1 -0
  52. package/dist/esm/__types__/typeUtils.js +4 -0
  53. package/dist/esm/__types__/typeUtils.js.map +1 -0
  54. package/dist/esm/__types__/useDatesTypeTest.d.ts +2 -0
  55. package/dist/esm/__types__/useDatesTypeTest.d.ts.map +1 -0
  56. package/dist/esm/__types__/useDatesTypeTest.js +53 -0
  57. package/dist/esm/__types__/useDatesTypeTest.js.map +1 -0
  58. package/dist/esm/clientTypes.d.ts +1 -1
  59. package/dist/esm/clientTypes.d.ts.map +1 -1
  60. package/dist/esm/clientTypes.js.map +1 -1
  61. package/dist/esm/index.d.ts +15 -8
  62. package/dist/esm/index.d.ts.map +1 -1
  63. package/dist/esm/index.js +12 -7
  64. package/dist/esm/index.js.map +1 -1
  65. package/dist/esm/queryTypes.d.ts +4 -4
  66. package/dist/esm/queryTypes.d.ts.map +1 -1
  67. package/dist/esm/queryTypes.js.map +1 -1
  68. package/dist/esm/schemaTypes.d.ts +2 -2
  69. package/dist/esm/schemaTypes.d.ts.map +1 -1
  70. package/dist/esm/schemaTypes.js.map +1 -1
  71. package/dist/standalone/index.js +104 -92
  72. package/dist/standalone/index.umd.cjs +2 -2
  73. package/package.json +4 -3
  74. package/src/Connection.ts +28 -18
  75. package/src/Reactor.js +7 -1
  76. package/src/SyncTable.ts +10 -10
  77. package/{__tests__/src → src/__types__}/fieldsTypeTest.ts +1 -1
  78. package/src/__types__/typeUtils.ts +39 -0
  79. package/{__tests__/src → src/__types__}/useDatesTypeTest.ts +1 -2
  80. package/src/clientTypes.ts +1 -1
  81. package/src/index.ts +36 -31
  82. package/src/queryTypes.ts +4 -4
  83. package/src/schemaTypes.ts +2 -5
  84. package/tsconfig.json +1 -1
  85. package/tsconfig.test.json +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/core",
3
- "version": "0.22.75",
3
+ "version": "0.22.76",
4
4
  "description": "Instant's core local abstraction",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
6
6
  "repository": {
@@ -53,12 +53,13 @@
53
53
  "dependencies": {
54
54
  "mutative": "^1.0.10",
55
55
  "uuid": "^11.1.0",
56
- "@instantdb/version": "0.22.75"
56
+ "@instantdb/version": "0.22.76"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest",
60
60
  "bench": "vitest bench",
61
- "test:ci": "vitest run",
61
+ "test:types": "tsc -p tsconfig.test.json --noEmit",
62
+ "test:ci": "vitest run && pnpm run test:types",
62
63
  "bench:ci": "vitest bench --run",
63
64
  "check": "tsc --noEmit",
64
65
  "check-exports": "attw --pack .",
package/src/Connection.ts CHANGED
@@ -36,7 +36,7 @@ type SendMessageData = {
36
36
 
37
37
  type MsgEvent<T extends Conn> = {
38
38
  target: Connection<T>;
39
- message: MessageData;
39
+ message: MessageData | MessageData[];
40
40
  };
41
41
 
42
42
  type CloseEvent<T extends Conn> = {
@@ -152,24 +152,13 @@ export class SSEConnection implements Connection<EventSourceType> {
152
152
  }, 10000);
153
153
 
154
154
  this.conn.onmessage = (e) => {
155
- const msg = JSON.parse(e.data);
156
- if (msg.op === 'sse-init') {
157
- this.initParams = {
158
- machineId: msg['machine-id'],
159
- sessionId: msg['session-id'],
160
- sseToken: msg['sse-token'],
161
- };
162
- if (this.onopen) {
163
- this.onopen({ target: this });
155
+ const message = JSON.parse(e.data);
156
+ if (Array.isArray(message)) {
157
+ for (const msg of message) {
158
+ this.handleMessage(msg);
164
159
  }
165
- clearTimeout(this.sseInitTimeout);
166
- return;
167
- }
168
- if (this.onmessage) {
169
- this.onmessage({
170
- target: this,
171
- message: msg,
172
- });
160
+ } else {
161
+ this.handleMessage(message);
173
162
  }
174
163
  };
175
164
 
@@ -178,6 +167,27 @@ export class SSEConnection implements Connection<EventSourceType> {
178
167
  };
179
168
  }
180
169
 
170
+ private handleMessage(msg: MessageData) {
171
+ if (msg.op === 'sse-init') {
172
+ this.initParams = {
173
+ machineId: msg['machine-id'],
174
+ sessionId: msg['session-id'],
175
+ sseToken: msg['sse-token'],
176
+ };
177
+ if (this.onopen) {
178
+ this.onopen({ target: this });
179
+ }
180
+ clearTimeout(this.sseInitTimeout);
181
+ return;
182
+ }
183
+ if (this.onmessage) {
184
+ this.onmessage({
185
+ target: this,
186
+ message: msg,
187
+ });
188
+ }
189
+ }
190
+
181
191
  // Runs the onerror and closes the connection
182
192
  private handleError() {
183
193
  try {
package/src/Reactor.js CHANGED
@@ -1500,7 +1500,13 @@ export default class Reactor {
1500
1500
  }
1501
1501
  // Try to reconnect via websocket the next time we connect
1502
1502
  this._transportType = 'ws';
1503
- this._handleReceive(targetTransport.id, e.message);
1503
+ if (Array.isArray(e.message)) {
1504
+ for (const msg of e.message) {
1505
+ this._handleReceive(targetTransport.id, msg);
1506
+ }
1507
+ } else {
1508
+ this._handleReceive(targetTransport.id, e.message);
1509
+ }
1504
1510
  };
1505
1511
 
1506
1512
  _transportOnError = (e) => {
package/src/SyncTable.ts CHANGED
@@ -309,7 +309,7 @@ export enum CallbackEventType {
309
309
  type QueryEntities<
310
310
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
311
311
  Q extends ValidQuery<Q, Schema>,
312
- UseDates extends boolean | undefined,
312
+ UseDates extends boolean,
313
313
  > = InstaQLResponse<Schema, Q, UseDates>[keyof InstaQLResponse<
314
314
  Schema,
315
315
  Q,
@@ -319,7 +319,7 @@ type QueryEntities<
319
319
  type QueryEntity<
320
320
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
321
321
  Q extends ValidQuery<Q, Schema>,
322
- UseDates extends boolean | undefined,
322
+ UseDates extends boolean,
323
323
  > = QueryEntities<Schema, Q, UseDates> extends (infer E)[] ? E : never;
324
324
 
325
325
  type ChangedFields<Entity> = {
@@ -332,7 +332,7 @@ type ChangedFields<Entity> = {
332
332
  export interface BaseCallbackEvent<
333
333
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
334
334
  Q extends ValidQuery<Q, Schema>,
335
- UseDates extends boolean | undefined,
335
+ UseDates extends boolean,
336
336
  > {
337
337
  type: CallbackEventType;
338
338
  data: InstaQLResponse<Schema, Q, UseDates>;
@@ -341,7 +341,7 @@ export interface BaseCallbackEvent<
341
341
  export interface InitialSyncBatch<
342
342
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
343
343
  Q extends ValidQuery<Q, Schema>,
344
- UseDates extends boolean | undefined,
344
+ UseDates extends boolean,
345
345
  > extends BaseCallbackEvent<Schema, Q, UseDates> {
346
346
  type: CallbackEventType.InitialSyncBatch;
347
347
  batch: QueryEntities<Schema, Q, UseDates>;
@@ -350,7 +350,7 @@ export interface InitialSyncBatch<
350
350
  export interface InitialSyncComplete<
351
351
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
352
352
  Q extends ValidQuery<Q, Schema>,
353
- UseDates extends boolean | undefined,
353
+ UseDates extends boolean,
354
354
  > extends BaseCallbackEvent<Schema, Q, UseDates> {
355
355
  type: CallbackEventType.InitialSyncComplete;
356
356
  }
@@ -358,7 +358,7 @@ export interface InitialSyncComplete<
358
358
  export interface SyncTransaction<
359
359
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
360
360
  Q extends ValidQuery<Q, Schema>,
361
- UseDates extends boolean | undefined,
361
+ UseDates extends boolean,
362
362
  > extends BaseCallbackEvent<Schema, Q, UseDates> {
363
363
  type: CallbackEventType.SyncTransaction;
364
364
  added: QueryEntities<Schema, Q, UseDates>;
@@ -373,7 +373,7 @@ export interface SyncTransaction<
373
373
  export interface LoadFromStorage<
374
374
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
375
375
  Q extends ValidQuery<Q, Schema>,
376
- UseDates extends boolean | undefined,
376
+ UseDates extends boolean,
377
377
  > extends BaseCallbackEvent<Schema, Q, UseDates> {
378
378
  type: CallbackEventType.LoadFromStorage;
379
379
  }
@@ -381,7 +381,7 @@ export interface LoadFromStorage<
381
381
  export interface SetupError<
382
382
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
383
383
  Q extends ValidQuery<Q, Schema>,
384
- UseDates extends boolean | undefined,
384
+ UseDates extends boolean,
385
385
  > extends BaseCallbackEvent<Schema, Q, UseDates> {
386
386
  type: CallbackEventType.Error;
387
387
  error: { message: string; hint?: any; type: string; status: number };
@@ -390,7 +390,7 @@ export interface SetupError<
390
390
  export type CallbackEvent<
391
391
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
392
392
  Q extends ValidQuery<Q, Schema>,
393
- UseDates extends boolean | undefined,
393
+ UseDates extends boolean,
394
394
  > =
395
395
  | InitialSyncBatch<Schema, Q, UseDates>
396
396
  | InitialSyncComplete<Schema, Q, UseDates>
@@ -401,7 +401,7 @@ export type CallbackEvent<
401
401
  export type SyncTableCallback<
402
402
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
403
403
  Q extends ValidQuery<Q, Schema>,
404
- UseDates extends boolean | undefined,
404
+ UseDates extends boolean,
405
405
  > = (event: CallbackEvent<Schema, Q, UseDates>) => void;
406
406
 
407
407
  export class SyncTable {
@@ -1,4 +1,4 @@
1
- import { i, init } from '../../src/index.ts';
1
+ import { i, init } from '../index.ts';
2
2
  import type { Equal, Expect, NotAny } from './typeUtils.ts';
3
3
 
4
4
  // These tests just check types. See `type _cases = ` for the test cases.
@@ -0,0 +1,39 @@
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,6 +1,5 @@
1
- import { i, init } from '../../src/index.ts';
1
+ import { i, init } from '../index.ts';
2
2
  import type { Equal, Expect, NotAny } from './typeUtils.ts';
3
-
4
3
  // These tests just check types. See `type _cases = ` for the test cases.
5
4
 
6
5
  const schema = i.schema({
@@ -14,7 +14,7 @@ export type AuthResult =
14
14
  export type AuthState =
15
15
  | { isLoading: true; error: undefined; user: undefined }
16
16
  | { isLoading: false; error: { message: string }; user: undefined }
17
- | { isLoading: false; error: undefined; user: User | null };
17
+ | { isLoading: false; error: undefined; user: User | null | undefined };
18
18
 
19
19
  export type ConnectionStatus =
20
20
  | 'connecting'
package/src/index.ts CHANGED
@@ -142,13 +142,13 @@ export type Config = {
142
142
  devtool?: boolean | DevtoolConfig;
143
143
  verbose?: boolean;
144
144
  queryCacheLimit?: number;
145
- useDateObjects?: boolean;
145
+ useDateObjects: boolean;
146
146
  disableValidation?: boolean;
147
147
  };
148
148
 
149
149
  export type InstantConfig<
150
150
  S extends InstantSchemaDef<any, any, any>,
151
- UseDates extends boolean | undefined = false,
151
+ UseDates extends boolean = false,
152
152
  > = {
153
153
  appId: string;
154
154
  schema?: S;
@@ -157,7 +157,7 @@ export type InstantConfig<
157
157
  devtool?: boolean | DevtoolConfig;
158
158
  verbose?: boolean;
159
159
  queryCacheLimit?: number;
160
- useDateObjects?: UseDates;
160
+ useDateObjects: UseDates;
161
161
  disableValidation?: boolean;
162
162
  };
163
163
 
@@ -212,11 +212,7 @@ type SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> =
212
212
  pageInfo: PageInfoResponse<Q>;
213
213
  };
214
214
 
215
- type InstaQLSubscriptionState<
216
- Schema,
217
- Q,
218
- UseDates extends boolean | undefined,
219
- > =
215
+ type InstaQLSubscriptionState<Schema, Q, UseDates extends boolean> =
220
216
  | { error: { message: string }; data: undefined; pageInfo: undefined }
221
217
  | {
222
218
  error: undefined;
@@ -232,13 +228,16 @@ type LifecycleSubscriptionState<
232
228
  isLoading: boolean;
233
229
  };
234
230
 
235
- type InstaQLLifecycleState<
236
- Schema,
237
- Q,
238
- UseDates extends boolean | undefined = false,
239
- > = InstaQLSubscriptionState<Schema, Q, UseDates> & {
240
- isLoading: boolean;
241
- };
231
+ type InstaQLLifecycleState<Schema, Q, UseDates extends boolean = false> =
232
+ | (InstaQLSubscriptionState<Schema, Q, UseDates> & {
233
+ isLoading: boolean;
234
+ })
235
+ | {
236
+ isLoading: true;
237
+ data: undefined;
238
+ pageInfo: undefined;
239
+ error: undefined;
240
+ };
242
241
 
243
242
  type UnsubscribeFn = () => void;
244
243
 
@@ -261,7 +260,7 @@ function initGlobalInstantCoreStore(): Record<string, any> {
261
260
  return globalThis.__instantDbStore;
262
261
  }
263
262
 
264
- function reactorKey(config: InstantConfig<any, boolean | undefined>): string {
263
+ function reactorKey(config: InstantConfig<any, boolean>): string {
265
264
  // @ts-expect-error
266
265
  const adminToken = config.__adminToken;
267
266
  return (
@@ -523,7 +522,7 @@ function coerceQuery(o: any) {
523
522
 
524
523
  class InstantCoreDatabase<
525
524
  Schema extends InstantSchemaDef<any, any, any>,
526
- UseDates extends boolean | undefined = false,
525
+ UseDates extends boolean = false,
527
526
  > implements IInstantDatabase<Schema>
528
527
  {
529
528
  public _reactor: Reactor<RoomsOf<Schema>>;
@@ -597,7 +596,7 @@ class InstantCoreDatabase<
597
596
  */
598
597
  subscribeQuery<
599
598
  Q extends ValidQuery<Q, Schema>,
600
- UseDatesLocal extends boolean | undefined = UseDates,
599
+ UseDatesLocal extends boolean = UseDates,
601
600
  >(
602
601
  query: Q,
603
602
  cb: (resp: InstaQLSubscriptionState<Schema, Q, UseDatesLocal>) => void,
@@ -800,21 +799,29 @@ function schemaChanged(
800
799
  */
801
800
  function init<
802
801
  Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,
803
- UseDates extends boolean | undefined = false,
802
+ UseDates extends boolean = false,
804
803
  >(
805
- config: InstantConfig<Schema, UseDates>,
804
+ // Allows config with missing `useDateObjects`, but keeps `UseDates`
805
+ // as a non-nullable in the InstantConfig type.
806
+ config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
807
+ useDateObjects?: UseDates;
808
+ },
806
809
  Storage?: any,
807
810
  NetworkListener?: any,
808
811
  versions?: { [key: string]: string },
809
812
  EventSourceImpl?: any,
810
813
  ): InstantCoreDatabase<Schema, UseDates> {
814
+ const configStrict = {
815
+ ...config,
816
+ useDateObjects: (config.useDateObjects ?? false) as UseDates,
817
+ };
811
818
  const existingClient = globalInstantCoreStore[
812
- reactorKey(config)
813
- ] as InstantCoreDatabase<any, Config['useDateObjects']>;
819
+ reactorKey(configStrict)
820
+ ] as InstantCoreDatabase<any, UseDates>;
814
821
 
815
822
  if (existingClient) {
816
- if (schemaChanged(existingClient, config.schema)) {
817
- existingClient._reactor.updateSchema(config.schema);
823
+ if (schemaChanged(existingClient, configStrict.schema)) {
824
+ existingClient._reactor.updateSchema(configStrict.schema);
818
825
  }
819
826
  return existingClient;
820
827
  }
@@ -822,8 +829,8 @@ function init<
822
829
  const reactor = new Reactor<RoomsOf<Schema>>(
823
830
  {
824
831
  ...defaultConfig,
825
- ...config,
826
- cardinalityInference: config.schema ? true : false,
832
+ ...configStrict,
833
+ cardinalityInference: configStrict.schema ? true : false,
827
834
  },
828
835
  Storage || IndexedDBStorage,
829
836
  NetworkListener || WindowNetworkListener,
@@ -831,12 +838,10 @@ function init<
831
838
  EventSourceImpl,
832
839
  );
833
840
 
834
- const client = new InstantCoreDatabase<any, Config['useDateObjects']>(
835
- reactor,
836
- );
837
- globalInstantCoreStore[reactorKey(config)] = client;
841
+ const client = new InstantCoreDatabase<any, UseDates>(reactor);
842
+ globalInstantCoreStore[reactorKey(configStrict)] = client;
838
843
 
839
- handleDevtool(config.appId, config.devtool);
844
+ handleDevtool(configStrict.appId, configStrict.devtool);
840
845
 
841
846
  return client;
842
847
  }
package/src/queryTypes.ts CHANGED
@@ -198,7 +198,7 @@ type QueryResponse<
198
198
  ? InstaQLQueryResult<E, Q, WithCardinalityInference, UseDates>
199
199
  : ResponseOf<{ [K in keyof Q]: Remove$<Q[K]> }, Schema>;
200
200
 
201
- type InstaQLResponse<Schema, Q, UseDates extends boolean | undefined = false> =
201
+ type InstaQLResponse<Schema, Q, UseDates extends boolean = false> =
202
202
  Schema extends IContainEntitiesAndLinks<any, any>
203
203
  ? Q extends InstaQLParams<Schema> | undefined
204
204
  ? InstaQLResult<Schema, Q, UseDates>
@@ -261,7 +261,7 @@ type InstaQLEntitySubqueryResult<
261
261
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
262
262
  EntityName extends keyof Schema['entities'],
263
263
  Query extends InstaQLEntitySubquery<Schema, EntityName> | undefined = {},
264
- UseDates extends boolean | undefined = false,
264
+ UseDates extends boolean = false,
265
265
  > = {
266
266
  [QueryPropName in keyof Query]: Schema['entities'][EntityName]['links'][QueryPropName] extends LinkAttrDef<
267
267
  infer Cardinality,
@@ -354,7 +354,7 @@ type InstaQLEntity<
354
354
  EntityName extends keyof Schema['entities'],
355
355
  Subquery extends InstaQLEntitySubquery<Schema, EntityName> | undefined = {},
356
356
  Fields extends InstaQLFields<Schema, EntityName> | undefined = undefined,
357
- UseDates extends boolean | undefined = false,
357
+ UseDates extends boolean = false,
358
358
  > = Expand<
359
359
  { id: string } & ComputeAttrs<
360
360
  ResolveEntityAttrs<Schema['entities'][EntityName], UseDates>,
@@ -400,7 +400,7 @@ type InstaQLQueryResult<
400
400
  type InstaQLResult<
401
401
  Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
402
402
  Query extends InstaQLParams<Schema> | undefined,
403
- UseDates extends boolean | undefined = false,
403
+ UseDates extends boolean = false,
404
404
  > = Expand<{
405
405
  [QueryPropName in keyof Query]: QueryPropName extends keyof Schema['entities']
406
406
  ? InstaQLEntity<
@@ -302,10 +302,7 @@ type OptionalKeys<Attrs extends AttrsDefs> = {
302
302
  * - Required keys => `key: ValueType`
303
303
  * - Optional keys => `key?: ValueType`
304
304
  */
305
- type MappedAttrs<
306
- Attrs extends AttrsDefs,
307
- UseDates extends boolean | undefined,
308
- > = {
305
+ type MappedAttrs<Attrs extends AttrsDefs, UseDates extends boolean> = {
309
306
  [K in RequiredKeys<Attrs>]: Attrs[K] extends DataAttrDef<infer V, any, any>
310
307
  ? V extends Date
311
308
  ? UseDates extends true
@@ -325,7 +322,7 @@ type MappedAttrs<
325
322
 
326
323
  export type ResolveEntityAttrs<
327
324
  EDef extends EntityDef<any, any, any>,
328
- UseDates extends boolean | undefined = false,
325
+ UseDates extends boolean = false,
329
326
  ResolvedAttrs = MappedAttrs<EDef['attrs'], UseDates>,
330
327
  > =
331
328
  EDef extends EntityDef<any, any, infer AsType>
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "include": ["src"],
4
- "exclude": ["node_modules", "dist"],
4
+ "exclude": ["node_modules", "dist", "src/__types__"],
5
5
  "compilerOptions": {
6
6
  "outDir": "dist/tsc",
7
7
  "rewriteRelativeImportExtensions": true,
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src", "src/__types__"],
4
+ "exclude": ["node_modules", "dist"]
5
+ }