@labdigital/commercetools-mock 0.7.1 → 0.9.1

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
@@ -127,7 +127,7 @@ var resolveValue = (obj, val) => {
127
127
  return obj[val.value];
128
128
  };
129
129
  var getLexer = (value) => {
130
- return new import_perplex.default(value).token("AND", /and(?![-_a-z0-9]+)/i).token("OR", /or(?![-_a-z0-9]+)/i).token("NOT", /not(?![-_a-z0-9]+)/i).token("WITHIN", /within(?![-_a-z0-9]+)/i).token("IN", /in(?![-_a-z0-9]+)/i).token("MATCHES_IGNORE_CASE", /matches\s+ignore\s+case(?![-_a-z0-9]+)/i).token("CONTAINS", /contains(?![-_a-z0-9]+)/i).token("ALL", /all(?![-_a-z0-9]+)/i).token("ANY", /any(?![-_a-z0-9]+)/i).token("EMPTY", /empty(?![-_a-z0-9]+)/i).token("IS", /is(?![-_a-z0-9]+)/i).token("DEFINED", /defined(?![-_a-z0-9]+)/i).token("FLOAT", /\d+\.\d+/).token("INT", /\d+/).token("VARIABLE", /:([-_A-Za-z0-9]+)/).token("IDENTIFIER", /[-_A-Za-z0-9]+/).token("STRING", /"((?:\\.|[^"\\])*)"/).token("STRING", /'((?:\\.|[^'\\])*)'/).token("COMMA", ",").token("(", "(").token(")", ")").token(">=", ">=").token("<=", "<=").token(">", ">").token("<", "<").token("!=", "!=").token("=", "=").token('"', '"').token("WS", /\s+/, true);
130
+ return new import_perplex.default(value).token("AND", /and(?![-_a-z0-9]+)/i).token("OR", /or(?![-_a-z0-9]+)/i).token("NOT", /not(?![-_a-z0-9]+)/i).token("WITHIN", /within(?![-_a-z0-9]+)/i).token("IN", /in(?![-_a-z0-9]+)/i).token("MATCHES_IGNORE_CASE", /matches\s+ignore\s+case(?![-_a-z0-9]+)/i).token("CONTAINS", /contains(?![-_a-z0-9]+)/i).token("ALL", /all(?![-_a-z0-9]+)/i).token("ANY", /any(?![-_a-z0-9]+)/i).token("EMPTY", /empty(?![-_a-z0-9]+)/i).token("IS", /is(?![-_a-z0-9]+)/i).token("DEFINED", /defined(?![-_a-z0-9]+)/i).token("FLOAT", /\d+\.\d+/).token("INT", /\d+/).token("VARIABLE", /:([-_A-Za-z0-9]+)/).token("BOOLEAN", /(true|false)/).token("IDENTIFIER", /[-_A-Za-z0-9]+/).token("STRING", /"((?:\\.|[^"\\])*)"/).token("STRING", /'((?:\\.|[^'\\])*)'/).token("COMMA", ",").token("(", "(").token(")", ")").token(">=", ">=").token("<=", "<=").token(">", ">").token("<", "<").token("!=", "!=").token("=", "=").token('"', '"').token("WS", /\s+/, true);
131
131
  };
