@rushdb/javascript-sdk 0.9.4 → 0.10.0

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 (100) hide show
  1. package/{types → dist}/api/create-api.d.ts +6 -6
  2. package/{types → dist}/api/types.d.ts +17 -17
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.mjs +1 -0
  5. package/dist/index.node.d.ts +137 -0
  6. package/dist/index.worker.d.ts +137 -0
  7. package/{types → dist}/sdk/model.d.ts +19 -15
  8. package/{types → dist}/sdk/record.d.ts +15 -12
  9. package/{types → dist}/sdk/sdk.d.ts +27 -27
  10. package/{types → dist}/sdk/transaction.d.ts +2 -2
  11. package/{types → dist}/types/query.d.ts +15 -8
  12. package/package.json +36 -39
  13. package/CHANGELOG.md +0 -180
  14. package/cjs/api/api.js +0 -328
  15. package/cjs/api/constants.js +0 -7
  16. package/cjs/api/create-api.js +0 -323
  17. package/cjs/api/index.js +0 -8
  18. package/cjs/api/rest-api-proxy.js +0 -22
  19. package/cjs/api/types.js +0 -2
  20. package/cjs/api/utils.js +0 -155
  21. package/cjs/common/constants.js +0 -10
  22. package/cjs/common/utils.js +0 -46
  23. package/cjs/index.cjs.node.js +0 -24
  24. package/cjs/index.cjs.worker.js +0 -24
  25. package/cjs/network/FetchHttpClient.js +0 -138
  26. package/cjs/network/HttpClient.js +0 -59
  27. package/cjs/network/NodeHttpClient.js +0 -103
  28. package/cjs/network/index.js +0 -28
  29. package/cjs/network/types.js +0 -2
  30. package/cjs/package.json +0 -4
  31. package/cjs/sdk/constants.js +0 -13
  32. package/cjs/sdk/errors.js +0 -27
  33. package/cjs/sdk/index.js +0 -23
  34. package/cjs/sdk/model.js +0 -147
  35. package/cjs/sdk/record.js +0 -122
  36. package/cjs/sdk/sdk.js +0 -46
  37. package/cjs/sdk/transaction.js +0 -17
  38. package/cjs/sdk/types.js +0 -2
  39. package/cjs/sdk/utils.js +0 -103
  40. package/cjs/types/expressions.js +0 -2
  41. package/cjs/types/index.js +0 -21
  42. package/cjs/types/query.js +0 -2
  43. package/cjs/types/schema.js +0 -2
  44. package/cjs/types/utils.js +0 -2
  45. package/cjs/types/value.js +0 -2
  46. package/esm/api/api.js +0 -324
  47. package/esm/api/constants.js +0 -4
  48. package/esm/api/create-api.js +0 -319
  49. package/esm/api/index.js +0 -2
  50. package/esm/api/rest-api-proxy.js +0 -18
  51. package/esm/api/types.js +0 -1
  52. package/esm/api/utils.js +0 -139
  53. package/esm/common/constants.js +0 -7
  54. package/esm/common/utils.js +0 -37
  55. package/esm/index.esm.node.js +0 -6
  56. package/esm/index.esm.worker.js +0 -6
  57. package/esm/network/FetchHttpClient.js +0 -133
  58. package/esm/network/HttpClient.js +0 -53
  59. package/esm/network/NodeHttpClient.js +0 -98
  60. package/esm/network/index.js +0 -24
  61. package/esm/network/types.js +0 -1
  62. package/esm/package.json +0 -4
  63. package/esm/sdk/constants.js +0 -10
  64. package/esm/sdk/errors.js +0 -21
  65. package/esm/sdk/index.js +0 -7
  66. package/esm/sdk/model.js +0 -143
  67. package/esm/sdk/record.js +0 -115
  68. package/esm/sdk/sdk.js +0 -42
  69. package/esm/sdk/transaction.js +0 -13
  70. package/esm/sdk/types.js +0 -1
  71. package/esm/sdk/utils.js +0 -93
  72. package/esm/types/expressions.js +0 -1
  73. package/esm/types/index.js +0 -5
  74. package/esm/types/query.js +0 -1
  75. package/esm/types/schema.js +0 -1
  76. package/esm/types/utils.js +0 -1
  77. package/esm/types/value.js +0 -1
  78. package/types/index.d.ts +0 -60
  79. /package/{types → dist}/api/api.d.ts +0 -0
  80. /package/{types → dist}/api/constants.d.ts +0 -0
  81. /package/{types → dist}/api/index.d.ts +0 -0
  82. /package/{types → dist}/api/rest-api-proxy.d.ts +0 -0
  83. /package/{types → dist}/api/utils.d.ts +0 -0
  84. /package/{types → dist}/common/constants.d.ts +0 -0
  85. /package/{types → dist}/common/utils.d.ts +0 -0
  86. /package/{types → dist}/network/FetchHttpClient.d.ts +0 -0
  87. /package/{types → dist}/network/HttpClient.d.ts +0 -0
  88. /package/{types → dist}/network/NodeHttpClient.d.ts +0 -0
  89. /package/{types → dist}/network/index.d.ts +0 -0
  90. /package/{types → dist}/network/types.d.ts +0 -0
  91. /package/{types → dist}/sdk/constants.d.ts +0 -0
  92. /package/{types → dist}/sdk/errors.d.ts +0 -0
  93. /package/{types → dist}/sdk/index.d.ts +0 -0
  94. /package/{types → dist}/sdk/types.d.ts +0 -0
  95. /package/{types → dist}/sdk/utils.d.ts +0 -0
  96. /package/{types → dist}/types/expressions.d.ts +0 -0
  97. /package/{types → dist}/types/index.d.ts +0 -0
  98. /package/{types → dist}/types/schema.d.ts +0 -0
  99. /package/{types → dist}/types/utils.d.ts +0 -0
  100. /package/{types → dist}/types/value.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import type { AnyObject, PropertyType, PropertyValue, PropertyWithValue, SearchQuery, Schema, FlattenTypes, InferSchemaTypesRead, InferSchemaTypesWrite, MaybeArray, OptionalKeysRead, RequiredKeysRead } from '../types/index.js';
