@maioradv/cms-basic-lib 1.7.4 → 1.7.6

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.
@@ -1,5 +1,5 @@
1
1
  import { Collection } from "../collections/types";
2
- import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
+ import { BooleanClause, ObjectClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
3
3
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
4
4
  import { QueryParamsDto } from "../core/utils/queryParams";
5
5
  import { Product } from "../products/types";
@@ -80,5 +80,7 @@ export type ClausesBundleDto = WhereClausesDto<{
80
80
  collectionId?: NumberClause;
81
81
  published?: BooleanClause;
82
82
  noCollections?: BooleanClause;
83
+ metafields?: ObjectClause<Partial<Metafield>>;
84
+ translations?: ObjectClause<Partial<Translation>>;
83
85
  }>;
84
86
  export type QueryBundleDto = QueryParamsDto<SortingBundleDto, ClausesBundleDto>;
@@ -1,5 +1,5 @@
1
1
  import { Bundle, BundleCollection, BundleProduct, BundleVariant } from "../bundles/types";
2
- import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
+ import { BooleanClause, ObjectClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
3
3
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
4
4
  import { QueryParamsDto } from "../core/utils/queryParams";
5
5
  import { CreateImageDto, Image } from "../images/types";
@@ -48,6 +48,8 @@ export type ClausesCollectionDto = WhereClausesDto<{
48
48
  hasParent?: BooleanClause;
49
49
  hasImages?: BooleanClause;
50
50
  allowChildren?: BooleanClause;
51
+ metafields?: ObjectClause<Partial<Metafield>>;
52
+ translations?: ObjectClause<Partial<Translation>>;
51
53
  }>;
52
54
  export type QueryCollectionDto = QueryParamsDto<SortingCollectionDto, ClausesCollectionDto>;
53
55
  export type FindOneCollectionDto = WithRelations<Collection, {
@@ -3,7 +3,8 @@ export type StringClause = string | undefined;
3
3
  export type DateClause = string | Date | undefined;
4
4
  export type BooleanClause = boolean | undefined;
5
5
  export type EnumClause<T> = T | T[] | undefined;
6
- export type ClausesDto = Record<string, NumberClause | StringClause | DateClause | BooleanClause | EnumClause<unknown>>;
6
+ export type ObjectClause<T> = T | T[] | undefined;
7
+ export type ClausesDto = Record<string, NumberClause | StringClause | DateClause | BooleanClause | EnumClause<unknown> | ObjectClause<unknown>>;
7
8
  export type DefaultClausesDto = {
8
9
  id?: NumberClause;
9
10
  createdAt?: DateClause;
@@ -14,4 +15,6 @@ export type DefaultClausesDto = {
14
15
  maxUpdatedAt?: DateClause;
15
16
  };
16
17
  export declare function where(args: ClausesDto): Record<string, any>;
18
+ export declare function MetafieldStringify(object: Record<string, string>): string;
19
+ export declare function TranslationStringify(object: Record<string, string>): string;
17
20
  export type WhereClausesDto<T extends ClausesDto> = T & DefaultClausesDto;
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.where = where;
4
+ exports.MetafieldStringify = MetafieldStringify;
5
+ exports.TranslationStringify = TranslationStringify;
4
6
  function where(args) {
5
7
  const res = {};
6
8
  Object.keys(args).forEach(function (key) {
7
- res[key] = args[key] instanceof Array ? args[key].join() : args[key];
9
+ if (key === 'metafields') {
10
+ res[key] = args[key] instanceof Array ? args[key].map(MetafieldStringify).join() : MetafieldStringify(args[key]);
11
+ }
12
+ else if (key === 'translations') {
13
+ res[key] = args[key] instanceof Array ? args[key].map(TranslationStringify).join() : TranslationStringify(args[key]);
14
+ }
15
+ else {
16
+ res[key] = args[key] instanceof Array ? args[key].join() : args[key];
17
+ }
8
18
  });
19
+ console.log(res);
9
20
  return res;
10
21
  }
22
+ function MetafieldStringify(object) {
23
+ return `${object.key || ''}:${object.value || ''}`;
24
+ }
25
+ function TranslationStringify(object) {
26
+ return `${object.key || ''}:${object.locale || ''}:${object.value || ''}`;
27
+ }
@@ -4,6 +4,7 @@ import { CreateLinkCollectionDto, CreateLinkDto, FindOneLinkCollectionDto, Link,
4
4
  export default class LinkCollections extends ApiModule implements RestApiModuleI {
5
5
  create(args: CreateLinkCollectionDto): Promise<LinkCollection>;
6
6
  findAll(args?: QueryLinkCollectionDto): Promise<PaginatedDto<LinkCollection>>;
7
+ count(id: number): Promise<number>;
7
8
  findOne(id: number): Promise<FindOneLinkCollectionDto>;
8
9
  update(id: number, data: UpdateLinkCollectionDto): Promise<LinkCollection>;
9
10
  remove(id: number): Promise<LinkCollection>;
@@ -9,6 +9,9 @@ class LinkCollections extends model_1.ApiModule {
9
9
  findAll(args = {}) {
10
10
  return this._call('get', '/link-collections', (0, queryParams_1.queryParams)(args));
11
11
  }
12
+ count(id) {
13
+ return this._call('get', `/link-collections/${id}/count`);
14
+ }
12
15
  findOne(id) {
13
16
  return this._call('get', `/link-collections/${id}`);
14
17
  }
@@ -1,4 +1,4 @@
1
- import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
1
+ import { BooleanClause, ObjectClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
2
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
3
3
  import { QueryParamsDto } from "../core/utils/queryParams";
4
4
  import { CreateImageDto, Image } from "../images/types";
@@ -56,11 +56,15 @@ export type SortingLinkDto = SortingParamsDto<{
56
56
  export type ClausesLinkCollectionDto = WhereClausesDto<{
57
57
  search?: StringClause;
58
58
  published?: BooleanClause;
59
+ metafields?: ObjectClause<Partial<Metafield>>;
60
+ translations?: ObjectClause<Partial<Translation>>;
59
61
  }>;
60
62
  export type ClausesLinkDto = WhereClausesDto<{
61
63
  search?: StringClause;
62
64
  linkCollectionId?: NumberClause;
63
65
  published?: BooleanClause;
66
+ metafields?: ObjectClause<Partial<Metafield>>;
67
+ translations?: ObjectClause<Partial<Translation>>;
64
68
  }>;
65
69
  export type QueryLinkCollectionDto = QueryParamsDto<SortingLinkCollectionDto, ClausesLinkCollectionDto>;
66
70
  export type QueryLinkDto = QueryParamsDto<SortingLinkDto, ClausesLinkDto>;
@@ -1,4 +1,4 @@
1
- import { BooleanClause, EnumClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
1
+ import { BooleanClause, EnumClause, ObjectClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
2
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
3
3
  import { QueryParamsDto } from "../core/utils/queryParams";
4
4
  import { CreateImageDto, Image } from "../images/types";
@@ -69,5 +69,7 @@ export type ClausesPopupDto = WhereClausesDto<{
69
69
  name?: StringClause;
70
70
  published?: BooleanClause;
71
71
  target?: EnumClause<PopupTarget>;
72
+ metafields?: ObjectClause<Partial<Metafield>>;
73
+ translations?: ObjectClause<Partial<Translation>>;
72
74
  }>;
73
75
  export type QueryPopupDto = QueryParamsDto<SortingPopupDto, ClausesPopupDto>;
@@ -1,4 +1,4 @@
1
- import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
1
+ import { BooleanClause, ObjectClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
2
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
3
3
  import { QueryParamsDto } from "../core/utils/queryParams";
4
4
  import { Metafield, OmitRequire, Translation } from "../types";
@@ -35,7 +35,7 @@ export type SortingProductAttributeDto = SortingParamsDto<{
35
35
  export type ClausesProductAttributeDto = WhereClausesDto<{
36
36
  name?: StringClause;
37
37
  published?: BooleanClause;
38
- slug?: StringClause[];
38
+ slug?: StringClause | StringClause[];
39
39
  }>;
40
40
  export type QueryProductAttributeDto = QueryParamsDto<SortingProductAttributeDto, ClausesProductAttributeDto>;
41
41
  export type SortingProductAttributeValueDto = SortingParamsDto<{
@@ -46,10 +46,12 @@ export type ClausesProductAttributeValueDto = WhereClausesDto<{
46
46
  search?: StringClause;
47
47
  name?: StringClause;
48
48
  published?: BooleanClause;
49
- attributeSlug?: StringClause[];
49
+ attributeSlug?: StringClause | StringClause[];
50
50
  productAttributeId?: NumberClause;
51
51
  collections?: NumberClause;
52
52
  bundles?: NumberClause;
53
53
  hasProducts?: BooleanClause;
54
+ metafields?: ObjectClause<Partial<Metafield>>;
55
+ translations?: ObjectClause<Partial<Translation>>;
54
56
  }>;
55
57
  export type QueryProductAttributeValueDto = QueryParamsDto<SortingProductAttributeValueDto, ClausesProductAttributeValueDto>;
@@ -1,5 +1,5 @@
1
1
  import { Collection } from "../collections/types";
2
- import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
+ import { BooleanClause, ObjectClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
3
3
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
4
4
  import { QueryParamsDto } from "../core/utils/queryParams";
5
5
  import { CreateImageDto, Image } from "../images/types";
@@ -115,5 +115,7 @@ export type ClausesProductDto = WhereClausesDto<{
115
115
  published?: BooleanClause;
116
116
  noCollections?: BooleanClause;
117
117
  hasImages?: BooleanClause;
118
+ metafields?: ObjectClause<Partial<Metafield>>;
119
+ translations?: ObjectClause<Partial<Translation>>;
118
120
  }>;
119
121
  export type QueryProductDto = QueryParamsDto<SortingProductDto, ClausesProductDto>;
@@ -1,4 +1,4 @@
1
- import { DateClause, EnumClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
1
+ import { DateClause, EnumClause, NumberClause, ObjectClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
2
2
  import { Sorting, SortingParamsDto } from "../core/dto/sorting";
3
3
  import { QueryParamsDto } from "../core/utils/queryParams";
4
4
  import { Metafield, OmitRequire } from "../types";
@@ -51,8 +51,9 @@ export type ClausesReservationDto = WhereClausesDto<{
51
51
  date?: DateClause;
52
52
  minDate?: DateClause;
53
53
  maxDate?: DateClause;
54
- source?: EnumClause<ReservationSource>[];
55
- status?: EnumClause<ReservationStatus>[];
56
- guestCount?: NumberClause[];
54
+ source?: EnumClause<ReservationSource>;
55
+ status?: EnumClause<ReservationStatus>;
56
+ guestCount?: NumberClause;
57
+ metafields?: ObjectClause<Partial<Metafield>>;
57
58
  }>;
58
59
  export type QueryReservationDto = QueryParamsDto<SortingReservationDto, ClausesReservationDto>;
@@ -21,6 +21,6 @@ export type SortingSettingDto = SortingParamsDto<{
21
21
  export type ClausesSettingDto = WhereClausesDto<{
22
22
  name?: StringClause;
23
23
  description?: StringClause;
24
- namespace?: StringClause[];
24
+ namespace?: StringClause | StringClause[];
25
25
  }>;
26
26
  export type QuerySettingDto = QueryParamsDto<SortingSettingDto, ClausesSettingDto>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maioradv/cms-basic-lib",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "JS lib for Maior CMS Basic Api",
5
5
  "repository": "https://github.com/maioradv/cms-basic-lib.git",
6
6
  "author": "Maior ADV Srl",