@empathyco/x-adapter-platform 1.0.0-alpha.37 → 1.0.0-alpha.39

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 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/facets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FacetModelName, Facet } from '@empathyco/x-types';\nimport { Schema } from '@empathyco/x-adapter';\n\n/**\n * Facet configuration containing the model name and the schema.\n */\nexport interface FacetConfig {\n modelName: FacetModelName;\n schema: Schema;\n}\n\n/**\n * Dictionary grouping facets configurations.\n */\nexport interface FacetsConfig {\n [key: Facet['id']]: FacetConfig;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/facets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Schema } from '@empathyco/x-adapter';\nimport { FacetModelName } from '@empathyco/x-types';\n\n/**\n * Facet configuration containing the model name and the schema.\n */\nexport interface FacetConfig {\n modelName: FacetModelName;\n schema: Schema;\n}\n"]}
@@ -1,16 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFacetConfig = void 0;
4
- const facet_schema_1 = require("../models/facet.schema");
4
+ const hierarchical_filter_schema_1 = require("../models/filters/hierarchical-filter.schema");
5
+ const number_filter_schema_1 = require("../models/filters/number-filter.schema");
6
+ const simple_filter_schema_1 = require("../models/filters/simple-filter.schema");
5
7
  /**
6
8
  * Returns the facet's config.
7
9
  *
8
- * @param facet - The facet to resolve the configuration.
10
+ * @param type - The facet type to resolve the configuration.
9
11
  * @returns The facet's config.
10
12
  */