1
+ import type { AnyObject, ExtractAggregateFields, FlattenTypes, InferSchemaTypesRead, InferSchemaTypesWrite, MaybeArray, OptionalKeysRead, PropertyType, PropertyValue, PropertyWithValue, RequiredKeysRead, Schema, SearchQuery } from '../types/index.js';
2
2
  import type { Transaction } from './transaction.js';
3
3
  import { RestApiProxy } from '../api/rest-api-proxy.js';
4
4
  type DBRecordInternalProps<S extends Schema = Schema> = {
@@ -13,6 +13,9 @@ type DBRecordInternalProps<S extends Schema = Schema> = {
13
13
  export type RecordProps<S extends Schema = Schema> = S extends S ? InferSchemaTypesRead<S> : {
14
14
  [K in keyof S]?: S[K];
15
15
  };
16
+ export type DBRecordInferred<S extends Schema, Q extends SearchQuery<S>> = Q extends {
17
+ aggregate: infer A extends Record<string, any>;
18
+ } ? DBRecord<S> & ExtractAggregateFields<A> : DBRecord<S>;
16
19
  export type DBRecord<S extends Schema = Schema> = FlattenTypes<DBRecordInternalProps<S> & FlattenTypes<RecordProps<S>>>;
17
20
  export type DBRecordTarget = DBRecord<any> | DBRecordInstance<any> | string;
18
21
  export type RelationTarget = DBRecordsArrayInstance<any> | MaybeArray<DBRecord<any>> | MaybeArray<DBRecordInstance<any>> | MaybeArray<string>;
@@ -84,30 +87,30 @@ export declare class DBRecordDraft {
84
87
  }[] | undefined;
85
88
  };
86
89
  }
