@infrab4a/connect 4.0.0-beta.49 → 4.0.0-beta.50
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/domain/generic/repository/find.repository.d.ts +1 -0
- package/domain/generic/repository/types/repository-find-result.type.d.ts +4 -1
- package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +47 -10
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
- package/fesm2015/infrab4a-connect.mjs +43 -13
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +46 -9
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +2 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +3 -2
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -1
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +4 -3
- package/package.json +1 -1
|
@@ -3249,12 +3249,22 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3249
3249
|
]
|
|
3250
3250
|
: []),
|
|
3251
3251
|
];
|
|
3252
|
+
this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
|
|
3252
3253
|
this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)?.columnName || attr);
|
|
3253
3254
|
}
|
|
3254
3255
|
async find(params) {
|
|
3255
3256
|
this.logger = DebugHelper.from(this, 'find');
|
|
3256
3257
|
const { filters, limits, orderBy, options } = params || {};
|
|
3257
3258
|
const enableCount = options?.enableCount ?? true;
|
|
3259
|
+
const variablesFilters = isNil(filters)
|
|
3260
|
+
? {}
|
|
3261
|
+
: {
|
|
3262
|
+
where: {
|
|
3263
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
3264
|
+
type: `${this.tableName}_bool_exp`,
|
|
3265
|
+
required: true,
|
|
3266
|
+
},
|
|
3267
|
+
};
|
|
3258
3268
|
const variablesCount = {
|
|
3259
3269
|
...(isNil(orderBy)
|
|
3260
3270
|
? {}
|
|
@@ -3265,15 +3275,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3265
3275
|
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3266
3276
|
},
|
|
3267
3277
|
}),
|
|
3268
|
-
...
|
|
3269
|
-
? {}
|
|
3270
|
-
: {
|
|
3271
|
-
where: {
|
|
3272
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
3273
|
-
type: `${this.tableName}_bool_exp`,
|
|
3274
|
-
required: true,
|
|
3275
|
-
},
|
|
3276
|
-
}),
|
|
3278
|
+
...variablesFilters,
|
|
3277
3279
|
};
|
|
3278
3280
|
const variables = {
|
|
3279
3281
|
...(isNil(limits) ? {} : limits),
|
|
@@ -3307,6 +3309,29 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3307
3309
|
},
|
|
3308
3310
|
]
|
|
3309
3311
|
: []),
|
|
3312
|
+
...((!params.limits?.offset &&
|
|
3313
|
+
params.options?.distinct?.map((distinct) => {
|
|
3314
|
+
const distinctOption = this.fields.find((fieldOption) => fieldOption === distinct) ??
|
|
3315
|
+
this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3316
|
+
const fieldName = Object.values(distinctOption).shift()?.columnName || distinct;
|
|
3317
|
+
return {
|
|
3318
|
+
operation: {
|
|
3319
|
+
name: `${this.tableName}`,
|
|
3320
|
+
alias: `${this.tableName}_${distinct.toString()}_distinct`,
|
|
3321
|
+
},
|
|
3322
|
+
fields: [distinctOption],
|
|
3323
|
+
variables: {
|
|
3324
|
+
...variablesFilters,
|
|
3325
|
+
[`${this.tableName}_${fieldName}_distinct`]: {
|
|
3326
|
+
type: `${this.tableName}_select_column!`,
|
|
3327
|
+
list: true,
|
|
3328
|
+
value: fieldName,
|
|
3329
|
+
name: 'distinct_on',
|
|
3330
|
+
},
|
|
3331
|
+
},
|
|
3332
|
+
};
|
|
3333
|
+
})) ||
|
|
3334
|
+
[]),
|
|
3310
3335
|
]);
|
|
3311
3336
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
3312
3337
|
return {
|
|
@@ -3328,6 +3353,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3328
3353
|
}), {}),
|
|
3329
3354
|
}
|
|
3330
3355
|
: {}),
|
|
3356
|
+
...(!params.limits?.offset &&
|
|
3357
|
+
options?.distinct?.length && {
|
|
3358
|
+
distinct: options?.distinct.reduce((distinct, current) => {
|
|
3359
|
+
const distinctOption = this.fields.find((fieldOption) => fieldOption === current) ??
|
|
3360
|
+
this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
3361
|
+
const fieldName = Object.values(distinctOption).shift()?.columnName || current;
|
|
3362
|
+
return {
|
|
3363
|
+
...distinct,
|
|
3364
|
+
[current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]),
|
|
3365
|
+
};
|
|
3366
|
+
}, {}),
|
|
3367
|
+
}),
|
|
3331
3368
|
};
|
|
3332
3369
|
}
|
|
3333
3370
|
};
|