@fibery/expression-utils 1.1.11 → 1.1.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.
@@ -0,0 +1,99 @@
1
+ export const dateToDateTimeIntervalLookup: {
2
+ "$today-date": {
3
+ start: string;
4
+ end: string;
5
+ };
6
+ "$tomorrow-date": {
7
+ start: string;
8
+ end: string;
9
+ };
10
+ "$yesterday-date": {
11
+ start: string;
12
+ end: string;
13
+ };
14
+ "$week-ago-date": {
15
+ start: string;
16
+ end: string;
17
+ };
18
+ "$week-from-now-date": {
19
+ start: string;
20
+ end: string;
21
+ };
22
+ "$month-ago-date": {
23
+ start: string;
24
+ end: string;
25
+ };
26
+ "$month-from-now-date": {
27
+ start: string;
28
+ end: string;
29
+ };
30
+ "$year-ago-date": {
31
+ start: string;
32
+ end: string;
33
+ };
34
+ "$year-from-now-date": {
35
+ start: string;
36
+ end: string;
37
+ };
38
+ };
39
+ export const formulaNowDateTimeParamPlaceholder: "$formula-now-date-time-placeholder";
40
+ export const formulaTodayDateParamPlaceholder: "$formula-today-date-placeholder";
41
+ export const monthAgoDateParamPlaceholder: "$month-ago-date";
42
+ export const monthAgoEndDateTimeParamPlaceholder: "$month-ago-date-time-end";
43
+ export const monthAgoStartDateTimeParamPlaceholder: "$month-ago-date-time-start";
44
+ export const monthFromNowDateParamPlaceholder: "$month-from-now-date";
45
+ export const monthFromNowEndDateTimeParamPlaceholder: "$month-from-now-date-time-end";
46
+ export const monthFromNowStartDateTimeParamPlaceholder: "$month-from-now-date-time-start";
47
+ export const paramsPlaceholdersLookup: {
48
+ "$today-date": () => any;
49
+ "$formula-today-date-placeholder": () => any;
50
+ "$formula-now-date-time-placeholder": () => any;
51
+ "$tomorrow-date": () => any;
52
+ "$yesterday-date": () => any;
53
+ "$week-ago-date": () => any;
54
+ "$week-from-now-date": () => any;
55
+ "$month-ago-date": () => any;
56
+ "$month-from-now-date": () => any;
57
+ "$year-ago-date": () => any;
58
+ "$year-from-now-date": () => any;
59
+ "$today-date-time-start": () => any;
60
+ "$today-date-time-end": () => any;
61
+ "$tomorrow-date-time-start": () => any;
62
+ "$tomorrow-date-time-end": () => any;
63
+ "$yesterday-date-time-start": () => any;
64
+ "$yesterday-date-time-end": () => any;
65
+ "$week-ago-date-time-start": () => any;
66
+ "$week-ago-date-time-end": () => any;
67
+ "$week-from-now-date-time-start": () => any;
68
+ "$week-from-now-date-time-end": () => any;
69
+ "$month-ago-date-time-start": () => any;
70
+ "$month-ago-date-time-end": () => any;
71
+ "$month-from-now-date-time-start": () => any;
72
+ "$month-from-now-date-time-end": () => any;
73
+ "$year-ago-date-time-start": () => any;
74
+ "$year-ago-date-time-end": () => any;
75
+ "$year-from-now-date-time-start": () => any;
76
+ "$year-from-now-date-time-end": () => any;
77
+ };
78
+ export function replacePlaceholdersInParams(params: any): any;
79
+ export const todayDateParamPlaceholder: "$today-date";
80
+ export const todayEndDateTimeParamPlaceholder: "$today-date-time-end";
81
+ export const todayStartDateTimeParamPlaceholder: "$today-date-time-start";
82
+ export const tomorrowDateParamPlaceholder: "$tomorrow-date";
83
+ export const tomorrowEndDateTimeParamPlaceholder: "$tomorrow-date-time-end";
84
+ export const tomorrowStartDateTimeParamPlaceholder: "$tomorrow-date-time-start";
85
+ export const weekAgoDateParamPlaceholder: "$week-ago-date";
86
+ export const weekAgoEndDateTimeParamPlaceholder: "$week-ago-date-time-end";
87
+ export const weekAgoStartDateTimeParamPlaceholder: "$week-ago-date-time-start";
88
+ export const weekFromNowDateParamPlaceholder: "$week-from-now-date";
89
+ export const weekFromNowEndDateTimeParamPlaceholder: "$week-from-now-date-time-end";
90
+ export const weekFromNowStartDateTimeParamPlaceholder: "$week-from-now-date-time-start";
91
+ export const yearAgoDateParamPlaceholder: "$year-ago-date";
92
+ export const yearAgoEndDateTimeParamPlaceholder: "$year-ago-date-time-end";
93
+ export const yearAgoStartDateTimeParamPlaceholder: "$year-ago-date-time-start";
94
+ export const yearFromNowDateParamPlaceholder: "$year-from-now-date";
95
+ export const yearFromNowEndDateTimeParamPlaceholder: "$year-from-now-date-time-end";
96
+ export const yearFromNowStartDateTimeParamPlaceholder: "$year-from-now-date-time-start";
97
+ export const yesterdayDateParamPlaceholder: "$yesterday-date";
98
+ export const yesterdayEndDateTimeParamPlaceholder: "$yesterday-date-time-end";
99
+ export const yesterdayStartDateTimeParamPlaceholder: "$yesterday-date-time-start";
@@ -9,9 +9,11 @@ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
9
9
  const serializeDate = momentDate => {
10
10
  return momentDate.format("YYYY-MM-DD");
11
11
  };