87
- export declare class DBRecordInstance<S extends Schema = Schema> extends RestApiProxy {
88
- data?: DBRecord<S>;
89
- constructor(data?: DBRecord<S>);
90
+ export declare class DBRecordInstance<S extends Schema = Schema, Q extends SearchQuery<S> = SearchQuery<S>> extends RestApiProxy {
91
+ data?: DBRecordInferred<S, Q>;
92
+ constructor(data?: DBRecordInferred<S, Q>);
90
93
  get id(): string;
91
94
  get label(): string;
92
95
  get proptypes(): FlattenTypes<FlattenTypes<{ [Key in RequiredKeysRead<S>]: S[Key]["type"]; } & { [Key_1 in OptionalKeysRead<S>]?: S[Key_1]["type"] | undefined; }>> | undefined;
93
96
  get date(): Date;
94
97
  get timestamp(): number;
95
- delete(transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
98
+ delete(transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
96
99
  message: string;
97
100
  }, Record<string, any>>>;
98
- update<S extends Schema = Schema>(partialData: DBRecordDraft | Partial<InferSchemaTypesWrite<S>>, transaction?: Transaction | string): Promise<DBRecordInstance<S>>;
99
- set<S extends Schema = Schema>(data: DBRecordDraft | InferSchemaTypesWrite<S>, transaction?: Transaction | string): Promise<DBRecordInstance<S>>;
100
- attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
101
+ update<S extends Schema = Schema>(partialData: DBRecordDraft | Partial<InferSchemaTypesWrite<S>>, transaction?: Transaction | string): Promise<DBRecordInstance<S, SearchQuery<S>>>;
102
+ set<S extends Schema = Schema>(data: DBRecordDraft | InferSchemaTypesWrite<S>, transaction?: Transaction | string): Promise<DBRecordInstance<S, SearchQuery<S>>>;
103
+ attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
101
104
  message: string;
102
105
  }, Record<string, any>>>;
103
- detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
106
+ detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
104
107
  message: string;
105
108
  }, Record<string, any>>>;
106
109
  }
107
- export declare class DBRecordsArrayInstance<S extends Schema = Schema> extends RestApiProxy {
108
- data?: DBRecord<S>[];
110
+ export declare class DBRecordsArrayInstance<S extends Schema = Schema, Q extends SearchQuery<S> = SearchQuery<S>> extends RestApiProxy {
111
+ data?: DBRecordInferred<S, Q>[];
109
112
  total: number | undefined;
110
113
  searchParams?: SearchQuery<S>;
111
- constructor(data?: DBRecord<S>[], total?: number, searchParams?: SearchQuery<S>);
114
+ constructor(data?: DBRecordInferred<S, Q>[], total?: number, searchParams?: SearchQuery<S>);
112
115
  }
113
116
  export {};
@@ -14,7 +14,7 @@ export declare const initSDK: (httpClient: HttpClient) => {
14
14
  readonly __id: string;
15
15
  readonly __label: string;
16
16
  readonly __proptypes?: import("../types/utils.js").FlattenTypes<{ [Key in import("../types/schema.js").RequiredKeysRead<S>]: S[Key]["type"]; } & { [Key_1 in import("../types/schema.js").OptionalKeysRead<S>]?: S[Key_1]["type"] | undefined; }> | undefined;
17
- } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S>;
17
+ } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S, import("../types/query.js").SearchQuery<S>>;
18
18
  api: ReturnType<typeof import("../api/create-api.js").createApi>;
19
19
  fetcher: ReturnType<typeof import("../network/index.js").createFetcher>;
20
20
  records: import("../api/types.js").RecordsApi;
@@ -23,26 +23,26 @@ export declare const initSDK: (httpClient: HttpClient) => {
23
23
  pagination?: Pick<import("../types/query.js").SearchQuery, "limit" | "skip">;
24
24
  search?: import("../types/query.js").SearchQuery<S> | undefined;
25
25
  transaction?: import("./transaction.js").Transaction | string;
26
- }) => Promise<import("../api/types.js").ApiResponse<import("./record.js").Relation[]>>;
26
+ }) => Promise<import("../index.node.js").ApiResponse<import("./record.js").Relation[]>>;
27
27
  };
28
28
  properties: {
29
- delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
30
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property[]>>;
31
- findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
32
- values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
29
+ delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
30
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property[]>>;
31
+ findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
32
+ values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
33
33
  };
34
34
  labels: {
35
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<Record<string, number>>>;
35
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<Record<string, number>>>;
36
36
  };
