@infrab4a/connect 5.4.0-beta.10 → 5.4.0-beta.12
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/index.cjs.js +36 -28
- package/index.esm.js +38 -22
- package/package.json +3 -3
- package/src/domain/shopping/models/order.d.ts +6 -0
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +7 -0
- package/src/utils/index.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -1815,7 +1815,7 @@ class AntifraudCardService {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
getTodayDateRange() {
|
|
1817
1817
|
const timeZone = 'America/Sao_Paulo';
|
|
1818
|
-
const today = dateFnsTz.
|
|
1818
|
+
const today = dateFnsTz.utcToZonedTime(new Date(), timeZone);
|
|
1819
1819
|
const day = dateFns.startOfDay(today);
|
|
1820
1820
|
const endOfDay = dateFns.endOfDay(today);
|
|
1821
1821
|
return { day: dateFns.addHours(day, 3), endOfDay: dateFns.addHours(endOfDay, 3) };
|
|
@@ -7892,22 +7892,6 @@ const fieldsConfiguration$2 = [
|
|
|
7892
7892
|
subscriberPrice: data.subscriber_price,
|
|
7893
7893
|
fullPriceDiscountPercentage: data.full_price_discount_percentage,
|
|
7894
7894
|
}),
|
|
7895
|
-
bindFindFilter: (sentence) => {
|
|
7896
|
-
const filters = Object.values(sentence).shift();
|
|
7897
|
-
return {
|
|
7898
|
-
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7899
|
-
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7900
|
-
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7901
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7902
|
-
}),
|
|
7903
|
-
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7904
|
-
subscriber_price: filters.subscriberPrice,
|
|
7905
|
-
}),
|
|
7906
|
-
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7907
|
-
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7908
|
-
}),
|
|
7909
|
-
};
|
|
7910
|
-
},
|
|
7911
7895
|
bindPersistData: (priceData) => ({
|
|
7912
7896
|
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
7913
7897
|
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
@@ -7921,6 +7905,10 @@ const fieldsConfiguration$2 = [
|
|
|
7921
7905
|
}),
|
|
7922
7906
|
},
|
|
7923
7907
|
},
|
|
7908
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
7909
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7910
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7911
|
+
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7924
7912
|
'published',
|
|
7925
7913
|
{
|
|
7926
7914
|
stock: {
|
|
@@ -7972,6 +7960,16 @@ const fieldsConfiguration$2 = [
|
|
|
7972
7960
|
],
|
|
7973
7961
|
},
|
|
7974
7962
|
},
|
|
7963
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7964
|
+
{
|
|
7965
|
+
metadata: {
|
|
7966
|
+
columnName: 'metadata',
|
|
7967
|
+
fields: ['title', 'description'],
|
|
7968
|
+
bindPersistData: (value) => ({
|
|
7969
|
+
metadata: { data: value },
|
|
7970
|
+
}),
|
|
7971
|
+
},
|
|
7972
|
+
},
|
|
7975
7973
|
],
|
|
7976
7974
|
},
|
|
7977
7975
|
},
|
|
@@ -8059,7 +8057,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8059
8057
|
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
8060
8058
|
return super.find({
|
|
8061
8059
|
...options,
|
|
8062
|
-
filters: { ...filters },
|
|
8060
|
+
filters: { ...filters, productId: { operator: exports.Where.ISNULL } },
|
|
8063
8061
|
fields: [
|
|
8064
8062
|
...bindFields,
|
|
8065
8063
|
...(bindFields.includes('price')
|
|
@@ -8280,7 +8278,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8280
8278
|
const plainData = this.paramsToPlain({ metadata });
|
|
8281
8279
|
if (!plainData.metadata)
|
|
8282
8280
|
return null;
|
|
8283
|
-
|
|
8281
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8282
|
+
const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8284
8283
|
pk_columns: {
|
|
8285
8284
|
value: { product_id: productId },
|
|
8286
8285
|
type: 'product_metadata_pk_columns_input',
|
|
@@ -8292,6 +8291,14 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8292
8291
|
required: true,
|
|
8293
8292
|
},
|
|
8294
8293
|
});
|
|
8294
|
+
if (!update_product_metadata_by_pk) {
|
|
8295
|
+
await this.mutation('insert_product_metadata', ['affected_rows'], {
|
|
8296
|
+
objects: {
|
|
8297
|
+
type: '[product_metadata_insert_input!]!',
|
|
8298
|
+
value: [{ product_id: productId, ...metadata }],
|
|
8299
|
+
},
|
|
8300
|
+
});
|
|
8301
|
+
}
|
|
8295
8302
|
return plainData.metadata;
|
|
8296
8303
|
}
|
|
8297
8304
|
async getId(id) {
|
|
@@ -8841,7 +8848,8 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8841
8848
|
const plainData = this.paramsToPlain({ metadata });
|
|
8842
8849
|
if (!plainData.metadata)
|
|
8843
8850
|
return null;
|
|
8844
|
-
|
|
8851
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8852
|
+
const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8845
8853
|
pk_columns: {
|
|
8846
8854
|
value: { product_id: productId },
|
|
8847
8855
|
type: 'product_metadata_pk_columns_input',
|
|
@@ -8853,6 +8861,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8853
8861
|
required: true,
|
|
8854
8862
|
},
|
|
8855
8863
|
});
|
|
8864
|
+
if (!update_product_metadata_by_pk) {
|
|
8865
|
+
await this.mutation('insert_product_metadata', ['affected_rows'], {
|
|
8866
|
+
objects: {
|
|
8867
|
+
type: '[product_metadata_insert_input!]!',
|
|
8868
|
+
value: [{ product_id: productId, ...metadata }],
|
|
8869
|
+
},
|
|
8870
|
+
});
|
|
8871
|
+
}
|
|
8856
8872
|
return plainData.metadata;
|
|
8857
8873
|
}
|
|
8858
8874
|
async getId(id) {
|
|
@@ -10234,14 +10250,6 @@ Object.defineProperty(exports, 'formatInTimeZone', {
|
|
|
10234
10250
|
enumerable: true,
|
|
10235
10251
|
get: function () { return dateFnsTz.formatInTimeZone; }
|
|
10236
10252
|
});
|
|
10237
|
-
Object.defineProperty(exports, 'fromZonedTime', {
|
|
10238
|
-
enumerable: true,
|
|
10239
|
-
get: function () { return dateFnsTz.fromZonedTime; }
|
|
10240
|
-
});
|
|
10241
|
-
Object.defineProperty(exports, 'toZonedTime', {
|
|
10242
|
-
enumerable: true,
|
|
10243
|
-
get: function () { return dateFnsTz.toZonedTime; }
|
|
10244
|
-
});
|
|
10245
10253
|
Object.defineProperty(exports, 'chunk', {
|
|
10246
10254
|
enumerable: true,
|
|
10247
10255
|
get: function () { return lodash.chunk; }
|
package/index.esm.js
CHANGED
|
@@ -3,8 +3,8 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
3
3
|
import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
|
|
4
4
|
import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
|
|
6
|
-
import {
|
|
7
|
-
export { formatInTimeZone
|
|
6
|
+
import { utcToZonedTime } from 'date-fns-tz';
|
|
7
|
+
export { formatInTimeZone } from 'date-fns-tz';
|
|
8
8
|
import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
|
|
9
9
|
export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
|
|
10
10
|
import { debug } from 'debug';
|
|
@@ -1791,7 +1791,7 @@ class AntifraudCardService {
|
|
|
1791
1791
|
}
|
|
1792
1792
|
getTodayDateRange() {
|
|
1793
1793
|
const timeZone = 'America/Sao_Paulo';
|
|
1794
|
-
const today =
|
|
1794
|
+
const today = utcToZonedTime(new Date(), timeZone);
|
|
1795
1795
|
const day = startOfDay(today);
|
|
1796
1796
|
const endOfDay$1 = endOfDay(today);
|
|
1797
1797
|
return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
|
|
@@ -7868,22 +7868,6 @@ const fieldsConfiguration$2 = [
|
|
|
7868
7868
|
subscriberPrice: data.subscriber_price,
|
|
7869
7869
|
fullPriceDiscountPercentage: data.full_price_discount_percentage,
|
|
7870
7870
|
}),
|
|
7871
|
-
bindFindFilter: (sentence) => {
|
|
7872
|
-
const filters = Object.values(sentence).shift();
|
|
7873
|
-
return {
|
|
7874
|
-
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7875
|
-
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7876
|
-
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7877
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7878
|
-
}),
|
|
7879
|
-
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7880
|
-
subscriber_price: filters.subscriberPrice,
|
|
7881
|
-
}),
|
|
7882
|
-
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7883
|
-
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7884
|
-
}),
|
|
7885
|
-
};
|
|
7886
|
-
},
|
|
7887
7871
|
bindPersistData: (priceData) => ({
|
|
7888
7872
|
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
7889
7873
|
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
@@ -7897,6 +7881,10 @@ const fieldsConfiguration$2 = [
|
|
|
7897
7881
|
}),
|
|
7898
7882
|
},
|
|
7899
7883
|
},
|
|
7884
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
7885
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7886
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7887
|
+
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7900
7888
|
'published',
|
|
7901
7889
|
{
|
|
7902
7890
|
stock: {
|
|
@@ -7948,6 +7936,16 @@ const fieldsConfiguration$2 = [
|
|
|
7948
7936
|
],
|
|
7949
7937
|
},
|
|
7950
7938
|
},
|
|
7939
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7940
|
+
{
|
|
7941
|
+
metadata: {
|
|
7942
|
+
columnName: 'metadata',
|
|
7943
|
+
fields: ['title', 'description'],
|
|
7944
|
+
bindPersistData: (value) => ({
|
|
7945
|
+
metadata: { data: value },
|
|
7946
|
+
}),
|
|
7947
|
+
},
|
|
7948
|
+
},
|
|
7951
7949
|
],
|
|
7952
7950
|
},
|
|
7953
7951
|
},
|
|
@@ -8035,7 +8033,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8035
8033
|
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
8036
8034
|
return super.find({
|
|
8037
8035
|
...options,
|
|
8038
|
-
filters: { ...filters },
|
|
8036
|
+
filters: { ...filters, productId: { operator: Where.ISNULL } },
|
|
8039
8037
|
fields: [
|
|
8040
8038
|
...bindFields,
|
|
8041
8039
|
...(bindFields.includes('price')
|
|
@@ -8256,7 +8254,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8256
8254
|
const plainData = this.paramsToPlain({ metadata });
|
|
8257
8255
|
if (!plainData.metadata)
|
|
8258
8256
|
return null;
|
|
8259
|
-
|
|
8257
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8258
|
+
const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8260
8259
|
pk_columns: {
|
|
8261
8260
|
value: { product_id: productId },
|
|
8262
8261
|
type: 'product_metadata_pk_columns_input',
|
|
@@ -8268,6 +8267,14 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8268
8267
|
required: true,
|
|
8269
8268
|
},
|
|
8270
8269
|
});
|
|
8270
|
+
if (!update_product_metadata_by_pk) {
|
|
8271
|
+
await this.mutation('insert_product_metadata', ['affected_rows'], {
|
|
8272
|
+
objects: {
|
|
8273
|
+
type: '[product_metadata_insert_input!]!',
|
|
8274
|
+
value: [{ product_id: productId, ...metadata }],
|
|
8275
|
+
},
|
|
8276
|
+
});
|
|
8277
|
+
}
|
|
8271
8278
|
return plainData.metadata;
|
|
8272
8279
|
}
|
|
8273
8280
|
async getId(id) {
|
|
@@ -8817,7 +8824,8 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8817
8824
|
const plainData = this.paramsToPlain({ metadata });
|
|
8818
8825
|
if (!plainData.metadata)
|
|
8819
8826
|
return null;
|
|
8820
|
-
|
|
8827
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8828
|
+
const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8821
8829
|
pk_columns: {
|
|
8822
8830
|
value: { product_id: productId },
|
|
8823
8831
|
type: 'product_metadata_pk_columns_input',
|
|
@@ -8829,6 +8837,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8829
8837
|
required: true,
|
|
8830
8838
|
},
|
|
8831
8839
|
});
|
|
8840
|
+
if (!update_product_metadata_by_pk) {
|
|
8841
|
+
await this.mutation('insert_product_metadata', ['affected_rows'], {
|
|
8842
|
+
objects: {
|
|
8843
|
+
type: '[product_metadata_insert_input!]!',
|
|
8844
|
+
value: [{ product_id: productId, ...metadata }],
|
|
8845
|
+
},
|
|
8846
|
+
});
|
|
8847
|
+
}
|
|
8832
8848
|
return plainData.metadata;
|
|
8833
8849
|
}
|
|
8834
8850
|
async getId(id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infrab4a/connect",
|
|
3
|
-
"version": "5.4.0-beta.
|
|
3
|
+
"version": "5.4.0-beta.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^0.27.2",
|
|
13
13
|
"class-transformer": "^0.5.1",
|
|
14
|
-
"date-fns": "
|
|
15
|
-
"date-fns-tz": "
|
|
14
|
+
"date-fns": "2.28.0",
|
|
15
|
+
"date-fns-tz": "2.0.1",
|
|
16
16
|
"debug": "^4.3.4",
|
|
17
17
|
"firebase": "^9.22.0",
|
|
18
18
|
"gql-query-builder": "3.7.0",
|
|
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
|
|
|
5
5
|
export declare const withHelpers: <TMixinBase extends MixinCtor<any, any[]> = MixinCtor<any, any[]>>(MixinBase: MixinCtor<any, any[]> & TMixinBase) => {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
[x: string]: any;
|
|
8
|
-
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
|
|
8
|
+
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T, import("firebase/firestore").DocumentData> | QueryDocumentSnapshot<T, import("firebase/firestore").DocumentData>[]): T[];
|
|
9
9
|
isSubCollection<T_1 extends ModelBaseStructure<T_1, T_1["identifiersFields"][number]>, E extends ModelBaseStructure<E, E["identifiersFields"][number]>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
|
|
10
10
|
};
|
|
11
11
|
} & TMixinBase;
|
|
@@ -5,4 +5,11 @@ export declare class VariantHasuraGraphQL extends Variant {
|
|
|
5
5
|
subscriberDiscountPercentage?: number;
|
|
6
6
|
subscriberPrice?: number;
|
|
7
7
|
hasStock?: boolean;
|
|
8
|
+
differentials?: string;
|
|
9
|
+
whoMustUse?: string;
|
|
10
|
+
howToUse?: string;
|
|
11
|
+
brandDescription?: string;
|
|
12
|
+
categoryId?: number;
|
|
13
|
+
ingredients?: string;
|
|
14
|
+
intGender?: number;
|
|
8
15
|
}
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { add, addBusinessDays, addDays, addMonths, addYears, Duration, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
|
|
2
|
-
import { formatInTimeZone
|
|
2
|
+
import { formatInTimeZone } from 'date-fns-tz';
|
|
3
3
|
import { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
|
|
4
4
|
export type DateDuration = Duration;
|
|
5
5
|
export * from './circular-dependencies';
|
|
@@ -14,4 +14,4 @@ export * from './obs-emitter';
|
|
|
14
14
|
export * from './parse-datetime';
|
|
15
15
|
export * from './serialize';
|
|
16
16
|
export * from './types';
|
|
17
|
-
export { add, addBusinessDays, addDays, addMonths, addYears,
|
|
17
|
+
export { add, addBusinessDays, addDays, addMonths, addYears, formatInTimeZone, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };
|