@djvlc/contracts-types 1.5.0 → 1.7.0
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/index.d.mts +3532 -3971
- package/dist/index.d.ts +3532 -3971
- package/dist/index.js +939 -582
- package/dist/index.mjs +902 -526
- package/package.json +7 -7
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,755 +1,1112 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
ACTION_SPEC_VERSION: () => ACTION_SPEC_VERSION,
|
|
24
|
-
ALLOWED_ROOT_VARIABLES: () => ALLOWED_ROOT_VARIABLES,
|
|
25
|
-
BUILTIN_FUNCTIONS: () => BUILTIN_FUNCTIONS,
|
|
26
|
-
BUILTIN_FUNCTION_NAMES: () => BUILTIN_FUNCTION_NAMES,
|
|
27
|
-
BUILTIN_PERMISSIONS: () => BUILTIN_PERMISSIONS,
|
|
28
|
-
BUILTIN_PROPERTY_GROUPS: () => BUILTIN_PROPERTY_GROUPS,
|
|
29
|
-
BUILTIN_ROLES: () => BUILTIN_ROLES,
|
|
30
|
-
COMPONENT_CATEGORIES: () => COMPONENT_CATEGORIES,
|
|
31
|
-
COMPONENT_META_SCHEMA_VERSION: () => COMPONENT_META_SCHEMA_VERSION,
|
|
32
|
-
CURRENT_SCHEMA_VERSION: () => CURRENT_SCHEMA_VERSION,
|
|
33
|
-
DATA_QUERY_SPEC_VERSION: () => DATA_QUERY_SPEC_VERSION,
|
|
34
|
-
ErrorCode: () => ErrorCode,
|
|
35
|
-
ErrorCodeCategory: () => ErrorCodeCategory,
|
|
36
|
-
ErrorMessages: () => ErrorMessages,
|
|
37
|
-
PAGE_SCHEMA_VERSION: () => PAGE_SCHEMA_VERSION,
|
|
38
|
-
PublishStatus: () => PublishStatus,
|
|
39
|
-
SCHEMA_VERSIONS: () => SCHEMA_VERSIONS,
|
|
40
|
-
compareVersions: () => compareVersions,
|
|
41
|
-
createDjvlcError: () => createDjvlcError,
|
|
42
|
-
createExpressionBinding: () => createExpressionBinding,
|
|
43
|
-
findMigrationPath: () => findMigrationPath,
|
|
44
|
-
getAllMigrations: () => getAllMigrations,
|
|
45
|
-
getContractsVersion: () => getContractsVersion,
|
|
46
|
-
getHttpStatusFromErrorCode: () => getHttpStatusFromErrorCode,
|
|
47
|
-
getVersionInfo: () => getVersionInfo,
|
|
48
|
-
isExpressionBinding: () => isExpressionBinding,
|
|
49
|
-
isRetryableError: () => isRetryableError,
|
|
50
|
-
isVersionCompatible: () => isVersionCompatible,
|
|
51
|
-
migratePageSchema: () => migratePageSchema,
|
|
52
|
-
needsMigration: () => needsMigration,
|
|
53
|
-
registerMigration: () => registerMigration
|
|
54
|
-
});
|
|
55
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
'use strict';
|
|
56
2
|
|
|
57
|
-
// src/
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function isVersionCompatible(required, current) {
|
|
71
|
-
const [reqMajor, reqMinor] = required.split(".").map(Number);
|
|
72
|
-
const [curMajor, curMinor] = current.split(".").map(Number);
|
|
73
|
-
return curMajor === reqMajor && curMinor >= reqMinor;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/errors/index.ts
|
|
3
|
+
// src/common/errors.ts
|
|
4
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
5
|
+
ErrorCategory2["SYSTEM"] = "SYSTEM";
|
|
6
|
+
ErrorCategory2["AUTH"] = "AUTH";
|
|
7
|
+
ErrorCategory2["PERMISSION"] = "PERMISSION";
|
|
8
|
+
ErrorCategory2["RESOURCE"] = "RESOURCE";
|
|
9
|
+
ErrorCategory2["VALIDATION"] = "VALIDATION";
|
|
10
|
+
ErrorCategory2["BUSINESS"] = "BUSINESS";
|
|
11
|
+
ErrorCategory2["RISK"] = "RISK";
|
|
12
|
+
return ErrorCategory2;
|
|
13
|
+
})(ErrorCategory || {});
|
|
77
14
|
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
78
|
-
ErrorCode2[
|
|
79
|
-
ErrorCode2[
|
|
80
|
-
ErrorCode2[
|
|
81
|
-
ErrorCode2[
|
|
82
|
-
ErrorCode2[
|
|
83
|
-
ErrorCode2[
|
|
84
|
-
ErrorCode2[
|
|
85
|
-
ErrorCode2[
|
|
86
|
-
ErrorCode2[
|
|
87
|
-
ErrorCode2[
|
|
88
|
-
ErrorCode2[
|
|
89
|
-
ErrorCode2[
|
|
90
|
-
ErrorCode2[
|
|
91
|
-
ErrorCode2[
|
|
92
|
-
ErrorCode2[
|
|
93
|
-
ErrorCode2[
|
|
94
|
-
ErrorCode2[
|
|
95
|
-
ErrorCode2[
|
|
96
|
-
ErrorCode2[
|
|
97
|
-
ErrorCode2[
|
|
98
|
-
ErrorCode2[
|
|
99
|
-
ErrorCode2[
|
|
100
|
-
ErrorCode2[
|
|
101
|
-
ErrorCode2[
|
|
102
|
-
ErrorCode2[
|
|
103
|
-
ErrorCode2[
|
|
104
|
-
ErrorCode2[
|
|
105
|
-
ErrorCode2[
|
|
106
|
-
ErrorCode2[
|
|
107
|
-
ErrorCode2[
|
|
108
|
-
ErrorCode2[
|
|
109
|
-
ErrorCode2[
|
|
110
|
-
ErrorCode2[
|
|
111
|
-
ErrorCode2[
|
|
112
|
-
ErrorCode2[
|
|
113
|
-
ErrorCode2[
|
|
114
|
-
ErrorCode2[
|
|
115
|
-
ErrorCode2[
|
|
116
|
-
ErrorCode2[
|
|
117
|
-
ErrorCode2[
|
|
118
|
-
ErrorCode2[
|
|
119
|
-
ErrorCode2[
|
|
120
|
-
ErrorCode2[
|
|
121
|
-
ErrorCode2[ErrorCode2["ACTIVITY_DISABLED"] = 6007] = "ACTIVITY_DISABLED";
|
|
122
|
-
ErrorCode2[ErrorCode2["EXPRESSION_SYNTAX_ERROR"] = 7001] = "EXPRESSION_SYNTAX_ERROR";
|
|
123
|
-
ErrorCode2[ErrorCode2["EXPRESSION_UNKNOWN_FUNCTION"] = 7002] = "EXPRESSION_UNKNOWN_FUNCTION";
|
|
124
|
-
ErrorCode2[ErrorCode2["EXPRESSION_INVALID_ARGUMENT"] = 7003] = "EXPRESSION_INVALID_ARGUMENT";
|
|
125
|
-
ErrorCode2[ErrorCode2["EXPRESSION_UNKNOWN_VARIABLE"] = 7004] = "EXPRESSION_UNKNOWN_VARIABLE";
|
|
126
|
-
ErrorCode2[ErrorCode2["EXPRESSION_TYPE_MISMATCH"] = 7005] = "EXPRESSION_TYPE_MISMATCH";
|
|
127
|
-
ErrorCode2[ErrorCode2["EXPRESSION_ACCESS_DENIED"] = 7006] = "EXPRESSION_ACCESS_DENIED";
|
|
128
|
-
ErrorCode2[ErrorCode2["SCHEMA_VERSION_MISMATCH"] = 8001] = "SCHEMA_VERSION_MISMATCH";
|
|
129
|
-
ErrorCode2[ErrorCode2["MIGRATION_FAILED"] = 8002] = "MIGRATION_FAILED";
|
|
130
|
-
ErrorCode2[ErrorCode2["MIGRATION_NOT_FOUND"] = 8003] = "MIGRATION_NOT_FOUND";
|
|
131
|
-
ErrorCode2[ErrorCode2["VERSION_INCOMPATIBLE"] = 8004] = "VERSION_INCOMPATIBLE";
|
|
15
|
+
ErrorCode2["SYSTEM_INTERNAL_ERROR"] = "SYSTEM_INTERNAL_ERROR";
|
|
16
|
+
ErrorCode2["SYSTEM_SERVICE_UNAVAILABLE"] = "SYSTEM_SERVICE_UNAVAILABLE";
|
|
17
|
+
ErrorCode2["SYSTEM_TIMEOUT"] = "SYSTEM_TIMEOUT";
|
|
18
|
+
ErrorCode2["SYSTEM_DATABASE_ERROR"] = "SYSTEM_DATABASE_ERROR";
|
|
19
|
+
ErrorCode2["SYSTEM_REDIS_ERROR"] = "SYSTEM_REDIS_ERROR";
|
|
20
|
+
ErrorCode2["AUTH_TOKEN_MISSING"] = "AUTH_TOKEN_MISSING";
|
|
21
|
+
ErrorCode2["AUTH_TOKEN_INVALID"] = "AUTH_TOKEN_INVALID";
|
|
22
|
+
ErrorCode2["AUTH_TOKEN_EXPIRED"] = "AUTH_TOKEN_EXPIRED";
|
|
23
|
+
ErrorCode2["AUTH_SIGNATURE_INVALID"] = "AUTH_SIGNATURE_INVALID";
|
|
24
|
+
ErrorCode2["AUTH_SESSION_EXPIRED"] = "AUTH_SESSION_EXPIRED";
|
|
25
|
+
ErrorCode2["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
26
|
+
ErrorCode2["PERMISSION_RESOURCE_FORBIDDEN"] = "PERMISSION_RESOURCE_FORBIDDEN";
|
|
27
|
+
ErrorCode2["PERMISSION_ACTION_FORBIDDEN"] = "PERMISSION_ACTION_FORBIDDEN";
|
|
28
|
+
ErrorCode2["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
|
|
29
|
+
ErrorCode2["RESOURCE_PAGE_NOT_FOUND"] = "RESOURCE_PAGE_NOT_FOUND";
|
|
30
|
+
ErrorCode2["RESOURCE_COMPONENT_NOT_FOUND"] = "RESOURCE_COMPONENT_NOT_FOUND";
|
|
31
|
+
ErrorCode2["RESOURCE_ACTION_NOT_FOUND"] = "RESOURCE_ACTION_NOT_FOUND";
|
|
32
|
+
ErrorCode2["RESOURCE_VERSION_NOT_FOUND"] = "RESOURCE_VERSION_NOT_FOUND";
|
|
33
|
+
ErrorCode2["VALIDATION_INVALID_PARAMS"] = "VALIDATION_INVALID_PARAMS";
|
|
34
|
+
ErrorCode2["VALIDATION_SCHEMA_MISMATCH"] = "VALIDATION_SCHEMA_MISMATCH";
|
|
35
|
+
ErrorCode2["VALIDATION_EXPRESSION_ERROR"] = "VALIDATION_EXPRESSION_ERROR";
|
|
36
|
+
ErrorCode2["VALIDATION_FIELD_REQUIRED"] = "VALIDATION_FIELD_REQUIRED";
|
|
37
|
+
ErrorCode2["VALIDATION_FIELD_TYPE_ERROR"] = "VALIDATION_FIELD_TYPE_ERROR";
|
|
38
|
+
ErrorCode2["BUSINESS_ACTIVITY_NOT_STARTED"] = "BUSINESS_ACTIVITY_NOT_STARTED";
|
|
39
|
+
ErrorCode2["BUSINESS_ACTIVITY_ENDED"] = "BUSINESS_ACTIVITY_ENDED";
|
|
40
|
+
ErrorCode2["BUSINESS_ALREADY_CLAIMED"] = "BUSINESS_ALREADY_CLAIMED";
|
|
41
|
+
ErrorCode2["BUSINESS_ALREADY_SIGNED"] = "BUSINESS_ALREADY_SIGNED";
|
|
42
|
+
ErrorCode2["BUSINESS_STOCK_EXHAUSTED"] = "BUSINESS_STOCK_EXHAUSTED";
|
|
43
|
+
ErrorCode2["BUSINESS_QUOTA_EXCEEDED"] = "BUSINESS_QUOTA_EXCEEDED";
|
|
44
|
+
ErrorCode2["BUSINESS_PREREQUISITE_NOT_MET"] = "BUSINESS_PREREQUISITE_NOT_MET";
|
|
45
|
+
ErrorCode2["RISK_RATE_LIMITED"] = "RISK_RATE_LIMITED";
|
|
46
|
+
ErrorCode2["RISK_BLOCKED"] = "RISK_BLOCKED";
|
|
47
|
+
ErrorCode2["RISK_CAPTCHA_REQUIRED"] = "RISK_CAPTCHA_REQUIRED";
|
|
48
|
+
ErrorCode2["RISK_DEVICE_ABNORMAL"] = "RISK_DEVICE_ABNORMAL";
|
|
49
|
+
ErrorCode2["RISK_IDEMPOTENCY_CONFLICT"] = "RISK_IDEMPOTENCY_CONFLICT";
|
|
50
|
+
ErrorCode2["COMPONENT_LOAD_FAILED"] = "COMPONENT_LOAD_FAILED";
|
|
51
|
+
ErrorCode2["COMPONENT_INTEGRITY_MISMATCH"] = "COMPONENT_INTEGRITY_MISMATCH";
|
|
52
|
+
ErrorCode2["COMPONENT_BLOCKED"] = "COMPONENT_BLOCKED";
|
|
53
|
+
ErrorCode2["COMPONENT_DEPRECATED"] = "COMPONENT_DEPRECATED";
|
|
54
|
+
ErrorCode2["COMPONENT_INCOMPATIBLE"] = "COMPONENT_INCOMPATIBLE";
|
|
55
|
+
ErrorCode2["PUBLISH_VERSION_CONFLICT"] = "PUBLISH_VERSION_CONFLICT";
|
|
56
|
+
ErrorCode2["PUBLISH_VALIDATION_FAILED"] = "PUBLISH_VALIDATION_FAILED";
|
|
57
|
+
ErrorCode2["PUBLISH_ROLLBACK_FAILED"] = "PUBLISH_ROLLBACK_FAILED";
|
|
132
58
|
return ErrorCode2;
|
|
133
59
|
})(ErrorCode || {});
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
60
|
+
var ErrorCodeToHttpStatus = {
|
|
61
|
+
// 系统错误 -> 500
|
|
62
|
+
["SYSTEM_INTERNAL_ERROR" /* SYSTEM_INTERNAL_ERROR */]: 500,
|
|
63
|
+
["SYSTEM_SERVICE_UNAVAILABLE" /* SYSTEM_SERVICE_UNAVAILABLE */]: 503,
|
|
64
|
+
["SYSTEM_TIMEOUT" /* SYSTEM_TIMEOUT */]: 504,
|
|
65
|
+
["SYSTEM_DATABASE_ERROR" /* SYSTEM_DATABASE_ERROR */]: 500,
|
|
66
|
+
["SYSTEM_REDIS_ERROR" /* SYSTEM_REDIS_ERROR */]: 500,
|
|
67
|
+
// 认证错误 -> 401
|
|
68
|
+
["AUTH_TOKEN_MISSING" /* AUTH_TOKEN_MISSING */]: 401,
|
|
69
|
+
["AUTH_TOKEN_INVALID" /* AUTH_TOKEN_INVALID */]: 401,
|
|
70
|
+
["AUTH_TOKEN_EXPIRED" /* AUTH_TOKEN_EXPIRED */]: 401,
|
|
71
|
+
["AUTH_SIGNATURE_INVALID" /* AUTH_SIGNATURE_INVALID */]: 401,
|
|
72
|
+
["AUTH_SESSION_EXPIRED" /* AUTH_SESSION_EXPIRED */]: 401,
|
|
73
|
+
// 权限错误 -> 403
|
|
74
|
+
["PERMISSION_DENIED" /* PERMISSION_DENIED */]: 403,
|
|
75
|
+
["PERMISSION_RESOURCE_FORBIDDEN" /* PERMISSION_RESOURCE_FORBIDDEN */]: 403,
|
|
76
|
+
["PERMISSION_ACTION_FORBIDDEN" /* PERMISSION_ACTION_FORBIDDEN */]: 403,
|
|
77
|
+
// 资源错误 -> 404
|
|
78
|
+
["RESOURCE_NOT_FOUND" /* RESOURCE_NOT_FOUND */]: 404,
|
|
79
|
+
["RESOURCE_PAGE_NOT_FOUND" /* RESOURCE_PAGE_NOT_FOUND */]: 404,
|
|
80
|
+
["RESOURCE_COMPONENT_NOT_FOUND" /* RESOURCE_COMPONENT_NOT_FOUND */]: 404,
|
|
81
|
+
["RESOURCE_ACTION_NOT_FOUND" /* RESOURCE_ACTION_NOT_FOUND */]: 404,
|
|
82
|
+
["RESOURCE_VERSION_NOT_FOUND" /* RESOURCE_VERSION_NOT_FOUND */]: 404,
|
|
83
|
+
// 参数错误 -> 400
|
|
84
|
+
["VALIDATION_INVALID_PARAMS" /* VALIDATION_INVALID_PARAMS */]: 400,
|
|
85
|
+
["VALIDATION_SCHEMA_MISMATCH" /* VALIDATION_SCHEMA_MISMATCH */]: 400,
|
|
86
|
+
["VALIDATION_EXPRESSION_ERROR" /* VALIDATION_EXPRESSION_ERROR */]: 400,
|
|
87
|
+
["VALIDATION_FIELD_REQUIRED" /* VALIDATION_FIELD_REQUIRED */]: 400,
|
|
88
|
+
["VALIDATION_FIELD_TYPE_ERROR" /* VALIDATION_FIELD_TYPE_ERROR */]: 400,
|
|
89
|
+
// 业务错误 -> 422
|
|
90
|
+
["BUSINESS_ACTIVITY_NOT_STARTED" /* BUSINESS_ACTIVITY_NOT_STARTED */]: 422,
|
|
91
|
+
["BUSINESS_ACTIVITY_ENDED" /* BUSINESS_ACTIVITY_ENDED */]: 422,
|
|
92
|
+
["BUSINESS_ALREADY_CLAIMED" /* BUSINESS_ALREADY_CLAIMED */]: 422,
|
|
93
|
+
["BUSINESS_ALREADY_SIGNED" /* BUSINESS_ALREADY_SIGNED */]: 422,
|
|
94
|
+
["BUSINESS_STOCK_EXHAUSTED" /* BUSINESS_STOCK_EXHAUSTED */]: 422,
|
|
95
|
+
["BUSINESS_QUOTA_EXCEEDED" /* BUSINESS_QUOTA_EXCEEDED */]: 422,
|
|
96
|
+
["BUSINESS_PREREQUISITE_NOT_MET" /* BUSINESS_PREREQUISITE_NOT_MET */]: 422,
|
|
97
|
+
// 风控错误 -> 429
|
|
98
|
+
["RISK_RATE_LIMITED" /* RISK_RATE_LIMITED */]: 429,
|
|
99
|
+
["RISK_BLOCKED" /* RISK_BLOCKED */]: 403,
|
|
100
|
+
["RISK_CAPTCHA_REQUIRED" /* RISK_CAPTCHA_REQUIRED */]: 428,
|
|
101
|
+
["RISK_DEVICE_ABNORMAL" /* RISK_DEVICE_ABNORMAL */]: 403,
|
|
102
|
+
["RISK_IDEMPOTENCY_CONFLICT" /* RISK_IDEMPOTENCY_CONFLICT */]: 409,
|
|
103
|
+
// 组件错误 -> 500/503
|
|
104
|
+
["COMPONENT_LOAD_FAILED" /* COMPONENT_LOAD_FAILED */]: 500,
|
|
105
|
+
["COMPONENT_INTEGRITY_MISMATCH" /* COMPONENT_INTEGRITY_MISMATCH */]: 500,
|
|
106
|
+
["COMPONENT_BLOCKED" /* COMPONENT_BLOCKED */]: 503,
|
|
107
|
+
["COMPONENT_DEPRECATED" /* COMPONENT_DEPRECATED */]: 410,
|
|
108
|
+
["COMPONENT_INCOMPATIBLE" /* COMPONENT_INCOMPATIBLE */]: 500,
|
|
109
|
+
// 发布错误 -> 409/400
|
|
110
|
+
["PUBLISH_VERSION_CONFLICT" /* PUBLISH_VERSION_CONFLICT */]: 409,
|
|
111
|
+
["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: 400,
|
|
112
|
+
["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: 500
|
|
143
113
|
};
|
|
144
114
|
var ErrorMessages = {
|
|
145
|
-
//
|
|
146
|
-
[
|
|
147
|
-
[
|
|
148
|
-
[
|
|
149
|
-
[
|
|
150
|
-
[
|
|
151
|
-
|
|
152
|
-
[
|
|
153
|
-
[
|
|
154
|
-
[
|
|
155
|
-
[
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
[
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
|
|
162
|
-
[
|
|
163
|
-
[
|
|
164
|
-
[
|
|
165
|
-
|
|
166
|
-
[
|
|
167
|
-
|
|
168
|
-
[
|
|
169
|
-
[
|
|
170
|
-
[
|
|
171
|
-
[
|
|
115
|
+
// 系统错误
|
|
116
|
+
["SYSTEM_INTERNAL_ERROR" /* SYSTEM_INTERNAL_ERROR */]: "\u7CFB\u7EDF\u5185\u90E8\u9519\u8BEF",
|
|
117
|
+
["SYSTEM_SERVICE_UNAVAILABLE" /* SYSTEM_SERVICE_UNAVAILABLE */]: "\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528",
|
|
118
|
+
["SYSTEM_TIMEOUT" /* SYSTEM_TIMEOUT */]: "\u8BF7\u6C42\u8D85\u65F6",
|
|
119
|
+
["SYSTEM_DATABASE_ERROR" /* SYSTEM_DATABASE_ERROR */]: "\u6570\u636E\u5E93\u9519\u8BEF",
|
|
120
|
+
["SYSTEM_REDIS_ERROR" /* SYSTEM_REDIS_ERROR */]: "\u7F13\u5B58\u670D\u52A1\u9519\u8BEF",
|
|
121
|
+
// 认证错误
|
|
122
|
+
["AUTH_TOKEN_MISSING" /* AUTH_TOKEN_MISSING */]: "\u7F3A\u5C11\u8BA4\u8BC1\u4EE4\u724C",
|
|
123
|
+
["AUTH_TOKEN_INVALID" /* AUTH_TOKEN_INVALID */]: "\u8BA4\u8BC1\u4EE4\u724C\u65E0\u6548",
|
|
124
|
+
["AUTH_TOKEN_EXPIRED" /* AUTH_TOKEN_EXPIRED */]: "\u8BA4\u8BC1\u4EE4\u724C\u5DF2\u8FC7\u671F",
|
|
125
|
+
["AUTH_SIGNATURE_INVALID" /* AUTH_SIGNATURE_INVALID */]: "\u7B7E\u540D\u65E0\u6548",
|
|
126
|
+
["AUTH_SESSION_EXPIRED" /* AUTH_SESSION_EXPIRED */]: "\u4F1A\u8BDD\u5DF2\u8FC7\u671F",
|
|
127
|
+
// 权限错误
|
|
128
|
+
["PERMISSION_DENIED" /* PERMISSION_DENIED */]: "\u6743\u9650\u4E0D\u8DB3",
|
|
129
|
+
["PERMISSION_RESOURCE_FORBIDDEN" /* PERMISSION_RESOURCE_FORBIDDEN */]: "\u65E0\u6743\u8BBF\u95EE\u8BE5\u8D44\u6E90",
|
|
130
|
+
["PERMISSION_ACTION_FORBIDDEN" /* PERMISSION_ACTION_FORBIDDEN */]: "\u65E0\u6743\u6267\u884C\u8BE5\u64CD\u4F5C",
|
|
131
|
+
// 资源错误
|
|
132
|
+
["RESOURCE_NOT_FOUND" /* RESOURCE_NOT_FOUND */]: "\u8D44\u6E90\u4E0D\u5B58\u5728",
|
|
133
|
+
["RESOURCE_PAGE_NOT_FOUND" /* RESOURCE_PAGE_NOT_FOUND */]: "\u9875\u9762\u4E0D\u5B58\u5728",
|
|
134
|
+
["RESOURCE_COMPONENT_NOT_FOUND" /* RESOURCE_COMPONENT_NOT_FOUND */]: "\u7EC4\u4EF6\u4E0D\u5B58\u5728",
|
|
135
|
+
["RESOURCE_ACTION_NOT_FOUND" /* RESOURCE_ACTION_NOT_FOUND */]: "\u52A8\u4F5C\u4E0D\u5B58\u5728",
|
|
136
|
+
["RESOURCE_VERSION_NOT_FOUND" /* RESOURCE_VERSION_NOT_FOUND */]: "\u7248\u672C\u4E0D\u5B58\u5728",
|
|
137
|
+
// 参数错误
|
|
138
|
+
["VALIDATION_INVALID_PARAMS" /* VALIDATION_INVALID_PARAMS */]: "\u53C2\u6570\u65E0\u6548",
|
|
139
|
+
["VALIDATION_SCHEMA_MISMATCH" /* VALIDATION_SCHEMA_MISMATCH */]: "Schema \u4E0D\u5339\u914D",
|
|
140
|
+
["VALIDATION_EXPRESSION_ERROR" /* VALIDATION_EXPRESSION_ERROR */]: "\u8868\u8FBE\u5F0F\u9519\u8BEF",
|
|
141
|
+
["VALIDATION_FIELD_REQUIRED" /* VALIDATION_FIELD_REQUIRED */]: "\u5FC5\u586B\u5B57\u6BB5\u7F3A\u5931",
|
|
142
|
+
["VALIDATION_FIELD_TYPE_ERROR" /* VALIDATION_FIELD_TYPE_ERROR */]: "\u5B57\u6BB5\u7C7B\u578B\u9519\u8BEF",
|
|
143
|
+
// 业务错误
|
|
144
|
+
["BUSINESS_ACTIVITY_NOT_STARTED" /* BUSINESS_ACTIVITY_NOT_STARTED */]: "\u6D3B\u52A8\u672A\u5F00\u59CB",
|
|
145
|
+
["BUSINESS_ACTIVITY_ENDED" /* BUSINESS_ACTIVITY_ENDED */]: "\u6D3B\u52A8\u5DF2\u7ED3\u675F",
|
|
146
|
+
["BUSINESS_ALREADY_CLAIMED" /* BUSINESS_ALREADY_CLAIMED */]: "\u5DF2\u7ECF\u9886\u53D6\u8FC7",
|
|
147
|
+
["BUSINESS_ALREADY_SIGNED" /* BUSINESS_ALREADY_SIGNED */]: "\u4ECA\u65E5\u5DF2\u7B7E\u5230",
|
|
148
|
+
["BUSINESS_STOCK_EXHAUSTED" /* BUSINESS_STOCK_EXHAUSTED */]: "\u5E93\u5B58\u4E0D\u8DB3",
|
|
149
|
+
["BUSINESS_QUOTA_EXCEEDED" /* BUSINESS_QUOTA_EXCEEDED */]: "\u8D85\u51FA\u914D\u989D\u9650\u5236",
|
|
150
|
+
["BUSINESS_PREREQUISITE_NOT_MET" /* BUSINESS_PREREQUISITE_NOT_MET */]: "\u524D\u7F6E\u6761\u4EF6\u672A\u6EE1\u8DB3",
|
|
151
|
+
// 风控错误
|
|
152
|
+
["RISK_RATE_LIMITED" /* RISK_RATE_LIMITED */]: "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",
|
|
153
|
+
["RISK_BLOCKED" /* RISK_BLOCKED */]: "\u8BF7\u6C42\u88AB\u963B\u65AD",
|
|
154
|
+
["RISK_CAPTCHA_REQUIRED" /* RISK_CAPTCHA_REQUIRED */]: "\u9700\u8981\u9A8C\u8BC1\u7801\u9A8C\u8BC1",
|
|
155
|
+
["RISK_DEVICE_ABNORMAL" /* RISK_DEVICE_ABNORMAL */]: "\u8BBE\u5907\u5F02\u5E38",
|
|
156
|
+
["RISK_IDEMPOTENCY_CONFLICT" /* RISK_IDEMPOTENCY_CONFLICT */]: "\u91CD\u590D\u8BF7\u6C42",
|
|
172
157
|
// 组件错误
|
|
173
|
-
[
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
[
|
|
178
|
-
|
|
179
|
-
[
|
|
180
|
-
|
|
181
|
-
[
|
|
182
|
-
[5002 /* PAGE_VERSION_NOT_FOUND */]: "\u9875\u9762\u7248\u672C\u4E0D\u5B58\u5728",
|
|
183
|
-
[5003 /* PAGE_SCHEMA_INVALID */]: "\u9875\u9762 Schema \u65E0\u6548",
|
|
184
|
-
[5004 /* PAGE_MANIFEST_INVALID */]: "\u9875\u9762 Manifest \u65E0\u6548",
|
|
185
|
-
[5005 /* PAGE_PUBLISH_FAILED */]: "\u9875\u9762\u53D1\u5E03\u5931\u8D25",
|
|
186
|
-
[5006 /* PAGE_ROLLBACK_FAILED */]: "\u9875\u9762\u56DE\u6EDA\u5931\u8D25",
|
|
187
|
-
// 活动错误
|
|
188
|
-
[6001 /* ACTIVITY_NOT_FOUND */]: "\u6D3B\u52A8\u4E0D\u5B58\u5728",
|
|
189
|
-
[6002 /* ACTIVITY_NOT_STARTED */]: "\u6D3B\u52A8\u672A\u5F00\u59CB",
|
|
190
|
-
[6003 /* ACTIVITY_ENDED */]: "\u6D3B\u52A8\u5DF2\u7ED3\u675F",
|
|
191
|
-
[6004 /* ACTIVITY_ALREADY_CLAIMED */]: "\u5DF2\u9886\u53D6\u8FC7",
|
|
192
|
-
[6005 /* ACTIVITY_ALREADY_SIGNED */]: "\u4ECA\u65E5\u5DF2\u7B7E\u5230",
|
|
193
|
-
[6006 /* ACTIVITY_LIMIT_EXCEEDED */]: "\u8D85\u51FA\u9886\u53D6\u9650\u5236",
|
|
194
|
-
[6007 /* ACTIVITY_DISABLED */]: "\u6D3B\u52A8\u5DF2\u7981\u7528",
|
|
195
|
-
// 表达式错误
|
|
196
|
-
[7001 /* EXPRESSION_SYNTAX_ERROR */]: "\u8868\u8FBE\u5F0F\u8BED\u6CD5\u9519\u8BEF",
|
|
197
|
-
[7002 /* EXPRESSION_UNKNOWN_FUNCTION */]: "\u672A\u77E5\u51FD\u6570",
|
|
198
|
-
[7003 /* EXPRESSION_INVALID_ARGUMENT */]: "\u65E0\u6548\u53C2\u6570",
|
|
199
|
-
[7004 /* EXPRESSION_UNKNOWN_VARIABLE */]: "\u672A\u77E5\u53D8\u91CF",
|
|
200
|
-
[7005 /* EXPRESSION_TYPE_MISMATCH */]: "\u7C7B\u578B\u4E0D\u5339\u914D",
|
|
201
|
-
[7006 /* EXPRESSION_ACCESS_DENIED */]: "\u8BBF\u95EE\u88AB\u62D2\u7EDD",
|
|
202
|
-
// 版本/迁移错误
|
|
203
|
-
[8001 /* SCHEMA_VERSION_MISMATCH */]: "Schema \u7248\u672C\u4E0D\u5339\u914D",
|
|
204
|
-
[8002 /* MIGRATION_FAILED */]: "\u8FC1\u79FB\u5931\u8D25",
|
|
205
|
-
[8003 /* MIGRATION_NOT_FOUND */]: "\u8FC1\u79FB\u811A\u672C\u4E0D\u5B58\u5728",
|
|
206
|
-
[8004 /* VERSION_INCOMPATIBLE */]: "\u7248\u672C\u4E0D\u517C\u5BB9"
|
|
158
|
+
["COMPONENT_LOAD_FAILED" /* COMPONENT_LOAD_FAILED */]: "\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25",
|
|
159
|
+
["COMPONENT_INTEGRITY_MISMATCH" /* COMPONENT_INTEGRITY_MISMATCH */]: "\u7EC4\u4EF6\u5B8C\u6574\u6027\u6821\u9A8C\u5931\u8D25",
|
|
160
|
+
["COMPONENT_BLOCKED" /* COMPONENT_BLOCKED */]: "\u7EC4\u4EF6\u5DF2\u88AB\u963B\u65AD",
|
|
161
|
+
["COMPONENT_DEPRECATED" /* COMPONENT_DEPRECATED */]: "\u7EC4\u4EF6\u5DF2\u5E9F\u5F03",
|
|
162
|
+
["COMPONENT_INCOMPATIBLE" /* COMPONENT_INCOMPATIBLE */]: "\u7EC4\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9",
|
|
163
|
+
// 发布错误
|
|
164
|
+
["PUBLISH_VERSION_CONFLICT" /* PUBLISH_VERSION_CONFLICT */]: "\u7248\u672C\u51B2\u7A81",
|
|
165
|
+
["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: "\u53D1\u5E03\u6821\u9A8C\u5931\u8D25",
|
|
166
|
+
["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: "\u56DE\u6EDA\u5931\u8D25"
|
|
207
167
|
};
|
|
208
|
-
function createDjvlcError(code,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
168
|
+
function createDjvlcError(code, message, details) {
|
|
169
|
+
const errorMessage = message || ErrorMessages[code] || "\u672A\u77E5\u9519\u8BEF";
|
|
170
|
+
const httpStatus = ErrorCodeToHttpStatus[code] || 500;
|
|
171
|
+
const error = new Error(errorMessage);
|
|
172
|
+
error.name = "DjvlcError";
|
|
173
|
+
error.code = code;
|
|
174
|
+
error.httpStatus = httpStatus;
|
|
175
|
+
error.details = details;
|
|
176
|
+
return error;
|
|
216
177
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
219
|
-
if (code === 1003 /* FORBIDDEN */) return 403;
|
|
220
|
-
if (code === 1004 /* NOT_FOUND */) return 404;
|
|
221
|
-
if (code === 1005 /* RATE_LIMITED */) return 429;
|
|
222
|
-
if (code === 1009 /* TIMEOUT */) return 408;
|
|
223
|
-
if (code === 1008 /* SERVICE_UNAVAILABLE */) return 503;
|
|
224
|
-
const numericCode = Number(code);
|
|
225
|
-
if (numericCode >= 1e3 && numericCode < 2e3) return 400;
|
|
226
|
-
if (numericCode >= 2e3 && numericCode < 3e3) return 400;
|
|
227
|
-
if (numericCode >= 3e3 && numericCode < 4e3) return 400;
|
|
228
|
-
if (numericCode >= 4e3 && numericCode < 5e3) return 404;
|
|
229
|
-
if (numericCode >= 5e3 && numericCode < 6e3) return 404;
|
|
230
|
-
if (numericCode >= 6e3 && numericCode < 7e3) return 400;
|
|
231
|
-
if (numericCode >= 7e3 && numericCode < 8e3) return 400;
|
|
232
|
-
if (numericCode >= 8e3 && numericCode < 9e3) return 400;
|
|
233
|
-
return 500;
|
|
234
|
-
}
|
|
235
|
-
function isRetryableError(code) {
|
|
236
|
-
return [
|
|
237
|
-
1009 /* TIMEOUT */,
|
|
238
|
-
1008 /* SERVICE_UNAVAILABLE */,
|
|
239
|
-
3005 /* QUERY_TIMEOUT */,
|
|
240
|
-
4006 /* COMPONENT_LOAD_FAILED */
|
|
241
|
-
].includes(code);
|
|
178
|
+
function isDjvlcError(error) {
|
|
179
|
+
return error instanceof Error && "code" in error && "httpStatus" in error && error.name === "DjvlcError";
|
|
242
180
|
}
|
|
243
181
|
|
|
244
|
-
// src/
|
|
182
|
+
// src/common/status.ts
|
|
183
|
+
var VersionStatus = /* @__PURE__ */ ((VersionStatus2) => {
|
|
184
|
+
VersionStatus2["DRAFT"] = "draft";
|
|
185
|
+
VersionStatus2["STABLE"] = "stable";
|
|
186
|
+
VersionStatus2["DEPRECATED"] = "deprecated";
|
|
187
|
+
VersionStatus2["BLOCKED"] = "blocked";
|
|
188
|
+
return VersionStatus2;
|
|
189
|
+
})(VersionStatus || {});
|
|
190
|
+
var PageStatus = /* @__PURE__ */ ((PageStatus2) => {
|
|
191
|
+
PageStatus2["DRAFT"] = "draft";
|
|
192
|
+
PageStatus2["PUBLISHED"] = "published";
|
|
193
|
+
PageStatus2["ARCHIVED"] = "archived";
|
|
194
|
+
return PageStatus2;
|
|
195
|
+
})(PageStatus || {});
|
|
196
|
+
var PublishChannel = /* @__PURE__ */ ((PublishChannel2) => {
|
|
197
|
+
PublishChannel2["PREVIEW"] = "preview";
|
|
198
|
+
PublishChannel2["GRAY"] = "gray";
|
|
199
|
+
PublishChannel2["PROD"] = "prod";
|
|
200
|
+
return PublishChannel2;
|
|
201
|
+
})(PublishChannel || {});
|
|
245
202
|
var PublishStatus = /* @__PURE__ */ ((PublishStatus2) => {
|
|
246
203
|
PublishStatus2["PENDING"] = "pending";
|
|
247
|
-
PublishStatus2["
|
|
204
|
+
PublishStatus2["PROCESSING"] = "processing";
|
|
248
205
|
PublishStatus2["SUCCESS"] = "success";
|
|
249
206
|
PublishStatus2["FAILED"] = "failed";
|
|
250
207
|
PublishStatus2["ROLLBACK"] = "rollback";
|
|
251
208
|
return PublishStatus2;
|
|
252
209
|
})(PublishStatus || {});
|
|
253
210
|
|
|
254
|
-
// src/
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
];
|
|
211
|
+
// src/common/audit.ts
|
|
212
|
+
var AuditAction = /* @__PURE__ */ ((AuditAction2) => {
|
|
213
|
+
AuditAction2["PAGE_CREATE"] = "page.create";
|
|
214
|
+
AuditAction2["PAGE_UPDATE"] = "page.update";
|
|
215
|
+
AuditAction2["PAGE_DELETE"] = "page.delete";
|
|
216
|
+
AuditAction2["PAGE_PUBLISH"] = "page.publish";
|
|
217
|
+
AuditAction2["PAGE_ROLLBACK"] = "page.rollback";
|
|
218
|
+
AuditAction2["COMPONENT_PUBLISH"] = "component.publish";
|
|
219
|
+
AuditAction2["COMPONENT_BLOCK"] = "component.block";
|
|
220
|
+
AuditAction2["COMPONENT_UNBLOCK"] = "component.unblock";
|
|
221
|
+
AuditAction2["ACTION_EXECUTE"] = "action.execute";
|
|
222
|
+
AuditAction2["DEFINITION_CREATE"] = "definition.create";
|
|
223
|
+
AuditAction2["DEFINITION_UPDATE"] = "definition.update";
|
|
224
|
+
AuditAction2["DEFINITION_PUBLISH"] = "definition.publish";
|
|
225
|
+
AuditAction2["SYSTEM_KILL_SWITCH"] = "system.kill_switch";
|
|
226
|
+
return AuditAction2;
|
|
227
|
+
})(AuditAction || {});
|
|
263
228
|
|
|
264
|
-
// src/
|
|
265
|
-
var
|
|
266
|
-
"basic",
|
|
267
|
-
"form",
|
|
268
|
-
"layout",
|
|
269
|
-
"navigation",
|
|
270
|
-
"feedback",
|
|
271
|
-
"display",
|
|
272
|
-
"data",
|
|
273
|
-
"business",
|
|
274
|
-
"chart",
|
|
275
|
-
"other"
|
|
276
|
-
];
|
|
229
|
+
// src/page/schema.ts
|
|
230
|
+
var CURRENT_SCHEMA_VERSION = "2.0.0";
|
|
277
231
|
|
|
278
|
-
// src/expression/
|
|
279
|
-
var
|
|
280
|
-
// 字符串函数
|
|
232
|
+
// src/expression/functions.ts
|
|
233
|
+
var STRING_FUNCTIONS = [
|
|
281
234
|
{
|
|
282
235
|
name: "len",
|
|
283
|
-
|
|
284
|
-
|
|
236
|
+
category: "string",
|
|
237
|
+
description: "\u83B7\u53D6\u5B57\u7B26\u4E32\u957F\u5EA6",
|
|
238
|
+
params: [{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" }],
|
|
285
239
|
returnType: "number",
|
|
286
|
-
|
|
240
|
+
pure: true,
|
|
241
|
+
examples: ['len("hello") // 5', "len(state.name) // \u52A8\u6001\u83B7\u53D6"]
|
|
287
242
|
},
|
|
288
243
|
{
|
|
289
244
|
name: "trim",
|
|
290
|
-
|
|
291
|
-
|
|
245
|
+
category: "string",
|
|
246
|
+
description: "\u53BB\u9664\u9996\u5C3E\u7A7A\u767D",
|
|
247
|
+
params: [{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" }],
|
|
292
248
|
returnType: "string",
|
|
293
|
-
|
|
249
|
+
pure: true,
|
|
250
|
+
examples: ['trim(" hello ") // "hello"']
|
|
294
251
|
},
|
|
295
252
|
{
|
|
296
253
|
name: "upper",
|
|
297
|
-
|
|
298
|
-
|
|
254
|
+
category: "string",
|
|
255
|
+
description: "\u8F6C\u6362\u4E3A\u5927\u5199",
|
|
256
|
+
params: [{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" }],
|
|
299
257
|
returnType: "string",
|
|
300
|
-
|
|
258
|
+
pure: true,
|
|
259
|
+
examples: ['upper("hello") // "HELLO"']
|
|
301
260
|
},
|
|
302
261
|
{
|
|
303
262
|
name: "lower",
|
|
304
|
-
|
|
305
|
-
|
|
263
|
+
category: "string",
|
|
264
|
+
description: "\u8F6C\u6362\u4E3A\u5C0F\u5199",
|
|
265
|
+
params: [{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" }],
|
|
306
266
|
returnType: "string",
|
|
307
|
-
|
|
267
|
+
pure: true,
|
|
268
|
+
examples: ['lower("HELLO") // "hello"']
|
|
308
269
|
},
|
|
309
270
|
{
|
|
310
|
-
name: "
|
|
271
|
+
name: "substring",
|
|
272
|
+
category: "string",
|
|
311
273
|
description: "\u622A\u53D6\u5B50\u5B57\u7B26\u4E32",
|
|
312
274
|
params: [
|
|
313
|
-
{ name: "str", type: "string", required: true },
|
|
314
|
-
{ name: "start", type: "number", required: true },
|
|
315
|
-
{ name: "
|
|
275
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
276
|
+
{ name: "start", type: "number", required: true, description: "\u8D77\u59CB\u4F4D\u7F6E" },
|
|
277
|
+
{ name: "end", type: "number", required: false, description: "\u7ED3\u675F\u4F4D\u7F6E" }
|
|
316
278
|
],
|
|
317
279
|
returnType: "string",
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
{
|
|
321
|
-
name: "concat",
|
|
322
|
-
description: "\u8FDE\u63A5\u5B57\u7B26\u4E32",
|
|
323
|
-
params: [
|
|
324
|
-
{ name: "values", type: "any", required: true, description: "\u53EF\u53D8\u53C2\u6570" }
|
|
325
|
-
],
|
|
326
|
-
returnType: "string",
|
|
327
|
-
examples: ['concat("a", "b", "c")']
|
|
280
|
+
pure: true,
|
|
281
|
+
examples: ['substring("hello", 0, 2) // "he"']
|
|
328
282
|
},
|
|
329
283
|
{
|
|
330
284
|
name: "replace",
|
|
285
|
+
category: "string",
|
|
331
286
|
description: "\u66FF\u6362\u5B57\u7B26\u4E32",
|
|
332
287
|
params: [
|
|
333
|
-
{ name: "str", type: "string", required: true },
|
|
334
|
-
{ name: "search", type: "string", required: true },
|
|
335
|
-
{ name: "replacement", type: "string", required: true }
|
|
288
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
289
|
+
{ name: "search", type: "string", required: true, description: "\u641C\u7D22\u5185\u5BB9" },
|
|
290
|
+
{ name: "replacement", type: "string", required: true, description: "\u66FF\u6362\u5185\u5BB9" }
|
|
336
291
|
],
|
|
337
292
|
returnType: "string",
|
|
338
|
-
|
|
293
|
+
pure: true,
|
|
294
|
+
examples: ['replace("hello", "l", "x") // "hexxo"']
|
|
339
295
|
},
|
|
340
296
|
{
|
|
341
297
|
name: "split",
|
|
342
|
-
|
|
298
|
+
category: "string",
|
|
299
|
+
description: "\u5206\u5272\u5B57\u7B26\u4E32\u4E3A\u6570\u7EC4",
|
|
343
300
|
params: [
|
|
344
|
-
{ name: "str", type: "string", required: true },
|
|
345
|
-
{ name: "separator", type: "string", required: true }
|
|
301
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
302
|
+
{ name: "separator", type: "string", required: true, description: "\u5206\u9694\u7B26" }
|
|
346
303
|
],
|
|
347
304
|
returnType: "array",
|
|
348
|
-
|
|
305
|
+
pure: true,
|
|
306
|
+
examples: ['split("a,b,c", ",") // ["a", "b", "c"]']
|
|
349
307
|
},
|
|
350
308
|
{
|
|
351
309
|
name: "join",
|
|
352
|
-
|
|
310
|
+
category: "string",
|
|
311
|
+
description: "\u5408\u5E76\u6570\u7EC4\u4E3A\u5B57\u7B26\u4E32",
|
|
353
312
|
params: [
|
|
354
|
-
{ name: "arr", type: "array", required: true },
|
|
355
|
-
{
|
|
313
|
+
{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" },
|
|
314
|
+
{
|
|
315
|
+
name: "separator",
|
|
316
|
+
type: "string",
|
|
317
|
+
required: false,
|
|
318
|
+
defaultValue: ",",
|
|
319
|
+
description: "\u5206\u9694\u7B26"
|
|
320
|
+
}
|
|
356
321
|
],
|
|
357
322
|
returnType: "string",
|
|
358
|
-
|
|
323
|
+
pure: true,
|
|
324
|
+
examples: ['join(["a", "b", "c"], "-") // "a-b-c"']
|
|
359
325
|
},
|
|
360
|
-
// 数字函数
|
|
361
326
|
{
|
|
362
|
-
name: "
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
327
|
+
name: "contains",
|
|
328
|
+
category: "string",
|
|
329
|
+
description: "\u68C0\u67E5\u662F\u5426\u5305\u542B\u5B50\u5B57\u7B26\u4E32",
|
|
330
|
+
params: [
|
|
331
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
332
|
+
{ name: "search", type: "string", required: true, description: "\u641C\u7D22\u5185\u5BB9" }
|
|
333
|
+
],
|
|
334
|
+
returnType: "boolean",
|
|
335
|
+
pure: true,
|
|
336
|
+
examples: ['contains("hello", "ell") // true']
|
|
367
337
|
},
|
|
368
338
|
{
|
|
369
|
-
name: "
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
339
|
+
name: "startsWith",
|
|
340
|
+
category: "string",
|
|
341
|
+
description: "\u68C0\u67E5\u662F\u5426\u4EE5\u6307\u5B9A\u524D\u7F00\u5F00\u59CB",
|
|
342
|
+
params: [
|
|
343
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
344
|
+
{ name: "prefix", type: "string", required: true, description: "\u524D\u7F00" }
|
|
345
|
+
],
|
|
346
|
+
returnType: "boolean",
|
|
347
|
+
pure: true,
|
|
348
|
+
examples: ['startsWith("hello", "he") // true']
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: "endsWith",
|
|
352
|
+
category: "string",
|
|
353
|
+
description: "\u68C0\u67E5\u662F\u5426\u4EE5\u6307\u5B9A\u540E\u7F00\u7ED3\u675F",
|
|
354
|
+
params: [
|
|
355
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
356
|
+
{ name: "suffix", type: "string", required: true, description: "\u540E\u7F00" }
|
|
357
|
+
],
|
|
358
|
+
returnType: "boolean",
|
|
359
|
+
pure: true,
|
|
360
|
+
examples: ['endsWith("hello", "lo") // true']
|
|
361
|
+
}
|
|
362
|
+
];
|
|
363
|
+
var NUMBER_FUNCTIONS = [
|
|
364
|
+
{
|
|
365
|
+
name: "toNumber",
|
|
366
|
+
category: "number",
|
|
367
|
+
description: "\u8F6C\u6362\u4E3A\u6570\u5B57",
|
|
368
|
+
params: [
|
|
369
|
+
{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" },
|
|
370
|
+
{
|
|
371
|
+
name: "defaultValue",
|
|
372
|
+
type: "number",
|
|
373
|
+
required: false,
|
|
374
|
+
defaultValue: 0,
|
|
375
|
+
description: "\u9ED8\u8BA4\u503C"
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
returnType: "number",
|
|
379
|
+
pure: true,
|
|
380
|
+
examples: ['toNumber("123") // 123', 'toNumber("abc", 0) // 0']
|
|
374
381
|
},
|
|
375
382
|
{
|
|
376
383
|
name: "round",
|
|
384
|
+
category: "number",
|
|
377
385
|
description: "\u56DB\u820D\u4E94\u5165",
|
|
378
386
|
params: [
|
|
379
|
-
{ name: "value", type: "number", required: true },
|
|
380
|
-
{
|
|
387
|
+
{ name: "value", type: "number", required: true, description: "\u8F93\u5165\u6570\u5B57" },
|
|
388
|
+
{
|
|
389
|
+
name: "decimals",
|
|
390
|
+
type: "number",
|
|
391
|
+
required: false,
|
|
392
|
+
defaultValue: 0,
|
|
393
|
+
description: "\u5C0F\u6570\u4F4D\u6570"
|
|
394
|
+
}
|
|
381
395
|
],
|
|
382
396
|
returnType: "number",
|
|
383
|
-
|
|
397
|
+
pure: true,
|
|
398
|
+
examples: ["round(3.14159, 2) // 3.14"]
|
|
384
399
|
},
|
|
385
400
|
{
|
|
386
401
|
name: "floor",
|
|
402
|
+
category: "number",
|
|
387
403
|
description: "\u5411\u4E0B\u53D6\u6574",
|
|
388
|
-
params: [{ name: "value", type: "number", required: true }],
|
|
404
|
+
params: [{ name: "value", type: "number", required: true, description: "\u8F93\u5165\u6570\u5B57" }],
|
|
389
405
|
returnType: "number",
|
|
390
|
-
|
|
406
|
+
pure: true,
|
|
407
|
+
examples: ["floor(3.7) // 3"]
|
|
391
408
|
},
|
|
392
409
|
{
|
|
393
410
|
name: "ceil",
|
|
411
|
+
category: "number",
|
|
394
412
|
description: "\u5411\u4E0A\u53D6\u6574",
|
|
395
|
-
params: [{ name: "value", type: "number", required: true }],
|
|
413
|
+
params: [{ name: "value", type: "number", required: true, description: "\u8F93\u5165\u6570\u5B57" }],
|
|
396
414
|
returnType: "number",
|
|
397
|
-
|
|
415
|
+
pure: true,
|
|
416
|
+
examples: ["ceil(3.2) // 4"]
|
|
398
417
|
},
|
|
399
418
|
{
|
|
400
419
|
name: "abs",
|
|
420
|
+
category: "number",
|
|
401
421
|
description: "\u7EDD\u5BF9\u503C",
|
|
402
|
-
params: [{ name: "value", type: "number", required: true }],
|
|
422
|
+
params: [{ name: "value", type: "number", required: true, description: "\u8F93\u5165\u6570\u5B57" }],
|
|
403
423
|
returnType: "number",
|
|
404
|
-
|
|
424
|
+
pure: true,
|
|
425
|
+
examples: ["abs(-5) // 5"]
|
|
405
426
|
},
|
|
406
427
|
{
|
|
407
428
|
name: "min",
|
|
429
|
+
category: "number",
|
|
408
430
|
description: "\u6700\u5C0F\u503C",
|
|
409
431
|
params: [
|
|
410
|
-
{ name: "values", type: "number", required: true, description: "\
|
|
432
|
+
{ name: "values", type: "number", required: true, variadic: true, description: "\u6570\u5B57\u5217\u8868" }
|
|
411
433
|
],
|
|
412
434
|
returnType: "number",
|
|
413
|
-
|
|
435
|
+
pure: true,
|
|
436
|
+
examples: ["min(1, 2, 3) // 1"]
|
|
414
437
|
},
|
|
415
438
|
{
|
|
416
439
|
name: "max",
|
|
440
|
+
category: "number",
|
|
417
441
|
description: "\u6700\u5927\u503C",
|
|
418
442
|
params: [
|
|
419
|
-
{ name: "values", type: "number", required: true, description: "\
|
|
443
|
+
{ name: "values", type: "number", required: true, variadic: true, description: "\u6570\u5B57\u5217\u8868" }
|
|
420
444
|
],
|
|
421
445
|
returnType: "number",
|
|
422
|
-
|
|
446
|
+
pure: true,
|
|
447
|
+
examples: ["max(1, 2, 3) // 3"]
|
|
423
448
|
},
|
|
424
|
-
|
|
449
|
+
{
|
|
450
|
+
name: "clamp",
|
|
451
|
+
category: "number",
|
|
452
|
+
description: "\u9650\u5236\u8303\u56F4",
|
|
453
|
+
params: [
|
|
454
|
+
{ name: "value", type: "number", required: true, description: "\u8F93\u5165\u6570\u5B57" },
|
|
455
|
+
{ name: "min", type: "number", required: true, description: "\u6700\u5C0F\u503C" },
|
|
456
|
+
{ name: "max", type: "number", required: true, description: "\u6700\u5927\u503C" }
|
|
457
|
+
],
|
|
458
|
+
returnType: "number",
|
|
459
|
+
pure: true,
|
|
460
|
+
examples: ["clamp(5, 0, 3) // 3"]
|
|
461
|
+
}
|
|
462
|
+
];
|
|
463
|
+
var ARRAY_FUNCTIONS = [
|
|
464
|
+
{
|
|
465
|
+
name: "length",
|
|
466
|
+
category: "array",
|
|
467
|
+
description: "\u83B7\u53D6\u6570\u7EC4\u957F\u5EA6",
|
|
468
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" }],
|
|
469
|
+
returnType: "number",
|
|
470
|
+
pure: true,
|
|
471
|
+
examples: ["length([1, 2, 3]) // 3"]
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
name: "first",
|
|
475
|
+
category: "array",
|
|
476
|
+
description: "\u83B7\u53D6\u7B2C\u4E00\u4E2A\u5143\u7D20",
|
|
477
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" }],
|
|
478
|
+
returnType: "any",
|
|
479
|
+
pure: true,
|
|
480
|
+
examples: ["first([1, 2, 3]) // 1"]
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
name: "last",
|
|
484
|
+
category: "array",
|
|
485
|
+
description: "\u83B7\u53D6\u6700\u540E\u4E00\u4E2A\u5143\u7D20",
|
|
486
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" }],
|
|
487
|
+
returnType: "any",
|
|
488
|
+
pure: true,
|
|
489
|
+
examples: ["last([1, 2, 3]) // 3"]
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: "at",
|
|
493
|
+
category: "array",
|
|
494
|
+
description: "\u83B7\u53D6\u6307\u5B9A\u7D22\u5F15\u7684\u5143\u7D20",
|
|
495
|
+
params: [
|
|
496
|
+
{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" },
|
|
497
|
+
{ name: "index", type: "number", required: true, description: "\u7D22\u5F15" }
|
|
498
|
+
],
|
|
499
|
+
returnType: "any",
|
|
500
|
+
pure: true,
|
|
501
|
+
examples: ["at([1, 2, 3], 1) // 2"]
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: "includes",
|
|
505
|
+
category: "array",
|
|
506
|
+
description: "\u68C0\u67E5\u662F\u5426\u5305\u542B\u5143\u7D20",
|
|
507
|
+
params: [
|
|
508
|
+
{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" },
|
|
509
|
+
{ name: "value", type: "any", required: true, description: "\u641C\u7D22\u503C" }
|
|
510
|
+
],
|
|
511
|
+
returnType: "boolean",
|
|
512
|
+
pure: true,
|
|
513
|
+
examples: ["includes([1, 2, 3], 2) // true"]
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "slice",
|
|
517
|
+
category: "array",
|
|
518
|
+
description: "\u622A\u53D6\u6570\u7EC4",
|
|
519
|
+
params: [
|
|
520
|
+
{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" },
|
|
521
|
+
{ name: "start", type: "number", required: true, description: "\u8D77\u59CB\u4F4D\u7F6E" },
|
|
522
|
+
{ name: "end", type: "number", required: false, description: "\u7ED3\u675F\u4F4D\u7F6E" }
|
|
523
|
+
],
|
|
524
|
+
returnType: "array",
|
|
525
|
+
pure: true,
|
|
526
|
+
examples: ["slice([1, 2, 3, 4], 1, 3) // [2, 3]"]
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
name: "concat",
|
|
530
|
+
category: "array",
|
|
531
|
+
description: "\u5408\u5E76\u6570\u7EC4",
|
|
532
|
+
params: [
|
|
533
|
+
{ name: "arrays", type: "array", required: true, variadic: true, description: "\u6570\u7EC4\u5217\u8868" }
|
|
534
|
+
],
|
|
535
|
+
returnType: "array",
|
|
536
|
+
pure: true,
|
|
537
|
+
examples: ["concat([1, 2], [3, 4]) // [1, 2, 3, 4]"]
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "unique",
|
|
541
|
+
category: "array",
|
|
542
|
+
description: "\u53BB\u91CD",
|
|
543
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" }],
|
|
544
|
+
returnType: "array",
|
|
545
|
+
pure: true,
|
|
546
|
+
examples: ["unique([1, 2, 2, 3]) // [1, 2, 3]"]
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
name: "reverse",
|
|
550
|
+
category: "array",
|
|
551
|
+
description: "\u53CD\u8F6C\u6570\u7EC4",
|
|
552
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u8F93\u5165\u6570\u7EC4" }],
|
|
553
|
+
returnType: "array",
|
|
554
|
+
pure: true,
|
|
555
|
+
examples: ["reverse([1, 2, 3]) // [3, 2, 1]"]
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: "sum",
|
|
559
|
+
category: "array",
|
|
560
|
+
description: "\u6C42\u548C",
|
|
561
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u6570\u5B57\u6570\u7EC4" }],
|
|
562
|
+
returnType: "number",
|
|
563
|
+
pure: true,
|
|
564
|
+
examples: ["sum([1, 2, 3]) // 6"]
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
name: "average",
|
|
568
|
+
category: "array",
|
|
569
|
+
description: "\u5E73\u5747\u503C",
|
|
570
|
+
params: [{ name: "arr", type: "array", required: true, description: "\u6570\u5B57\u6570\u7EC4" }],
|
|
571
|
+
returnType: "number",
|
|
572
|
+
pure: true,
|
|
573
|
+
examples: ["average([1, 2, 3]) // 2"]
|
|
574
|
+
}
|
|
575
|
+
];
|
|
576
|
+
var DATE_FUNCTIONS = [
|
|
425
577
|
{
|
|
426
578
|
name: "now",
|
|
427
|
-
|
|
579
|
+
category: "date",
|
|
580
|
+
description: "\u5F53\u524D\u65F6\u95F4\u6233",
|
|
428
581
|
params: [],
|
|
429
582
|
returnType: "number",
|
|
430
|
-
|
|
583
|
+
pure: false,
|
|
584
|
+
examples: ["now() // 1704067200000"]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "today",
|
|
588
|
+
category: "date",
|
|
589
|
+
description: "\u4ECA\u5929\u65E5\u671F\uFF08YYYY-MM-DD\uFF09",
|
|
590
|
+
params: [],
|
|
591
|
+
returnType: "string",
|
|
592
|
+
pure: false,
|
|
593
|
+
examples: ['today() // "2024-01-01"']
|
|
431
594
|
},
|
|
432
595
|
{
|
|
433
596
|
name: "dateFormat",
|
|
597
|
+
category: "date",
|
|
434
598
|
description: "\u683C\u5F0F\u5316\u65E5\u671F",
|
|
435
599
|
params: [
|
|
436
|
-
{ name: "
|
|
437
|
-
{ name: "format", type: "string", required:
|
|
600
|
+
{ name: "date", type: "any", required: true, description: "\u65E5\u671F\uFF08\u65F6\u95F4\u6233\u6216\u5B57\u7B26\u4E32\uFF09" },
|
|
601
|
+
{ name: "format", type: "string", required: true, description: "\u683C\u5F0F\u6A21\u677F" }
|
|
438
602
|
],
|
|
439
603
|
returnType: "string",
|
|
440
|
-
|
|
604
|
+
pure: true,
|
|
605
|
+
examples: ['dateFormat(now(), "YYYY-MM-DD") // "2024-01-01"']
|
|
441
606
|
},
|
|
442
607
|
{
|
|
443
608
|
name: "dateParse",
|
|
609
|
+
category: "date",
|
|
444
610
|
description: "\u89E3\u6790\u65E5\u671F\u5B57\u7B26\u4E32",
|
|
445
611
|
params: [
|
|
446
|
-
{ name: "
|
|
447
|
-
{ name: "format", type: "string", required: false }
|
|
612
|
+
{ name: "str", type: "string", required: true, description: "\u65E5\u671F\u5B57\u7B26\u4E32" },
|
|
613
|
+
{ name: "format", type: "string", required: false, description: "\u683C\u5F0F\u6A21\u677F" }
|
|
448
614
|
],
|
|
449
615
|
returnType: "number",
|
|
450
|
-
|
|
616
|
+
pure: true,
|
|
617
|
+
examples: ['dateParse("2024-01-01") // 1704067200000']
|
|
451
618
|
},
|
|
452
|
-
// 数组函数
|
|
453
619
|
{
|
|
454
|
-
name: "
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
620
|
+
name: "dateAdd",
|
|
621
|
+
category: "date",
|
|
622
|
+
description: "\u65E5\u671F\u52A0\u51CF",
|
|
623
|
+
params: [
|
|
624
|
+
{ name: "date", type: "any", required: true, description: "\u65E5\u671F" },
|
|
625
|
+
{ name: "amount", type: "number", required: true, description: "\u6570\u91CF" },
|
|
626
|
+
{ name: "unit", type: "string", required: true, description: "\u5355\u4F4D\uFF08day/week/month/year\uFF09" }
|
|
627
|
+
],
|
|
628
|
+
returnType: "number",
|
|
629
|
+
pure: true,
|
|
630
|
+
examples: ['dateAdd(now(), 7, "day") // \u4E00\u5468\u540E']
|
|
459
631
|
},
|
|
460
632
|
{
|
|
461
|
-
name: "
|
|
462
|
-
|
|
463
|
-
|
|
633
|
+
name: "dateDiff",
|
|
634
|
+
category: "date",
|
|
635
|
+
description: "\u65E5\u671F\u5DEE",
|
|
636
|
+
params: [
|
|
637
|
+
{ name: "date1", type: "any", required: true, description: "\u65E5\u671F1" },
|
|
638
|
+
{ name: "date2", type: "any", required: true, description: "\u65E5\u671F2" },
|
|
639
|
+
{ name: "unit", type: "string", required: false, defaultValue: "day", description: "\u5355\u4F4D" }
|
|
640
|
+
],
|
|
641
|
+
returnType: "number",
|
|
642
|
+
pure: true,
|
|
643
|
+
examples: ['dateDiff("2024-01-10", "2024-01-01", "day") // 9']
|
|
644
|
+
}
|
|
645
|
+
];
|
|
646
|
+
var LOGIC_FUNCTIONS = [
|
|
647
|
+
{
|
|
648
|
+
name: "if",
|
|
649
|
+
category: "logic",
|
|
650
|
+
description: "\u6761\u4EF6\u5224\u65AD",
|
|
651
|
+
params: [
|
|
652
|
+
{ name: "condition", type: "boolean", required: true, description: "\u6761\u4EF6" },
|
|
653
|
+
{ name: "trueValue", type: "any", required: true, description: "\u6761\u4EF6\u4E3A\u771F\u65F6\u7684\u503C" },
|
|
654
|
+
{ name: "falseValue", type: "any", required: true, description: "\u6761\u4EF6\u4E3A\u5047\u65F6\u7684\u503C" }
|
|
655
|
+
],
|
|
464
656
|
returnType: "any",
|
|
465
|
-
|
|
657
|
+
pure: true,
|
|
658
|
+
examples: ['if(state.count > 0, "\u6709", "\u65E0")']
|
|
466
659
|
},
|
|
467
660
|
{
|
|
468
|
-
name: "
|
|
469
|
-
|
|
661
|
+
name: "and",
|
|
662
|
+
category: "logic",
|
|
663
|
+
description: "\u903B\u8F91\u4E0E",
|
|
470
664
|
params: [
|
|
471
|
-
{
|
|
472
|
-
|
|
665
|
+
{
|
|
666
|
+
name: "values",
|
|
667
|
+
type: "boolean",
|
|
668
|
+
required: true,
|
|
669
|
+
variadic: true,
|
|
670
|
+
description: "\u5E03\u5C14\u503C\u5217\u8868"
|
|
671
|
+
}
|
|
473
672
|
],
|
|
474
673
|
returnType: "boolean",
|
|
475
|
-
|
|
674
|
+
pure: true,
|
|
675
|
+
examples: ["and(true, true, false) // false"]
|
|
476
676
|
},
|
|
477
677
|
{
|
|
478
|
-
name: "
|
|
479
|
-
|
|
678
|
+
name: "or",
|
|
679
|
+
category: "logic",
|
|
680
|
+
description: "\u903B\u8F91\u6216",
|
|
480
681
|
params: [
|
|
481
|
-
{
|
|
482
|
-
|
|
483
|
-
|
|
682
|
+
{
|
|
683
|
+
name: "values",
|
|
684
|
+
type: "boolean",
|
|
685
|
+
required: true,
|
|
686
|
+
variadic: true,
|
|
687
|
+
description: "\u5E03\u5C14\u503C\u5217\u8868"
|
|
688
|
+
}
|
|
484
689
|
],
|
|
485
|
-
returnType: "
|
|
486
|
-
|
|
690
|
+
returnType: "boolean",
|
|
691
|
+
pure: true,
|
|
692
|
+
examples: ["or(true, false) // true"]
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "not",
|
|
696
|
+
category: "logic",
|
|
697
|
+
description: "\u903B\u8F91\u975E",
|
|
698
|
+
params: [{ name: "value", type: "boolean", required: true, description: "\u5E03\u5C14\u503C" }],
|
|
699
|
+
returnType: "boolean",
|
|
700
|
+
pure: true,
|
|
701
|
+
examples: ["not(true) // false"]
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
name: "eq",
|
|
705
|
+
category: "logic",
|
|
706
|
+
description: "\u76F8\u7B49\u5224\u65AD",
|
|
707
|
+
params: [
|
|
708
|
+
{ name: "a", type: "any", required: true, description: "\u503C1" },
|
|
709
|
+
{ name: "b", type: "any", required: true, description: "\u503C2" }
|
|
710
|
+
],
|
|
711
|
+
returnType: "boolean",
|
|
712
|
+
pure: true,
|
|
713
|
+
examples: ["eq(1, 1) // true"]
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: "ne",
|
|
717
|
+
category: "logic",
|
|
718
|
+
description: "\u4E0D\u76F8\u7B49\u5224\u65AD",
|
|
719
|
+
params: [
|
|
720
|
+
{ name: "a", type: "any", required: true, description: "\u503C1" },
|
|
721
|
+
{ name: "b", type: "any", required: true, description: "\u503C2" }
|
|
722
|
+
],
|
|
723
|
+
returnType: "boolean",
|
|
724
|
+
pure: true,
|
|
725
|
+
examples: ["ne(1, 2) // true"]
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: "gt",
|
|
729
|
+
category: "logic",
|
|
730
|
+
description: "\u5927\u4E8E",
|
|
731
|
+
params: [
|
|
732
|
+
{ name: "a", type: "number", required: true, description: "\u503C1" },
|
|
733
|
+
{ name: "b", type: "number", required: true, description: "\u503C2" }
|
|
734
|
+
],
|
|
735
|
+
returnType: "boolean",
|
|
736
|
+
pure: true,
|
|
737
|
+
examples: ["gt(2, 1) // true"]
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
name: "gte",
|
|
741
|
+
category: "logic",
|
|
742
|
+
description: "\u5927\u4E8E\u7B49\u4E8E",
|
|
743
|
+
params: [
|
|
744
|
+
{ name: "a", type: "number", required: true, description: "\u503C1" },
|
|
745
|
+
{ name: "b", type: "number", required: true, description: "\u503C2" }
|
|
746
|
+
],
|
|
747
|
+
returnType: "boolean",
|
|
748
|
+
pure: true,
|
|
749
|
+
examples: ["gte(2, 2) // true"]
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
name: "lt",
|
|
753
|
+
category: "logic",
|
|
754
|
+
description: "\u5C0F\u4E8E",
|
|
755
|
+
params: [
|
|
756
|
+
{ name: "a", type: "number", required: true, description: "\u503C1" },
|
|
757
|
+
{ name: "b", type: "number", required: true, description: "\u503C2" }
|
|
758
|
+
],
|
|
759
|
+
returnType: "boolean",
|
|
760
|
+
pure: true,
|
|
761
|
+
examples: ["lt(1, 2) // true"]
|
|
487
762
|
},
|
|
488
|
-
|
|
763
|
+
{
|
|
764
|
+
name: "lte",
|
|
765
|
+
category: "logic",
|
|
766
|
+
description: "\u5C0F\u4E8E\u7B49\u4E8E",
|
|
767
|
+
params: [
|
|
768
|
+
{ name: "a", type: "number", required: true, description: "\u503C1" },
|
|
769
|
+
{ name: "b", type: "number", required: true, description: "\u503C2" }
|
|
770
|
+
],
|
|
771
|
+
returnType: "boolean",
|
|
772
|
+
pure: true,
|
|
773
|
+
examples: ["lte(2, 2) // true"]
|
|
774
|
+
}
|
|
775
|
+
];
|
|
776
|
+
var UTILITY_FUNCTIONS = [
|
|
489
777
|
{
|
|
490
778
|
name: "default",
|
|
491
|
-
|
|
779
|
+
category: "utility",
|
|
780
|
+
description: "\u9ED8\u8BA4\u503C",
|
|
492
781
|
params: [
|
|
493
|
-
{ name: "value", type: "any", required: true },
|
|
494
|
-
{ name: "defaultValue", type: "any", required: true }
|
|
782
|
+
{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" },
|
|
783
|
+
{ name: "defaultValue", type: "any", required: true, description: "\u9ED8\u8BA4\u503C" }
|
|
495
784
|
],
|
|
496
785
|
returnType: "any",
|
|
497
|
-
|
|
786
|
+
pure: true,
|
|
787
|
+
examples: ['default(state.name, "\u672A\u77E5")']
|
|
498
788
|
},
|
|
499
789
|
{
|
|
500
|
-
name: "
|
|
501
|
-
|
|
790
|
+
name: "coalesce",
|
|
791
|
+
category: "utility",
|
|
792
|
+
description: "\u8FD4\u56DE\u7B2C\u4E00\u4E2A\u975E\u7A7A\u503C",
|
|
502
793
|
params: [
|
|
503
|
-
{ name: "
|
|
504
|
-
{ name: "trueValue", type: "any", required: true },
|
|
505
|
-
{ name: "falseValue", type: "any", required: true }
|
|
794
|
+
{ name: "values", type: "any", required: true, variadic: true, description: "\u503C\u5217\u8868" }
|
|
506
795
|
],
|
|
507
796
|
returnType: "any",
|
|
508
|
-
|
|
797
|
+
pure: true,
|
|
798
|
+
examples: ['coalesce(null, undefined, "value") // "value"']
|
|
509
799
|
},
|
|
510
800
|
{
|
|
511
801
|
name: "isEmpty",
|
|
802
|
+
category: "utility",
|
|
512
803
|
description: "\u68C0\u67E5\u662F\u5426\u4E3A\u7A7A",
|
|
513
|
-
params: [{ name: "value", type: "any", required: true }],
|
|
804
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
514
805
|
returnType: "boolean",
|
|
515
|
-
|
|
806
|
+
pure: true,
|
|
807
|
+
examples: ['isEmpty("") // true', "isEmpty([]) // true"]
|
|
516
808
|
},
|
|
517
809
|
{
|
|
518
810
|
name: "isNull",
|
|
519
|
-
|
|
520
|
-
|
|
811
|
+
category: "utility",
|
|
812
|
+
description: "\u68C0\u67E5\u662F\u5426\u4E3A null/undefined",
|
|
813
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
814
|
+
returnType: "boolean",
|
|
815
|
+
pure: true,
|
|
816
|
+
examples: ["isNull(null) // true"]
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
name: "type",
|
|
820
|
+
category: "utility",
|
|
821
|
+
description: "\u83B7\u53D6\u503C\u7C7B\u578B",
|
|
822
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
823
|
+
returnType: "string",
|
|
824
|
+
pure: true,
|
|
825
|
+
examples: ['type([]) // "array"', 'type({}) // "object"']
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
name: "toString",
|
|
829
|
+
category: "type",
|
|
830
|
+
description: "\u8F6C\u6362\u4E3A\u5B57\u7B26\u4E32",
|
|
831
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
832
|
+
returnType: "string",
|
|
833
|
+
pure: true,
|
|
834
|
+
examples: ['toString(123) // "123"']
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
name: "toBoolean",
|
|
838
|
+
category: "type",
|
|
839
|
+
description: "\u8F6C\u6362\u4E3A\u5E03\u5C14\u503C",
|
|
840
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
521
841
|
returnType: "boolean",
|
|
522
|
-
|
|
842
|
+
pure: true,
|
|
843
|
+
examples: ['toBoolean("true") // true', "toBoolean(1) // true"]
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
name: "toJSON",
|
|
847
|
+
category: "utility",
|
|
848
|
+
description: "\u8F6C\u6362\u4E3A JSON \u5B57\u7B26\u4E32",
|
|
849
|
+
params: [{ name: "value", type: "any", required: true, description: "\u8F93\u5165\u503C" }],
|
|
850
|
+
returnType: "string",
|
|
851
|
+
pure: true,
|
|
852
|
+
examples: ['toJSON({a: 1}) // "{\\"a\\":1}"']
|
|
523
853
|
},
|
|
524
|
-
// JSON 函数
|
|
525
854
|
{
|
|
526
|
-
name: "
|
|
855
|
+
name: "fromJSON",
|
|
856
|
+
category: "utility",
|
|
527
857
|
description: "\u89E3\u6790 JSON \u5B57\u7B26\u4E32",
|
|
528
|
-
params: [{ name: "str", type: "string", required: true }],
|
|
858
|
+
params: [{ name: "str", type: "string", required: true, description: "JSON \u5B57\u7B26\u4E32" }],
|
|
529
859
|
returnType: "any",
|
|
530
|
-
|
|
860
|
+
pure: true,
|
|
861
|
+
examples: ['fromJSON("{\\"a\\":1}") // {a: 1}']
|
|
531
862
|
},
|
|
532
863
|
{
|
|
533
|
-
name: "
|
|
534
|
-
|
|
535
|
-
|
|
864
|
+
name: "get",
|
|
865
|
+
category: "object",
|
|
866
|
+
description: "\u83B7\u53D6\u5D4C\u5957\u5C5E\u6027",
|
|
867
|
+
params: [
|
|
868
|
+
{ name: "obj", type: "object", required: true, description: "\u8F93\u5165\u5BF9\u8C61" },
|
|
869
|
+
{ name: "path", type: "string", required: true, description: "\u5C5E\u6027\u8DEF\u5F84\uFF08\u70B9\u5206\u9694\uFF09" },
|
|
870
|
+
{ name: "defaultValue", type: "any", required: false, description: "\u9ED8\u8BA4\u503C" }
|
|
871
|
+
],
|
|
872
|
+
returnType: "any",
|
|
873
|
+
pure: true,
|
|
874
|
+
examples: ['get(state, "user.name", "\u672A\u77E5")']
|
|
875
|
+
}
|
|
876
|
+
];
|
|
877
|
+
var FORMAT_FUNCTIONS = [
|
|
878
|
+
{
|
|
879
|
+
name: "currency",
|
|
880
|
+
category: "format",
|
|
881
|
+
description: "\u683C\u5F0F\u5316\u8D27\u5E01",
|
|
882
|
+
params: [
|
|
883
|
+
{ name: "value", type: "number", required: true, description: "\u91D1\u989D" },
|
|
884
|
+
{
|
|
885
|
+
name: "symbol",
|
|
886
|
+
type: "string",
|
|
887
|
+
required: false,
|
|
888
|
+
defaultValue: "\xA5",
|
|
889
|
+
description: "\u8D27\u5E01\u7B26\u53F7"
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
name: "decimals",
|
|
893
|
+
type: "number",
|
|
894
|
+
required: false,
|
|
895
|
+
defaultValue: 2,
|
|
896
|
+
description: "\u5C0F\u6570\u4F4D\u6570"
|
|
897
|
+
}
|
|
898
|
+
],
|
|
899
|
+
returnType: "string",
|
|
900
|
+
pure: true,
|
|
901
|
+
examples: ['currency(1234.5) // "\xA51,234.50"']
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
name: "percent",
|
|
905
|
+
category: "format",
|
|
906
|
+
description: "\u683C\u5F0F\u5316\u767E\u5206\u6BD4",
|
|
907
|
+
params: [
|
|
908
|
+
{ name: "value", type: "number", required: true, description: "\u6570\u503C\uFF080-1\uFF09" },
|
|
909
|
+
{
|
|
910
|
+
name: "decimals",
|
|
911
|
+
type: "number",
|
|
912
|
+
required: false,
|
|
913
|
+
defaultValue: 0,
|
|
914
|
+
description: "\u5C0F\u6570\u4F4D\u6570"
|
|
915
|
+
}
|
|
916
|
+
],
|
|
917
|
+
returnType: "string",
|
|
918
|
+
pure: true,
|
|
919
|
+
examples: ['percent(0.1234) // "12%"']
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
name: "number",
|
|
923
|
+
category: "format",
|
|
924
|
+
description: "\u683C\u5F0F\u5316\u6570\u5B57\uFF08\u5343\u5206\u4F4D\uFF09",
|
|
925
|
+
params: [
|
|
926
|
+
{ name: "value", type: "number", required: true, description: "\u6570\u503C" },
|
|
927
|
+
{
|
|
928
|
+
name: "decimals",
|
|
929
|
+
type: "number",
|
|
930
|
+
required: false,
|
|
931
|
+
defaultValue: 0,
|
|
932
|
+
description: "\u5C0F\u6570\u4F4D\u6570"
|
|
933
|
+
}
|
|
934
|
+
],
|
|
935
|
+
returnType: "string",
|
|
936
|
+
pure: true,
|
|
937
|
+
examples: ['number(1234567) // "1,234,567"']
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "pluralize",
|
|
941
|
+
category: "format",
|
|
942
|
+
description: "\u590D\u6570\u5F62\u5F0F",
|
|
943
|
+
params: [
|
|
944
|
+
{ name: "count", type: "number", required: true, description: "\u6570\u91CF" },
|
|
945
|
+
{ name: "singular", type: "string", required: true, description: "\u5355\u6570\u5F62\u5F0F" },
|
|
946
|
+
{ name: "plural", type: "string", required: true, description: "\u590D\u6570\u5F62\u5F0F" }
|
|
947
|
+
],
|
|
948
|
+
returnType: "string",
|
|
949
|
+
pure: true,
|
|
950
|
+
examples: ['pluralize(1, "item", "items") // "1 item"']
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
name: "mask",
|
|
954
|
+
category: "format",
|
|
955
|
+
description: "\u63A9\u7801\u5904\u7406",
|
|
956
|
+
params: [
|
|
957
|
+
{ name: "str", type: "string", required: true, description: "\u8F93\u5165\u5B57\u7B26\u4E32" },
|
|
958
|
+
{
|
|
959
|
+
name: "keepPrefix",
|
|
960
|
+
type: "number",
|
|
961
|
+
required: false,
|
|
962
|
+
defaultValue: 3,
|
|
963
|
+
description: "\u4FDD\u7559\u524D\u7F00"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
name: "keepSuffix",
|
|
967
|
+
type: "number",
|
|
968
|
+
required: false,
|
|
969
|
+
defaultValue: 4,
|
|
970
|
+
description: "\u4FDD\u7559\u540E\u7F00"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
name: "maskChar",
|
|
974
|
+
type: "string",
|
|
975
|
+
required: false,
|
|
976
|
+
defaultValue: "*",
|
|
977
|
+
description: "\u63A9\u7801\u5B57\u7B26"
|
|
978
|
+
}
|
|
979
|
+
],
|
|
536
980
|
returnType: "string",
|
|
537
|
-
|
|
981
|
+
pure: true,
|
|
982
|
+
examples: ['mask("13812345678", 3, 4) // "138****5678"']
|
|
538
983
|
}
|
|
539
984
|
];
|
|
540
|
-
var
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
985
|
+
var ALL_BUILTIN_FUNCTIONS = [
|
|
986
|
+
...STRING_FUNCTIONS,
|
|
987
|
+
...NUMBER_FUNCTIONS,
|
|
988
|
+
...ARRAY_FUNCTIONS,
|
|
989
|
+
...DATE_FUNCTIONS,
|
|
990
|
+
...LOGIC_FUNCTIONS,
|
|
991
|
+
...UTILITY_FUNCTIONS,
|
|
992
|
+
...FORMAT_FUNCTIONS
|
|
548
993
|
];
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// src/rbac/index.ts
|
|
561
|
-
var BUILTIN_PERMISSIONS = {
|
|
562
|
-
// 页面权限
|
|
563
|
-
PAGE_READ: "page:read",
|
|
564
|
-
PAGE_CREATE: "page:create",
|
|
565
|
-
PAGE_UPDATE: "page:update",
|
|
566
|
-
PAGE_DELETE: "page:delete",
|
|
567
|
-
PAGE_PUBLISH: "page:publish",
|
|
568
|
-
PAGE_ROLLBACK: "page:rollback",
|
|
569
|
-
// 组件权限
|
|
570
|
-
COMPONENT_READ: "component:read",
|
|
571
|
-
COMPONENT_CREATE: "component:create",
|
|
572
|
-
COMPONENT_BLOCK: "component:block",
|
|
573
|
-
COMPONENT_UNBLOCK: "component:unblock",
|
|
574
|
-
// 活动权限
|
|
575
|
-
ACTIVITY_READ: "activity:read",
|
|
576
|
-
ACTIVITY_CREATE: "activity:create",
|
|
577
|
-
ACTIVITY_UPDATE: "activity:update",
|
|
578
|
-
// 定义权限
|
|
579
|
-
DEFINITION_READ: "definition:read",
|
|
580
|
-
DEFINITION_CREATE: "definition:create",
|
|
581
|
-
DEFINITION_UPDATE: "definition:update",
|
|
582
|
-
// 管理员权限
|
|
583
|
-
ADMIN_ALL: "*:*"
|
|
584
|
-
};
|
|
585
|
-
var BUILTIN_ROLES = {
|
|
586
|
-
/** 超级管理员 */
|
|
587
|
-
SUPER_ADMIN: "super_admin",
|
|
588
|
-
/** 租户管理员 */
|
|
589
|
-
TENANT_ADMIN: "tenant_admin",
|
|
590
|
-
/** 应用管理员 */
|
|
591
|
-
APP_ADMIN: "app_admin",
|
|
592
|
-
/** 编辑者 */
|
|
593
|
-
EDITOR: "editor",
|
|
594
|
-
/** 发布者 */
|
|
595
|
-
PUBLISHER: "publisher",
|
|
596
|
-
/** 审核者 */
|
|
597
|
-
REVIEWER: "reviewer",
|
|
598
|
-
/** 查看者 */
|
|
599
|
-
VIEWER: "viewer"
|
|
994
|
+
var ALLOWED_FUNCTION_NAMES = ALL_BUILTIN_FUNCTIONS.map((f) => f.name);
|
|
995
|
+
var DEFAULT_EXPRESSION_VALIDATION_CONFIG = {
|
|
996
|
+
allowedContextPaths: ["state", "binding", "context", "props", "event"],
|
|
997
|
+
allowedFunctions: ALLOWED_FUNCTION_NAMES,
|
|
998
|
+
maxDepth: 10,
|
|
999
|
+
maxLength: 1e3,
|
|
1000
|
+
allowTemplate: true,
|
|
1001
|
+
allowChaining: true
|
|
600
1002
|
};
|
|
601
1003
|
|
|
602
|
-
// src/
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var migrations = [];
|
|
606
|
-
function registerMigration(migration) {
|
|
607
|
-
const exists = migrations.some(
|
|
608
|
-
(m) => m.from === migration.from && m.to === migration.to
|
|
609
|
-
);
|
|
610
|
-
if (exists) {
|
|
611
|
-
throw new Error(`Migration from ${migration.from} to ${migration.to} already exists`);
|
|
612
|
-
}
|
|
613
|
-
migrations.push(migration);
|
|
1004
|
+
// src/page/expression.ts
|
|
1005
|
+
function literal(value) {
|
|
1006
|
+
return value;
|
|
614
1007
|
}
|
|
615
|
-
function
|
|
616
|
-
return
|
|
1008
|
+
function stateRef(path, fallback) {
|
|
1009
|
+
return {
|
|
1010
|
+
type: "state",
|
|
1011
|
+
value: path,
|
|
1012
|
+
fallback,
|
|
1013
|
+
meta: { dependencies: [`state.${path}`] }
|
|
1014
|
+
};
|
|
617
1015
|
}
|
|
618
|
-
function
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
path.push(nextMigration);
|
|
627
|
-
current = nextMigration.to;
|
|
628
|
-
if (path.length > 100) {
|
|
629
|
-
throw new Error("Migration path too long, possible circular dependency");
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return path;
|
|
1016
|
+
function bindingRef(bindingId, path, fallback) {
|
|
1017
|
+
return {
|
|
1018
|
+
type: "binding",
|
|
1019
|
+
value: `${bindingId}.${path}`,
|
|
1020
|
+
fallback,
|
|
1021
|
+
meta: { dependencies: [`binding.${bindingId}.${path}`] }
|
|
1022
|
+
};
|
|
633
1023
|
}
|
|
634
|
-
function
|
|
635
|
-
const
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
fromVersion,
|
|
642
|
-
toVersion,
|
|
643
|
-
appliedMigrations: []
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
try {
|
|
647
|
-
const path = findMigrationPath(fromVersion, toVersion);
|
|
648
|
-
let result = { ...data };
|
|
649
|
-
const appliedMigrations = [];
|
|
650
|
-
for (const migration of path) {
|
|
651
|
-
result = migration.migrate(result);
|
|
652
|
-
result.schemaVersion = migration.to;
|
|
653
|
-
appliedMigrations.push(`${migration.from} -> ${migration.to}`);
|
|
1024
|
+
function template(templateString, fallback) {
|
|
1025
|
+
const dependencies = [];
|
|
1026
|
+
const pattern = /\$\{([^}]+)\}/g;
|
|
1027
|
+
let match;
|
|
1028
|
+
while ((match = pattern.exec(templateString)) !== null) {
|
|
1029
|
+
if (match[1]) {
|
|
1030
|
+
dependencies.push(match[1]);
|
|
654
1031
|
}
|
|
655
|
-
return {
|
|
656
|
-
success: true,
|
|
657
|
-
data: result,
|
|
658
|
-
fromVersion,
|
|
659
|
-
toVersion,
|
|
660
|
-
appliedMigrations
|
|
661
|
-
};
|
|
662
|
-
} catch (error) {
|
|
663
|
-
return {
|
|
664
|
-
success: false,
|
|
665
|
-
fromVersion,
|
|
666
|
-
toVersion,
|
|
667
|
-
appliedMigrations: [],
|
|
668
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
669
|
-
};
|
|
670
1032
|
}
|
|
1033
|
+
return {
|
|
1034
|
+
type: "template",
|
|
1035
|
+
value: templateString,
|
|
1036
|
+
fallback,
|
|
1037
|
+
meta: { dependencies }
|
|
1038
|
+
};
|
|
671
1039
|
}
|
|
672
|
-
function
|
|
673
|
-
|
|
674
|
-
const target = targetVersion || CURRENT_SCHEMA_VERSION;
|
|
675
|
-
return currentVersion !== target;
|
|
676
|
-
}
|
|
677
|
-
function getVersionInfo(version) {
|
|
678
|
-
const [major, minor, patch] = version.split(".").map(Number);
|
|
679
|
-
return { major, minor, patch };
|
|
680
|
-
}
|
|
681
|
-
function compareVersions(a, b) {
|
|
682
|
-
const va = getVersionInfo(a);
|
|
683
|
-
const vb = getVersionInfo(b);
|
|
684
|
-
if (va.major !== vb.major) return va.major < vb.major ? -1 : 1;
|
|
685
|
-
if (va.minor !== vb.minor) return va.minor < vb.minor ? -1 : 1;
|
|
686
|
-
if (va.patch !== vb.patch) return va.patch < vb.patch ? -1 : 1;
|
|
687
|
-
return 0;
|
|
1040
|
+
function queryRef(queryId, path, fallback) {
|
|
1041
|
+
return bindingRef(queryId, path, fallback);
|
|
688
1042
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
1043
|
+
|
|
1044
|
+
// src/component/meta.ts
|
|
1045
|
+
var CURRENT_COMPONENT_META_VERSION = "2.0.0";
|
|
1046
|
+
|
|
1047
|
+
// src/action/types.ts
|
|
1048
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
1049
|
+
ActionType2["CLAIM"] = "claim";
|
|
1050
|
+
ActionType2["SIGNIN"] = "signin";
|
|
1051
|
+
ActionType2["LOTTERY"] = "lottery";
|
|
1052
|
+
ActionType2["RESERVE"] = "reserve";
|
|
1053
|
+
ActionType2["BIND"] = "bind";
|
|
1054
|
+
ActionType2["TASK_COMPLETE"] = "task_complete";
|
|
1055
|
+
ActionType2["VOTE"] = "vote";
|
|
1056
|
+
ActionType2["SHARE"] = "share";
|
|
1057
|
+
ActionType2["FORM_SUBMIT"] = "form_submit";
|
|
1058
|
+
ActionType2["CUSTOM"] = "custom";
|
|
1059
|
+
return ActionType2;
|
|
1060
|
+
})(ActionType || {});
|
|
1061
|
+
|
|
1062
|
+
// src/action/spec.ts
|
|
1063
|
+
var CURRENT_ACTION_SPEC_VERSION = "2.0.0";
|
|
1064
|
+
|
|
1065
|
+
// src/data-query/spec.ts
|
|
1066
|
+
var CURRENT_DATA_QUERY_SPEC_VERSION = "2.0.0";
|
|
1067
|
+
|
|
1068
|
+
// src/index.ts
|
|
1069
|
+
var VERSION = "2.1.0";
|
|
1070
|
+
var PROTOCOL_VERSION = "2.0.0";
|
|
1071
|
+
var PAGE_SCHEMA_VERSION = "2.0.0";
|
|
1072
|
+
var COMPONENT_META_SCHEMA_VERSION = "2.0.0";
|
|
1073
|
+
var ACTION_SPEC_VERSION = "2.0.0";
|
|
1074
|
+
var DATA_QUERY_SPEC_VERSION = "2.0.0";
|
|
1075
|
+
|
|
1076
|
+
exports.ACTION_SPEC_VERSION = ACTION_SPEC_VERSION;
|
|
1077
|
+
exports.ALLOWED_FUNCTION_NAMES = ALLOWED_FUNCTION_NAMES;
|
|
1078
|
+
exports.ALL_BUILTIN_FUNCTIONS = ALL_BUILTIN_FUNCTIONS;
|
|
1079
|
+
exports.ARRAY_FUNCTIONS = ARRAY_FUNCTIONS;
|
|
1080
|
+
exports.ActionType = ActionType;
|
|
1081
|
+
exports.AuditAction = AuditAction;
|
|
1082
|
+
exports.COMPONENT_META_SCHEMA_VERSION = COMPONENT_META_SCHEMA_VERSION;
|
|
1083
|
+
exports.CURRENT_ACTION_SPEC_VERSION = CURRENT_ACTION_SPEC_VERSION;
|
|
1084
|
+
exports.CURRENT_COMPONENT_META_VERSION = CURRENT_COMPONENT_META_VERSION;
|
|
1085
|
+
exports.CURRENT_DATA_QUERY_SPEC_VERSION = CURRENT_DATA_QUERY_SPEC_VERSION;
|
|
1086
|
+
exports.CURRENT_SCHEMA_VERSION = CURRENT_SCHEMA_VERSION;
|
|
1087
|
+
exports.DATA_QUERY_SPEC_VERSION = DATA_QUERY_SPEC_VERSION;
|
|
1088
|
+
exports.DATE_FUNCTIONS = DATE_FUNCTIONS;
|
|
1089
|
+
exports.DEFAULT_EXPRESSION_VALIDATION_CONFIG = DEFAULT_EXPRESSION_VALIDATION_CONFIG;
|
|
1090
|
+
exports.ErrorCategory = ErrorCategory;
|
|
1091
|
+
exports.ErrorCode = ErrorCode;
|
|
1092
|
+
exports.ErrorCodeToHttpStatus = ErrorCodeToHttpStatus;
|
|
1093
|
+
exports.ErrorMessages = ErrorMessages;
|
|
1094
|
+
exports.FORMAT_FUNCTIONS = FORMAT_FUNCTIONS;
|
|
1095
|
+
exports.LOGIC_FUNCTIONS = LOGIC_FUNCTIONS;
|
|
1096
|
+
exports.NUMBER_FUNCTIONS = NUMBER_FUNCTIONS;
|
|
1097
|
+
exports.PAGE_SCHEMA_VERSION = PAGE_SCHEMA_VERSION;
|
|
1098
|
+
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1099
|
+
exports.PageStatus = PageStatus;
|
|
1100
|
+
exports.PublishChannel = PublishChannel;
|
|
1101
|
+
exports.PublishStatus = PublishStatus;
|
|
1102
|
+
exports.STRING_FUNCTIONS = STRING_FUNCTIONS;
|
|
1103
|
+
exports.UTILITY_FUNCTIONS = UTILITY_FUNCTIONS;
|
|
1104
|
+
exports.VERSION = VERSION;
|
|
1105
|
+
exports.VersionStatus = VersionStatus;
|
|
1106
|
+
exports.bindingRef = bindingRef;
|
|
1107
|
+
exports.createDjvlcError = createDjvlcError;
|
|
1108
|
+
exports.isDjvlcError = isDjvlcError;
|
|
1109
|
+
exports.literal = literal;
|
|
1110
|
+
exports.queryRef = queryRef;
|
|
1111
|
+
exports.stateRef = stateRef;
|
|
1112
|
+
exports.template = template;
|