remult 3.4.2 → 3.5.0-next.2

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 (72) hide show
  1. package/esm/internals.js +1 -0
  2. package/esm/postgres/postgres-data-provider.js +4 -5
  3. package/esm/remult-duckdb.js +4 -0
  4. package/esm/remult-knex/index.js +69 -14
  5. package/esm/remult-mongo.js +25 -7
  6. package/esm/remult-sqlite-core.js +4 -1
  7. package/esm/server/remult-api-server.js +14 -6
  8. package/esm/src/buildRestDataProvider.js +8 -6
  9. package/esm/src/context.js +1 -1
  10. package/esm/src/data-api.js +2 -2
  11. package/esm/src/data-interfaces.js +2 -1
  12. package/esm/src/data-providers/array-entity-data-provider.js +9 -4
  13. package/esm/src/data-providers/rest-data-provider-using-fetch.js +13 -6
  14. package/esm/src/data-providers/retry.js +11 -6
  15. package/esm/src/data-providers/sql-database.js +40 -30
  16. package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +35 -4
  17. package/esm/src/filter/filter-interfaces.js +18 -4
  18. package/esm/src/live-query/SubscriptionChannel.js +13 -8
  19. package/esm/src/remult-proxy.js +12 -0
  20. package/esm/src/remult-static.js +2 -0
  21. package/esm/src/remult3/Fields.js +14 -14
  22. package/esm/src/remult3/RepositoryImplementation.js +69 -32
  23. package/esm/src/remult3/remult3.js +2 -0
  24. package/esm/src/server-action.js +43 -14
  25. package/esm/src/sort.js +18 -0
  26. package/index.d.ts +4 -3
  27. package/internals.d.ts +1 -0
  28. package/internals.js +3 -1
  29. package/package.json +41 -1
  30. package/postgres/postgres-data-provider.d.ts +2 -3
  31. package/postgres/postgres-data-provider.js +4 -4
  32. package/remult-duckdb.d.ts +2 -0
  33. package/remult-duckdb.js +4 -0
  34. package/remult-knex/index.d.ts +2 -0
  35. package/remult-knex/index.js +153 -83
  36. package/remult-mongo.js +28 -7
  37. package/remult-sqlite-core.d.ts +2 -1
  38. package/remult-sqlite-core.js +4 -0
  39. package/server/remult-api-server.d.ts +28 -1
  40. package/server/remult-api-server.js +19 -12
  41. package/src/buildRestDataProvider.d.ts +1 -1
  42. package/src/buildRestDataProvider.js +8 -6
  43. package/src/column-interfaces.d.ts +5 -1
  44. package/src/context.js +1 -1
  45. package/src/data-api.js +2 -2
  46. package/src/data-interfaces.d.ts +0 -1
  47. package/src/data-interfaces.js +3 -0
  48. package/src/data-providers/array-entity-data-provider.js +9 -4
  49. package/src/data-providers/rest-data-provider-using-fetch.d.ts +1 -1
  50. package/src/data-providers/rest-data-provider-using-fetch.js +11 -4
  51. package/src/data-providers/retry.d.ts +4 -1
  52. package/src/data-providers/retry.js +26 -16
  53. package/src/data-providers/sql-database.d.ts +7 -3
  54. package/src/data-providers/sql-database.js +99 -81
  55. package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +8 -0
  56. package/src/filter/filter-consumer-bridge-to-sql-request.js +58 -19
  57. package/src/filter/filter-interfaces.js +19 -2
  58. package/src/live-query/SubscriptionChannel.js +16 -10
  59. package/src/remult-proxy.js +28 -0
  60. package/src/remult-static.d.ts +4 -0
  61. package/src/remult-static.js +2 -0
  62. package/src/remult3/Fields.d.ts +5 -3
  63. package/src/remult3/Fields.js +24 -13
  64. package/src/remult3/RepositoryImplementation.d.ts +7 -0
  65. package/src/remult3/RepositoryImplementation.js +325 -264
  66. package/src/remult3/remult3.d.ts +68 -5
  67. package/src/remult3/remult3.js +2 -0
  68. package/src/server-action.d.ts +34 -2
  69. package/src/server-action.js +195 -115
  70. package/src/sort.d.ts +19 -0
  71. package/src/sort.js +20 -1
  72. package/src/sql-command.d.ts +2 -1