132
132
  var generateMatchFunc = (predicate) => {
133
133
  const lexer = getLexer(predicate);
@@ -137,6 +137,12 @@ var generateMatchFunc = (predicate) => {
137
137
  value: t.token.match,
138
138
  pos: t.token.strpos()
139
139
  };
140
+ }).nud("BOOLEAN", 1, (t) => {
141
+ return {
142
+ type: "boolean",
143
+ value: t.token.match === "true" ? true : false,
144
+ pos: t.token.strpos()
145
+ };
140
146
  }).nud("VARIABLE", 100, (t) => {
141
147
  return {
142
148
  type: "var",
@@ -820,6 +826,21 @@ var getBaseResourceProperties = () => {
820
826
  version: 0
821
827
  };
822
828
  };
829
+ var nestedLookup = (obj, path) => {
830
+ if (!path || path === "") {
831
+ return obj;
832
+ }
833
+ const parts = path.split(".");
834
+ let val = obj;
835
+ for (let i = 0; i < parts.length; i++) {
836
+ const part = parts[i];
837
+ if (val == void 0) {
838
+ return void 0;
839
+ }
840
+ val = val[part];
841
+ }
842
+ return val;
843
+ };
823
844
  var QueryParamsAsArray = (input) => {
824
845
  if (input == void 0) {
825
846
  return [];
@@ -929,10 +950,41 @@ var createPrice = (draft) => {
929
950
  };
930
951
  };
931
952
  var createTypedMoney = (value) => {
953
+ let fractionDigits = 2;
954
+ switch (value.currencyCode.toUpperCase()) {
955
+ case "BHD":
956
+ case "IQD":
957
+ case "JOD":
958
+ case "KWD":
959
+ case "LYD":
960
+ case "OMR":
961
+ case "TND":
962
+ fractionDigits = 3;
963
+ break;
964
+ case "CVE":
965
+ case "DJF":
966
+ case "GNF":
967
+ case "IDR":
968
+ case "JPY":
969
+ case "KMF":
970
+ case "KRW":
971
+ case "PYG":
972
+ case "RWF":
973
+ case "UGX":
974
+ case "VND":
975
+ case "VUV":
976
+ case "XAF":
977
+ case "XOF":
978
+ case "XPF":
979
+ fractionDigits = 0;
980
+ break;
981
+ default:
982
+ fractionDigits = 2;
983
+ }
932
984
  return {
933
985
  type: "centPrecision",
934
- fractionDigits: 2,
935
- ...value
986
+ ...value,
987
+ fractionDigits
936
988
  };
937
989
  };
938
990
  var resolveStoreReference = (ref, projectKey, storage) => {
@@ -1140,7 +1192,14 @@ var AbstractRepository = class {
1140
1192
  if (!(0, import_deep_equal.default)(modifiedResource, resource)) {
1141
1193
  this.save(context, modifiedResource);
1142
1194
  }
1143
- return modifiedResource;
1195
+ const result = this.postProcessResource(modifiedResource);
1196
+ if (!result) {
1197
+ throw new Error("invalid post process action");
1198
+ }
1199
+ return result;
1200
+ }
1201
+ postProcessResource(resource) {
1202
+ return resource;
1144
1203
  }
1145
1204
  };
1146
1205
  var AbstractResourceRepository = class extends AbstractRepository {
@@ -1149,31 +1208,36 @@ var AbstractResourceRepository = class extends AbstractRepository {
1149
1208
  this._storage.assertStorage(this.getTypeId());
1150
1209
  }
1151
1210
  query(context, params = {}) {
1152
- return this._storage.query(context.projectKey, this.getTypeId(), {
1211
+ const result = this._storage.query(context.projectKey, this.getTypeId(), {
1153
1212
  expand: params.expand,
1154
1213
  where: params.where,
1155
1214
  offset: params.offset,
1156
1215
  limit: params.limit
1157
1216
  });
1217
+ result.results = result.results.map(this.postProcessResource);
1218
+ return result;
1158
1219
  }
1159
1220
  get(context, id, params = {}) {
1160
- return this._storage.get(context.projectKey, this.getTypeId(), id, params);
1221
+ const resource = this._storage.get(context.projectKey, this.getTypeId(), id, params);
1222
+ return this.postProcessResource(resource);
1161
1223
  }
1162
1224
  getByKey(context, key, params = {}) {
1163
- return this._storage.getByKey(
1225
+ const resource = this._storage.getByKey(
1164
1226
  context.projectKey,
1165
1227
  this.getTypeId(),
1166
1228
  key,
1167
1229
  params
1168
1230
  );
1231
+ return this.postProcessResource(resource);
1169
1232
  }
1170
1233
  delete(context, id, params = {}) {
1171
- return this._storage.delete(
1234
+ const resource = this._storage.delete(
1172
1235
  context.projectKey,
1173
1236
  this.getTypeId(),
1174
1237
  id,
1175
1238
  params
1176
1239
  );
1240
+ return this.postProcessResource(resource);
1177
1241
  }
1178
1242
  save(context, resource) {
1179
1243
  const current = this.get(context, resource.id);
@@ -2457,6 +2521,25 @@ var DiscountCodeService = class extends AbstractService {
2457
2521
  }
2458
2522
  };
2459
2523
 
2524
+ // src/lib/masking.ts
2525
+ var maskSecretValue = (resource, path) => {
2526
+ const parts = path.split(".");
2527
+ const clone = JSON.parse(JSON.stringify(resource));
2528
+ let val = clone;
2529
+ const target = parts.pop();
2530
+ for (let i = 0; i < parts.length; i++) {
2531
+ const part = parts[i];
2532
+ val = val[part];
2533
+ if (val === void 0) {
2534
+ return resource;
2535
+ }
2536
+ }
2537
+ if (val && target && val[target]) {
2538
+ val[target] = "****";
2539
+ }
2540
+ return clone;
2541
+ };
2542
+
2460
2543
  // src/repositories/extension.ts
2461
2544
  var ExtensionRepository = class extends AbstractResourceRepository {
2462
2545
  constructor() {
@@ -2479,6 +2562,23 @@ var ExtensionRepository = class extends AbstractResourceRepository {
2479
2562
  getTypeId() {
2480
2563
  return "extension";
2481
2564
  }
2565
+ postProcessResource(resource) {
2566
+ var _a;
2567
+ if (resource) {
2568
+ if (resource.destination.type === "HTTP" && ((_a = resource.destination.authentication) == null ? void 0 : _a.type) === "AuthorizationHeader") {
2569
+ return maskSecretValue(
2570
+ resource,
2571
+ "destination.authentication.headerValue"
2572
+ );
2573
+ } else if (resource.destination.type == "AWSLambda") {
2574
+ return maskSecretValue(
2575
+ resource,
2576
+ "destination.accessSecret"
2577
+ );
2578
+ }
2579
+ }
2580
+ return resource;
2581
+ }
2482
2582
  create(context, draft) {
2483
2583
  const resource = {
2484
2584
  ...getBaseResourceProperties(),
@@ -2909,38 +3009,71 @@ var parseFilterExpression = (filter, staged) => {
2909
3009
  var getLexer2 = (value) => {
2910
3010
  return new import_perplex2.default(value).token("MISSING", /missing(?![-_a-z0-9]+)/i).token("EXISTS", /exists(?![-_a-z0-9]+)/i).token("RANGE", /range(?![-_a-z0-9]+)/i).token("TO", /to(?![-_a-z0-9]+)/i).token("IDENTIFIER", /[-_\.a-z]+/i).token("FLOAT", /\d+\.\d+/).token("INT", /\d+/).token("STRING", /"((?:\\.|[^"\\])*)"/).token("STRING", /'((?:\\.|[^'\\])*)'/).token("COMMA", ",").token("STAR", "*").token("(", "(").token(":", ":").token(")", ")").token('"', '"').token("WS", /\s+/, true);
2911
3011
  };
2912
- var generateMatchFunc2 = (filter) => {
3012
+ var parseFilter = (filter) => {
2913
3013
  const lexer = getLexer2(filter);
2914
3014
  const parser = new import_pratt2.default(lexer).builder().nud("IDENTIFIER", 100, (t) => {
2915
3015
  return t.token.match;
2916
3016
  }).led(":", 100, ({ left, bp }) => {
2917
- const expr = parser.parse({ terminals: [bp - 1] });
2918
- if (Array.isArray(expr)) {
2919
- return (obj) => {
2920
- return expr.includes(obj);
2921
- };
3017
+ let parsed = parser.parse({ terminals: [bp - 1] });
3018
+ let expressions;
3019
+ expressions = !Array.isArray(parsed) ? [parsed] : parsed;
3020
+ const unique = new Set(expressions.map((expr) => expr.type));
3021
+ if (unique.size > 1) {
3022
+ throw new Error("Invalid expression");
2922
3023
  }
2923
- if (typeof expr === "function") {
2924
- return (obj) => {
2925
- return expr(obj);
3024
+ if (expressions.some((expr) => expr.type == "Symbol")) {
3025
+ return {
3026
+ source: left,
3027
+ type: "FilterExpression",
3028
+ children: expressions.map((e) => {
3029
+ if (e.type != "Symbol") {
3030
+ throw new Error("Invalid expression");
3031
+ }
3032
+ return {
3033
+ type: "FilterExpression",
3034
+ match: (obj) => {
3035
+ return obj === e.value;
3036
+ }
3037
+ };
3038
+ })
2926
3039
  };
2927
3040
  }
2928
- return (obj) => {
2929
- return obj === expr;
3041
+ return {
3042
+ source: left,
3043
+ type: expressions[0].type,
3044
+ children: expressions
2930
3045
  };
2931
3046
  }).nud("STRING", 20, (t) => {
2932
- return t.token.groups[1];
3047
+ return {
3048
+ type: "Symbol",
3049
+ kind: "string",
3050
+ value: t.token.groups[1]
3051
+ };
2933
3052
  }).nud("INT", 5, (t) => {
2934
- return parseInt(t.token.match, 10);
3053
+ return {
3054
+ type: "Symbol",
3055
+ kind: "int",
3056
+ value: parseInt(t.token.match, 10)
3057
+ };
2935
3058
  }).nud("STAR", 5, (t) => {
2936
- return null;
3059
+ return {
3060
+ type: "Symbol",
3061
+ kind: "any",
3062
+ value: null
3063
+ };
2937
3064
  }).nud("EXISTS", 10, ({ bp }) => {
2938
- return (val) => {
2939
- return val !== void 0;
3065
+ return {
3066
+ type: "FilterExpression",
3067
+ match: (obj) => {
3068
+ return obj !== void 0;
3069
+ }
2940
3070
  };
2941
3071
  }).nud("MISSING", 10, ({ bp }) => {
2942
- return (val) => {
2943
- return val === void 0;
3072
+ return {
3073
+ type: "FilterExpression",
3074
+ match: (obj) => {
3075
+ return obj === void 0;
3076
+ }
2944
3077
  };
2945
3078
  }).led("COMMA", 200, ({ left, token, bp }) => {
2946
3079
  const expr = parser.parse({ terminals: [bp - 1] });
@@ -2949,38 +3082,74 @@ var generateMatchFunc2 = (filter) => {
2949
3082
  } else {
2950
3083
  return [left, expr];
2951
3084
  }
3085
+ }).nud("(", 100, (t) => {
3086
+ const expr = parser.parse({ terminals: [")"] });
3087
+ lexer.expect(")");
3088
+ return expr;
2952
3089
  }).bp(")", 0).led("TO", 20, ({ left, bp }) => {
2953
3090
  const expr = parser.parse({ terminals: [bp - 1] });
2954
- return [left, expr];
3091
+ return {
3092
+ start: left.value,
3093
+ stop: expr.value
3094
+ };
2955
3095
  }).nud("RANGE", 20, ({ bp }) => {
2956
- lexer.next();
2957
- const [start, stop] = parser.parse();
2958
- console.log(start, stop);
2959
- if (start !== null && stop !== null) {
2960
- return (obj) => {
2961
- return obj >= start && obj <= stop;
2962
- };
2963
- } else if (start === null && stop !== null) {
2964
- return (obj) => {
2965
- return obj <= stop;
2966
- };
2967
- } else if (start !== null && stop === null) {
2968
- return (obj) => {
2969
- return obj >= start;
2970
- };
2971
- } else {
2972
- return (obj) => {
2973
- return true;
2974
- };
3096
+ let ranges = parser.parse();
3097
+ if (!Array.isArray(ranges)) {
3098
+ ranges = [ranges];
2975
3099
  }
3100
+ return ranges.map((range) => {
3101
+ let func = void 0;
3102
+ if (range.start !== null && range.stop !== null) {
3103
+ func = (obj) => {
3104
+ return obj >= range.start && obj <= range.stop;
3105
+ };
3106
+ } else if (range.start === null && range.stop !== null) {
3107
+ func = (obj) => {
3108
+ return obj <= range.stop;
3109
+ };
3110
+ } else if (range.start !== null && range.stop === null) {
3111
+ func = (obj) => {
3112
+ return obj >= range.start;
3113
+ };
3114
+ } else {
3115
+ func = (obj) => {
3116
+ return true;
3117
+ };
3118
+ }
3119
+ return {
3120
+ type: "RangeExpression",
3121
+ start: range.start,
3122
+ stop: range.stop,
3123
+ match: func
3124
+ };
3125
+ });
2976
3126
  }).build();
2977
- const result = parser.parse();
2978
- if (typeof result !== "function") {
3127
+ return parser.parse();
3128
+ };
3129
+ var generateMatchFunc2 = (filter) => {
3130
+ const result = parseFilter(filter);
3131
+ if (!result) {
2979
3132
  const lines = filter.split("\n");
2980
3133
  const column = lines[lines.length - 1].length;
2981
3134
  throw new Error(`Syntax error while parsing '${filter}'.`);
2982
3135
  }
2983
- return result;
3136
+ if (result.type == "TermExpression") {
3137
+ throw new Error(`Syntax error while parsing '${filter}'.`);
3138
+ }
3139
+ return (obj) => {
3140
+ if (!result.children)
3141
+ return false;
3142
+ return result.children.some((c) => c.match(obj));
3143
+ };
3144
+ };
3145
+ var generateFacetFunc = (filter) => {
3146
+ if (!filter.includes(":")) {
3147
+ return {
3148
+ source: filter,
3149
+ type: "TermExpression"
3150
+ };
3151
+ }
3152
+ return parseFilter(filter);
2984
3153
  };
2985
3154
  var filterProduct = (source, exprFunc) => {
2986
3155
  return (p, markMatchingVariants) => {
@@ -3010,6 +3179,9 @@ var resolveVariantValue = (obj, path) => {
3010
3179
  if (path === void 0) {
3011
3180
  return obj;
3012
3181
  }
3182
+ if (path.startsWith("variants.")) {
3183
+ path = path.substring(path.indexOf(".") + 1);
3184
+ }
3013
3185
  if (path.startsWith("attributes.")) {
3014
3186
  const [, attrName, ...rest] = path.split(".");
3015
3187
  if (!obj.attributes) {
@@ -3026,21 +3198,6 @@ var resolveVariantValue = (obj, path) => {
3026
3198
  }
3027
3199
  return nestedLookup(obj, path);
3028
3200
  };
3029
- var nestedLookup = (obj, path) => {
3030
- if (!path || path === "") {
3031
- return obj;
3032
- }
3033
- const parts = path.split(".");
3034
- let val = obj;
3035
- for (let i = 0; i < parts.length; i++) {
3036
- const part = parts[i];
3037
- if (val == void 0) {
3038
- return void 0;
3039
- }
3040
- val = val[part];
3041
- }
3042
- return val;
3043
- };
3044
3201
  var getVariants = (p, staged) => {
3045
3202
  var _a, _b, _c, _d;
3046
3203
  return [
@@ -3133,6 +3290,7 @@ var ProductProjectionSearch = class {
3133
3290
  );
3134
3291
  }
3135
3292
  }
3293
+ const facets = this.getFacets(params, resources);
3136
3294
  if (params["filter.query"]) {
3137
3295
  try {
3138
3296
  const filters = params["filter.query"].map(
@@ -3166,7 +3324,7 @@ var ProductProjectionSearch = class {
3166
3324
  offset,
3167
3325
  limit,
3168
3326
  results: resources.map(this.transform),
3169
- facets: {}
3327
+ facets
3170
3328
  };
3171
3329
  }
3172
3330
  transform(product) {
@@ -3177,6 +3335,9 @@ var ProductProjectionSearch = class {
3177
3335
  lastModifiedAt: product.lastModifiedAt,
3178
3336
  version: product.version,
3179
3337
  name: obj.name,
3338
+ key: product.key,
3339
+ description: obj.description,
3340
+ metaDescription: obj.metaDescription,
3180
3341
  slug: obj.slug,
3181
3342
  categories: obj.categories,
3182
3343
  masterVariant: obj.masterVariant,
@@ -3184,6 +3345,145 @@ var ProductProjectionSearch = class {
3184
3345
  productType: product.productType
3185
3346
  };
3186
3347
  }
3348
+ getFacets(params, products) {
3349
+ if (!params.facet)
3350
+ return {};
3351
+ const staged = false;
3352
+ const result = {};
3353
+ for (const facet of params.facet) {
3354
+ const expression = generateFacetFunc(facet);
3355
+ if (expression.type === "TermExpression") {
3356
+ result[facet] = this.termFacet(expression.source, products, staged);
3357
+ }
3358
+ if (expression.type === "RangeExpression") {
3359
+ result[expression.source] = this.rangeFacet(
3360
+ expression.source,
3361
+ expression.children,
3362
+ products,
3363
+ staged
3364
+ );
3365
+ }
3366
+ if (expression.type === "FilterExpression") {
3367
+ result[expression.source] = this.filterFacet(
3368
+ expression.source,
3369
+ expression.children,
3370
+ products,
3371
+ staged
3372
+ );
3373
+ }
3374
+ }
3375
+ return result;
3376
+ }
3377
+ termFacet(facet, products, staged) {
3378
+ const result = {
3379
+ type: "terms",
3380
+ dataType: "text",
3381
+ missing: 0,
3382
+ total: 0,
3383
+ other: 0,
3384
+ terms: []
3385
+ };
3386
+ const terms = {};
3387
+ if (facet.startsWith("variants.")) {
3388
+ products.forEach((p) => {
3389
+ const variants = getVariants(p, staged);
3390
+ variants.forEach((v) => {
3391
+ result.total++;
3392
+ let value = resolveVariantValue(v, facet);
3393
+ if (value === void 0) {
3394
+ result.missing++;
3395
+ } else {
3396
+ if (typeof value === "number") {
3397
+ value = Number(value).toFixed(1);
3398
+ }
3399
+ terms[value] = value in terms ? terms[value] + 1 : 1;
3400
+ }
3401
+ });
3402
+ });
3403
+ } else {
3404
+ products.forEach((p) => {
3405
+ const value = nestedLookup(p, facet);
3406
+ result.total++;
3407
+ if (value === void 0) {
3408
+ result.missing++;
3409
+ } else {
3410
+ terms[value] = value in terms ? terms[value] + 1 : 1;
3411
+ }
3412
+ });
3413
+ }
3414
+ for (const term in terms) {
3415
+ result.terms.push({
3416
+ term,
3417
+ count: terms[term]
3418
+ });
3419
+ }
3420
+ return result;
3421
+ }
3422
+ filterFacet(source, filters, products, staged) {
3423
+ let count = 0;
3424
+ if (source.startsWith("variants.")) {
3425
+ for (const p of products) {
3426
+ for (const v of getVariants(p, staged)) {
3427
+ const val = resolveVariantValue(v, source);
3428
+ if (filters == null ? void 0 : filters.some((f) => f.match(val))) {
3429
+ count++;
3430
+ }
3431
+ }
3432
+ }
3433
+ } else {
3434
+ throw new Error("not supported");
3435
+ }
3436
+ return {
3437
+ type: "filter",
3438
+ count
3439
+ };
3440
+ }
3441
+ rangeFacet(source, ranges, products, staged) {
3442
+ const counts = (ranges == null ? void 0 : ranges.map((range) => {
3443
+ if (source.startsWith("variants.")) {
3444
+ const values = [];
3445
+ for (const p of products) {
3446
+ for (const v of getVariants(p, staged)) {
3447
+ const val = resolveVariantValue(v, source);
3448
+ if (val === void 0) {
3449
+ continue;
3450
+ }
3451
+ if (range.match(val)) {
3452
+ values.push(val);
3453
+ }
3454
+ }
3455
+ }
3456
+ const numValues = values.length;
3457
+ return {
3458
+ type: "double",
3459
+ from: range.start || 0,
3460
+ fromStr: range.start !== null ? Number(range.start).toFixed(1) : "",
3461
+ to: range.stop || 0,
3462
+ toStr: range.stop !== null ? Number(range.stop).toFixed(1) : "",
3463
+ count: numValues,
3464
+ total: values.reduce((a, b) => a + b, 0),
3465
+ min: numValues > 0 ? Math.min(...values) : 0,
3466
+ max: numValues > 0 ? Math.max(...values) : 0,
3467
+ mean: numValues > 0 ? mean(values) : 0
3468
+ };
3469
+ } else {
3470
+ throw new Error("not supported");
3471
+ }
3472
+ })) || [];
3473
+ const data = {
3474
+ type: "range",
3475
+ dataType: "number",
3476
+ ranges: counts
3477
+ };
3478
+ return data;
3479
+ }
3480
+ };
3481
+ var mean = (arr) => {
3482
+ let total = 0;
3483
+ for (let i = 0; i < arr.length; i++) {
3484
+ total += arr[i];
3485
+ }
3486
+ return total / arr.length;
3187
3487
  };
3188
3488
 
3189
3489
  // src/repositories/product-projection.ts
@@ -3211,6 +3511,7 @@ var ProductProjectionRepository = class extends AbstractResourceRepository {
3211
3511
  const results = this._searchService.search(context.projectKey, {
3212
3512
  filter: QueryParamsAsArray(query.filter),
3213
3513
  "filter.query": QueryParamsAsArray(query["filter.query"]),
3514
+ facet: QueryParamsAsArray(query.facet),
3214
3515
  offset: query.offset ? Number(query.offset) : void 0,
3215
3516
  limit: query.limit ? Number(query.limit) : void 0,
3216
3517
  expand: QueryParamsAsArray(query.expand)
@@ -3560,25 +3861,6 @@ var ProductTypeService = class extends AbstractService {
3560
3861
  }
3561
3862
  };
3562
3863
 
3563
- // src/lib/masking.ts
3564
- var maskSecretValue = (resource, path) => {
3565
- const parts = path.split(".");
3566
- const clone = JSON.parse(JSON.stringify(resource));
3567
- let val = clone;
3568
- const target = parts.pop();
3569
- for (let i = 0; i < parts.length; i++) {
3570
- const part = parts[i];
3571
- val = val[part];
3572
- if (val === void 0) {
3573
- return resource;
3574
- }
3575
- }
3576
- if (val && target && val[target]) {
3577
- val[target] = "****";
3578
- }
3579
- return clone;
3580
- };
3581
-
3582
3864
  // src/repositories/project.ts
3583
3865
  var ProjectRepository = class extends AbstractRepository {
3584
3866
  constructor() {
@@ -3636,11 +3918,16 @@ var ProjectRepository = class extends AbstractRepository {
3636
3918
  }
3637
3919
  get(context) {
3638
3920
  const resource = this._storage.getProject(context.projectKey);
3639
- const masked = maskSecretValue(
3640
- resource,
3641
- "externalOAuth.authorizationHeader"
3642
- );
3643
- return masked;
3921
+ return this.postProcessResource(resource);
3922
+ }
3923
+ postProcessResource(resource) {
3924
+ if (resource) {
3925
+ return maskSecretValue(
3926
+ resource,
3927
+ "externalOAuth.authorizationHeader"
3928
+ );
3929
+ }
3930
+ return resource;
3644
3931
  }
3645
3932
  save(context, resource) {
3646
3933
  const current = this.get(context);
@@ -3909,6 +4196,14 @@ var StateRepository = class extends AbstractResourceRepository {
3909
4196
  },
3910
4197
  setRoles: (context, resource, { roles }) => {
3911
4198
  resource.roles = roles;
4199
+ },
4200
+ setTransitions: (context, resource, { transitions }) => {
4201
+ resource.transitions = transitions == null ? void 0 : transitions.map((resourceId) => {
4202
+ return {
4203
+ id: resourceId.id || "",
4204
+ typeId: "state"
4205
+ };
4206
+ });
3912
4207
  }
3913
4208
  };
3914
4209
  }