11
- function getFacetConfig(facet) {
13
+ function getFacetConfig(type) {
12
14
  var _a;
13
- return (_a = facet_schema_1.facetsConfig[facet]) !== null && _a !== void 0 ? _a : facet_schema_1.facetsConfig.default;
15
+ const typeConfigs = {
16
+ value: {
17
+ modelName: 'SimpleFacet',
18
+ schema: simple_filter_schema_1.simpleFilterSchema
19
+ },
20
+ hierarchical: {
21
+ modelName: 'HierarchicalFacet',
22
+ schema: hierarchical_filter_schema_1.hierarchicalFilterSchema
23
+ },
24
+ range: {
25
+ modelName: 'NumberRangeFacet',
26
+ schema: number_filter_schema_1.numberFilterSchema
27
+ }
28
+ };
29
+ return (_a = typeConfigs[type]) !== null && _a !== void 0 ? _a : typeConfigs.value;
14
30
  }
15
31
  exports.getFacetConfig = getFacetConfig;
16
32
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/schemas/facets/utils.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAGtD;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAAa;;IAC1C,OAAO,MAAA,2BAAY,CAAC,KAAK,CAAC,mCAAI,2BAAY,CAAC,OAAO,CAAC;AACrD,CAAC;AAFD,wCAEC","sourcesContent":["import { facetsConfig } from '../models/facet.schema';\nimport { FacetConfig } from './types';\n\n/**\n * Returns the facet's config.\n *\n * @param facet - The facet to resolve the configuration.\n * @returns The facet's config.\n */\nexport function getFacetConfig(facet: string): FacetConfig {\n return facetsConfig[facet] ?? facetsConfig.default;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/schemas/facets/utils.ts"],"names":[],"mappings":";;;AACA,6FAAwF;AACxF,iFAA4E;AAC5E,iFAA4E;AAG5E;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,IAAuB;;IACpD,MAAM,WAAW,GAA2C;QAC1D,KAAK,EAAE;YACL,SAAS,EAAE,aAAa;YACxB,MAAM,EAAE,yCAAkB;SAC3B;QACD,YAAY,EAAE;YACZ,SAAS,EAAE,mBAAmB;YAC9B,MAAM,EAAE,qDAAwB;SACjC;QACD,KAAK,EAAE;YACL,SAAS,EAAE,kBAAkB;YAC7B,MAAM,EAAE,yCAAkB;SAC3B;KACF,CAAC;IACF,OAAO,MAAA,WAAW,CAAC,IAAI,CAAC,mCAAI,WAAW,CAAC,KAAK,CAAC;AAChD,CAAC;AAhBD,wCAgBC","sourcesContent":["import { PlatformFacetType } from '../../types/models/facet.model';\nimport { hierarchicalFilterSchema } from '../models/filters/hierarchical-filter.schema';\nimport { numberFilterSchema } from '../models/filters/number-filter.schema';\nimport { simpleFilterSchema } from '../models/filters/simple-filter.schema';\nimport { FacetConfig } from './types';\n\n/**\n * Returns the facet's config.\n *\n * @param type - The facet type to resolve the configuration.\n * @returns The facet's config.\n */\nexport function getFacetConfig(type: PlatformFacetType): FacetConfig {\n const typeConfigs: Record<PlatformFacetType, FacetConfig> = {\n value: {\n modelName: 'SimpleFacet',\n schema: simpleFilterSchema\n },\n hierarchical: {\n modelName: 'HierarchicalFacet',\n schema: hierarchicalFilterSchema\n },\n range: {\n modelName: 'NumberRangeFacet',\n schema: numberFilterSchema\n }\n };\n return typeConfigs[type] ?? typeConfigs.value;\n}\n"]}
@@ -1,37 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.facetsConfig = exports.facetSchema = void 0;
3
+ exports.facetSchema = void 0;
4
4
  const x_adapter_1 = require("@empathyco/x-adapter");
5
5
  const utils_1 = require("../facets/utils");
6
- const hierarchical_filter_schema_1 = require("./filters/hierarchical-filter.schema");
7
- const number_filter_schema_1 = require("./filters/number-filter.schema");
8
- const simple_filter_schema_1 = require("./filters/simple-filter.schema");
9
6
  exports.facetSchema = (0, x_adapter_1.createMutableSchema)({
10
7
  id: 'facet',
11
8
  label: 'facet',
12
- modelName: source => {
13
- return (0, utils_1.getFacetConfig)(source.facet).modelName;
14
- },
9
+ modelName: ({ type }) => (0, utils_1.getFacetConfig)(type).modelName,
15
10
  filters: {
16
11
  $path: 'values',
17
- $subSchema: ({ facet }) => (0, utils_1.getFacetConfig)(facet).schema,
12
+ $subSchema: ({ type }) => (0, utils_1.getFacetConfig)(type).schema,
18
13
  $context: {
19
14
  facetId: 'facet'
20
15
  }
21
16
  }
22
17
  });
23
- exports.facetsConfig = {
24
- categoryPaths: {
25
- modelName: 'HierarchicalFacet',
26
- schema: hierarchical_filter_schema_1.hierarchicalFilterSchema
27
- },
28
- price: {
29
- modelName: 'NumberRangeFacet',
30
- schema: number_filter_schema_1.numberFilterSchema
31
- },
32
- default: {
33
- modelName: 'SimpleFacet',
34
- schema: simple_filter_schema_1.simpleFilterSchema
35
- }
36
- };
37
18
  //# sourceMappingURL=facet.schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"facet.schema.js","sourceRoot":"","sources":["../../../../src/schemas/models/facet.schema.ts"],"names":[],"mappings":";;;AAAA,oDAAmE;AAQnE,2CAAiD;AAEjD,qFAAgF;AAChF,yEAAoE;AACpE,yEAAoE;AAEvD,QAAA,WAAW,GAAG,IAAA,+BAAmB,EAK5C;IACA,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,MAAM,CAAC,EAAE;QAClB,OAAO,IAAA,sBAAc,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAgB,CAAC;IACvD,CAAC;IACD,OAAO,EAAE;QACP,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,MAAa;QAC9D,QAAQ,EAAE;YACR,OAAO,EAAE,OAAO;SACjB;KACF;CACF,CAAC,CAAC;AAEU,QAAA,YAAY,GAAiB;IACxC,aAAa,EAAE;QACb,SAAS,EAAE,mBAAmB;QAC9B,MAAM,EAAE,qDAAwB;KACjC;IACD,KAAK,EAAE;QACL,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,yCAAkB;KAC3B;IACD,OAAO,EAAE;QACP,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,yCAAkB;KAC3B;CACF,CAAC","sourcesContent":["import { createMutableSchema, Schema } from '@empathyco/x-adapter';\nimport {\n EditableNumberRangeFacet,\n HierarchicalFacet,\n NumberRangeFacet,\n SimpleFacet\n} from '@empathyco/x-types';\nimport { PlatformFacet } from '../../types/models/facet.model';\nimport { getFacetConfig } from '../facets/utils';\nimport { FacetsConfig } from '../facets/types';\nimport { hierarchicalFilterSchema } from './filters/hierarchical-filter.schema';\nimport { numberFilterSchema } from './filters/number-filter.schema';\nimport { simpleFilterSchema } from './filters/simple-filter.schema';\n\nexport const facetSchema = createMutableSchema<\n Schema<\n PlatformFacet,\n HierarchicalFacet | NumberRangeFacet | SimpleFacet | EditableNumberRangeFacet\n >\n>({\n id: 'facet',\n label: 'facet',\n modelName: source => {\n return getFacetConfig(source.facet).modelName as any;\n },\n filters: {\n $path: 'values',\n $subSchema: ({ facet }) => getFacetConfig(facet).schema as any,\n $context: {\n facetId: 'facet'\n }\n }\n});\n\nexport const facetsConfig: FacetsConfig = {\n categoryPaths: {\n modelName: 'HierarchicalFacet',\n schema: hierarchicalFilterSchema\n },\n price: {\n modelName: 'NumberRangeFacet',\n schema: numberFilterSchema\n },\n default: {\n modelName: 'SimpleFacet',\n schema: simpleFilterSchema\n }\n};\n"]}
1
+ {"version":3,"file":"facet.schema.js","sourceRoot":"","sources":["../../../../src/schemas/models/facet.schema.ts"],"names":[],"mappings":";;;AAAA,oDAAmE;AAQnE,2CAAiD;AAEpC,QAAA,WAAW,GAAG,IAAA,+BAAmB,EAK5C;IACA,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC,SAAgB;IAC9D,OAAO,EAAE;QACP,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC,MAAM;QACrD,QAAQ,EAAE;YACR,OAAO,EAAE,OAAO;SACjB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { createMutableSchema, Schema } from '@empathyco/x-adapter';\nimport {\n EditableNumberRangeFacet,\n HierarchicalFacet,\n NumberRangeFacet,\n SimpleFacet\n} from '@empathyco/x-types';\nimport { PlatformFacet } from '../../types/models/facet.model';\nimport { getFacetConfig } from '../facets/utils';\n\nexport const facetSchema = createMutableSchema<\n Schema<\n PlatformFacet,\n HierarchicalFacet | NumberRangeFacet | SimpleFacet | EditableNumberRangeFacet\n >\n>({\n id: 'facet',\n label: 'facet',\n modelName: ({ type }) => getFacetConfig(type).modelName as any,\n filters: {\n $path: 'values',\n $subSchema: ({ type }) => getFacetConfig(type).schema,\n $context: {\n facetId: 'facet'\n }\n }\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"facet.model.js","sourceRoot":"","sources":["../../../../src/types/models/facet.model.ts"],"names":[],"mappings":"","sourcesContent":["import { BooleanFilter, Facet, Filter } from '@empathyco/x-types';\n\n/**\n * Facet model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFacet {\n facet: string;\n values: PlatformFilter[];\n}\n\n/**\n * Filter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFilter {\n count: number;\n filter: string;\n id: string;\n value: string;\n}\n\n/**\n * HierarchicalFilter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformHierarchicalFilter extends PlatformFilter {\n children: PlatformFacet;\n}\n\n/**\n * Hierarchical Facet model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFacet extends Facet {\n /** Model name to indicate the facet type. */\n modelName: 'HierarchicalFacet';\n /** Filters available for the facet. */\n filters: AdapterHierarchicalFilter[];\n}\n\n/**\n * Hierarchical Filter model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFilter extends BooleanFilter {\n /** Model name to indicate the filter type. */\n modelName: 'HierarchicalFilter';\n /** A unique id used to reference the parent filter or null if it hasn't. */\n parentId: Filter['id'] | null;\n /** Descendants filters. */\n children?: AdapterHierarchicalFilter[];\n}\n"]}
1
+ {"version":3,"file":"facet.model.js","sourceRoot":"","sources":["../../../../src/types/models/facet.model.ts"],"names":[],"mappings":"","sourcesContent":["import { BooleanFilter, Facet, Filter } from '@empathyco/x-types';\n\n/**\n * Facet model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFacet {\n facet: string;\n type: PlatformFacetType;\n values: PlatformFilter[];\n}\n\n/**\n * Facet type for the `platform` API. It can be: value, hierarchical or range.\n *\n * @public\n */\nexport type PlatformFacetType = 'value' | 'hierarchical' | 'range';\n\n/**\n * Filter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFilter {\n count: number;\n filter: string;\n id: string;\n value: string;\n}\n\n/**\n * HierarchicalFilter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformHierarchicalFilter extends PlatformFilter {\n children: PlatformFacet;\n}\n\n/**\n * Hierarchical Facet model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFacet extends Facet {\n /** Model name to indicate the facet type. */\n modelName: 'HierarchicalFacet';\n /** Filters available for the facet. */\n filters: AdapterHierarchicalFilter[];\n}\n\n/**\n * Hierarchical Filter model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFilter extends BooleanFilter {\n /** Model name to indicate the filter type. */\n modelName: 'HierarchicalFilter';\n /** A unique id used to reference the parent filter or null if it hasn't. */\n parentId: Filter['id'] | null;\n /** Descendants filters. */\n children?: AdapterHierarchicalFilter[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/facets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FacetModelName, Facet } from '@empathyco/x-types';\nimport { Schema } from '@empathyco/x-adapter';\n\n/**\n * Facet configuration containing the model name and the schema.\n */\nexport interface FacetConfig {\n modelName: FacetModelName;\n schema: Schema;\n}\n\n/**\n * Dictionary grouping facets configurations.\n */\nexport interface FacetsConfig {\n [key: Facet['id']]: FacetConfig;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/facets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Schema } from '@empathyco/x-adapter';\nimport { FacetModelName } from '@empathyco/x-types';\n\n/**\n * Facet configuration containing the model name and the schema.\n */\nexport interface FacetConfig {\n modelName: FacetModelName;\n schema: Schema;\n}\n"]}
@@ -1,12 +1,28 @@
1
- import { facetsConfig } from '../models/facet.schema';
1
+ import { hierarchicalFilterSchema } from '../models/filters/hierarchical-filter.schema';
2
+ import { numberFilterSchema } from '../models/filters/number-filter.schema';
3
+ import { simpleFilterSchema } from '../models/filters/simple-filter.schema';
2
4
  /**
3
5
  * Returns the facet's config.
4
6
  *
5
- * @param facet - The facet to resolve the configuration.
7
+ * @param type - The facet type to resolve the configuration.
6
8
  * @returns The facet's config.
7
9
  */
8
- export function getFacetConfig(facet) {
10
+ export function getFacetConfig(type) {
9
11
  var _a;
10
- return (_a = facetsConfig[facet]) !== null && _a !== void 0 ? _a : facetsConfig.default;
12
+ const typeConfigs = {
13
+ value: {
14
+ modelName: 'SimpleFacet',
15
+ schema: simpleFilterSchema
16
+ },
17
+ hierarchical: {
18
+ modelName: 'HierarchicalFacet',
19
+ schema: hierarchicalFilterSchema
20
+ },
21
+ range: {
22
+ modelName: 'NumberRangeFacet',
23
+ schema: numberFilterSchema
24
+ }
25
+ };
26
+ return (_a = typeConfigs[type]) !== null && _a !== void 0 ? _a : typeConfigs.value;
11
27
  }
12
28
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/schemas/facets/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;;IAC1C,OAAO,MAAA,YAAY,CAAC,KAAK,CAAC,mCAAI,YAAY,CAAC,OAAO,CAAC;AACrD,CAAC","sourcesContent":["import { facetsConfig } from '../models/facet.schema';\nimport { FacetConfig } from './types';\n\n/**\n * Returns the facet's config.\n *\n * @param facet - The facet to resolve the configuration.\n * @returns The facet's config.\n */\nexport function getFacetConfig(facet: string): FacetConfig {\n return facetsConfig[facet] ?? facetsConfig.default;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/schemas/facets/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAuB;;IACpD,MAAM,WAAW,GAA2C;QAC1D,KAAK,EAAE;YACL,SAAS,EAAE,aAAa;YACxB,MAAM,EAAE,kBAAkB;SAC3B;QACD,YAAY,EAAE;YACZ,SAAS,EAAE,mBAAmB;YAC9B,MAAM,EAAE,wBAAwB;SACjC;QACD,KAAK,EAAE;YACL,SAAS,EAAE,kBAAkB;YAC7B,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC;IACF,OAAO,MAAA,WAAW,CAAC,IAAI,CAAC,mCAAI,WAAW,CAAC,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import { PlatformFacetType } from '../../types/models/facet.model';\nimport { hierarchicalFilterSchema } from '../models/filters/hierarchical-filter.schema';\nimport { numberFilterSchema } from '../models/filters/number-filter.schema';\nimport { simpleFilterSchema } from '../models/filters/simple-filter.schema';\nimport { FacetConfig } from './types';\n\n/**\n * Returns the facet's config.\n *\n * @param type - The facet type to resolve the configuration.\n * @returns The facet's config.\n */\nexport function getFacetConfig(type: PlatformFacetType): FacetConfig {\n const typeConfigs: Record<PlatformFacetType, FacetConfig> = {\n value: {\n modelName: 'SimpleFacet',\n schema: simpleFilterSchema\n },\n hierarchical: {\n modelName: 'HierarchicalFacet',\n schema: hierarchicalFilterSchema\n },\n range: {\n modelName: 'NumberRangeFacet',\n schema: numberFilterSchema\n }\n };\n return typeConfigs[type] ?? typeConfigs.value;\n}\n"]}
@@ -1,34 +1,15 @@
1
1
  import { createMutableSchema } from '@empathyco/x-adapter';
2
2
  import { getFacetConfig } from '../facets/utils';
3
- import { hierarchicalFilterSchema } from './filters/hierarchical-filter.schema';
4
- import { numberFilterSchema } from './filters/number-filter.schema';
5
- import { simpleFilterSchema } from './filters/simple-filter.schema';
6
3
  export const facetSchema = createMutableSchema({
7
4
  id: 'facet',
8
5
  label: 'facet',
9
- modelName: source => {
10
- return getFacetConfig(source.facet).modelName;
11
- },
6
+ modelName: ({ type }) => getFacetConfig(type).modelName,
12
7
  filters: {
13
8
  $path: 'values',
14
- $subSchema: ({ facet }) => getFacetConfig(facet).schema,
9
+ $subSchema: ({ type }) => getFacetConfig(type).schema,
15
10
  $context: {
16
11
  facetId: 'facet'
17
12
  }
18
13
  }
19
14
  });
20
- export const facetsConfig = {
21
- categoryPaths: {
22
- modelName: 'HierarchicalFacet',
23
- schema: hierarchicalFilterSchema
24
- },
25
- price: {
26
- modelName: 'NumberRangeFacet',
27
- schema: numberFilterSchema
28
- },
29
- default: {
30
- modelName: 'SimpleFacet',
31
- schema: simpleFilterSchema
32
- }
33
- };
34
15
  //# sourceMappingURL=facet.schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"facet.schema.js","sourceRoot":"","sources":["../../../../src/schemas/models/facet.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAU,MAAM,sBAAsB,CAAC;AAQnE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAK5C;IACA,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,MAAM,CAAC,EAAE;QAClB,OAAO,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAgB,CAAC;IACvD,CAAC;IACD,OAAO,EAAE;QACP,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAa;QAC9D,QAAQ,EAAE;YACR,OAAO,EAAE,OAAO;SACjB;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,aAAa,EAAE;QACb,SAAS,EAAE,mBAAmB;QAC9B,MAAM,EAAE,wBAAwB;KACjC;IACD,KAAK,EAAE;QACL,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,kBAAkB;KAC3B;IACD,OAAO,EAAE;QACP,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,kBAAkB;KAC3B;CACF,CAAC","sourcesContent":["import { createMutableSchema, Schema } from '@empathyco/x-adapter';\nimport {\n EditableNumberRangeFacet,\n HierarchicalFacet,\n NumberRangeFacet,\n SimpleFacet\n} from '@empathyco/x-types';\nimport { PlatformFacet } from '../../types/models/facet.model';\nimport { getFacetConfig } from '../facets/utils';\nimport { FacetsConfig } from '../facets/types';\nimport { hierarchicalFilterSchema } from './filters/hierarchical-filter.schema';\nimport { numberFilterSchema } from './filters/number-filter.schema';\nimport { simpleFilterSchema } from './filters/simple-filter.schema';\n\nexport const facetSchema = createMutableSchema<\n Schema<\n PlatformFacet,\n HierarchicalFacet | NumberRangeFacet | SimpleFacet | EditableNumberRangeFacet\n >\n>({\n id: 'facet',\n label: 'facet',\n modelName: source => {\n return getFacetConfig(source.facet).modelName as any;\n },\n filters: {\n $path: 'values',\n $subSchema: ({ facet }) => getFacetConfig(facet).schema as any,\n $context: {\n facetId: 'facet'\n }\n }\n});\n\nexport const facetsConfig: FacetsConfig = {\n categoryPaths: {\n modelName: 'HierarchicalFacet',\n schema: hierarchicalFilterSchema\n },\n price: {\n modelName: 'NumberRangeFacet',\n schema: numberFilterSchema\n },\n default: {\n modelName: 'SimpleFacet',\n schema: simpleFilterSchema\n }\n};\n"]}
1
+ {"version":3,"file":"facet.schema.js","sourceRoot":"","sources":["../../../../src/schemas/models/facet.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAU,MAAM,sBAAsB,CAAC;AAQnE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAK5C;IACA,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,SAAgB;IAC9D,OAAO,EAAE;QACP,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM;QACrD,QAAQ,EAAE;YACR,OAAO,EAAE,OAAO;SACjB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { createMutableSchema, Schema } from '@empathyco/x-adapter';\nimport {\n EditableNumberRangeFacet,\n HierarchicalFacet,\n NumberRangeFacet,\n SimpleFacet\n} from '@empathyco/x-types';\nimport { PlatformFacet } from '../../types/models/facet.model';\nimport { getFacetConfig } from '../facets/utils';\n\nexport const facetSchema = createMutableSchema<\n Schema<\n PlatformFacet,\n HierarchicalFacet | NumberRangeFacet | SimpleFacet | EditableNumberRangeFacet\n >\n>({\n id: 'facet',\n label: 'facet',\n modelName: ({ type }) => getFacetConfig(type).modelName as any,\n filters: {\n $path: 'values',\n $subSchema: ({ type }) => getFacetConfig(type).schema,\n $context: {\n facetId: 'facet'\n }\n }\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"facet.model.js","sourceRoot":"","sources":["../../../../src/types/models/facet.model.ts"],"names":[],"mappings":"","sourcesContent":["import { BooleanFilter, Facet, Filter } from '@empathyco/x-types';\n\n/**\n * Facet model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFacet {\n facet: string;\n values: PlatformFilter[];\n}\n\n/**\n * Filter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFilter {\n count: number;\n filter: string;\n id: string;\n value: string;\n}\n\n/**\n * HierarchicalFilter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformHierarchicalFilter extends PlatformFilter {\n children: PlatformFacet;\n}\n\n/**\n * Hierarchical Facet model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFacet extends Facet {\n /** Model name to indicate the facet type. */\n modelName: 'HierarchicalFacet';\n /** Filters available for the facet. */\n filters: AdapterHierarchicalFilter[];\n}\n\n/**\n * Hierarchical Filter model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFilter extends BooleanFilter {\n /** Model name to indicate the filter type. */\n modelName: 'HierarchicalFilter';\n /** A unique id used to reference the parent filter or null if it hasn't. */\n parentId: Filter['id'] | null;\n /** Descendants filters. */\n children?: AdapterHierarchicalFilter[];\n}\n"]}
1
+ {"version":3,"file":"facet.model.js","sourceRoot":"","sources":["../../../../src/types/models/facet.model.ts"],"names":[],"mappings":"","sourcesContent":["import { BooleanFilter, Facet, Filter } from '@empathyco/x-types';\n\n/**\n * Facet model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFacet {\n facet: string;\n type: PlatformFacetType;\n values: PlatformFilter[];\n}\n\n/**\n * Facet type for the `platform` API. It can be: value, hierarchical or range.\n *\n * @public\n */\nexport type PlatformFacetType = 'value' | 'hierarchical' | 'range';\n\n/**\n * Filter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformFilter {\n count: number;\n filter: string;\n id: string;\n value: string;\n}\n\n/**\n * HierarchicalFilter model for the `platform` API.\n *\n * @public\n */\nexport interface PlatformHierarchicalFilter extends PlatformFilter {\n children: PlatformFacet;\n}\n\n/**\n * Hierarchical Facet model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFacet extends Facet {\n /** Model name to indicate the facet type. */\n modelName: 'HierarchicalFacet';\n /** Filters available for the facet. */\n filters: AdapterHierarchicalFilter[];\n}\n\n/**\n * Hierarchical Filter model used when combining search response mappers.\n *\n * @internal\n */\nexport interface AdapterHierarchicalFilter extends BooleanFilter {\n /** Model name to indicate the filter type. */\n modelName: 'HierarchicalFilter';\n /** A unique id used to reference the parent filter or null if it hasn't. */\n parentId: Filter['id'] | null;\n /** Descendants filters. */\n children?: AdapterHierarchicalFilter[];\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { FacetModelName, Facet } from '@empathyco/x-types';
2
1
  import { Schema } from '@empathyco/x-adapter';
2
+ import { FacetModelName } from '@empathyco/x-types';
3
3
  /**
4
4
  * Facet configuration containing the model name and the schema.
5
5
  */
@@ -7,9 +7,3 @@ export interface FacetConfig {
7
7
  modelName: FacetModelName;
8
8
  schema: Schema;
9
9
  }
10
- /**
11
- * Dictionary grouping facets configurations.
12
- */
13
- export interface FacetsConfig {
14
- [key: Facet['id']]: FacetConfig;
15
- }
@@ -1,8 +1,9 @@
1
+ import { PlatformFacetType } from '../../types/models/facet.model';
1
2
  import { FacetConfig } from './types';
2
3
  /**
3
4
  * Returns the facet's config.
4
5
  *
5
- * @param facet - The facet to resolve the configuration.
6
+ * @param type - The facet type to resolve the configuration.
6
7
  * @returns The facet's config.
7
8
  */
8
- export declare function getFacetConfig(facet: string): FacetConfig;
9
+ export declare function getFacetConfig(type: PlatformFacetType): FacetConfig;
@@ -1,6 +1,4 @@
1
1
  import { Schema } from '@empathyco/x-adapter';
2
2
  import { EditableNumberRangeFacet, HierarchicalFacet, NumberRangeFacet, SimpleFacet } from '@empathyco/x-types';
3
3
  import { PlatformFacet } from '../../types/models/facet.model';
4
- import { FacetsConfig } from '../facets/types';
5
4
  export declare const facetSchema: import("@empathyco/x-adapter").MutableSchema<Schema<PlatformFacet, EditableNumberRangeFacet | HierarchicalFacet | NumberRangeFacet | SimpleFacet>>;
6
- export declare const facetsConfig: FacetsConfig;
@@ -6,8 +6,15 @@ import { BooleanFilter, Facet, Filter } from '@empathyco/x-types';
6
6
  */
7
7
  export interface PlatformFacet {
8
8
  facet: string;
9
+ type: PlatformFacetType;
9
10
  values: PlatformFilter[];
10
11
  }
12
+ /**
13
+ * Facet type for the `platform` API. It can be: value, hierarchical or range.
14
+ *
15
+ * @public
16
+ */
17
+ export declare type PlatformFacetType = 'value' | 'hierarchical' | 'range';
11
18
  /**
12
19
  * Filter model for the `platform` API.
13
20
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-adapter-platform",
3
- "version": "1.0.0-alpha.37",
3
+ "version": "1.0.0-alpha.39",
4
4
  "description": "A search client for the Empathy Platform API",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@empathyco/x-adapter": "^8.0.0-alpha.11",
42
- "@empathyco/x-types": "^10.0.0-alpha.38",
42
+ "@empathyco/x-types": "^10.0.0-alpha.39",
43
43
  "@empathyco/x-utils": "^1.0.0-alpha.10",
44
44
  "tslib": "~2.3.0"
45
45
  },
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "17d5671eee5423faac83cdb48fdd38723a7dbbc6"
59
+ "gitHead": "a7c306fd475bd3d2d74dcd8f314d37d766a6e782"
60
60
  }