@agnostack/next-shopify 1.13.5 → 1.13.6-beta.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/CHANGELOG.md +25 -6
- package/dist/lib/handlers/api/graph.d.ts.map +1 -1
- package/dist/lib/handlers/api/graph.js +84 -79
- package/dist/lib/handlers/api/graph.js.map +1 -1
- package/dist/lib/handlers/api/proxy.d.ts.map +1 -1
- package/dist/lib/handlers/api/proxy.js +115 -149
- package/dist/lib/handlers/api/proxy.js.map +1 -1
- package/dist/lib/handlers/api/rest.d.ts.map +1 -1
- package/dist/lib/handlers/api/rest.js +70 -65
- package/dist/lib/handlers/api/rest.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +5 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.js +1 -0
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/session.d.ts.map +1 -1
- package/dist/lib/utils/session.js +2 -2
- package/dist/lib/utils/session.js.map +1 -1
- package/dist/lib/utils/verification.d.ts +2 -0
- package/dist/lib/utils/verification.d.ts.map +1 -0
- package/dist/lib/utils/verification.js +69 -0
- package/dist/lib/utils/verification.js.map +1 -0
- package/dist/react/hooks/index.d.ts +2 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.js +5 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/hooks/useVerification.d.ts +9 -0
- package/dist/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/react/hooks/useVerification.js +63 -0
- package/dist/react/hooks/useVerification.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/types.d.ts +1 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +1 -0
- package/dist/react/types.js.map +1 -0
- package/dist/shared/datetime.d.ts +96 -0
- package/dist/shared/datetime.d.ts.map +1 -0
- package/dist/shared/datetime.js +285 -0
- package/dist/shared/datetime.js.map +1 -0
- package/dist/shared/display.d.ts +88 -23
- package/dist/shared/display.d.ts.map +1 -1
- package/dist/shared/display.js +409 -104
- package/dist/shared/display.js.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/shopify.d.ts +0 -6
- package/dist/shared/shopify.d.ts.map +1 -1
- package/dist/shared/shopify.js +1 -28
- package/dist/shared/shopify.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export const TIME_FORMAT_LONG: "HH:mm";
|
|
2
|
+
export const TIME_FORMAT_AMPM: "h:mm a";
|
|
3
|
+
export const DATE_FORMAT_MED: "M/d/yyyy";
|
|
4
|
+
export const DATE_FORMAT_LONG: "MM/dd/yyyy";
|
|
5
|
+
export const DATE_FORMAT_TRACKING: "MMddyyyy";
|
|
6
|
+
export const DATE_FORMAT_ORGANIZED: "yyyy-MM-dd";
|
|
7
|
+
export namespace CUSTOM_FORMATS {
|
|
8
|
+
const UTC: string;
|
|
9
|
+
const ISO: string;
|
|
10
|
+
const UNIX: string;
|
|
11
|
+
}
|
|
12
|
+
export namespace LOCALE_FORMATS {
|
|
13
|
+
export { DATE_MINI };
|
|
14
|
+
export { DATE_SHORT };
|
|
15
|
+
export { DATE_MED };
|
|
16
|
+
export { DATE_FULL };
|
|
17
|
+
export { DATE_HUGE };
|
|
18
|
+
export { DATETIME_MINI };
|
|
19
|
+
export { DATETIME_SHORT };
|
|
20
|
+
export { DATETIME_MED };
|
|
21
|
+
export { DATETIME_MED_WITH_SECONDS };
|
|
22
|
+
export { DATETIME_FULL_NO_ZONE };
|
|
23
|
+
export { DATETIME_HUGE_NO_ZONE };
|
|
24
|
+
export { TIME_SIMPLE };
|
|
25
|
+
}
|
|
26
|
+
export function getDaysInMonth(year: any, month: any): number;
|
|
27
|
+
export function setDateTimeLocale(locale: any): void;
|
|
28
|
+
export function setDateTimeZone(zone: any): void;
|
|
29
|
+
export function getDateTimeFormat({ locale, mappings }?: {
|
|
30
|
+
locale: any;
|
|
31
|
+
mappings?: {
|
|
32
|
+
day: string;
|
|
33
|
+
month: string;
|
|
34
|
+
year: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
}): any;
|
|
37
|
+
export function getDateTimeFromString({ format, value, ...options }?: {
|
|
38
|
+
format: any;
|
|
39
|
+
value: any;
|
|
40
|
+
}): any;
|
|
41
|
+
export function convertDateTime(value: any, { shouldThrow, shouldLog, ...options }?: {
|
|
42
|
+
shouldThrow?: boolean | undefined;
|
|
43
|
+
shouldLog?: any;
|
|
44
|
+
}): any;
|
|
45
|
+
export function convertDuration(value: any, { shouldThrow, ...options }?: {
|
|
46
|
+
shouldThrow?: boolean | undefined;
|
|
47
|
+
}): any;
|
|
48
|
+
export function getDuration(dt1: any, dt2: any): any;
|
|
49
|
+
export function getCurrentDateTime(): any;
|
|
50
|
+
export function getDaysBetween(dt1: any, dt2: any): number;
|
|
51
|
+
export function getWeeksBetween(dt1: any, dt2: any): number;
|
|
52
|
+
export function isSameHour(dt1: any, dt2: any): boolean;
|
|
53
|
+
export function isSameDay(dt1: any, dt2: any): boolean;
|
|
54
|
+
export function ensureDateTime(value: any, options: any): any;
|
|
55
|
+
export function formatTimestamps(timestamps: any, defaultValue: any): {};
|
|
56
|
+
export function formatRequiredTimestamps({ created_at, updated_at, ...timestamps }?: {
|
|
57
|
+
created_at: any;
|
|
58
|
+
updated_at: any;
|
|
59
|
+
}): {
|
|
60
|
+
created_at: string;
|
|
61
|
+
updated_at: string;
|
|
62
|
+
};
|
|
63
|
+
export function toJSDate(value: any, options: any): any;
|
|
64
|
+
export function toUnixInteger(value: any, options: any): any;
|
|
65
|
+
export function toUnixString(value: any, options: any): string;
|
|
66
|
+
export function toISOString(value: any, options: any): any;
|
|
67
|
+
export function toUTCString(value: any, options: any): any;
|
|
68
|
+
export function toFormatted({ format, value, zone, ...options }?: {
|
|
69
|
+
format: any;
|
|
70
|
+
value: any;
|
|
71
|
+
zone: any;
|
|
72
|
+
}): any;
|
|
73
|
+
export function convertFormatted({ value, to: { format: toFormat, ...toOptions }, from: { format: fromFormat, ...fromOptions }, }?: {
|
|
74
|
+
value: any;
|
|
75
|
+
to?: {
|
|
76
|
+
format: any;
|
|
77
|
+
} | undefined;
|
|
78
|
+
from?: {
|
|
79
|
+
format: any;
|
|
80
|
+
} | undefined;
|
|
81
|
+
}): any;
|
|
82
|
+
export function compareDate(date1: any, date2: any): number;
|
|
83
|
+
declare const DATE_MINI: any;
|
|
84
|
+
declare const DATE_SHORT: any;
|
|
85
|
+
declare const DATE_MED: any;
|
|
86
|
+
declare const DATE_FULL: any;
|
|
87
|
+
declare const DATE_HUGE: any;
|
|
88
|
+
declare const DATETIME_MINI: any;
|
|
89
|
+
declare const DATETIME_SHORT: any;
|
|
90
|
+
declare const DATETIME_MED: any;
|
|
91
|
+
declare const DATETIME_MED_WITH_SECONDS: any;
|
|
92
|
+
declare const DATETIME_FULL_NO_ZONE: any;
|
|
93
|
+
declare const DATETIME_HUGE_NO_ZONE: any;
|
|
94
|
+
declare const TIME_SIMPLE: any;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=datetime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../src/shared/datetime.js"],"names":[],"mappings":"AAcA,uCAAuC;AACvC,wCAAwC;AAExC,yCAAyC;AACzC,4CAA4C;AAC5C,8CAA8C;AAC9C,iDAAiD;;;;;;;;;;;;;;;;;;;;AAqE1C,8DAEN;AAEM,qDAIN;AAEM,iDAIN;AAEM;;;;;;;QAUN;AAEM;;;QA4BN;AAEM;;;QA4CN;AAEM;;QAwDN;AAEM,qDAEN;AAEM,0CAEN;AAMM,2DAEN;AAEM,4DAEN;AAOM,wDAEN;AAEM,uDAEN;AAEM,8DAEN;AAEM,yEAKN;AAEM;;;;;;EAON;AAEM,wDAEN;AAEM,6DAEN;AAGM,+DAEN;AAGM,2DAEN;AAGM,2DAEN;AAGM;;;;QAqCN;AAEM;;;;;;;;QAkBN;AAEM,4DAEN;AAlWD,6BAGC;;;;;AAED,iCAGC"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareDate = exports.convertFormatted = exports.toFormatted = exports.toUTCString = exports.toISOString = exports.toUnixString = exports.toUnixInteger = exports.toJSDate = exports.formatRequiredTimestamps = exports.formatTimestamps = exports.ensureDateTime = exports.isSameDay = exports.isSameHour = exports.getWeeksBetween = exports.getDaysBetween = exports.getCurrentDateTime = exports.getDuration = exports.convertDuration = exports.convertDateTime = exports.getDateTimeFromString = exports.getDateTimeFormat = exports.setDateTimeZone = exports.setDateTimeLocale = exports.getDaysInMonth = exports.LOCALE_FORMATS = exports.CUSTOM_FORMATS = exports.DATE_FORMAT_ORGANIZED = exports.DATE_FORMAT_TRACKING = exports.DATE_FORMAT_LONG = exports.DATE_FORMAT_MED = exports.TIME_FORMAT_AMPM = exports.TIME_FORMAT_LONG = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable no-use-before-define */
|
|
6
|
+
const luxon_1 = require("luxon");
|
|
7
|
+
const display_1 = require("./display");
|
|
8
|
+
// TODO!!!: keep in sync between next-shopify and lib-core
|
|
9
|
+
// TODO: consolidate these to export as COMMON_FORMATS
|
|
10
|
+
exports.TIME_FORMAT_LONG = 'HH:mm';
|
|
11
|
+
exports.TIME_FORMAT_AMPM = 'h:mm a';
|
|
12
|
+
exports.DATE_FORMAT_MED = 'M/d/yyyy';
|
|
13
|
+
exports.DATE_FORMAT_LONG = 'MM/dd/yyyy';
|
|
14
|
+
exports.DATE_FORMAT_TRACKING = 'MMddyyyy';
|
|
15
|
+
exports.DATE_FORMAT_ORGANIZED = 'yyyy-MM-dd';
|
|
16
|
+
const { DATE_SHORT, DATE_MED, DATE_FULL, DATE_HUGE, DATETIME_SHORT, DATETIME_MED, DATETIME_MED_WITH_SECONDS, DATETIME_FULL, DATETIME_HUGE, TIME_SIMPLE, } = luxon_1.DateTime;
|
|
17
|
+
const DATE_MINI = Object.assign(Object.assign({}, DATE_SHORT), { year: '2-digit' });
|
|
18
|
+
const DATETIME_MINI = Object.assign(Object.assign({}, DATETIME_SHORT), { year: '2-digit' });
|
|
19
|
+
const {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
timeZoneName: _timeZoneNameF } = DATETIME_FULL, DATETIME_FULL_NO_ZONE = tslib_1.__rest(DATETIME_FULL, ["timeZoneName"]);
|
|
22
|
+
const {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
timeZoneName: _timeZoneNameH } = DATETIME_HUGE, DATETIME_HUGE_NO_ZONE = tslib_1.__rest(DATETIME_HUGE, ["timeZoneName"]);
|
|
25
|
+
exports.CUSTOM_FORMATS = {
|
|
26
|
+
UTC: 'UTC',
|
|
27
|
+
ISO: 'ISO',
|
|
28
|
+
UNIX: 'UNIX',
|
|
29
|
+
};
|
|
30
|
+
exports.LOCALE_FORMATS = {
|
|
31
|
+
DATE_MINI,
|
|
32
|
+
DATE_SHORT,
|
|
33
|
+
DATE_MED,
|
|
34
|
+
DATE_FULL,
|
|
35
|
+
DATE_HUGE,
|
|
36
|
+
DATETIME_MINI,
|
|
37
|
+
DATETIME_SHORT,
|
|
38
|
+
DATETIME_MED,
|
|
39
|
+
DATETIME_MED_WITH_SECONDS,
|
|
40
|
+
DATETIME_FULL_NO_ZONE,
|
|
41
|
+
DATETIME_HUGE_NO_ZONE,
|
|
42
|
+
TIME_SIMPLE,
|
|
43
|
+
};
|
|
44
|
+
const DATE_PARTS = {
|
|
45
|
+
day: 'dd',
|
|
46
|
+
month: 'MM',
|
|
47
|
+
year: 'yyyy',
|
|
48
|
+
};
|
|
49
|
+
const validLocaleFormats = Object.values(exports.LOCALE_FORMATS);
|
|
50
|
+
const hasSomeNumbers = (value) => /\d/.test(value);
|
|
51
|
+
const hasOnlyValidCharacters = (value) => /^[\w-+:,\\/\s.]+$/.test(value); // TODO: confirm if these are all needed?
|
|
52
|
+
const getDaysInMonth = (year, month) => (new Date(year, month, 0).getDate());
|
|
53
|
+
exports.getDaysInMonth = getDaysInMonth;
|
|
54
|
+
const setDateTimeLocale = (locale) => {
|
|
55
|
+
if ((0, display_1.stringNotEmpty)(locale)) {
|
|
56
|
+
luxon_1.Settings.defaultLocale = locale;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.setDateTimeLocale = setDateTimeLocale;
|
|
60
|
+
const setDateTimeZone = (zone) => {
|
|
61
|
+
if ((0, display_1.stringNotEmpty)(zone)) {
|
|
62
|
+
luxon_1.Settings.defaultZone = zone;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.setDateTimeZone = setDateTimeZone;
|
|
66
|
+
const getDateTimeFormat = ({ locale, mappings = DATE_PARTS } = {}) => {
|
|
67
|
+
const localeParts = (0, exports.getCurrentDateTime)().toLocaleParts({ locale });
|
|
68
|
+
return localeParts.map(({ type, value }) => {
|
|
69
|
+
if (type === 'literal') {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
return mappings[type];
|
|
73
|
+
}).filter(display_1.stringNotEmpty).join('');
|
|
74
|
+
};
|
|
75
|
+
exports.getDateTimeFormat = getDateTimeFormat;
|
|
76
|
+
const getDateTimeFromString = (_a = {}) => {
|
|
77
|
+
var { format, value } = _a, options = tslib_1.__rest(_a, ["format", "value"]);
|
|
78
|
+
if (!hasSomeNumbers(value) ||
|
|
79
|
+
!hasOnlyValidCharacters(value) ||
|
|
80
|
+
((0, display_1.isType)(value, 'string') && (0, display_1.stringEmpty)(value))) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
if ((0, display_1.stringNotEmpty)(format)) {
|
|
84
|
+
return luxon_1.DateTime.fromFormat(value, format, options);
|
|
85
|
+
}
|
|
86
|
+
if ((0, display_1.isNumericNegatable)(value)) {
|
|
87
|
+
return luxon_1.DateTime.fromSeconds((0, display_1.ensureNumericNegatable)(value));
|
|
88
|
+
}
|
|
89
|
+
let dateTime = luxon_1.DateTime.fromISO(value, options);
|
|
90
|
+
if (!(dateTime === null || dateTime === void 0 ? void 0 : dateTime.isValid)) {
|
|
91
|
+
dateTime = luxon_1.DateTime.fromSQL(value, options);
|
|
92
|
+
}
|
|
93
|
+
if (!(dateTime === null || dateTime === void 0 ? void 0 : dateTime.isValid)) {
|
|
94
|
+
dateTime = luxon_1.DateTime.fromRFC2822(value, options);
|
|
95
|
+
}
|
|
96
|
+
return dateTime;
|
|
97
|
+
};
|
|
98
|
+
exports.getDateTimeFromString = getDateTimeFromString;
|
|
99
|
+
const convertDateTime = (value, _a = {}) => {
|
|
100
|
+
var { shouldThrow = true, shouldLog = shouldThrow } = _a, options = tslib_1.__rest(_a, ["shouldThrow", "shouldLog"]);
|
|
101
|
+
let dateTime;
|
|
102
|
+
try {
|
|
103
|
+
switch (true) {
|
|
104
|
+
// eslint-disable-next-line eqeqeq
|
|
105
|
+
case (value == undefined): {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case luxon_1.DateTime.isDateTime(value): {
|
|
109
|
+
dateTime = value;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case (value instanceof Date): {
|
|
113
|
+
dateTime = luxon_1.DateTime.fromJSDate(value, options);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case (0, display_1.isType)(value, 'object'): {
|
|
117
|
+
dateTime = luxon_1.DateTime.fromObject(value, options);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
default: {
|
|
121
|
+
dateTime = (0, exports.getDateTimeFromString)(Object.assign({ value }, options));
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (dateTime && !dateTime.isValid) {
|
|
126
|
+
if (shouldLog) {
|
|
127
|
+
console.info('Issue converting timestamp', { value, dateTime });
|
|
128
|
+
}
|
|
129
|
+
throw new Error(['Error converting timestamp', dateTime === null || dateTime === void 0 ? void 0 : dateTime.invalidExplanation].filter(display_1.stringNotEmpty).join('. '));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (shouldThrow) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
dateTime = undefined;
|
|
137
|
+
}
|
|
138
|
+
return dateTime;
|
|
139
|
+
};
|
|
140
|
+
exports.convertDateTime = convertDateTime;
|
|
141
|
+
const convertDuration = (value, _a = {}) => {
|
|
142
|
+
var { shouldThrow = true } = _a, options = tslib_1.__rest(_a, ["shouldThrow"]);
|
|
143
|
+
let duration;
|
|
144
|
+
try {
|
|
145
|
+
switch (true) {
|
|
146
|
+
// eslint-disable-next-line eqeqeq
|
|
147
|
+
case (value == undefined): {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case luxon_1.Duration.isDuration(value): {
|
|
151
|
+
duration = value;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case (0, display_1.isType)(value, 'object'): {
|
|
155
|
+
duration = luxon_1.Duration.fromObject(value, options);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case (0, display_1.isNumericNegatable)(value): {
|
|
159
|
+
duration = luxon_1.Duration.fromMillis(value, options);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case ((0, display_1.isType)(value, 'string') &&
|
|
163
|
+
(0, display_1.stringNotEmpty)(value) &&
|
|
164
|
+
hasSomeNumbers(value) &&
|
|
165
|
+
hasOnlyValidCharacters(value)):
|
|
166
|
+
{
|
|
167
|
+
duration = luxon_1.Duration.fromISOTime(value, options);
|
|
168
|
+
if (!(duration === null || duration === void 0 ? void 0 : duration.isValid)) {
|
|
169
|
+
duration = luxon_1.Duration.fromISO(value, options);
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
default: {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (duration && !duration.isValid) {
|
|
178
|
+
console.error('Error converting duration', { value, duration });
|
|
179
|
+
throw new Error(['Error converting duration', duration === null || duration === void 0 ? void 0 : duration.invalidExplanation].filter(display_1.stringNotEmpty).join('. '));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (shouldThrow) {
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
duration = undefined;
|
|
187
|
+
}
|
|
188
|
+
return duration;
|
|
189
|
+
};
|
|
190
|
+
exports.convertDuration = convertDuration;
|
|
191
|
+
const getDuration = (dt1, dt2) => (luxon_1.Interval.fromDateTimes((0, exports.convertDateTime)(dt1), (0, exports.convertDateTime)(dt2)).toDuration());
|
|
192
|
+
exports.getDuration = getDuration;
|
|
193
|
+
const getCurrentDateTime = () => (luxon_1.DateTime.now());
|
|
194
|
+
exports.getCurrentDateTime = getCurrentDateTime;
|
|
195
|
+
const getDateTimeDifference = (dt1, dt2 = (0, exports.getCurrentDateTime)(), unit) => {
|
|
196
|
+
var _a;
|
|
197
|
+
return ((_a = dt2.diff((0, exports.ensureDateTime)(dt1), unit)) === null || _a === void 0 ? void 0 : _a[unit]);
|
|
198
|
+
};
|
|
199
|
+
const getDaysBetween = (dt1, dt2) => (Math.abs(getDateTimeDifference(dt1, dt2, 'days')));
|
|
200
|
+
exports.getDaysBetween = getDaysBetween;
|
|
201
|
+
const getWeeksBetween = (dt1, dt2) => (Math.abs(getDateTimeDifference(dt1, dt2, 'weeks')));
|
|
202
|
+
exports.getWeeksBetween = getWeeksBetween;
|
|
203
|
+
const isSameDateTime = (dt1, dt2 = (0, exports.getCurrentDateTime)(), unit) => (
|
|
204
|
+
// eslint-disable-next-line eqeqeq
|
|
205
|
+
dt1.startOf(unit).ts == dt2.startOf(unit).ts);
|
|
206
|
+
const isSameHour = (dt1, dt2) => (isSameDateTime(dt1, dt2, 'hour'));
|
|
207
|
+
exports.isSameHour = isSameHour;
|
|
208
|
+
const isSameDay = (dt1, dt2) => (isSameDateTime(dt1, dt2, 'day'));
|
|
209
|
+
exports.isSameDay = isSameDay;
|
|
210
|
+
const ensureDateTime = (value, options) => {
|
|
211
|
+
var _a;
|
|
212
|
+
return ((_a = (0, exports.convertDateTime)(value, options)) !== null && _a !== void 0 ? _a : (0, exports.getCurrentDateTime)());
|
|
213
|
+
};
|
|
214
|
+
exports.ensureDateTime = ensureDateTime;
|
|
215
|
+
const formatTimestamps = (timestamps, defaultValue) => (Object.entries((0, display_1.ensureObject)(timestamps)).reduce((_timestamps, [name, value]) => (Object.assign(Object.assign({}, _timestamps), { [name]: value ? (0, exports.toUnixString)(value) : defaultValue })), {}));
|
|
216
|
+
exports.formatTimestamps = formatTimestamps;
|
|
217
|
+
const formatRequiredTimestamps = (_a = {}) => {
|
|
218
|
+
var { created_at, updated_at } = _a, timestamps = tslib_1.__rest(_a, ["created_at", "updated_at"]);
|
|
219
|
+
const _createdTimestamp = (0, exports.toUnixString)(created_at);
|
|
220
|
+
const updatedTimestamp = updated_at ? (0, exports.toUnixString)(updated_at) : _createdTimestamp;
|
|
221
|
+
const createdTimestamp = `${Math.min(_createdTimestamp, updatedTimestamp)}`; // HMMM: why doing math on strings??
|
|
222
|
+
const otherTimestamps = (0, exports.formatTimestamps)(timestamps, createdTimestamp);
|
|
223
|
+
return Object.assign({ created_at: createdTimestamp, updated_at: updatedTimestamp }, otherTimestamps);
|
|
224
|
+
};
|
|
225
|
+
exports.formatRequiredTimestamps = formatRequiredTimestamps;
|
|
226
|
+
const toJSDate = (value, options) => ((0, exports.ensureDateTime)(value, options).toJSDate());
|
|
227
|
+
exports.toJSDate = toJSDate;
|
|
228
|
+
const toUnixInteger = (value, options) => ((0, exports.ensureDateTime)(value, options).toUnixInteger());
|
|
229
|
+
exports.toUnixInteger = toUnixInteger;
|
|
230
|
+
// consolidate w/ toFormatted({ value, CUSTOM_FORMATS.UNIX })
|
|
231
|
+
const toUnixString = (value, options) => (`${(0, exports.toUnixInteger)((0, exports.convertDateTime)(value, options), options)}`);
|
|
232
|
+
exports.toUnixString = toUnixString;
|
|
233
|
+
// consolidate w/ toFormatted({ value, format: CUSTOM_FORMATS.ISO })
|
|
234
|
+
const toISOString = (value, options) => ((0, exports.ensureDateTime)(value, options).toISO());
|
|
235
|
+
exports.toISOString = toISOString;
|
|
236
|
+
// consolidate w/ toFormatted({ value, format: CUSTOM_FORMATS.UTC })
|
|
237
|
+
const toUTCString = (value, options) => ((0, exports.ensureDateTime)(value, options).toUTC().toString());
|
|
238
|
+
exports.toUTCString = toUTCString;
|
|
239
|
+
// HMMM: return toString if no format (or similar)??
|
|
240
|
+
const toFormatted = (_a = {}) => {
|
|
241
|
+
var { format, value, zone } = _a, options = tslib_1.__rest(_a, ["format", "value", "zone"]);
|
|
242
|
+
// eslint-disable-next-line eqeqeq
|
|
243
|
+
if (format == undefined) {
|
|
244
|
+
throw new Error('Please supply a format');
|
|
245
|
+
}
|
|
246
|
+
let datetime = (0, exports.ensureDateTime)(value, options);
|
|
247
|
+
if ((0, display_1.stringNotEmpty)(zone)) {
|
|
248
|
+
datetime = datetime.setZone(zone);
|
|
249
|
+
}
|
|
250
|
+
switch (true) {
|
|
251
|
+
case (format === exports.CUSTOM_FORMATS.UTC): {
|
|
252
|
+
return datetime.toUTC().toString();
|
|
253
|
+
}
|
|
254
|
+
case (format === exports.CUSTOM_FORMATS.ISO): {
|
|
255
|
+
return datetime.toISO();
|
|
256
|
+
}
|
|
257
|
+
case (format === exports.CUSTOM_FORMATS.UNIX): {
|
|
258
|
+
return `${(0, exports.toUnixInteger)(datetime)}`;
|
|
259
|
+
}
|
|
260
|
+
case ((0, display_1.isType)(format, 'string')): {
|
|
261
|
+
return datetime.toFormat(format, options);
|
|
262
|
+
}
|
|
263
|
+
default: {
|
|
264
|
+
if (!validLocaleFormats.includes(format)) {
|
|
265
|
+
console.warn('Please consider using a format from LOCALE_FORMATS');
|
|
266
|
+
}
|
|
267
|
+
return datetime.toLocaleString(format, options);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
exports.toFormatted = toFormatted;
|
|
272
|
+
const convertFormatted = (_a = {}) => {
|
|
273
|
+
var { value } = _a, _b = _a.to, _c = _b === void 0 ? {} : _b, { format: toFormat } = _c, toOptions = tslib_1.__rest(_c, ["format"]), _d = _a.from, _e = _d === void 0 ? {} : _d, { format: fromFormat } = _e, fromOptions = tslib_1.__rest(_e, ["format"]);
|
|
274
|
+
if ((0, display_1.stringEmpty)(toFormat) || (0, display_1.stringEmpty)(fromFormat)) {
|
|
275
|
+
throw new Error('Please supply to/from formats');
|
|
276
|
+
}
|
|
277
|
+
if ((0, display_1.stringEmpty)(value)) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
return (0, exports.toFormatted)(Object.assign({ format: toFormat, value: (0, exports.getDateTimeFromString)(Object.assign({ value, format: fromFormat }, fromOptions)) }, toOptions));
|
|
281
|
+
};
|
|
282
|
+
exports.convertFormatted = convertFormatted;
|
|
283
|
+
const compareDate = (date1, date2) => (-(0, exports.convertDateTime)(date1).diff((0, exports.convertDateTime)(date2)).as('milliseconds'));
|
|
284
|
+
exports.compareDate = compareDate;
|
|
285
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../src/shared/datetime.js"],"names":[],"mappings":";;;;AAAA,yCAAyC;AACzC,iCAA8D;AAE9D,uCAOkB;AAElB,0DAA0D;AAC1D,sDAAsD;AACzC,QAAA,gBAAgB,GAAG,OAAO,CAAA;AAC1B,QAAA,gBA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KAAK,EAAE,IAAA,6BAAqB,kBAAG,KAAK,EAAE,MAAM,EAAE,UAAU,IAAK,WAAW,EAAG,IACxE,SAAS,EACZ,CAAA;AACJ,CAAC,CAAA;AAlBY,QAAA,gBAAgB,oBAkB5B;AAEM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC3C,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CACxE,CAAA;AAFY,QAAA,WAAW,eAEvB"}
|
package/dist/shared/display.d.ts
CHANGED
|
@@ -1,38 +1,103 @@
|
|
|
1
|
-
export function getGUID(): any;
|
|
2
|
-
export function getInteger(): any;
|
|
3
|
-
export function ensureObject(object: any): any;
|
|
4
|
-
export function ensureString(string: any): string;
|
|
5
|
-
export function ensureStringOnly(string: any): string;
|
|
6
|
-
export function ensureArray(array?: any[]): any[];
|
|
7
|
-
export function ensureNumeric(string: any): number;
|
|
8
|
-
export function uppercase(string: any): string;
|
|
9
1
|
export function getRequestMethod(body: any, _method: any): string;
|
|
10
|
-
export function
|
|
11
|
-
|
|
2
|
+
export function normalizeShopifyId(shopifyData: any): {
|
|
3
|
+
gid?: string | undefined;
|
|
4
|
+
entity_type?: string | undefined;
|
|
5
|
+
entity_id?: string | undefined;
|
|
6
|
+
id?: string | undefined;
|
|
12
7
|
};
|
|
8
|
+
export function random(max?: number, min?: number): number;
|
|
9
|
+
export function nextRandom(max?: number, min?: number): any;
|
|
10
|
+
export function arrayRandom(_values: any, _max?: number): any[];
|
|
11
|
+
export function arrayRandomItem(_values: any): any;
|
|
12
|
+
export function isArray(value: any): boolean;
|
|
13
|
+
export function isSet(value: any): boolean;
|
|
13
14
|
export function isType(value: any, type: any): boolean;
|
|
15
|
+
export function isTypeEnhanced(value: any, type: any): boolean;
|
|
16
|
+
export function safeTrim(value: any): any;
|
|
17
|
+
export function safeParse(value: any, trim: any): any;
|
|
18
|
+
export function ensureString(string: any): string;
|
|
19
|
+
export function ensureStringOnly(string: any): string;
|
|
20
|
+
export function ensureStringAscii(string: any): string;
|
|
21
|
+
export function ensureStringClean(string: any): string;
|
|
22
|
+
export function ensureAlphaNumeric(string: any): string;
|
|
14
23
|
export function isNumericOnly(value: any): boolean;
|
|
24
|
+
export function isNumericNegatable(value: any): boolean;
|
|
25
|
+
export function ensureNumeric(string: any): number;
|
|
26
|
+
export function ensureNumericOnly(string: any): number;
|
|
27
|
+
export function ensureNumericNegatable(string: any): number;
|
|
28
|
+
export function ensureNumericConstrained(value: any, { min: _min, max: _max }?: {
|
|
29
|
+
min?: number | undefined;
|
|
30
|
+
max?: number | undefined;
|
|
31
|
+
}): number;
|
|
32
|
+
export function ensureArray(array?: any[]): any[];
|
|
33
|
+
export function ensureArraySet(arrayOrSet: any): any[];
|
|
34
|
+
export function arrayEmpty(array: any, disableEmptyString?: boolean): boolean;
|
|
35
|
+
export function arrayNotEmpty(array: any, disableEmptyString?: boolean): boolean;
|
|
36
|
+
export function findLastMatch(array: any, filterCallback?: (value: any) => any): any;
|
|
37
|
+
export function ensureObject(object: any): any;
|
|
15
38
|
export function objectEmpty(object: any): boolean;
|
|
16
39
|
export function objectNotEmpty(object: any): boolean;
|
|
17
|
-
export function
|
|
18
|
-
export function
|
|
40
|
+
export function nullable(object: any): any;
|
|
41
|
+
export function objectContainsAnyValue(object: any): boolean;
|
|
42
|
+
export function cleanObject(object: any, allowEmptyLeafs: any, isEmptyCallback: any): any;
|
|
19
43
|
export function stringNotEmptyOnly(stringable: any): boolean;
|
|
20
44
|
export function stringEmptyOnly(stringable: any): boolean;
|
|
21
|
-
export function
|
|
22
|
-
export function
|
|
23
|
-
export function
|
|
24
|
-
export function unsnakecase(string: any, replacement?: string): string;
|
|
25
|
-
export function isTrue(value: any, falsy: any): boolean;
|
|
26
|
-
export function cleanObject(object: any, allowEmptyLeafs: any, isEmptyCallback: any): any;
|
|
27
|
-
export function safeTrim(value: any): any;
|
|
28
|
-
export function safeParse(value: any, trim: any): any;
|
|
29
|
-
export function splitCommas(value: any): any[];
|
|
30
|
-
export function arrayIncludesAll(_values: any, comparison: any): boolean;
|
|
31
|
-
export function arraysMatch(array1: any, array2: any): boolean;
|
|
45
|
+
export function stringNotEmpty(stringable: any): boolean;
|
|
46
|
+
export function stringEmpty(stringable: any): boolean;
|
|
47
|
+
export function compareNumber(number1?: number, number2?: number): number;
|
|
32
48
|
export function compareString(string1: any, string2: any): number;
|
|
33
49
|
export function compareEntryKeys([string1]: [any], [string2]: [any]): number;
|
|
34
50
|
export function objectToSortedString(object: any, separator?: string): string;
|
|
51
|
+
export function isHTML(string: any): any;
|
|
52
|
+
export function freeze(logMessage: any, object: any, type?: string): void;
|
|
53
|
+
export function replaceSpaces(string: any, replacement?: string): any;
|
|
54
|
+
export function zencase(string: any, replacement?: string): any;
|
|
55
|
+
export function dashcase(string: any): any;
|
|
56
|
+
export function undashcase(string: any, replacement?: string): string;
|
|
57
|
+
export function snakecase(string: any): any;
|
|
58
|
+
export function unsnakecase(string: any, replacement?: string): string;
|
|
59
|
+
export function uppercase(string: any): string;
|
|
60
|
+
export function lowercase(string: any, defaultValue?: string): string;
|
|
61
|
+
export function slugify(string: any): string;
|
|
62
|
+
export function capitalize(string: any): string;
|
|
63
|
+
export function camelCase(string: any): string;
|
|
64
|
+
export function titleCase(string: any, _overrides: any): string;
|
|
35
65
|
export function removeLeadingSlash(string: any): string;
|
|
66
|
+
export function removeLeadingTrailingQuotes(string: any): string;
|
|
67
|
+
export function removeTrailingSlash(string: any): string;
|
|
68
|
+
export function removeLeadingTrailingSlash(string: any): string;
|
|
36
69
|
export function ensureLeadingSlash(string: any): string;
|
|
70
|
+
export function ensureTrailingSlash(string: any): string;
|
|
71
|
+
export function ensureExtension(string: any, extension: any): any;
|
|
72
|
+
export function wrappedEncode(basePath: any, _wrappingPath: any): string;
|
|
73
|
+
export function splitCommas(value: any): any[];
|
|
74
|
+
export function combineCommas(values: any): any[];
|
|
75
|
+
export function normalizeArray(input: any, separator?: string): any;
|
|
76
|
+
export function arrayToObject(arrayable: any, key: any): any;
|
|
77
|
+
export function isTrue(value: any, falsy: any): boolean;
|
|
78
|
+
export function parseKeywords(keywordGroup: any, previous: any): string;
|
|
79
|
+
export function parseKeywordGroups(keywordGroups: any): string;
|
|
80
|
+
export function parseProjectName(_name: any): {
|
|
81
|
+
name: string;
|
|
82
|
+
parts: string[];
|
|
83
|
+
organization: string;
|
|
84
|
+
projectName: string;
|
|
85
|
+
};
|
|
86
|
+
export function parseProject(packageInfo: any): (string | {
|
|
87
|
+
keywords: any;
|
|
88
|
+
appOwner: any;
|
|
89
|
+
appName: any;
|
|
90
|
+
siteName: any;
|
|
91
|
+
shortName: any;
|
|
92
|
+
companyName: string;
|
|
93
|
+
projectName: string;
|
|
94
|
+
})[];
|
|
95
|
+
export function querystringToObject(queryString: any): {
|
|
96
|
+
[k: string]: string;
|
|
97
|
+
};
|
|
98
|
+
export function arrayIncludesAll(_values: any, comparison: any): boolean;
|
|
99
|
+
export function arraysMatch(array1: any, array2: any): boolean;
|
|
37
100
|
export function appendQuery(_basePath: any, queryString: any): string;
|
|
101
|
+
export function getGUID(): any;
|
|
102
|
+
export function getInteger(): any;
|
|
38
103
|
//# sourceMappingURL=display.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/shared/display.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/shared/display.js"],"names":[],"mappings":"AAKO,kEAIN;AAEM;;;;;EAmCN;AAEM,2DAGN;AAEM,4DAeN;AAEM,gEAmBN;AAEM,mDAEN;AAEM,6CAGN;AAEM,2CAGN;AAEM,uDAGN;AAEM,+DAwBN;AAEM,0CAON;AAEM,sDAeN;AAEM,kDAEN;AAGM,sDAGN;AAEM,uDAGN;AAEM,uDAGN;AAEM,wDAGN;AAEM,mDAIN;AAEM,wDAIN;AAGM,mDAEN;AAEM,uDAEN;AAGM,4DAEN;AAEM;;;WAQN;AAEM,kDAGN;AAEM,uDAEN;AAEM,8EAGN;AAEM,iFAGN;AAEM,qFAEN;AAEM,+CAEN;AAGM,kDAEN;AAEM,qDAEN;AAEM,2CAIN;AAEM,6DAEN;AAOM,0FAqBN;AAMM,6DAGN;AAEM,0DAEN;AAEM,yDAGN;AAEM,sDAEN;AAOM,0EAEN;AAEM,kEAUN;AAEM,6EAEN;AAEM,8EAKN;AAEM,yCAEN;AAEM,0EAEN;AAEM,sEAIN;AAgBM,gEAQN;AAEM,2CAEN;AAEM,sEAEN;AAEM,4CAEN;AAEM,uEAEN;AAEM,+CAEN;AAEM,sEAIN;AAEM,6CAEN;AAEM,gDAGN;AAEM,+CASN;AAEM,gEA6DN;AAEM,wDAEN;AAEM,iEAEN;AAGM,yDAEN;AAEM,gEAEN;AAEM,wDAEN;AAEM,yDAEN;AAEM,kEAQN;AAEM,yEAON;AAEM,+CAWN;AAEM,kDAUN;AAEM,oEAON;AAEM,6DAKN;AAEM,wDAGN;AAGM,wEASN;AAEM,+DAcN;AAEM;;;;;EAWN;AAEM;;;;;;;;KAkBN;AAMM;;EAON;AAEM,yEAKN;AAEM,+DAEN;AAEM,sEAMN;AAIM,+BAEN;AAEM,kCAEN"}
|