12
+
12
13
  const serializeDateTime = momentDate => {
13
14
  return momentDate.toISOString();
14
15
  };
16
+
15
17
  const formulaTodayDateParamPlaceholder = "$formula-today-date-placeholder";
16
18
  const formulaNowDateTimeParamPlaceholder = "$formula-now-date-time-placeholder";
17
19
  const todayDateParamPlaceholder = "$today-date";
@@ -72,28 +74,13 @@ const paramsPlaceholdersLookup = {
72
74
  [yearFromNowStartDateTimeParamPlaceholder]: () => serializeDateTime(moment__default["default"]().add(1, "year").startOf("day")),
73
75
  [yearFromNowEndDateTimeParamPlaceholder]: () => serializeDateTime(moment__default["default"]().add(1, "year").endOf("day"))
74
76
  };
75
- const dynamicFilterParamPrefix = `$dynamic_`;
76
- const isDynamicFilterParam = paramValue => paramValue.startsWith(dynamicFilterParamPrefix);
77
- const getFieldIdFromDynamicParam = paramValue => paramValue.substring(dynamicFilterParamPrefix.length);
78
- const mapDynamicParams = (params, onDynamicParam) => {
79
- if (!params) {
80
- return params;
81
- }
82
- return Object.fromEntries(Object.entries(params).map(([key, value]) => {
83
- if (___default["default"].isArray(value)) {
84
- return [key, value.map(v => {
85
- return ___default["default"].isString(v) && isDynamicFilterParam(v) ? onDynamicParam(v) : v;
86
- })];
87
- } else {
88
- return [key, ___default["default"].isString(value) && isDynamicFilterParam(value) ? onDynamicParam(value) : value];
89
- }
90
- }));
91
- };
92
77
  const replacePlaceholdersInParams = params => params && ___default["default"].mapValues(params, (value, key) => {
93
78
  const replaceFn = paramsPlaceholdersLookup[key];
79
+
94
80
  if (replaceFn) {
95
81
  return replaceFn();
96
82
  }
83
+
97
84
  return value;
98
85
  });
99
86
  const dateToDateTimeIntervalLookup = {
@@ -136,12 +123,8 @@ const dateToDateTimeIntervalLookup = {
136
123
  };
137
124
 
138
125
  exports.dateToDateTimeIntervalLookup = dateToDateTimeIntervalLookup;
139
- exports.dynamicFilterParamPrefix = dynamicFilterParamPrefix;
140
126
  exports.formulaNowDateTimeParamPlaceholder = formulaNowDateTimeParamPlaceholder;
141
127
  exports.formulaTodayDateParamPlaceholder = formulaTodayDateParamPlaceholder;
142
- exports.getFieldIdFromDynamicParam = getFieldIdFromDynamicParam;
143
- exports.isDynamicFilterParam = isDynamicFilterParam;
144
- exports.mapDynamicParams = mapDynamicParams;
145
128
  exports.monthAgoDateParamPlaceholder = monthAgoDateParamPlaceholder;
146
129
  exports.monthAgoEndDateTimeParamPlaceholder = monthAgoEndDateTimeParamPlaceholder;
147
130
  exports.monthAgoStartDateTimeParamPlaceholder = monthAgoStartDateTimeParamPlaceholder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/expression-utils",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "utils for working with fibery api expressions",
5
5
  "exports": {
6
6
  ".": "./lib/expression-utils.js",
@@ -24,20 +24,20 @@
24
24
  ],
25
25
  "private": false,
26
26
  "dependencies": {
27
- "@fibery/helpers": "1.0.2",
28
27
  "lodash": "4.17.21",
29
- "moment": "2.29.4"
28
+ "moment": "2.29.4",
29
+ "@fibery/helpers": "1.0.3"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/core": "7.20.5",
33
- "@fibery/babel-preset": "7.2.0",
34
- "@fibery/eslint-config": "8.3.0",
35
33
  "jest": "27.5.1",
36
34
  "jest-junit": "13.0.0",
37
- "microbundle": "0.15.0"
35
+ "microbundle": "0.15.0",
36
+ "@fibery/babel-preset": "7.2.0",
37
+ "@fibery/eslint-config": "8.3.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@fibery/schema": "^8.1.0"
40
+ "@fibery/schema": "^8.1.11"
41
41
  },
42
42
  "jest": {
43
43
  "testEnvironment": "node",
@@ -1,20 +0,0 @@
1
- var _ = require('lodash');
2
-
3
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
4
-
5
- var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
6
-
7
- const getEntityQueryVariables = schema => {
8
- const grouped = ___default["default"].groupBy(schema.typeObjects.filter(x => x.isDomain), typeObject => typeObject.pluralTitle);
9
- return ___default["default"].flatten(Object.values(grouped).map(group => {
10
- return group.map(typeObject => ({
11
- typeObject,
12
- id: `entityQuery_${typeObject.id}`,
13
- title: group.length > 1 ? `${typeObject.pluralTitle} (${typeObject.nameParts.namespace})` : typeObject.pluralTitle,
14
- isCollection: true,
15
- description: `All Entities from "${typeObject.title}" Database`
16
- }));
17
- }));
18
- };
19
-
20
- exports.getEntityQueryVariables = getEntityQueryVariables;