@nocobase/utils 1.5.0-beta.3 → 1.5.0-beta.30
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/lib/date.d.ts +1 -0
- package/lib/date.js +11 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/object-to-cli-args.d.ts +6 -0
- package/lib/object-to-cli-args.js +43 -0
- package/lib/parse-date.js +9 -9
- package/package.json +2 -2
package/lib/date.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export declare const moment2str: (value?: dayjs.Dayjs, options?: Moment2strOptio
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function offsetFromString(string: string | number): number;
|
|
38
38
|
export declare const getPickerFormat: (picker: any) => "YYYY-MM" | "YYYY" | "YYYY[W]W" | "YYYY-MM-DD" | "YYYY[Q]Q";
|
|
39
|
+
export declare const getDateTimeFormat: (picker: any, format: any, showTime: any, timeFormat: any) => any;
|
package/lib/date.js
CHANGED
|
@@ -37,6 +37,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var date_exports = {};
|
|
39
39
|
__export(date_exports, {
|
|
40
|
+
getDateTimeFormat: () => getDateTimeFormat,
|
|
40
41
|
getDefaultFormat: () => getDefaultFormat,
|
|
41
42
|
getPickerFormat: () => getPickerFormat,
|
|
42
43
|
moment2str: () => moment2str,
|
|
@@ -205,8 +206,18 @@ const getPickerFormat = /* @__PURE__ */ __name((picker) => {
|
|
|
205
206
|
return "YYYY-MM-DD";
|
|
206
207
|
}
|
|
207
208
|
}, "getPickerFormat");
|
|
209
|
+
const getDateTimeFormat = /* @__PURE__ */ __name((picker, format, showTime, timeFormat) => {
|
|
210
|
+
if (picker === "date") {
|
|
211
|
+
if (showTime) {
|
|
212
|
+
return `${format} ${timeFormat || "HH:mm:ss"}`;
|
|
213
|
+
}
|
|
214
|
+
return format;
|
|
215
|
+
}
|
|
216
|
+
return format;
|
|
217
|
+
}, "getDateTimeFormat");
|
|
208
218
|
// Annotate the CommonJS export names for ESM import in node:
|
|
209
219
|
0 && (module.exports = {
|
|
220
|
+
getDateTimeFormat,
|
|
210
221
|
getDefaultFormat,
|
|
211
222
|
getPickerFormat,
|
|
212
223
|
moment2str,
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -70,6 +70,7 @@ __reExport(src_exports, require("./uid"), module.exports);
|
|
|
70
70
|
__reExport(src_exports, require("./url"), module.exports);
|
|
71
71
|
__reExport(src_exports, require("./i18n"), module.exports);
|
|
72
72
|
__reExport(src_exports, require("./wrap-middleware"), module.exports);
|
|
73
|
+
__reExport(src_exports, require("./object-to-cli-args"), module.exports);
|
|
73
74
|
var import_json_schema = require("@formily/json-schema");
|
|
74
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
76
|
0 && (module.exports = {
|
|
@@ -101,5 +102,6 @@ var import_json_schema = require("@formily/json-schema");
|
|
|
101
102
|
...require("./uid"),
|
|
102
103
|
...require("./url"),
|
|
103
104
|
...require("./i18n"),
|
|
104
|
-
...require("./wrap-middleware")
|
|
105
|
+
...require("./wrap-middleware"),
|
|
106
|
+
...require("./object-to-cli-args")
|
|
105
107
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var object_to_cli_args_exports = {};
|
|
29
|
+
__export(object_to_cli_args_exports, {
|
|
30
|
+
objectToCliArgs: () => objectToCliArgs
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(object_to_cli_args_exports);
|
|
33
|
+
function objectToCliArgs(obj) {
|
|
34
|
+
return Object.entries(obj).filter(([_, value]) => value !== null && value !== void 0).map(([key, value]) => {
|
|
35
|
+
const stringValue = typeof value === "object" ? JSON.stringify(value) : value;
|
|
36
|
+
return `--${key}=${stringValue}`;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
__name(objectToCliArgs, "objectToCliArgs");
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
objectToCliArgs
|
|
43
|
+
});
|
package/lib/parse-date.js
CHANGED
|
@@ -99,7 +99,7 @@ function parseWeek(value) {
|
|
|
99
99
|
}
|
|
100
100
|
__name(parseWeek, "parseWeek");
|
|
101
101
|
function parseMonth(value) {
|
|
102
|
-
if (/^\d\d\d\d
|
|
102
|
+
if (/^\d\d\d\d-\d\d$/.test(value)) {
|
|
103
103
|
return {
|
|
104
104
|
unit: "month",
|
|
105
105
|
start: `${value}-01 00:00:00`
|
|
@@ -108,7 +108,7 @@ function parseMonth(value) {
|
|
|
108
108
|
}
|
|
109
109
|
__name(parseMonth, "parseMonth");
|
|
110
110
|
function parseDay(value) {
|
|
111
|
-
if (/^\d\d\d\d
|
|
111
|
+
if (/^\d\d\d\d-\d\d-\d\d$/.test(value)) {
|
|
112
112
|
return {
|
|
113
113
|
unit: "day",
|
|
114
114
|
start: `${value} 00:00:00`
|
|
@@ -117,7 +117,7 @@ function parseDay(value) {
|
|
|
117
117
|
}
|
|
118
118
|
__name(parseDay, "parseDay");
|
|
119
119
|
function parseHour(value) {
|
|
120
|
-
if (/^\d\d\d\d
|
|
120
|
+
if (/^\d\d\d\d-\d\d-\d\d(T|\s)\d\d$/.test(value)) {
|
|
121
121
|
return {
|
|
122
122
|
unit: "hour",
|
|
123
123
|
start: `${value}:00:00`
|
|
@@ -126,7 +126,7 @@ function parseHour(value) {
|
|
|
126
126
|
}
|
|
127
127
|
__name(parseHour, "parseHour");
|
|
128
128
|
function parseMinute(value) {
|
|
129
|
-
if (/^\d\d\d\d
|
|
129
|
+
if (/^\d\d\d\d-\d\d-\d\d(T|\s)\d\d:\d\d$/.test(value)) {
|
|
130
130
|
return {
|
|
131
131
|
unit: "minute",
|
|
132
132
|
start: `${value}:00`
|
|
@@ -135,7 +135,7 @@ function parseMinute(value) {
|
|
|
135
135
|
}
|
|
136
136
|
__name(parseMinute, "parseMinute");
|
|
137
137
|
function parseSecond(value) {
|
|
138
|
-
if (/^\d\d\d\d
|
|
138
|
+
if (/^\d\d\d\d-\d\d-\d\d(T|\s)\d\d:\d\d:\d\d$/.test(value)) {
|
|
139
139
|
return {
|
|
140
140
|
unit: "second",
|
|
141
141
|
start: `${value}`
|
|
@@ -144,7 +144,7 @@ function parseSecond(value) {
|
|
|
144
144
|
}
|
|
145
145
|
__name(parseSecond, "parseSecond");
|
|
146
146
|
function parseMillisecond(value) {
|
|
147
|
-
if (/^\d\d\d\d
|
|
147
|
+
if (/^\d\d\d\d-\d\d-\d\d(T|\s)\d\d:\d\d:\d\d\.\d\d\d$/.test(value)) {
|
|
148
148
|
return {
|
|
149
149
|
unit: "millisecond",
|
|
150
150
|
start: `${value}`
|
|
@@ -192,7 +192,7 @@ function parseDate(value, options = {}) {
|
|
|
192
192
|
let timezone = options.timezone || "+00:00";
|
|
193
193
|
const input = value;
|
|
194
194
|
if (typeof value === "string") {
|
|
195
|
-
const match = /(.+)((
|
|
195
|
+
const match = /(.+)((\+|-)\d\d:\d\d)$/.exec(value);
|
|
196
196
|
if (match) {
|
|
197
197
|
value = match[1];
|
|
198
198
|
timezone = match[2];
|
|
@@ -242,13 +242,13 @@ function parseDateBetween(value, options = {}) {
|
|
|
242
242
|
if (typeof value !== "string") {
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
-
const match = /(.+)((
|
|
245
|
+
const match = /(.+)((\+|-)\d\d:\d\d)$/.exec(value);
|
|
246
246
|
let timezone = options.timezone || "+00:00";
|
|
247
247
|
if (match) {
|
|
248
248
|
value = match[1];
|
|
249
249
|
timezone = match[2];
|
|
250
250
|
}
|
|
251
|
-
const m = /^(\(|\[)(.+)
|
|
251
|
+
const m = /^(\(|\[)(.+),(.+)(\)|\])$/.exec(value);
|
|
252
252
|
if (!m) {
|
|
253
253
|
return;
|
|
254
254
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "1.5.0-beta.
|
|
3
|
+
"version": "1.5.0-beta.30",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"multer": "^1.4.5-lts.1",
|
|
17
17
|
"object-path": "^0.11.8"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "40c48b2ecf3e2315a76dcb729dbda825b6a1331c"
|
|
20
20
|
}
|