@@ -91,9 +91,9 @@ export class myServerAction extends Action {
91
91
  await decideTransaction(remult, this.options, async () => {
92
92
  if (!remult.isAllowedForInstance(undefined, this.options.allowed))
93
93
  throw new ForbiddenError();
94
- info.args = await prepareReceivedArgs(this.types(), info.args, remult, ds, res);
94
+ info.args = await prepareReceivedArgs(this.types(), await fromWire(info.args, remult, this.options, 'args'), remult, ds, res);
95
95
  try {
96
- result.data = await this.originalMethod(info.args);
96
+ result.data = await toWire(await this.originalMethod(info.args), remult, this.options, 'result');
97
97
  }
98
98
  catch (err) {
99
99
  throw err;
@@ -151,13 +151,16 @@ export function BackendMethod(options) {
151
151
  if (target.prototype !== undefined) {
152
152
  // if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
153
153
  let serverAction = new myServerAction((options?.apiPrefix ? options.apiPrefix + '/' : '') + key, () => getTypes(), options, (args) => originalMethod.apply(undefined, args));
154
- serverAction.doWork = async (args, self, url, http) => {
155
- args = prepareArgsToSend(getTypes(), args);
154
+ serverAction.doWork = async (args, self, caller) => {
155
+ const calling = caller ?? remult;
156
+ const url = calling.apiClient.url;
157
+ const http = buildRestDataProvider(calling.apiClient.httpClient);
158
+ const sent = await toWire(prepareArgsToSend(getTypes(), args), calling, options, 'args');
156
159
  if (options.blockUser === false) {
157
- return await remultStatic.actionInfo.runActionWithoutBlockingUI(async () => (await serverAction.run({ args }, url, http)).data);
160
+ return await remultStatic.actionInfo.runActionWithoutBlockingUI(async () => fromWire((await serverAction.run({ args: sent }, url, http)).data, calling, options, 'result'));
158
161
  }
159
162
  else
160
- return (await serverAction.run({ args }, url, http)).data;
163
+ return fromWire((await serverAction.run({ args: sent }, url, http)).data, calling, options, 'result');
161
164
  };
162
165
  result = async function (...args) {
163
166
  if (!isBackend()) {
@@ -194,10 +197,10 @@ export function BackendMethod(options) {
194
197
  '/' +
195
198
  (options?.apiPrefix ? options.apiPrefix + '/' : '') +
196
199
  key, options ? (options.queue ?? false) : false, options.allowed, async (d, req, res) => {
197
- d.args = d.args.map((x) => (isCustomUndefined(x) ? undefined : x));
198
200
  let allowed = options.allowed;
199
201
  try {
200
202
  let remult = req;
203
+ d.args = (await fromWire(d.args, remult, options, 'args')).map((x) => (isCustomUndefined(x) ? undefined : x));
201
204
  let r;
202
205
  await decideTransaction(remult, options, async () => {
203
206
  d.args = await prepareReceivedArgs(getTypes(), d.args, remult, remult.dataProvider, res);
@@ -217,8 +220,13 @@ export function BackendMethod(options) {
217
220
  $and: [repo.metadata.options.apiPrefilter ?? {}],
218
221
  },
219
222
  });
223
+ // The client sent a stale row id, so this is a 400 even when
224
+ // defaultErrorStatus is 500.
220
225
  if (rows.length != 1)
221
- throw new Error('not found or too many matches');
226
+ throw {
227
+ message: 'not found or too many matches',
228
+ httpStatusCode: 400,
229
+ };
222
230
  y = rows[0];
223
231
  await repo.getEntityRef(y)._updateEntityBasedOnApi(rowInfo.data);
224
232
  }
@@ -228,7 +236,7 @@ export function BackendMethod(options) {
228
236
  await defs.__validateEntity();
229
237
  try {
230
238
  r = {
231
- result: await originalMethod.apply(y, d.args),
239
+ result: await toWire(await originalMethod.apply(y, d.args), remult, options, 'result'),
232
240
  rowInfo: {
233
241
  data: await defs.toApiJson(),
234
242
  isNewRow: defs.isNew(),
@@ -250,7 +258,7 @@ export function BackendMethod(options) {
250
258
  await controllerRef.__validateEntity();
251
259
  try {
252
260
  r = {
253
- result: await originalMethod.apply(y, d.args),
261
+ result: await toWire(await originalMethod.apply(y, d.args), remult, options, 'result'),
254
262
  fields: await controllerRef.toApiJson(),
255
263
  };
256
264
  }
@@ -271,8 +279,11 @@ export function BackendMethod(options) {
271
279
  });
272
280
  }
273
281
  },
274
- doWork: async function (args, self, baseUrl, http) {
275
- args = prepareArgsToSend(getTypes(), args);
282
+ doWork: async function (args, self, caller) {
283
+ const calling = caller ?? remult;
284
+ const baseUrl = calling.apiClient.url;
285
+ const http = buildRestDataProvider(calling.apiClient.httpClient);
286
+ args = await toWire(prepareArgsToSend(getTypes(), args), calling, options, 'args');
276
287
  if (remultStatic.allEntities.includes(target.constructor)) {
277
288
  let defs = getEntityRef(self);
278
289
  await defs.__validateEntity();
@@ -296,7 +307,7 @@ export function BackendMethod(options) {
296
307
  },
297
308
  }, baseUrl, http);
298
309
  await defs._updateResultsFromServerAction(r.rowInfo);
299
- return r.result;
310
+ return fromWire(r.result, calling, options, 'result');
300
311
  }
301
312
  catch (err) {
302
313
  throw defs.catchSaveErrors(err);
@@ -316,7 +327,7 @@ export function BackendMethod(options) {
316
327
  fields: await defs.toApiJson(),
317
328
  }, baseUrl, http);
318
329
  await defs._updateEntityBasedOnApi(r.fields);
319
- return r.result;
330
+ return fromWire(r.result, calling, options, 'result');
320
331
  }
321
332
  catch (e) {
322
333
  throw defs.catchSaveErrors(e);
@@ -343,6 +354,12 @@ export function BackendMethod(options) {
343
354
  return result;
344
355
  };
345
356
  }
357
+ Object.defineProperty(BackendMethod, 'serializer', {
358
+ get: () => remultStatic.backendMethodSerializer,
359
+ set: (value) => {
360
+ remultStatic.backendMethodSerializer = value;
361
+ },
362
+ });
346
363
  const customUndefined = {
347
364
  _isUndefined: true,
348
365
  };
@@ -354,6 +371,18 @@ function registerAction(target, resultMethod) {
354
371
  function isCustomUndefined(x) {
355
372
  return x && x._isUndefined;
356
373
  }
374
+ async function toWire(value, remult, options, part) {
375
+ const serializer = remultStatic.backendMethodSerializer;
376
+ return serializer
377
+ ? serializer[part].serialize(value, { remult, options })
378
+ : value;
379
+ }
380
+ async function fromWire(value, remult, options, part) {
381
+ const serializer = remultStatic.backendMethodSerializer;
382
+ return serializer
383
+ ? serializer[part].deserialize(value, { remult, options })
384
+ : value;
385
+ }
357
386
  export class ProgressListener {
358
387
  res;
359
388
  constructor(res) {
package/esm/src/sort.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { remultStatic } from './remult-static.js';
1
2
  import { getRelationFieldInfo } from './remult3/relationInfoMember.js';
2
3
  /**
3
4
  * The `Sort` class is used to describe sorting criteria for queries. It is mainly used internally,
@@ -161,9 +162,26 @@ export class Sort {
161
162
  return orderBy;
162
163
  }
163
164
  }
165
+ /**
166
+ * Where NULL sorts, for the whole app: set it on both the server and the client.
167
+ * @see https://remult.dev/docs/field-types#where-null-sorts
168
+ */
169
+ export const NullSort = remultStatic.nullSort || (remultStatic.nullSort = { order: 'native' });
170
+ /** Remult's own order, without a database: `native` is NULL lowest. */
171
+ export function isNullFirstSort(isDescending) {
172
+ if (NullSort.order === 'native')
173
+ return !isDescending;
174
+ return NullSort.order[isDescending ? 'desc' : 'asc'] === 'NULLS FIRST';
175
+ }
164
176
  export function compareForSort(left, right, descending) {
165
177
  left = fixValueForSort(left);
166
178
  right = fixValueForSort(right);
179
+ // `null > 'a'` and `null < 'a'` are both false, which is not an order.
180
+ if (left == null || right == null) {
181
+ if (left == right)
182
+ return 0;
183
+ return (left == null) === isNullFirstSort(descending) ? -1 : 1;
184
+ }
167
185
  let r = 0;
168
186
  if (left > right)
169
187
  r = 1;
package/index.d.ts CHANGED
@@ -2,8 +2,9 @@ import type { ClassType } from './classType.js';
2
2
  import type { DataProvider } from './src/data-interfaces.js';
3
3
  export { ArrayEntityDataProvider } from './src/data-providers/array-entity-data-provider.js';
4
4
  export type { ClassType } from './classType.js';
5
- export type { ValidateFieldEvent, MembersOnly, NumericKeys, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, FindOptionsBase, QueryResult, QueryOptions, UpsertOptions, Repository, GroupByOptions, GroupByResult, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, EntitySelectFields, InsertOrUpdateOptions, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
5
+ export type { ValidateFieldEvent, MembersOnly, NumericKeys, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, FindOptionsBase, QueryResult, QueryOptions, UpsertOptions, Repository, GroupByOptions, GroupByResult, FindFirstOptions, ComparisonValueFilter, ComparableTypes, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, EntitySelectFields, InsertOrUpdateOptions, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
6
6
  LifecycleEvent, FieldsRefBase, FieldsRefForEntityBase, RepositoryRelationsForEntityBase, ControllerRefForControllerBase, ControllerRefBase, ControllerRef, EntityRefForEntityBase, IdMetadata, FindFirstOptionsBase, } from './src/remult3/remult3.js';
7
+ export type { NotAField } from './src/remult3/remult3.js';
7
8
  export { standardSchema } from './src/standard-schema/index.js';
8
9
  export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListInfo, } from './src/remult3/RepositoryImplementation.js';
9
10
  export type { ValueListFieldOptions } from './src/remult3/RepositoryImplementation.js';
@@ -40,12 +41,12 @@ export { JsonEntityIndexedDbStorage } from './src/data-providers/json-entity-ind
40
41
  export { IndexedDbDataProvider, IndexedDbIndexBuilder, } from './src/data-providers/indexed-db-data-provider.js';
41
42
  export type { IndexedDbDataProviderOptions, IndexedDbIndexDef, } from './src/data-providers/indexed-db-data-provider.js';
42
43
  export { Controller, BackendMethod, ProgressListener, ForbiddenError, } from './src/server-action.js';
43
- export type { BackendMethodOptions } from './src/server-action.js';
44
+ export type { BackendMethodOptions, BackendMethodSerializer, BackendMethodSerializerContext, BackendMethodValueSerializer, } from './src/server-action.js';
44
45
  export { Allow, Remult, withRemult, isBackend, EventSource, } from './src/context.js';
45
46
  export type { Allowed, RemultContext, ApiClient, AllowedForInstance, EventDispatcher, UserInfo, } from './src/context.js';
46
47
  export type { ExternalHttpProvider } from './src/buildRestDataProvider.js';
47
48
  export { Sort } from './src/sort.js';
48
- export type { SortSegment } from './src/sort.js';
49
+ export type { SortSegment, NativeNullSort, NullOrder } from './src/sort.js';
49
50
  export { CompoundIdField } from './src/CompoundIdField.js';
50
51
  export { Filter } from './src/filter/filter-interfaces.js';
51
52
  export type { FilterConsumer, FilterPreciseValues, } from './src/filter/filter-interfaces.js';
package/internals.d.ts CHANGED
@@ -18,6 +18,7 @@ export type { ClassType } from './classType.js';
18
18
  export type { SubscriptionServerRouteApi, SubscriptionServerRouteHandlerArgs, } from './server/remult-api-server.js';
19
19
  export type { DataApiResponse } from './src/data-api.js';
20
20
  export { flags } from './src/remult3/remult3.js';
21
+ export { NullSort } from './src/sort.js';
21
22
  export { SseSubscriptionClient } from './src/live-query/SseSubscriptionClient.js';
22
23
  export { DataProviderPromiseWrapper } from './src/data-interfaces.js';
23
24
  export { pagedQueryResult } from './src/remult3/pagedQueryResult.js';
package/internals.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pagedQueryResult = exports.DataProviderPromiseWrapper = exports.SseSubscriptionClient = exports.flags = exports.isOfType = exports.actionInfo = exports.walkFilter = exports.omitFilterField = exports.__updateEntityBasedOnWhere = exports.getEntitySettings = exports.fieldOptionsEnricher = exports.getControllerRef = exports.controllerRefImpl = exports.decorateColumnSettings = exports.getRelationFieldInfo = exports.getRelationInfo = exports.sqlRelationsFilter = exports.sqlRelations = void 0;
3
+ exports.pagedQueryResult = exports.DataProviderPromiseWrapper = exports.SseSubscriptionClient = exports.NullSort = exports.flags = exports.isOfType = exports.actionInfo = exports.walkFilter = exports.omitFilterField = exports.__updateEntityBasedOnWhere = exports.getEntitySettings = exports.fieldOptionsEnricher = exports.getControllerRef = exports.controllerRefImpl = exports.decorateColumnSettings = exports.getRelationFieldInfo = exports.getRelationInfo = exports.sqlRelationsFilter = exports.sqlRelations = void 0;
4
4
  var remult_static_js_1 = require("./src/remult-static.js");
5
5
  var sql_relations_js_1 = require("./src/data-providers/sql-relations.js");
6
6
  Object.defineProperty(exports, "sqlRelations", { enumerable: true, get: function () { return sql_relations_js_1.sqlRelations; } });
@@ -25,6 +25,8 @@ var isOfType_js_1 = require("./src/isOfType.js");
25
25
  Object.defineProperty(exports, "isOfType", { enumerable: true, get: function () { return isOfType_js_1.isOfType; } });
26
26
  var remult3_js_1 = require("./src/remult3/remult3.js");
27
27
  Object.defineProperty(exports, "flags", { enumerable: true, get: function () { return remult3_js_1.flags; } });
28
+ var sort_js_1 = require("./src/sort.js");
29
+ Object.defineProperty(exports, "NullSort", { enumerable: true, get: function () { return sort_js_1.NullSort; } });
28
30
  var SseSubscriptionClient_js_1 = require("./src/live-query/SseSubscriptionClient.js");
29
31
  Object.defineProperty(exports, "SseSubscriptionClient", { enumerable: true, get: function () { return SseSubscriptionClient_js_1.SseSubscriptionClient; } });
30
32
  var data_interfaces_js_1 = require("./src/data-interfaces.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "3.4.2",
3
+ "version": "3.5.0-next.2",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -26,6 +26,46 @@
26
26
  "dependencies": {
27
27
  "tslib": "^2.3.1"
28
28
  },
29
+ "peerDependencies": {
30
+ "@duckdb/node-api": ">=1.3.2-alpha.26",
31
+ "@libsql/client": ">=0.5.6",
32
+ "better-sqlite3": ">=12.2.0",
33
+ "cloudflare": ">=4.4.1",
34
+ "knex": ">=2.4.0",
35
+ "mongodb": ">=4.17.1",
36
+ "pg": ">=8.3.0",
37
+ "sql.js": ">=1.9.0",
38
+ "sqlite3": ">=5.1.7"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "@duckdb/node-api": {
42
+ "optional": true
43
+ },
44
+ "@libsql/client": {
45
+ "optional": true
46
+ },
47
+ "better-sqlite3": {
48
+ "optional": true
49
+ },
50
+ "cloudflare": {
51
+ "optional": true
52
+ },
53
+ "knex": {
54
+ "optional": true
55
+ },
56
+ "mongodb": {
57
+ "optional": true
58
+ },
59
+ "pg": {
60
+ "optional": true
61
+ },
62
+ "sql.js": {
63
+ "optional": true
64
+ },
65
+ "sqlite3": {
66
+ "optional": true
67
+ }
68
+ },
29
69
  "exports": {
30
70
  ".": {
31
71
  "require": "./index.js",
@@ -1,6 +1,7 @@
1
1
  import type { ClientBase, PoolConfig, QueryResult } from 'pg';
2
2
  import { SqlDatabase } from '../src/data-providers/sql-database.js';
3
3
  import type { EntityMetadata } from '../src/remult3/remult3.js';
4
+ import type { NativeNullSort } from '../src/sort.js';
4
5
  import type { SqlCommand, SqlImplementation } from '../src/sql-command.js';
5
6
  import type { CanBuildMigrations, MigrationBuilder, MigrationCode } from '../migrations/migration-types.js';
6
7
  import type { DataProvider } from '../index.js';
@@ -23,13 +24,12 @@ export declare class PostgresDataProvider implements SqlImplementation, CanBuild
23
24
  wrapIdentifier?: (name: string) => string;
24
25
  caseInsensitiveIdentifiers?: boolean;
25
26
  schema?: string;
26
- orderByNullsFirst?: boolean;
27
27
  } | undefined);
28
28
  end(): Promise<void>;
29
29
  provideMigrationBuilder(builder: MigrationCode): MigrationBuilder;
30
30
  wrapIdentifier: (name: string) => string;
31
31
  ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
32
- orderByNullsFirst?: boolean;
32
+ nativeNullSort: NativeNullSort;
33
33
  transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;
34
34
  }
35
35
  export interface PostgresCommandSource {
@@ -43,7 +43,6 @@ export declare function createPostgresDataProvider(options?: {
43
43
  wrapIdentifier?: (name: string) => string;
44
44
  caseInsensitiveIdentifiers?: boolean;
45
45
  schema?: string;
46
- orderByNullsFirst?: boolean;
47
46
  }): Promise<SqlDatabase>;
48
47
  export declare function preparePostgresQueueStorage(sql: SqlDatabase): Promise<import("../server/remult-api-server.js").EntityQueueStorage>;
49
48
  export declare class PostgresSchemaWrapper implements PostgresPool {
@@ -24,12 +24,14 @@ var PostgresDataProvider = /** @class */ (function () {
24
24
  })
25
25
  .join('.');
26
26
  };
27
+ this.nativeNullSort = {
28
+ order: { asc: 'NULLS LAST', desc: 'NULLS FIRST' },
29
+ syntax: 'NULLS FIRST/LAST',
30
+ };
27
31
  if (options === null || options === void 0 ? void 0 : options.wrapIdentifier)
28
32
  this.wrapIdentifier = options.wrapIdentifier;
29
33
  if (!(options === null || options === void 0 ? void 0 : options.wrapIdentifier) && (options === null || options === void 0 ? void 0 : options.caseInsensitiveIdentifiers))
30
34
  this.wrapIdentifier = function (name) { return name; };
31
- if (options === null || options === void 0 ? void 0 : options.orderByNullsFirst)
32
- this.orderByNullsFirst = options.orderByNullsFirst;
33
35
  if (options === null || options === void 0 ? void 0 : options.schema) {
34
36
  this.pool = new PostgresSchemaWrapper(pool, options.schema);
35
37
  }
@@ -134,7 +136,6 @@ var PostgresDataProvider = /** @class */ (function () {
134
136
  //@ts-ignore
135
137
  pool: client,
136
138
  wrapIdentifier: this.wrapIdentifier,
137
- orderByNullsFirst: this.orderByNullsFirst,
138
139
  })];
139
140
  case 4:
140
141
  _a.sent();
@@ -233,7 +234,6 @@ function createPostgresDataProvider(options) {
233
234
  wrapIdentifier: options.wrapIdentifier,
234
235
  caseInsensitiveIdentifiers: options.caseInsensitiveIdentifiers,
235
236
  schema: options.schema,
236
- orderByNullsFirst: options.orderByNullsFirst,
237
237
  }));
238
238
  return [2 /*return*/, db];
239
239
  });
@@ -1,9 +1,11 @@
1
1
  import type { DuckDBConnection } from '@duckdb/node-api';
2
2
  import { SqliteCoreDataProvider } from './remult-sqlite-core.js';
3
+ import type { NativeNullSort } from './src/sort.js';
3
4
  import { type FieldMetadata, type EntityMetadata } from './index.js';
4
5
  export declare class DuckDBDataProvider extends SqliteCoreDataProvider {
5
6
  private connection;
6
7
  constructor(connection: DuckDBConnection);
8
+ nativeNullSort: NativeNullSort;
7
9
  wrapIdentifier(name: string): string;
8
10
  getCreateTableSql(entity: EntityMetadata<any>): Promise<string[]>;
9
11
  addColumnSqlSyntax(x: FieldMetadata, dbName: string, isAlterColumn: boolean): string;
package/remult-duckdb.js CHANGED
@@ -14,6 +14,10 @@ var DuckDBDataProvider = /** @class */ (function (_super) {
14
14
  return [2 /*return*/, this.connection.disconnectSync()];
15
15
  }); }); }, false, true) || this;
16
16
  _this.connection = connection;
17
+ _this.nativeNullSort = {
18
+ order: { asc: 'NULLS LAST', desc: 'NULLS LAST' },
19
+ syntax: 'NULLS FIRST/LAST',
20
+ };
17
21
  return _this;
18
22
  }
19
23
  DuckDBDataProvider.prototype.wrapIdentifier = function (name) {
@@ -4,6 +4,7 @@ import type { FieldMetadata } from '../src/column-interfaces.js';
4
4
  import type { DataProvider, EntityDataProvider } from '../src/data-interfaces.js';
5
5
  import type { EntityFilter, EntityMetadata } from '../src/remult3/remult3.js';
6
6
  import type { RepositoryOverloads } from '../src/remult3/RepositoryImplementation.js';
7
+ import { type NativeNullSort } from '../src/sort.js';
7
8
  import type { HasJsonColumnStorage, HasWrapIdentifier, JsonColumnStorage, SqlCommand, SqlCommandFactory, SqlResult } from '../src/sql-command.js';
8
9
  import type { CanBuildMigrations, MigrationBuilder, MigrationCode } from '../migrations/migration-types.js';
9
10
  export declare class KnexDataProvider implements DataProvider, HasWrapIdentifier, HasJsonColumnStorage, SqlCommandFactory, CanBuildMigrations {
@@ -15,6 +16,7 @@ export declare class KnexDataProvider implements DataProvider, HasWrapIdentifier
15
16
  execute(sql: string): Promise<SqlResult>;
16
17
  static getDb(dataProvider?: DataProvider): Knex<any, any[]>;
17
18
  wrapIdentifier: (name: string) => string;
19
+ get nativeNullSort(): NativeNullSort;
18
20
  get jsonColumnStorage(): JsonColumnStorage;
19
21
  getEntityDataProvider(entity: EntityMetadata<any>): EntityDataProvider;
20
22
  transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;