37
37
  tx: {
38
38
  begin: (config?: Partial<{
39
39
  ttl: number;
40
40
  }>) => Promise<import("./transaction.js").Transaction>;
41
- commit: (id: string) => Promise<import("../api/types.js").ApiResponse<{
41
+ commit: (id: string) => Promise<import("../index.node.js").ApiResponse<{
42
42
  message: string;
43
43
  }>>;
44
44
  get: (id: string) => Promise<import("./transaction.js").Transaction>;
45
- rollback: (id: string) => Promise<import("../api/types.js").ApiResponse<{
45
+ rollback: (id: string) => Promise<import("../index.node.js").ApiResponse<{
46
46
  message: string;
47
47
  }>>;
48
48
  };
@@ -57,7 +57,7 @@ export declare const initSDK: (httpClient: HttpClient) => {
57
57
  readonly __id: string;
58
58
  readonly __label: string;
59
59
  readonly __proptypes?: import("../types/utils.js").FlattenTypes<{ [Key in import("../types/schema.js").RequiredKeysRead<S>]: S[Key]["type"]; } & { [Key_1 in import("../types/schema.js").OptionalKeysRead<S>]?: S[Key_1]["type"] | undefined; }> | undefined;
60
- } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S>;
60
+ } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S, import("../types/query.js").SearchQuery<S>>;
61
61
  api: ReturnType<typeof import("../api/create-api.js").createApi>;
62
62
  fetcher: ReturnType<typeof import("../network/index.js").createFetcher>;
63
63
  records: import("../api/types.js").RecordsApi;
@@ -66,26 +66,26 @@ export declare const initSDK: (httpClient: HttpClient) => {
66
66
  pagination?: Pick<import("../types/query.js").SearchQuery, "limit" | "skip">;
67
67
  search?: import("../types/query.js").SearchQuery<S> | undefined;
68
68
  transaction?: import("./transaction.js").Transaction | string;
69
- }) => Promise<import("../api/types.js").ApiResponse<import("./record.js").Relation[]>>;
69
+ }) => Promise<import("../index.node.js").ApiResponse<import("./record.js").Relation[]>>;
70
70
  };
71
71
  properties: {
72
- delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
73
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property[]>>;
74
- findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
75
- values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
72
+ delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
73
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property[]>>;
74
+ findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
75
+ values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
76
76
  };
77
77
  labels: {
78
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<Record<string, number>>>;
78
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<Record<string, number>>>;
79
79
  };
80
80
  tx: {
81
81
  begin: (config?: Partial<{
82
82
  ttl: number;
83
83
  }>) => Promise<import("./transaction.js").Transaction>;
84
- commit: (id: string) => Promise<import("../api/types.js").ApiResponse<{
84
+ commit: (id: string) => Promise<import("../index.node.js").ApiResponse<{
85
85
  message: string;
86
86
  }>>;
87
87
  get: (id: string) => Promise<import("./transaction.js").Transaction>;
88
- rollback: (id: string) => Promise<import("../api/types.js").ApiResponse<{
88
+ rollback: (id: string) => Promise<import("../index.node.js").ApiResponse<{
89
89
  message: string;
90
90
  }>>;
91
91
  };
@@ -100,7 +100,7 @@ export declare const initSDK: (httpClient: HttpClient) => {
100
100
  readonly __id: string;
101
101
  readonly __label: string;
102
102
  readonly __proptypes?: import("../types/utils.js").FlattenTypes<{ [Key in import("../types/schema.js").RequiredKeysRead<S>]: S[Key]["type"]; } & { [Key_1 in import("../types/schema.js").OptionalKeysRead<S>]?: S[Key_1]["type"] | undefined; }> | undefined;
103
- } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S>;
103
+ } & import("../types/utils.js").FlattenTypes<import("./record.js").RecordProps<S>>>): DBRecordInstance<S, import("../types/query.js").SearchQuery<S>>;
104
104
  api: ReturnType<typeof import("../api/create-api.js").createApi>;
105
105
  fetcher: ReturnType<typeof import("../network/index.js").createFetcher>;
106
106
  records: import("../api/types.js").RecordsApi;
@@ -109,26 +109,26 @@ export declare const initSDK: (httpClient: HttpClient) => {
109
109
  pagination?: Pick<import("../types/query.js").SearchQuery, "limit" | "skip">;
110
110
  search?: import("../types/query.js").SearchQuery<S> | undefined;
111
111
  transaction?: import("./transaction.js").Transaction | string;
112
- }) => Promise<import("../api/types.js").ApiResponse<import("./record.js").Relation[]>>;
112
+ }) => Promise<import("../index.node.js").ApiResponse<import("./record.js").Relation[]>>;
113
113
  };
