@qrvey/utils 1.10.0-0 → 1.10.0-timezone-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/charts/adapters/endpointData.js +0 -3
- package/dist/cjs/charts/adapters/endpointData.js +0 -3
- package/dist/cjs/dates/adapters/ISOToNumericOffset.d.ts +6 -0
- package/dist/cjs/dates/adapters/ISOToNumericOffset.js +19 -0
- package/dist/cjs/dates/adapters/index.d.ts +2 -0
- package/dist/cjs/dates/adapters/index.js +2 -0
- package/dist/cjs/dates/adapters/numericOffsetToISO.d.ts +6 -0
- package/dist/cjs/dates/adapters/numericOffsetToISO.js +27 -0
- package/dist/cjs/dates/constants/ISO_8601_REGEX.d.ts +1 -0
- package/dist/cjs/dates/constants/ISO_8601_REGEX.js +4 -0
- package/dist/cjs/dates/constants/index.d.ts +1 -0
- package/dist/cjs/dates/constants/index.js +1 -0
- package/dist/cjs/dates/helpers/getDateByTimezone.d.ts +8 -0
- package/dist/cjs/dates/helpers/getDateByTimezone.js +39 -0
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.js +25 -0
- package/dist/cjs/dates/helpers/getTimezoneObject.d.ts +4 -0
- package/dist/cjs/dates/helpers/getTimezoneObject.js +24 -0
- package/dist/cjs/dates/helpers/index.d.ts +3 -1
- package/dist/cjs/dates/helpers/index.js +3 -1
- package/dist/cjs/dates/helpers/isValidISOOffset.d.ts +7 -0
- package/dist/cjs/dates/helpers/isValidISOOffset.js +17 -0
- package/dist/cjs/dates/interfaces/IDTimezone.d.ts +4 -0
- package/dist/cjs/dates/interfaces/IDTimezone.js +2 -0
- package/dist/cjs/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
- package/dist/cjs/dates/interfaces/IDTimezoneOffset.js +2 -0
- package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
- package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.js +2 -0
- package/dist/cjs/dates/interfaces/index.d.ts +3 -0
- package/dist/cjs/dates/interfaces/index.js +3 -0
- package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/cjs/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
- package/dist/cjs/filters/helpers/common/getFiltersByTimezone.js +26 -0
- package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/index.js +1 -0
- package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/cjs/format/format.d.ts +1 -1
- package/dist/cjs/format/format.js +10 -4
- package/dist/cjs/general/index.d.ts +1 -0
- package/dist/cjs/general/index.js +1 -0
- package/dist/cjs/general/numeric/getSign.d.ts +6 -0
- package/dist/cjs/general/numeric/getSign.js +12 -0
- package/dist/cjs/general/numeric/index.d.ts +1 -0
- package/dist/cjs/general/numeric/index.js +17 -0
- package/dist/cjs/general/object/applyTimezoneDeep.d.ts +8 -0
- package/dist/cjs/general/object/applyTimezoneDeep.js +43 -0
- package/dist/cjs/general/object/index.d.ts +1 -0
- package/dist/cjs/general/object/index.js +1 -0
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/cjs/interfaces/general/IWidgetConfig.d.ts +2 -1
- package/dist/cjs/qrvey/helpers/transformValue.js +34 -6
- package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/IBModel.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/IBTimezone.d.ts +4 -0
- package/dist/cjs/qrvey/interfaces/IBTimezone.js +2 -0
- package/dist/cjs/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/cjs/qrvey/interfaces/IModel.d.ts +3 -1
- package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +6 -0
- package/dist/cjs/qrvey/interfaces/index.d.ts +1 -0
- package/dist/cjs/qrvey/interfaces/index.js +1 -0
- package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +2 -0
- package/dist/cjs/services/adapters/BModelToUIModel.adapter.js +2 -0
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.d.ts +3 -0
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.js +9 -0
- package/dist/cjs/services/helpers/Request.d.ts +1 -1
- package/dist/cjs/services/helpers/Request.js +11 -5
- package/dist/dates/adapters/ISOToNumericOffset.d.ts +6 -0
- package/dist/dates/adapters/ISOToNumericOffset.js +15 -0
- package/dist/dates/adapters/index.d.ts +2 -0
- package/dist/dates/adapters/index.js +2 -0
- package/dist/dates/adapters/numericOffsetToISO.d.ts +6 -0
- package/dist/dates/adapters/numericOffsetToISO.js +23 -0
- package/dist/dates/constants/ISO_8601_REGEX.d.ts +1 -0
- package/dist/dates/constants/ISO_8601_REGEX.js +1 -0
- package/dist/dates/constants/index.d.ts +1 -0
- package/dist/dates/constants/index.js +1 -0
- package/dist/dates/helpers/getDateByTimezone.d.ts +8 -0
- package/dist/dates/helpers/getDateByTimezone.js +35 -0
- package/dist/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
- package/dist/dates/helpers/getDateByTimezoneOffset.js +21 -0
- package/dist/dates/helpers/getTimezoneObject.d.ts +4 -0
- package/dist/dates/helpers/getTimezoneObject.js +20 -0
- package/dist/dates/helpers/index.d.ts +3 -1
- package/dist/dates/helpers/index.js +3 -1
- package/dist/dates/helpers/isValidISOOffset.d.ts +7 -0
- package/dist/dates/helpers/isValidISOOffset.js +13 -0
- package/dist/dates/interfaces/IDTimezone.d.ts +4 -0
- package/dist/dates/interfaces/IDTimezone.js +1 -0
- package/dist/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
- package/dist/dates/interfaces/IDTimezoneOffset.js +1 -0
- package/dist/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
- package/dist/dates/interfaces/IGetDateByTimezoneSettings.js +1 -0
- package/dist/dates/interfaces/index.d.ts +3 -0
- package/dist/dates/interfaces/index.js +3 -0
- package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
- package/dist/filters/helpers/common/getFiltersByTimezone.js +22 -0
- package/dist/filters/helpers/common/index.d.ts +1 -0
- package/dist/filters/helpers/common/index.js +1 -0
- package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/format/format.d.ts +1 -1
- package/dist/format/format.js +10 -4
- package/dist/general/index.d.ts +1 -0
- package/dist/general/index.js +1 -0
- package/dist/general/numeric/getSign.d.ts +6 -0
- package/dist/general/numeric/getSign.js +8 -0
- package/dist/general/numeric/index.d.ts +1 -0
- package/dist/general/numeric/index.js +1 -0
- package/dist/general/object/applyTimezoneDeep.d.ts +8 -0
- package/dist/general/object/applyTimezoneDeep.js +39 -0
- package/dist/general/object/index.d.ts +1 -0
- package/dist/general/object/index.js +1 -0
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/interfaces/general/IWidgetConfig.d.ts +2 -1
- package/dist/qrvey/helpers/transformValue.js +34 -6
- package/dist/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/qrvey/interfaces/IBModel.d.ts +2 -0
- package/dist/qrvey/interfaces/IBTimezone.d.ts +4 -0
- package/dist/qrvey/interfaces/IBTimezone.js +1 -0
- package/dist/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/qrvey/interfaces/IModel.d.ts +3 -1
- package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +6 -0
- package/dist/qrvey/interfaces/index.d.ts +1 -0
- package/dist/qrvey/interfaces/index.js +1 -0
- package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +2 -0
- package/dist/services/adapters/BModelToUIModel.adapter.js +2 -0
- package/dist/services/adapters/BTimezoneToUITimezone.d.ts +3 -0
- package/dist/services/adapters/BTimezoneToUITimezone.js +5 -0
- package/dist/services/helpers/Request.d.ts +1 -1
- package/dist/services/helpers/Request.js +11 -5
- package/package.json +5 -5
- package/dist/cjs/dates/helpers/adjustTimezone.d.ts +0 -6
- package/dist/cjs/dates/helpers/adjustTimezone.js +0 -19
- package/dist/dates/helpers/adjustTimezone.d.ts +0 -6
- package/dist/dates/helpers/adjustTimezone.js +0 -15
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyTimezoneDeep = void 0;
|
|
4
|
+
const DATE_FORMAT_1 = require("../../dates/constants/DATE_FORMAT");
|
|
5
|
+
const DATE_GROUPING_TIME_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_TIME_PROPERTY");
|
|
6
|
+
const getDateByTimezone_1 = require("../../dates/helpers/getDateByTimezone");
|
|
7
|
+
const validateDate_1 = require("../../dates/helpers/validateDate");
|
|
8
|
+
const isEmpty_1 = require("../mix/isEmpty");
|
|
9
|
+
const isObject_1 = require("./isObject");
|
|
10
|
+
/**
|
|
11
|
+
* Transforms the date+times propertiesof the given object by the Timezone object
|
|
12
|
+
* @param {any} obj the object
|
|
13
|
+
* @param {IDTimezone} timezone the timezone object
|
|
14
|
+
* @returns {IFSData | IFUData} the new filter data with the transformed datetime values
|
|
15
|
+
*/
|
|
16
|
+
function applyTimezoneDeep(obj, timezone) {
|
|
17
|
+
if ((0, isEmpty_1.isEmpty)(obj))
|
|
18
|
+
return obj;
|
|
19
|
+
const result = {};
|
|
20
|
+
try {
|
|
21
|
+
for (const i in obj) {
|
|
22
|
+
if ((0, isObject_1.isObject)(obj[i])) {
|
|
23
|
+
result[i] = applyTimezoneDeep(obj[i], timezone);
|
|
24
|
+
}
|
|
25
|
+
else if (obj[i] instanceof Date ||
|
|
26
|
+
!isNaN(obj[i]) ||
|
|
27
|
+
(0, validateDate_1.validateDate)(obj[i], DATE_FORMAT_1.DATE_FORMAT.HOUR)) {
|
|
28
|
+
result[i] = (0, getDateByTimezone_1.getDateByTimezone)(obj[i], {
|
|
29
|
+
property: DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR,
|
|
30
|
+
timezone,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
result[i] = obj[i];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
catch (_a) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.applyTimezoneDeep = applyTimezoneDeep;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./applyTimezoneDeep"), exports);
|
|
17
18
|
__exportStar(require("./cloneDeep"), exports);
|
|
18
19
|
__exportStar(require("./get"), exports);
|
|
19
20
|
__exportStar(require("./getAttribute"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
1
2
|
import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
|
|
2
3
|
export interface IWidgetConfig {
|
|
3
4
|
appid?: string;
|
|
@@ -5,6 +6,6 @@ export interface IWidgetConfig {
|
|
|
5
6
|
domain: string;
|
|
6
7
|
i18n?: II18nConfig;
|
|
7
8
|
qv_token?: string;
|
|
8
|
-
|
|
9
|
+
timezone?: IDTimezone;
|
|
9
10
|
userid?: string;
|
|
10
11
|
}
|
|
@@ -10,6 +10,7 @@ const format_1 = require("../../format/format");
|
|
|
10
10
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
11
11
|
const getI18nDateGroupLabel_1 = require("../../globalization/helpers/getI18nDateGroupLabel");
|
|
12
12
|
const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
|
|
13
|
+
const getDateByTimezone_1 = require("../../dates/helpers/getDateByTimezone");
|
|
13
14
|
/**
|
|
14
15
|
* Transforms a value depending of localization/globalization and extras settings.
|
|
15
16
|
* @param value A value to transform
|
|
@@ -19,14 +20,41 @@ const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
|
|
|
19
20
|
function transformValue(value, settings) {
|
|
20
21
|
if ((0, isEmpty_1.isEmpty)(value))
|
|
21
22
|
return value;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const defaultSettings = getDefaultSettings(settings);
|
|
24
|
+
let timezonedValue = value;
|
|
25
|
+
if (!defaultSettings.noTimezone) {
|
|
26
|
+
timezonedValue = (0, getDateByTimezone_1.getDateByTimezone)(value, {
|
|
27
|
+
property: defaultSettings.property,
|
|
28
|
+
timezone: defaultSettings.timezone,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
let valueWithI18n = timezonedValue;
|
|
32
|
+
if (!defaultSettings.noTranslate) {
|
|
33
|
+
valueWithI18n = (0, getI18nDateGroupLabel_1.getI18nDateGroupLabel)(timezonedValue, defaultSettings.property, defaultSettings.translate);
|
|
34
|
+
}
|
|
35
|
+
let valueWithLocalization = valueWithI18n;
|
|
36
|
+
if (!defaultSettings.noLocale) {
|
|
37
|
+
valueWithLocalization = (0, format_1.addFormat)(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
|
|
38
|
+
}
|
|
39
|
+
let valueWithSuffix = valueWithI18n;
|
|
40
|
+
if (!defaultSettings.noSuffix) {
|
|
41
|
+
valueWithSuffix = (0, getValueWithSuffixes_1.getValueWithSuffixes)(valueWithLocalization, {
|
|
42
|
+
suffixTranslateLabel: defaultSettings.suffixTranslateLabel,
|
|
43
|
+
translate: defaultSettings.translate,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return valueWithSuffix;
|
|
28
47
|
}
|
|
29
48
|
exports.transformValue = transformValue;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the default settings properties
|
|
51
|
+
* @param {ITransformValueSettings} settings the given settings
|
|
52
|
+
* @returns {ITransformValueSettings} the settings with default properties
|
|
53
|
+
*/
|
|
54
|
+
function getDefaultSettings(settings) {
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
|
+
return Object.assign(Object.assign({}, settings), { noLocale: (_a = settings === null || settings === void 0 ? void 0 : settings.noLocale) !== null && _a !== void 0 ? _a : false, noSuffix: (_b = settings === null || settings === void 0 ? void 0 : settings.noSuffix) !== null && _b !== void 0 ? _b : false, noTimezone: (_c = settings === null || settings === void 0 ? void 0 : settings.noTimezone) !== null && _c !== void 0 ? _c : false, noTranslate: (_d = settings === null || settings === void 0 ? void 0 : settings.noTranslate) !== null && _d !== void 0 ? _d : false });
|
|
57
|
+
}
|
|
30
58
|
/**
|
|
31
59
|
* Gets the outputformat settings
|
|
32
60
|
* @param settings The settings of the transformValue function
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IBColumn } from "../../columns/interfaces/IBColumn";
|
|
2
|
+
import { IBTimezone } from "./IBTimezone";
|
|
2
3
|
/**
|
|
3
4
|
* Structure for Dataset in the frontend side of Qrvey App
|
|
4
5
|
*/
|
|
@@ -7,4 +8,5 @@ export interface IBDataset {
|
|
|
7
8
|
name?: string;
|
|
8
9
|
options?: IBColumn[];
|
|
9
10
|
qrveyid: string;
|
|
11
|
+
timezone?: IBTimezone;
|
|
10
12
|
}
|
|
@@ -2,6 +2,7 @@ import { IAppStatus } from "./IAppStatus";
|
|
|
2
2
|
import { IBModelBranchesMap } from "./IBModelBranchesMap";
|
|
3
3
|
import { IBModelData } from "./IBModelData";
|
|
4
4
|
import { IAppType } from "./IAppType";
|
|
5
|
+
import { IBTimezone } from "./IBTimezone";
|
|
5
6
|
export interface IBModel {
|
|
6
7
|
appType: IAppType;
|
|
7
8
|
appid: string;
|
|
@@ -16,5 +17,6 @@ export interface IBModel {
|
|
|
16
17
|
questionOrder: string[];
|
|
17
18
|
questions: IBModelData;
|
|
18
19
|
status: IAppStatus;
|
|
20
|
+
timezone: IBTimezone;
|
|
19
21
|
userid: string;
|
|
20
22
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
3
|
import { IBDataset } from "./IBDataset";
|
|
3
4
|
/**
|
|
4
5
|
* Structure for Dataset in the frontend side of Qrvey App
|
|
5
6
|
*/
|
|
6
|
-
export interface IDataset extends Omit<IBDataset, "name" | "options"> {
|
|
7
|
+
export interface IDataset extends Omit<IBDataset, "name" | "options" | "timezone"> {
|
|
7
8
|
label?: string;
|
|
8
9
|
options?: IColumn[];
|
|
10
|
+
timezone?: IDTimezone;
|
|
9
11
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
3
|
import { IBModel } from "./IBModel";
|
|
3
4
|
import { IModelBranchesMap } from "./IModelBranchesMap";
|
|
4
|
-
export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder"> {
|
|
5
|
+
export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder" | "timezone"> {
|
|
5
6
|
columns: IColumn[];
|
|
6
7
|
columnOrder: string[];
|
|
7
8
|
branchesMap: IModelBranchesMap[];
|
|
8
9
|
label: string;
|
|
10
|
+
timezone: IDTimezone;
|
|
9
11
|
totalRecords: number;
|
|
10
12
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
2
|
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
3
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
3
4
|
import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
|
|
4
5
|
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
5
6
|
export interface ITransformValueSettings {
|
|
6
7
|
column: IColumn;
|
|
7
8
|
property: IColumnPropertyType;
|
|
9
|
+
timezone?: IDTimezone;
|
|
8
10
|
translate: II18nServiceTranslate;
|
|
9
11
|
i18n: II18nConfig;
|
|
10
12
|
suffixTranslateLabel?: string;
|
|
13
|
+
noLocale?: boolean;
|
|
14
|
+
noTranslate?: boolean;
|
|
15
|
+
noSuffix?: boolean;
|
|
16
|
+
noTimezone?: boolean;
|
|
11
17
|
}
|
|
@@ -4,6 +4,7 @@ export * from "./IBDataset";
|
|
|
4
4
|
export * from "./IBModel";
|
|
5
5
|
export * from "./IBModelBranchesMapBranch";
|
|
6
6
|
export * from "./IBModelData";
|
|
7
|
+
export * from "./IBTimezone";
|
|
7
8
|
export * from "./ICalculation";
|
|
8
9
|
export * from "./ICalculationInfo";
|
|
9
10
|
export * from "./ICalculationType";
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./IBDataset"), exports);
|
|
|
20
20
|
__exportStar(require("./IBModel"), exports);
|
|
21
21
|
__exportStar(require("./IBModelBranchesMapBranch"), exports);
|
|
22
22
|
__exportStar(require("./IBModelData"), exports);
|
|
23
|
+
__exportStar(require("./IBTimezone"), exports);
|
|
23
24
|
__exportStar(require("./ICalculation"), exports);
|
|
24
25
|
__exportStar(require("./ICalculationInfo"), exports);
|
|
25
26
|
__exportStar(require("./ICalculationType"), exports);
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BDatasetsToUIDatasets = void 0;
|
|
4
4
|
const getAttribute_1 = require("../../general/object/getAttribute");
|
|
5
5
|
const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
|
|
6
|
+
const BTimezoneToUITimezone_1 = require("./BTimezoneToUITimezone");
|
|
6
7
|
function BDatasetsToUIDatasets(datasets = []) {
|
|
7
8
|
return datasets.map((dataset) => ({
|
|
8
9
|
qrveyid: (0, getAttribute_1.getAttribute)(dataset, "qrvey_id"),
|
|
9
10
|
label: dataset.name,
|
|
10
11
|
options: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(dataset.options, dataset),
|
|
12
|
+
timezone: (0, BTimezoneToUITimezone_1.BTimezoneToUITimezone)(dataset.timezone),
|
|
11
13
|
}));
|
|
12
14
|
}
|
|
13
15
|
exports.BDatasetsToUIDatasets = BDatasetsToUIDatasets;
|
|
@@ -4,6 +4,7 @@ exports.BModelToUIModel = void 0;
|
|
|
4
4
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
5
5
|
const BBranchesMapToUIBranchesMap_adapter_1 = require("./BBranchesMapToUIBranchesMap.adapter");
|
|
6
6
|
const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
|
|
7
|
+
const BTimezoneToUITimezone_1 = require("./BTimezoneToUITimezone");
|
|
7
8
|
function BModelToUIModel(model) {
|
|
8
9
|
if ((0, isEmpty_1.isEmpty)(model))
|
|
9
10
|
return;
|
|
@@ -23,6 +24,7 @@ function BModelToUIModel(model) {
|
|
|
23
24
|
totalRecords: model.numResponses,
|
|
24
25
|
qrveyid: model.qrveyid,
|
|
25
26
|
status: model.status,
|
|
27
|
+
timezone: (0, BTimezoneToUITimezone_1.BTimezoneToUITimezone)(model.timezone),
|
|
26
28
|
userid: model.userid,
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BTimezoneToUITimezone = void 0;
|
|
4
|
+
function BTimezoneToUITimezone(timezone) {
|
|
5
|
+
return {
|
|
6
|
+
offset: timezone.offset || timezone.numericOffset,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
exports.BTimezoneToUITimezone = BTimezoneToUITimezone;
|
|
@@ -2,7 +2,7 @@ export default class Request {
|
|
|
2
2
|
static checkStatus(response: any): Promise<any>;
|
|
3
3
|
static hasQvToken(config: any): boolean;
|
|
4
4
|
static getQvToken(config: any): any;
|
|
5
|
-
static
|
|
5
|
+
static getTimezoneOffset(config: any): string;
|
|
6
6
|
static hasApiKey(config: any): boolean;
|
|
7
7
|
static getApiKey(config: any): any;
|
|
8
8
|
static makeUrl(config: any, url: any, params?: any): string;
|
|
@@ -9,6 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const numericOffsetToISO_1 = require("../../dates/adapters/numericOffsetToISO");
|
|
13
|
+
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
12
14
|
const getAttribute_1 = require("../../general/object/getAttribute");
|
|
13
15
|
const serialize_1 = require("../../general/object/serialize");
|
|
14
16
|
const parseUrl_1 = require("../../general/string/parseUrl");
|
|
@@ -26,8 +28,12 @@ class Request {
|
|
|
26
28
|
static getQvToken(config) {
|
|
27
29
|
return (0, getAttribute_1.getAttribute)(config, "qv_token");
|
|
28
30
|
}
|
|
29
|
-
static
|
|
30
|
-
|
|
31
|
+
static getTimezoneOffset(config) {
|
|
32
|
+
var _a;
|
|
33
|
+
const timezoneOffset = (_a = config.timezone) === null || _a === void 0 ? void 0 : _a.offset;
|
|
34
|
+
if (!(0, isEmpty_1.isEmpty)(timezoneOffset)) {
|
|
35
|
+
return (0, numericOffsetToISO_1.numericOffsetToISO)(timezoneOffset);
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
static hasApiKey(config) {
|
|
33
39
|
return !!this.getApiKey(config);
|
|
@@ -70,9 +76,9 @@ class Request {
|
|
|
70
76
|
cfg.credentials = "include";
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
cfg.headers["q-timezone-control"] = `offset=${
|
|
79
|
+
const timezoneOffset = this.getTimezoneOffset(reqData.config);
|
|
80
|
+
if (timezoneOffset) {
|
|
81
|
+
cfg.headers["q-timezone-control"] = `offset=${timezoneOffset}`;
|
|
76
82
|
}
|
|
77
83
|
// AbortSignal (https://developers.google.com/web/updates/2017/09/abortable-fetch)
|
|
78
84
|
if (reqData.config && reqData.config.signal) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
2
|
+
import { isValidISOOffset } from "../helpers/isValidISOOffset";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the numeric offset (minutes) from the ISO offset (string)
|
|
5
|
+
* @param {string} offset the timezone offset
|
|
6
|
+
* @returns {number} the offset in minutes
|
|
7
|
+
*/
|
|
8
|
+
export function ISOToNumericOffset(offset) {
|
|
9
|
+
if (typeof offset === "number" || !isNaNV2(offset))
|
|
10
|
+
return +offset;
|
|
11
|
+
if (!isValidISOOffset(offset))
|
|
12
|
+
return 0;
|
|
13
|
+
const [hours, minutes] = offset.split(":").map(Number);
|
|
14
|
+
return hours * 60 + minutes;
|
|
15
|
+
}
|
|
@@ -5,8 +5,10 @@ export * from "./dateToQuarterYear";
|
|
|
5
5
|
export * from "./dateToWeekYear";
|
|
6
6
|
export * from "./dateToYear";
|
|
7
7
|
export * from "./hmsToDate";
|
|
8
|
+
export * from "./ISOToNumericOffset";
|
|
8
9
|
export * from "./mdyDateToDate";
|
|
9
10
|
export * from "./monthYearToDate";
|
|
11
|
+
export * from "./numericOffsetToISO";
|
|
10
12
|
export * from "./quarterYearToDate";
|
|
11
13
|
export * from "./weekYearToDate";
|
|
12
14
|
export * from "./yearToDate";
|
|
@@ -5,8 +5,10 @@ export * from "./dateToQuarterYear";
|
|
|
5
5
|
export * from "./dateToWeekYear";
|
|
6
6
|
export * from "./dateToYear";
|
|
7
7
|
export * from "./hmsToDate";
|
|
8
|
+
export * from "./ISOToNumericOffset";
|
|
8
9
|
export * from "./mdyDateToDate";
|
|
9
10
|
export * from "./monthYearToDate";
|
|
11
|
+
export * from "./numericOffsetToISO";
|
|
10
12
|
export * from "./quarterYearToDate";
|
|
11
13
|
export * from "./weekYearToDate";
|
|
12
14
|
export * from "./yearToDate";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
2
|
+
import { getSign } from "../../general/numeric/getSign";
|
|
3
|
+
import { padLeadingZeros } from "../../general/string/padLeadingZeros";
|
|
4
|
+
import { isValidISOOffset } from "../helpers/isValidISOOffset";
|
|
5
|
+
/**
|
|
6
|
+
* Gets the ISO offset From the numeric offset (minutes)
|
|
7
|
+
* @param {number} offset the timezone offset
|
|
8
|
+
* @returns {string} the offset in minutes
|
|
9
|
+
*/
|
|
10
|
+
export function numericOffsetToISO(offset) {
|
|
11
|
+
let newOffset = offset;
|
|
12
|
+
if (typeof offset === "string" && isValidISOOffset(offset))
|
|
13
|
+
return String(newOffset);
|
|
14
|
+
if (typeof offset !== "number" && isNaNV2(offset))
|
|
15
|
+
return "+00:00";
|
|
16
|
+
if (typeof offset === "string" && !isNaNV2(offset))
|
|
17
|
+
newOffset = +offset;
|
|
18
|
+
const sign = getSign(newOffset);
|
|
19
|
+
newOffset = Math.abs(newOffset);
|
|
20
|
+
const hours = padLeadingZeros(Math.floor(newOffset / 60), 2);
|
|
21
|
+
const minutes = padLeadingZeros(newOffset % 60, 2);
|
|
22
|
+
return `${sign}${hours}:${minutes}`;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ISO_8601_REGEX: RegExp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ISO_8601_REGEX = /^[+-]?\d{2}:\d{2}$/;
|
|
@@ -38,6 +38,7 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
|
|
|
38
38
|
export * from "./DATE_YEAR_QUARTERS";
|
|
39
39
|
export * from "./DATE_YEAR_QUARTERS_RANGE";
|
|
40
40
|
export * from "./DATETIME_COLUMN_FORMAT";
|
|
41
|
+
export * from "./ISO_8601_REGEX";
|
|
41
42
|
export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
|
|
42
43
|
export * from "./TIME_GROUPING_PROPERTY_INFO";
|
|
43
44
|
export * from "./TIME_GROUPING_PROPERTY_LABEL";
|
|
@@ -38,6 +38,7 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
|
|
|
38
38
|
export * from "./DATE_YEAR_QUARTERS";
|
|
39
39
|
export * from "./DATE_YEAR_QUARTERS_RANGE";
|
|
40
40
|
export * from "./DATETIME_COLUMN_FORMAT";
|
|
41
|
+
export * from "./ISO_8601_REGEX";
|
|
41
42
|
export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
|
|
42
43
|
export * from "./TIME_GROUPING_PROPERTY_INFO";
|
|
43
44
|
export * from "./TIME_GROUPING_PROPERTY_LABEL";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IGetDateByTimezoneSettings } from "../interfaces/IGetDateByTimezoneSettings";
|
|
2
|
+
/**
|
|
3
|
+
* Gets a date value in the given timezone
|
|
4
|
+
* @param {string} date the date
|
|
5
|
+
* @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
|
|
6
|
+
* @returns {string} A transformed value
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDateByTimezone(date: string, settings: IGetDateByTimezoneSettings): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { DATE_GROUPING_TIME_PROPERTY } from "../constants/DATE_GROUPING_TIME_PROPERTY";
|
|
3
|
+
import { getDateByDateFormat } from "./getDateByDateFormat";
|
|
4
|
+
import { getDateByTimezoneOffset } from "./getDateByTimezoneOffset";
|
|
5
|
+
import { getDateFormatByProperty } from "./getDateFormatByProperty";
|
|
6
|
+
import { getFormattedDateByFormat } from "./getFormattedDateByFormat";
|
|
7
|
+
/**
|
|
8
|
+
* Gets a date value in the given timezone
|
|
9
|
+
* @param {string} date the date
|
|
10
|
+
* @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
|
|
11
|
+
* @returns {string} A transformed value
|
|
12
|
+
*/
|
|
13
|
+
export function getDateByTimezone(date, settings) {
|
|
14
|
+
const defaultSettings = getDefaultSettings(settings);
|
|
15
|
+
const isDateTime = [
|
|
16
|
+
DATE_GROUPING_TIME_PROPERTY.HOUR,
|
|
17
|
+
DATE_GROUPING_TIME_PROPERTY.MINUTE,
|
|
18
|
+
DATE_GROUPING_TIME_PROPERTY.SECOND,
|
|
19
|
+
].includes(defaultSettings.property);
|
|
20
|
+
if (!isEmpty(defaultSettings.timezone.offset) && isDateTime) {
|
|
21
|
+
const dateFormat = getDateFormatByProperty(defaultSettings.property);
|
|
22
|
+
const formattedDate = getDateByDateFormat(date, dateFormat);
|
|
23
|
+
const timezonedDate = getDateByTimezoneOffset(formattedDate, defaultSettings.timezone.offset);
|
|
24
|
+
return getFormattedDateByFormat(timezonedDate, dateFormat);
|
|
25
|
+
}
|
|
26
|
+
return date;
|
|
27
|
+
}
|
|
28
|
+
function getDefaultSettings(settings) {
|
|
29
|
+
return {
|
|
30
|
+
property: settings.property,
|
|
31
|
+
timezone: (settings === null || settings === void 0 ? void 0 : settings.timezone) || {
|
|
32
|
+
offset: undefined,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets a Date with the given offset of the Timezone.
|
|
3
|
+
* No given an offset the default is going to be set by the browser
|
|
4
|
+
* @param date String, object or millisencond number of the date
|
|
5
|
+
* @returns updated Date object
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): Date;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { ISOToNumericOffset } from "../adapters/ISOToNumericOffset";
|
|
3
|
+
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { isValidPotentialDate } from "./isValidPotentialDate";
|
|
5
|
+
import { validateDate } from "./validateDate";
|
|
6
|
+
/**
|
|
7
|
+
* Gets a Date with the given offset of the Timezone.
|
|
8
|
+
* No given an offset the default is going to be set by the browser
|
|
9
|
+
* @param date String, object or millisencond number of the date
|
|
10
|
+
* @returns updated Date object
|
|
11
|
+
*/
|
|
12
|
+
export function getDateByTimezoneOffset(date, offset) {
|
|
13
|
+
if (!isValidPotentialDate(date) ||
|
|
14
|
+
(typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
|
|
15
|
+
return date;
|
|
16
|
+
const dt = new Date(date.valueOf());
|
|
17
|
+
const newOffset = isEmpty(offset) || offset === "browser"
|
|
18
|
+
? dt.getTimezoneOffset()
|
|
19
|
+
: ISOToNumericOffset(offset);
|
|
20
|
+
return new Date(+dt + newOffset * 1000 * 60);
|
|
21
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
2
|
+
import { IModel } from "../../qrvey/interfaces/IModel";
|
|
3
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
4
|
+
export declare function getTimezoneObject(timezone: IDTimezone, model: IModel | IDataset): IDTimezone;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
export function getTimezoneObject(timezone, model) {
|
|
3
|
+
var _a;
|
|
4
|
+
let newTimezone = {
|
|
5
|
+
offset: "+00:00",
|
|
6
|
+
};
|
|
7
|
+
if (isEmpty(timezone)) {
|
|
8
|
+
if (!isEmpty(model)) {
|
|
9
|
+
newTimezone = {
|
|
10
|
+
offset: ((_a = model.timezone) === null || _a === void 0 ? void 0 : _a.offset) || newTimezone.offset,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
newTimezone = {
|
|
16
|
+
offset: (timezone === null || timezone === void 0 ? void 0 : timezone.offset) || newTimezone.offset,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return newTimezone;
|
|
20
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
export * from "./adjustTimezone";
|
|
2
1
|
export * from "./areIncludedDateTokens";
|
|
3
2
|
export * from "./getDateByDateFormat";
|
|
3
|
+
export * from "./getDateByTimezone";
|
|
4
4
|
export * from "./getDateFormatByProperty";
|
|
5
5
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
6
|
export * from "./getDatePickerPickLevel";
|
|
7
7
|
export * from "./getDateRange";
|
|
8
8
|
export * from "./getFormattedDateByFormat";
|
|
9
9
|
export * from "./getSeparatorByDateFormat";
|
|
10
|
+
export * from "./getTimezoneObject";
|
|
10
11
|
export * from "./getWeek";
|
|
11
12
|
export * from "./isValidDateObject";
|
|
12
13
|
export * from "./isValidPotentialDate";
|
|
14
|
+
export * from "./getDateByTimezoneOffset";
|
|
13
15
|
export * from "./validateDate";
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
export * from "./adjustTimezone";
|
|
2
1
|
export * from "./areIncludedDateTokens";
|
|
3
2
|
export * from "./getDateByDateFormat";
|
|
3
|
+
export * from "./getDateByTimezone";
|
|
4
4
|
export * from "./getDateFormatByProperty";
|
|
5
5
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
6
|
export * from "./getDatePickerPickLevel";
|
|
7
7
|
export * from "./getDateRange";
|
|
8
8
|
export * from "./getFormattedDateByFormat";
|
|
9
9
|
export * from "./getSeparatorByDateFormat";
|
|
10
|
+
export * from "./getTimezoneObject";
|
|
10
11
|
export * from "./getWeek";
|
|
11
12
|
export * from "./isValidDateObject";
|
|
12
13
|
export * from "./isValidPotentialDate";
|
|
14
|
+
export * from "./getDateByTimezoneOffset";
|
|
13
15
|
export * from "./validateDate";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate if offset uses a valid ISO 8601 offset specification
|
|
3
|
+
* - If the given offset is a numeric, returns an invalid flag.
|
|
4
|
+
* @param {string} offset the timezone offset
|
|
5
|
+
* @returns {boolean} true if the given offset is valid
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidISOOffset(offset: number | string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ISO_8601_REGEX } from "../constants/ISO_8601_REGEX";
|
|
2
|
+
/**
|
|
3
|
+
* Validate if offset uses a valid ISO 8601 offset specification
|
|
4
|
+
* - If the given offset is a numeric, returns an invalid flag.
|
|
5
|
+
* @param {string} offset the timezone offset
|
|
6
|
+
* @returns {boolean} true if the given offset is valid
|
|
7
|
+
*/
|
|
8
|
+
export function isValidISOOffset(offset) {
|
|
9
|
+
if (typeof offset !== "string")
|
|
10
|
+
return false;
|
|
11
|
+
const newOffset = (offset || "").trim();
|
|
12
|
+
return ISO_8601_REGEX.test(newOffset);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type IDTimezoneOffset = number | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|