@ruiapp/rapid-core 0.10.7 → 0.10.9

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.
package/dist/index.js CHANGED
@@ -2742,12 +2742,16 @@ async function findEntities(server, dataAccessor, options) {
2742
2742
  return entities;
2743
2743
  }
2744
2744
  async function findEntity(server, dataAccessor, options) {
2745
- const entities = await findEntities(server, dataAccessor, {
2746
- ...options,
2747
- ...{
2745
+ if (options.pagination) {
2746
+ options.pagination.limit = 1;
2747
+ }
2748
+ else {
2749
+ options.pagination = {
2750
+ offset: 0,
2748
2751
  limit: 1,
2749
- },
2750
- });
2752
+ };
2753
+ }
2754
+ const entities = await findEntities(server, dataAccessor, options);
2751
2755
  return lodash.first(entities);
2752
2756
  }
2753
2757
  async function findById(server, dataAccessor, options) {
@@ -2973,7 +2977,7 @@ async function convertEntityFiltersToRowFilters(routeContext, server, model, bas
2973
2977
  }
2974
2978
  let itemType;
2975
2979
  if (filter.operator === "in" || filter.operator === "notIn") {
2976
- itemType = filter.itemType || pgPropertyTypeColumnMap[property.type];
2980
+ itemType = filter.itemType || (property && pgPropertyTypeColumnMap[property.type]);
2977
2981
  }
2978
2982
  replacedFilters.push({
2979
2983
  operator: filter.operator,
@@ -3004,6 +3008,7 @@ async function findManyRelationLinksViaLinkTable(options) {
3004
3008
  singularCode: relationModel.singularCode,
3005
3009
  });
3006
3010
  const findEntityOptions = {
3011
+ routeContext,
3007
3012
  filters: [
3008
3013
  {
3009
3014
  field: "id",
@@ -3042,11 +3047,12 @@ async function findManyRelationLinksViaLinkTable(options) {
3042
3047
  return { relationLinks, targetEntities };
3043
3048
  }
3044
3049
  async function findManyRelatedEntitiesViaIdPropertyCode(options) {
3045
- const { server, relationProperty, mainEntityIds, selectRelationOptions } = options;
3050
+ const { server, routeContext, relationProperty, mainEntityIds, selectRelationOptions } = options;
3046
3051
  const dataAccessor = server.getDataAccessor({
3047
3052
  singularCode: relationProperty.targetSingularCode,
3048
3053
  });
3049
3054
  const findEntityOptions = {
3055
+ routeContext,
3050
3056
  filters: [
3051
3057
  {
3052
3058
  field: relationProperty.selfIdColumnName,
@@ -3087,11 +3093,12 @@ async function findManyRelatedEntitiesViaIdPropertyCode(options) {
3087
3093
  return await findEntities(server, dataAccessor, findEntityOptions);
3088
3094
  }
3089
3095
  async function findOneRelatedEntitiesViaIdPropertyCode(options) {
3090
- const { server, relationProperty, relationEntityIds, selectRelationOptions } = options;
3096
+ const { server, routeContext, relationProperty, relationEntityIds, selectRelationOptions } = options;
3091
3097
  const dataAccessor = server.getDataAccessor({
3092
3098
  singularCode: relationProperty.targetSingularCode,
3093
3099
  });
3094
3100
  const findEntityOptions = {
3101
+ routeContext,
3095
3102
  filters: [
3096
3103
  {
3097
3104
  field: "id",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -362,12 +362,15 @@ async function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor,
362
362
  }
363
363
 
364
364
  async function findEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: FindEntityOptions) {
365
- const entities = await findEntities(server, dataAccessor, {
366
- ...options,
367
- ...{
365
+ if (options.pagination) {
366
+ options.pagination.limit = 1;
367
+ } else {
368
+ options.pagination = {
369
+ offset: 0,
368
370
  limit: 1,
369
- },
370
- });
371
+ };
372
+ }
373
+ const entities = await findEntities(server, dataAccessor, options);
371
374
  return first(entities);
372
375
  }
373
376
 
@@ -614,7 +617,7 @@ async function convertEntityFiltersToRowFilters(
614
617
 
615
618
  let itemType: string | undefined;
616
619
  if (filter.operator === "in" || filter.operator === "notIn") {
617
- itemType = filter.itemType || pgPropertyTypeColumnMap[property.type];
620
+ itemType = filter.itemType || (property && pgPropertyTypeColumnMap[property.type]);
618
621
  }
619
622
 
620
623
  replacedFilters.push({
@@ -649,6 +652,7 @@ async function findManyRelationLinksViaLinkTable(options: FindManyRelationEntiti
649
652
  });
650
653
 
651
654
  const findEntityOptions: FindEntityOptions = {
655
+ routeContext,
652
656
  filters: [
653
657
  {
654
658
  field: "id",
@@ -692,12 +696,13 @@ async function findManyRelationLinksViaLinkTable(options: FindManyRelationEntiti
692
696
  }
693
697
 
694
698
  async function findManyRelatedEntitiesViaIdPropertyCode(options: FindManyRelationEntitiesOptions) {
695
- const { server, relationProperty, mainEntityIds, selectRelationOptions } = options;
699
+ const { server, routeContext, relationProperty, mainEntityIds, selectRelationOptions } = options;
696
700
  const dataAccessor = server.getDataAccessor({
697
701
  singularCode: relationProperty.targetSingularCode as string,
698
702
  });
699
703
 
700
704
  const findEntityOptions: FindEntityOptions = {
705
+ routeContext,
701
706
  filters: [
702
707
  {
703
708
  field: relationProperty.selfIdColumnName,
@@ -741,13 +746,14 @@ async function findManyRelatedEntitiesViaIdPropertyCode(options: FindManyRelatio
741
746
  }
742
747
 
743
748
  async function findOneRelatedEntitiesViaIdPropertyCode(options: FindOneRelationEntitiesOptions) {
744
- const { server, relationProperty, relationEntityIds, selectRelationOptions } = options;
749
+ const { server, routeContext, relationProperty, relationEntityIds, selectRelationOptions } = options;
745
750
 
746
751
  const dataAccessor = server.getDataAccessor({
747
752
  singularCode: relationProperty.targetSingularCode as string,
748
753
  });
749
754
 
750
755
  const findEntityOptions: FindEntityOptions = {
756
+ routeContext,
751
757
  filters: [
752
758
  {
753
759
  field: "id",