@saasquatch/program-boilerplate 3.5.12-0 → 3.5.12-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.
Files changed (2) hide show
  1. package/dist/utils.js +21 -26
  2. package/package.json +2 -2
package/dist/utils.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUserCustomFieldsFromJsonata = exports.getTriggerSchema = exports.numToEquality = exports.inferType = exports.getGoalAnalyticTimestamp = exports.setRewardSchedule = void 0;
4
4
  const queries_1 = require("./queries");
5
- const jsonata = require("jsonata");
6
5
  const jsonata_paths_extractor_1 = require("@saasquatch/jsonata-paths-extractor");
7
6
  /**
8
7
  * Append a reward schedule to the template and return the new template
@@ -192,37 +191,33 @@ exports.getTriggerSchema = getTriggerSchema;
192
191
  */
193
192
  function getUserCustomFieldsFromJsonata(jsonataExpressions) {
194
193
  let userCustomFields = [];
195
- const getJsonataASTSafe = (expression) => {
196
- try {
197
- return jsonata(expression).ast();
198
- }
199
- catch (e) { }
200
- };
201
194
  if (typeof jsonataExpressions === "string") {
202
195
  jsonataExpressions = [jsonataExpressions];
203
196
  }
204
197
  for (const expression of jsonataExpressions) {
205
- const ast = getJsonataASTSafe(expression);
206
- if (!ast)
207
- continue;
208
- const allPaths = jsonata_paths_extractor_1.default(ast);
209
- for (const path of allPaths) {
210
- if (path.startsWith("/user/customFields/")) {
211
- const key = path.split("/")[3];
212
- if (key)
213
- userCustomFields.push(key);
214
- }
215
- if (path.startsWith("/user/referredByReferral/referrerUser/customFields/")) {
216
- const key = path.split("/")[5];
217
- if (key)
218
- userCustomFields.push(key);
219
- }
220
- if (path.startsWith("/referral/referrerUser/customFields/")) {
221
- const key = path.split("/")[4];
222
- if (key)
223
- userCustomFields.push(key);
198
+ try {
199
+ const allPaths = jsonata_paths_extractor_1.default(expression);
200
+ for (const path of allPaths) {
201
+ if (path.startsWith("/user/customFields/")) {
202
+ const key = path.split("/")[3];
203
+ if (key)
204
+ userCustomFields.push(key);
205
+ }
206
+ if (path.startsWith("/user/referredByReferral/referrerUser/customFields/")) {
207
+ const key = path.split("/")[5];
208
+ if (key)
209
+ userCustomFields.push(key);
210
+ }
211
+ if (path.startsWith("/referral/referrerUser/customFields/")) {
212
+ const key = path.split("/")[4];
213
+ if (key)
214
+ userCustomFields.push(key);
215
+ }
224
216
  }
225
217
  }
218
+ catch (e) {
219
+ continue;
220
+ }
226
221
  }
227
222
  //dedup
228
223
  return Array.from(new Set(userCustomFields));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasquatch/program-boilerplate",
3
- "version": "3.5.12-0",
3
+ "version": "3.5.12-1",
4
4
  "description": "Boilerplate for writing programs",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -32,7 +32,7 @@
32
32
  "typescript": "^3.9.9"
33
33
  },
34
34
  "dependencies": {
35
- "@saasquatch/jsonata-paths-extractor": "^0.1.0-1",
35
+ "@saasquatch/jsonata-paths-extractor": "^1.0.0-0",
36
36
  "bson-objectid": "^1.3.1",
37
37
  "compression": "^1.7.4",
38
38
  "express": "^4.17.1",