@nocobase/utils 1.8.0-beta.9 → 1.9.0-alpha.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/lib/common.d.ts CHANGED
@@ -32,3 +32,4 @@ export declare function treeFind<T = any>(tree: T | T[], callback: (node: T) =>
32
32
  * @returns {Array} - The sorted tree structure
33
33
  */
34
34
  export declare function sortTree(tree: any[], sortBy: string | Function, childrenKey?: string, isAsc?: boolean): any;
35
+ export declare function sleep(ms: number): Promise<void>;
package/lib/common.js CHANGED
@@ -43,6 +43,7 @@ __export(common_exports, {
43
43
  isPlainObject: () => isPlainObject,
44
44
  isString: () => isString,
45
45
  nextTick: () => nextTick,
46
+ sleep: () => sleep,
46
47
  sortTree: () => sortTree,
47
48
  treeFind: () => treeFind
48
49
  });
@@ -124,6 +125,12 @@ function sortTree(tree, sortBy, childrenKey = "children", isAsc = true) {
124
125
  });
125
126
  }
126
127
  __name(sortTree, "sortTree");
128
+ function sleep(ms) {
129
+ return new Promise((resolve) => {
130
+ setTimeout(resolve, ms);
131
+ });
132
+ }
133
+ __name(sleep, "sleep");
127
134
  // Annotate the CommonJS export names for ESM import in node:
128
135
  0 && (module.exports = {
129
136
  hasEmptyValue,
@@ -132,6 +139,7 @@ __name(sortTree, "sortTree");
132
139
  isPlainObject,
133
140
  isString,
134
141
  nextTick,
142
+ sleep,
135
143
  sortTree,
136
144
  treeFind
137
145
  });
package/lib/date.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface Str2momentOptions {
12
12
  picker?: 'year' | 'month' | 'week' | 'quarter';
13
13
  utcOffset?: number;
14
14
  utc?: boolean;
15
+ dateOnly?: boolean;
15
16
  }
16
17
  export type Str2momentValue = string | string[] | dayjs.Dayjs | dayjs.Dayjs[];
17
18
  export interface GetDefaultFormatProps {
package/lib/date.js CHANGED
@@ -102,10 +102,16 @@ const toMoment = /* @__PURE__ */ __name((val, options) => {
102
102
  return;
103
103
  }
104
104
  const offset = options.utcOffset;
105
- const { gmt, picker, utc = true } = options;
105
+ const { gmt, picker, utc = true, dateOnly } = options;
106
106
  if ((0, import_dayjs.dayjs)(val).isValid()) {
107
+ if (dateOnly) {
108
+ const date = (0, import_dayjs.dayjs)(val);
109
+ if (!date.isValid()) return val;
110
+ const dateString = date.format("YYYY-MM-DD");
111
+ return import_dayjs.dayjs.utc(dateString, "YYYY-MM-DD");
112
+ }
107
113
  if (!utc) {
108
- return (0, import_dayjs.dayjs)(val);
114
+ return import_dayjs.dayjs.utc(val);
109
115
  }
110
116
  if (import_dayjs.dayjs.isDayjs(val)) {
111
117
  return offset ? val.utcOffset(offsetFromString(offset)) : val;
package/lib/index.d.ts CHANGED
@@ -37,5 +37,6 @@ export * from './url';
37
37
  export * from './i18n';
38
38
  export * from './wrap-middleware';
39
39
  export * from './object-to-cli-args';
40
+ export * from './parsedValue';
40
41
  export * from './dateRangeUtils';
41
42
  export { Schema } from '@formily/json-schema';
package/lib/index.js CHANGED
@@ -72,6 +72,7 @@ __reExport(src_exports, require("./url"), module.exports);
72
72
  __reExport(src_exports, require("./i18n"), module.exports);
73
73
  __reExport(src_exports, require("./wrap-middleware"), module.exports);
74
74
  __reExport(src_exports, require("./object-to-cli-args"), module.exports);
75
+ __reExport(src_exports, require("./parsedValue"), module.exports);
75
76
  __reExport(src_exports, require("./dateRangeUtils"), module.exports);
76
77
  var import_json_schema = require("@formily/json-schema");
77
78
  // Annotate the CommonJS export names for ESM import in node:
@@ -107,5 +108,6 @@ var import_json_schema = require("@formily/json-schema");
107
108
  ...require("./i18n"),
108
109
  ...require("./wrap-middleware"),
109
110
  ...require("./object-to-cli-args"),
111
+ ...require("./parsedValue"),
110
112
  ...require("./dateRangeUtils")
111
113
  });
@@ -196,6 +196,9 @@ const parseFilter = /* @__PURE__ */ __name(async (filter, opts = {}) => {
196
196
  if (isDateOperator(operator)) {
197
197
  const field = getField == null ? void 0 : getField(path);
198
198
  if ((field == null ? void 0 : field.constructor.name) === "DateOnlyField" || (field == null ? void 0 : field.constructor.name) === "DatetimeNoTzField") {
199
+ if (value.type) {
200
+ return (0, import_dateRangeUtils.getDayRangeByParams)({ ...value, timezone: (field == null ? void 0 : field.timezone) || timezone });
201
+ }
199
202
  return value;
200
203
  }
201
204
  return dateValueWrapper(value, (field == null ? void 0 : field.timezone) || timezone);
@@ -0,0 +1 @@
1
+ export declare const parsedValue: (value: any, variables: any) => any;
@@ -0,0 +1,57 @@
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 parsedValue_exports = {};
29
+ __export(parsedValue_exports, {
30
+ parsedValue: () => parsedValue
31
+ });
32
+ module.exports = __toCommonJS(parsedValue_exports);
33
+ var import_json_templates = require("./json-templates");
34
+ function appendArrayColumn(scope, key) {
35
+ const paths = key.split(".");
36
+ let data = scope;
37
+ for (let p = 0; p < paths.length && data != null; p++) {
38
+ const path = paths[p];
39
+ const isIndex = path.match(/^\d+$/);
40
+ if (Array.isArray(data) && !isIndex && !data[path]) {
41
+ data[path] = data.map((item) => item[path]).flat();
42
+ }
43
+ data = data == null ? void 0 : data[path];
44
+ }
45
+ }
46
+ __name(appendArrayColumn, "appendArrayColumn");
47
+ const parsedValue = /* @__PURE__ */ __name((value, variables) => {
48
+ const template = (0, import_json_templates.parse)(value);
49
+ template.parameters.forEach(({ key }) => {
50
+ appendArrayColumn(variables, key);
51
+ });
52
+ return template(variables);
53
+ }, "parsedValue");
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ parsedValue
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/utils",
3
- "version": "1.8.0-beta.9",
3
+ "version": "1.9.0-alpha.1",
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.2",
17
17
  "object-path": "^0.11.8"
18
18
  },
19
- "gitHead": "a3449d646c72965845f8c52e52fff9dba759c564"
19
+ "gitHead": "71ebde8a27da3c5c4d64194571804eeab6e95ce0"
20
20
  }