114
114
  properties: {
115
- delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
116
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property[]>>;
117
- findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property>>;
118
- values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
115
+ delete: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
116
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property[]>>;
117
+ findById: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property>>;
118
+ values: (id: string, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<import("../types/value.js").Property & import("../types/value.js").PropertyValuesData>>;
119
119
  };
120
120
  labels: {
121
- find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../api/types.js").ApiResponse<Record<string, number>>>;
121
+ find: <S extends Schema = any>(searchParams: import("../types/query.js").SearchQuery<S>, transaction?: import("./transaction.js").Transaction | string) => Promise<import("../index.node.js").ApiResponse<Record<string, number>>>;
122
122
  };
123
123
  tx: {
124
124
  begin: (config?: Partial<{
125
125
  ttl: number;
126
126
  }>) => Promise<import("./transaction.js").Transaction>;
127
- commit: (id: string) => Promise<import("../api/types.js").ApiResponse<{
127
+ commit: (id: string) => Promise<import("../index.node.js").ApiResponse<{
128
128
  message: string;
129
129
  }>>;
130
130
  get: (id: string) => Promise<import("./transaction.js").Transaction>;
131
- rollback: (id: string) => Promise<import("../api/types.js").ApiResponse<{
131
+ rollback: (id: string) => Promise<import("../index.node.js").ApiResponse<{
132
132
  message: string;
133
133
  }>>;
134
134
  };
@@ -2,10 +2,10 @@ import { RestApiProxy } from '../api/rest-api-proxy.js';
2
2
  export declare class Transaction extends RestApiProxy {
3
3
  readonly id: string;
4
4
  constructor(id: string);
5
- rollback(): Promise<import("../api/types.js").ApiResponse<{
5
+ rollback(): Promise<import("../index.node.js").ApiResponse<{
6
6
  message: string;
7
7
  }>>;
8
- commit(): Promise<import("../api/types.js").ApiResponse<{
8
+ commit(): Promise<import("../index.node.js").ApiResponse<{
9
9
  message: string;
10
10
  }>>;
11
11
  }
@@ -1,13 +1,12 @@
1
- import type { RelationOptions } from '../sdk/index.js';
2
- import type { BooleanExpression, PropertyExpression, PropertyExpressionByType, DatetimeExpression, LogicalGrouping, NullExpression, NumberExpression, StringExpression } from './expressions.js';
1
+ import type { Model, RelationOptions } from '../sdk/index.js';
2
+ import type { BooleanExpression, DatetimeExpression, LogicalGrouping, NullExpression, NumberExpression, PropertyExpression, PropertyExpressionByType, StringExpression } from './expressions.js';
3
3
  import type { Schema } from './schema.js';
4
- import type { MaybeArray, RequireAtLeastOne } from './utils.js';
5
- export type Relation = RelationOptions | string;
6
- export type Related = {
7
- [Key in keyof Models]?: {
4
+ import type { AnyObject, MaybeArray, RequireAtLeastOne } from './utils.js';
5
+ export type Related<M extends Record<string, Model['schema']> = Models> = keyof M extends never ? AnyObject : {
6
+ [Key in keyof M]?: {
8
7
  $alias?: string;
9
- $relation?: Relation;
10
- } & Where<Models[Key]>;
8
+ $relation?: RelationOptions | string;
9
+ } & Where<M[Key]>;
11
10
  };
12
11
  export type LogicalExpressionValue<T = PropertyExpression & Related> = AndExpression<T> | NorExpression<T> | NotExpression<T> | OrExpression<T> | T | XorExpression<T>;
13
12
  export type AndExpression<T = PropertyExpression & Related> = {
@@ -80,6 +79,14 @@ export type Aggregate = {
80
79
  } | {
81
80
  [field: string]: AggregateFn | string;
82
81
  };
82
+ type InferAggregateType<T extends AggregateFn | string> = T extends string ? any : T extends {
83
+ fn: 'sum' | 'avg' | 'min' | 'max' | 'count';
84
+ } ? number : T extends {
85
+ fn: 'collect';
86
+ } ? any[] : never;
87
+ export type ExtractAggregateFields<A extends Record<string, AggregateFn>> = {
88
+ [K in keyof A]: InferAggregateType<A[K]>;
89
+ };
83
90
  export type WhereClause<S extends Schema = Schema> = {
84
91
  where?: Where<S>;
85
92
  };
package/package.json CHANGED
@@ -2,20 +2,45 @@
2
2
  "name": "@rushdb/javascript-sdk",
3
3
  "description": "RushDB Javascript SDK",
4
4
  "keywords": [
5
- "neo4j",
6
5
  "database",
7
- "firebase-alternative",
8
- "firebase",
9
- "cypher",
10
- "instant",
6
+ "graph database",
7
+ "instant database",
8
+ "instant-database",
9
+ "instantdatabase",
10
+ "instant db",
11
+ "instant-db",
11
12
  "instantdb",
13
+ "neo4j",
14
+ "cypher",
15
+ "ai",
16
+ "ai database",
17
+ "etl",
18
+ "data-pipeline",
19
+ "data science",
20
+ "data-science",
21
+ "data management",
22
+ "data-management",
23
+ "machine learning",
24
+ "machine-learning",
25
+ "persistence",
26
+ "db",
27
+ "graph",
28
+ "graphs",
29
+ "graph-database",
30
+ "self-hosted",
31
+ "rush-db",
32
+ "rush db",
12
33
  "rushdb"
13
34
  ],
14
35
  "license": "Apache-2.0",
15
- "version": "0.9.4",
36
+ "version": "0.10.0",
16
37
  "type": "module",
17
- "main": "cjs/index.cjs.node.js",
18
- "types": "types/index.d.ts",
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "main": "./dist/index.cjs",
42
+ "module": "./dist/index.mjs",
43
+ "types": "./dist/index.worker.d.ts",
19
44
  "devDependencies": {},
20
45
  "peerDependencies": {},
21
46
  "sideEffects": false,
@@ -27,38 +52,10 @@
27
52
  "type": "https",
28
53
  "url": "https://github.com/rush-db/rushdb"
29
54
  },
30
- "exports": {
31
- "types": "./types/index.d.ts",
32
- "browser": {
33
- "import": "./esm/index.esm.worker.js",
34
- "require": "./cjs/index.cjs.worker.js"
35
- },
36
- "bun": {
37
- "import": "./esm/index.esm.worker.js",
38
- "require": "./cjs/index.cjs.worker.js"
39
- },
40
- "deno": {
41
- "import": "./esm/index.esm.worker.js",
42
- "require": "./cjs/index.cjs.worker.js"
43
- },
44
- "worker": {
45
- "import": "./esm/index.esm.worker.js",
46
- "require": "./cjs/index.cjs.worker.js"
47
- },
48
- "workerd": {
49
- "import": "./esm/index.esm.worker.js",
50
- "require": "./cjs/index.cjs.worker.js"
51
- },
52
- "default": {
53
- "import": "./esm/index.esm.node.js",
54
- "require": "./cjs/index.cjs.node.js"
55
- }
56
- },
57
55
  "scripts": {
58
- "build": "pnpm clean && pnpm build-esm && pnpm build-cjs && pnpm postbuild",
59
- "build-esm": "mkdir -p esm && tsc -p tsconfig.esm.json",
60
- "build-cjs": "mkdir -p cjs && tsc -p tsconfig.cjs.json",
61
- "postbuild": "node scripts/post-build.js",
56
+ "build": "pnpm clean && pnpm build:package && pnpm build:types",
57
+ "build:package": "node esbuild.config.cjs",
58
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
62
59
  "types:check": "tsc --noEmit",
63
60
  "clean": "rm -rf ./dist ./node_modules/.cache ./coverage ./esm ./cjs ./types",
64
61
  "flush": "rm -rf node_modules",
package/CHANGELOG.md DELETED
@@ -1,180 +0,0 @@
1
- # @rushdb/javascript-sdk
2
-
3
- ## 0.9.4
4
-
5
- ### Patch Changes
6
-
7
- - 09e2d57: Update docs, minor fixes and cleanups
8
-
9
- ## 0.9.3
10
-
11
- ### Patch Changes
12
-
13
- - 22ce867: billing setup update for dev/prod envs
14
-
15
- ## 0.9.2
16
-
17
- ### Patch Changes
18
-
19
- - eafe1b5: updated secret credentials
20
-
21
- ## 0.9.1
22
-
23
- ### Patch Changes
24
-
25
- - b055539: Dashboard/website: Introduced start plan, updated dashboard && website layouts
26
-
27
- ## 0.9.0
28
-
29
- ### Minor Changes
30
-
31
- - 6cc7392: Release 0.9.0 version with updated billing
32
-
33
- ## 0.8.2
34
-
35
- ### Patch Changes
36
-
37
- - 6e900d7: bump other packages to 0.8.1
38
-
39
- ## 0.8.1
40
-
41
- ### Patch Changes
42
-
43
- - 3d65528: Core/Dashboard/Website now accept billing data from internal billing service instead of hardcoded values
44
-
45
- ## 0.8.0
46
-
47
- ### Minor Changes
48
-
49
- - 49e3153: Dependencies update & landing page rework
50
-
51
- ## 0.7.2
52
-
53
- ### Patch Changes
54
-
55
- - c32b9bf: Aggregations minor fixes
56
-
57
- ## 0.7.1
58
-
59
- ### Patch Changes
60
-
61
- - 0551051: Restore original skip & limit behaviour for nested search
62
-
63
- ## 0.7.0
64
-
65
- ### Minor Changes
66
-
67
- - 5470782: Fix result cut-off for nested queries and url parsing in node.js env at sdk's networking
68
-
69
- ## 0.6.0
70
-
71
- ### Minor Changes
72
-
73
- - 6ec52f2: Add simple backup module, cli command and minor fixes
74
-
75
- ## 0.5.0
76
-
77
- ### Minor Changes
78
-
79
- - 3112626: Implemented logger feature for sdk
80
-
81
- ## 0.4.1
82
-
83
- ### Patch Changes
84
-
85
- - 070d094: Minor cloud update
86
-
87
- ## 0.4.0
88
-
89
- ### Minor Changes
90
-
91
- - 0e04a46: Version bump
92
-
93
- ### Patch Changes
94
-
95
- - 4f83de0: Minor fixes and updates
96
- - defeaf0: Minor fixes and updates
97
-
98
- ## 0.3.1
99
-
100
- ### Patch Changes
101
-
102
- - d3b73ac: Minor fixes
103
-
104
- ## 0.3.0
105
-
106
- ### Minor Changes
107
-
108
- - 70d108d: CLI commands & datetime helpers in the Javascript SDK
109
-
110
- ## 0.2.10
111
-
112
- ### Patch Changes
113
-
114
- - 89f2783: Update readme and license
115
-
116
- ## 0.2.9
117
-
118
- ### Patch Changes
119
-
120
- - 9580ede: Update infrastructure and minor fixes
121
-
122
- ## 0.2.8
123
-
124
- ### Patch Changes
125
-
126
- - 1cf62ae: Minor fixes and cleanups
127
-
128
- ## 0.2.7
129
-
130
- ### Patch Changes
131
-
132
- - 147cc2b: Build docker image only on version bump
133
-
134
- ## 0.2.6
135
-
136
- ### Patch Changes
137
-
138
- - 89852a4: Update docker image release
139
-
140
- ## 0.2.5
141
-
142
- ### Patch Changes
143
-
144
- - cd0be33: Release flow improvements
145
-
146
- ## 0.2.4
147
-
148
- ### Patch Changes
149
-
150
- - 3741a7e: Release workflow change
151
-
152
- ## 0.2.3
153
-
154
- ### Patch Changes
155
-
156
- - c7f1eb9: Update workflow
157
-
158
- ## 0.2.2
159
-
160
- ### Patch Changes
161
-
162
- - de0fb17: Update release workflow
163
-
164
- ## 0.2.1
165
-
166
- ### Patch Changes
167
-
168
- - f934b0f: Bump version
169
-
170
- ## 0.2.0
171
-
172
- ### Minor Changes
173
-
174
- - cb1e4be: Update readme, cleanups, build public image
175
-
176
- ## 0.1.0
177
-
178
- ### Minor Changes
179
-
180
- - 0fc7f66: Initial release before migrating to RushDB domain