@arronqzy/blueprint-dsl 1.0.16 → 1.0.17
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.cjs +211 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +209 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,146 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/messages.ts
|
|
4
|
+
var ZH_CN = {
|
|
5
|
+
invalidJson: "\u4E0D\u662F\u6709\u6548 JSON\uFF1A{reason}",
|
|
6
|
+
invalidFormat: "\u683C\u5F0F\u65E0\u6548",
|
|
7
|
+
jsonInvalid: "JSON \u683C\u5F0F\u65E0\u6548",
|
|
8
|
+
jsonEmpty: "JSON \u4E0D\u80FD\u4E3A\u7A7A",
|
|
9
|
+
jsonRootMustBeContainer: "JSON \u6839\u8282\u70B9\u5FC5\u987B\u662F object \u6216 array",
|
|
10
|
+
contentEmpty: "\u5185\u5BB9\u4E3A\u7A7A",
|
|
11
|
+
contentRequired: "\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A",
|
|
12
|
+
codeRequired: "\u4EE3\u7801\u4E0D\u80FD\u4E3A\u7A7A",
|
|
13
|
+
javascriptSyntaxError: "JavaScript \u8BED\u6CD5\u9519\u8BEF",
|
|
14
|
+
logicUpdateRequired: "\u9700\u8981\u5B9A\u4E49 update(input) \u51FD\u6570",
|
|
15
|
+
apiItemMustBeObject: "apis[{index}] \u5FC5\u987B\u662F\u5BF9\u8C61",
|
|
16
|
+
apiItemFieldRequired: "apis[{index}].{field} \u5FC5\u586B\u4E14\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32",
|
|
17
|
+
apiItemMethodInvalid: "apis[{index}].method \u5FC5\u987B\u662F {methods} \u4E4B\u4E00",
|
|
18
|
+
apiItemFieldStringMap: "apis[{index}].{field} \u5FC5\u987B\u662F string \u5B57\u5178",
|
|
19
|
+
apiItemFieldString: "apis[{index}].{field} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32",
|
|
20
|
+
apiRootMustBeObject: "\u6839\u8282\u70B9\u5FC5\u987B\u662F\u5BF9\u8C61",
|
|
21
|
+
apiVersionMismatch: "version \u5FC5\u987B\u4E3A {version}",
|
|
22
|
+
apiNameRequired: "name \u5FC5\u586B\u4E14\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32",
|
|
23
|
+
apiBaseUrlString: "baseUrl \u5FC5\u987B\u662F\u5B57\u7B26\u4E32",
|
|
24
|
+
apiListMustBeArray: "apis \u5FC5\u987B\u662F\u6570\u7EC4",
|
|
25
|
+
apiListEmpty: "apis \u81F3\u5C11\u5305\u542B\u4E00\u6761\u63A5\u53E3",
|
|
26
|
+
apiNameDuplicated: "\u63A5\u53E3\u540D\u79F0\u91CD\u590D\uFF1A{name}",
|
|
27
|
+
apiTemplateName: "\u793A\u4F8B\u63A5\u53E3\u96C6\u5408",
|
|
28
|
+
apiTemplateListUsers: "\u83B7\u53D6\u7528\u6237\u5217\u8868",
|
|
29
|
+
apiTemplateListUsersDesc: "\u5206\u9875\u67E5\u8BE2\u7528\u6237\uFF1Bpage / tenant / token \u53EF\u7528 Scope \u6A21\u7248",
|
|
30
|
+
apiTemplateCreateUser: "\u521B\u5EFA\u7528\u6237",
|
|
31
|
+
apiTemplateCreateUserDesc: "\u521B\u5EFA\u7528\u6237\uFF1BURL \u4E0E body \u5747\u652F\u6301 Scope \u6A21\u7248",
|
|
32
|
+
apiTemplateGetUser: "\u83B7\u53D6\u7528\u6237\u8BE6\u60C5",
|
|
33
|
+
apiTemplateGetUserDesc: "\u6309 id \u67E5\u8BE2\uFF1B\u8DEF\u5F84\u91CC\u53EF\u76F4\u63A5\u5199 Scope \u6A21\u7248",
|
|
34
|
+
fetchUrlMissing: "\u8BF7\u6C42 URL \u672A\u914D\u7F6E",
|
|
35
|
+
fetchBodyInvalidJson: "\u8BF7\u6C42\u4F53\u4E0D\u662F\u6709\u6548 JSON\uFF1A{reason}",
|
|
36
|
+
fetchResponseInvalidJson: "\u54CD\u5E94\u4E0D\u662F\u6709\u6548\u7684 JSON",
|
|
37
|
+
fetchAborted: "\u8BF7\u6C42\u5DF2\u4E2D\u6B62",
|
|
38
|
+
fetchTimeout: "\u8BF7\u6C42\u8D85\u65F6\uFF08{ms}ms\uFF09",
|
|
39
|
+
headersTemplateNotObject: "\u8BF7\u6C42\u5934\u6A21\u677F\u89E3\u6790\u540E\u4E0D\u662F\u6709\u6548\u7684 JSON \u5BF9\u8C61",
|
|
40
|
+
headersNotObject: "\u8BF7\u6C42\u5934\u4E0D\u662F\u6709\u6548\u7684 JSON \u5BF9\u8C61",
|
|
41
|
+
swaggerInvalid: "Swagger \u6587\u6863\u683C\u5F0F\u65E0\u6548",
|
|
42
|
+
openApiNoOperations: "\u672A\u5728 OpenAPI \u6587\u6863\u4E2D\u627E\u5230\u63A5\u53E3",
|
|
43
|
+
swagger2NoOperations: "\u672A\u5728 Swagger 2.0 \u6587\u6863\u4E2D\u627E\u5230\u63A5\u53E3",
|
|
44
|
+
swaggerUnsupported: "\u4EC5\u652F\u6301 OpenAPI 3.x \u4E0E Swagger 2.0 \u6587\u6863",
|
|
45
|
+
storageUnsupported: "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 {storage}",
|
|
46
|
+
storageKeyEmpty: "\u5B58\u50A8\u5199\u5165 key \u89E3\u6790\u4E3A\u7A7A",
|
|
47
|
+
clockCountPositive: "\u8F93\u51FA\u6B21\u6570\u987B\u5927\u4E8E 0",
|
|
48
|
+
clockIntervalPositive: "\u5F53\u524D\u914D\u7F6E\u4E0B\u65F6\u949F\u4FE1\u53F7\u95F4\u9694\u987B\u5927\u4E8E 0 \u79D2",
|
|
49
|
+
lifecycleSignalMissing: "\u751F\u547D\u5468\u671F\u4FE1\u53F7\u7F3A\u5931",
|
|
50
|
+
blueprintCycle: "\u84DD\u56FE\u5F15\u7528\u5B58\u5728\u6B7B\u5FAA\u73AF\uFF1A{path}",
|
|
51
|
+
debugMustStartFromLifecycle: "\u8C03\u8BD5\u4F1A\u8BDD\u53EA\u80FD\u4ECE\u751F\u547D\u5468\u671F\u8282\u70B9\u5F00\u59CB",
|
|
52
|
+
nodeRemoved: "\u8282\u70B9\u5DF2\u4ECE\u84DD\u56FE\u4E2D\u79FB\u9664",
|
|
53
|
+
clockNeedsTrue: "\u65F6\u949F\u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u542F\u52A8",
|
|
54
|
+
blueprintNeedsTrue: "\u84DD\u56FE\u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u6267\u884C",
|
|
55
|
+
blueprintNotSelected: "\u672A\u9009\u62E9\u84DD\u56FE\u5E93\u4E2D\u7684\u84DD\u56FE",
|
|
56
|
+
blueprintResolverMissing: "\u84DD\u56FE\u5E93\u89E3\u6790\u5668\u672A\u914D\u7F6E",
|
|
57
|
+
blueprintRecordMissing: "\u84DD\u56FE\u5E93\u8BB0\u5F55\u4E0D\u5B58\u5728: {id}",
|
|
58
|
+
fetchNoUpstream: "\u6570\u636E\u6E90\u8282\u70B9\u672A\u6536\u5230\u4E0A\u6E38\u8F93\u51FA\uFF0C\u8BF7\u786E\u8BA4\u8FDE\u7EBF\u4E0E\u4E0A\u6E38\u8282\u70B9\u5DF2\u6267\u884C",
|
|
59
|
+
fetchNeedsTrue: "\u6570\u636E\u6E90\u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u53D1\u8D77\u8BF7\u6C42",
|
|
60
|
+
jsonNeedsTrue: "JSON \u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u89E3\u6790",
|
|
61
|
+
storageNeedsTrue: "\u5B58\u50A8\u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u8BFB\u5199\u7F13\u5B58",
|
|
62
|
+
andNeedsBothTrue: "\u5E76\u8FD0\u7B97\uFF1A\u4E24\u4E2A\u8F93\u5165\u987B\u5747\u4E3A\u771F\u4FE1\u53F7"
|
|
63
|
+
};
|
|
64
|
+
var EN_US = {
|
|
65
|
+
invalidJson: "Invalid JSON: {reason}",
|
|
66
|
+
invalidFormat: "invalid format",
|
|
67
|
+
jsonInvalid: "Invalid JSON",
|
|
68
|
+
jsonEmpty: "JSON cannot be empty",
|
|
69
|
+
jsonRootMustBeContainer: "JSON root must be an object or array",
|
|
70
|
+
contentEmpty: "Content is empty",
|
|
71
|
+
contentRequired: "Content cannot be empty",
|
|
72
|
+
codeRequired: "Code cannot be empty",
|
|
73
|
+
javascriptSyntaxError: "JavaScript syntax error",
|
|
74
|
+
logicUpdateRequired: "An update(input) function is required",
|
|
75
|
+
apiItemMustBeObject: "apis[{index}] must be an object",
|
|
76
|
+
apiItemFieldRequired: "apis[{index}].{field} is required and must be a non-empty string",
|
|
77
|
+
apiItemMethodInvalid: "apis[{index}].method must be one of {methods}",
|
|
78
|
+
apiItemFieldStringMap: "apis[{index}].{field} must be a string map",
|
|
79
|
+
apiItemFieldString: "apis[{index}].{field} must be a string",
|
|
80
|
+
apiRootMustBeObject: "Root must be an object",
|
|
81
|
+
apiVersionMismatch: "version must be {version}",
|
|
82
|
+
apiNameRequired: "name is required and must be a non-empty string",
|
|
83
|
+
apiBaseUrlString: "baseUrl must be a string",
|
|
84
|
+
apiListMustBeArray: "apis must be an array",
|
|
85
|
+
apiListEmpty: "apis must contain at least one API",
|
|
86
|
+
apiNameDuplicated: "Duplicate API name: {name}",
|
|
87
|
+
apiTemplateName: "Sample API collection",
|
|
88
|
+
apiTemplateListUsers: "List users",
|
|
89
|
+
apiTemplateListUsersDesc: "Paged user query; page / tenant / token accept Scope templates",
|
|
90
|
+
apiTemplateCreateUser: "Create user",
|
|
91
|
+
apiTemplateCreateUserDesc: "Create a user; URL and body both accept Scope templates",
|
|
92
|
+
apiTemplateGetUser: "Get user detail",
|
|
93
|
+
apiTemplateGetUserDesc: "Query by id; Scope templates can be used directly in the path",
|
|
94
|
+
fetchUrlMissing: "Request URL is not configured",
|
|
95
|
+
fetchBodyInvalidJson: "Request body is not valid JSON: {reason}",
|
|
96
|
+
fetchResponseInvalidJson: "Response is not valid JSON",
|
|
97
|
+
fetchAborted: "Request aborted",
|
|
98
|
+
fetchTimeout: "Request timed out ({ms}ms)",
|
|
99
|
+
headersTemplateNotObject: "Headers template does not resolve to a JSON object",
|
|
100
|
+
headersNotObject: "Headers are not a valid JSON object",
|
|
101
|
+
swaggerInvalid: "Invalid Swagger document",
|
|
102
|
+
openApiNoOperations: "No operations found in the OpenAPI document",
|
|
103
|
+
swagger2NoOperations: "No operations found in the Swagger 2.0 document",
|
|
104
|
+
swaggerUnsupported: "Only OpenAPI 3.x and Swagger 2.0 documents are supported",
|
|
105
|
+
storageUnsupported: "{storage} is not available in this environment",
|
|
106
|
+
storageKeyEmpty: "Storage write key resolved to empty",
|
|
107
|
+
clockCountPositive: "Output count must be greater than 0",
|
|
108
|
+
clockIntervalPositive: "Clock interval must be greater than 0 seconds with the current config",
|
|
109
|
+
lifecycleSignalMissing: "Lifecycle signal is missing",
|
|
110
|
+
blueprintCycle: "Blueprint references form a cycle: {path}",
|
|
111
|
+
debugMustStartFromLifecycle: "A debug session can only start from a lifecycle node",
|
|
112
|
+
nodeRemoved: "Node was removed from the blueprint",
|
|
113
|
+
clockNeedsTrue: "Clock node starts only after receiving a true signal",
|
|
114
|
+
blueprintNeedsTrue: "Blueprint node runs only after receiving a true signal",
|
|
115
|
+
blueprintNotSelected: "No blueprint selected from the library",
|
|
116
|
+
blueprintResolverMissing: "Blueprint library resolver is not configured",
|
|
117
|
+
blueprintRecordMissing: "Blueprint library record not found: {id}",
|
|
118
|
+
fetchNoUpstream: "Data source node received no upstream output; check the connection and that upstream nodes ran",
|
|
119
|
+
fetchNeedsTrue: "Data source node sends the request only after receiving a true signal",
|
|
120
|
+
jsonNeedsTrue: "JSON node parses only after receiving a true signal",
|
|
121
|
+
storageNeedsTrue: "Storage node reads/writes only after receiving a true signal",
|
|
122
|
+
andNeedsBothTrue: "AND: both inputs must be true signals"
|
|
123
|
+
};
|
|
124
|
+
var CATALOGS = {
|
|
125
|
+
"zh-CN": ZH_CN,
|
|
126
|
+
"en-US": EN_US
|
|
127
|
+
};
|
|
128
|
+
var currentLocale = "zh-CN";
|
|
129
|
+
function setBlueprintDslLocale(locale) {
|
|
130
|
+
currentLocale = locale;
|
|
131
|
+
}
|
|
132
|
+
function getBlueprintDslLocale() {
|
|
133
|
+
return currentLocale;
|
|
134
|
+
}
|
|
135
|
+
function dslMessage(key, params) {
|
|
136
|
+
const template = CATALOGS[currentLocale][key];
|
|
137
|
+
if (!params) return template;
|
|
138
|
+
return template.replace(
|
|
139
|
+
/\{(\w+)\}/g,
|
|
140
|
+
(match, name) => name in params ? String(params[name]) : match
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
3
144
|
// src/lifecycle.ts
|
|
4
145
|
var PAGE_LIFECYCLE_PHASES = [
|
|
5
146
|
"created",
|
|
@@ -139,7 +280,7 @@ function registerDefaultBehaviors(registry) {
|
|
|
139
280
|
registry.registerJS("lifecycle-emit", async ({ token, io }) => {
|
|
140
281
|
const lifecycle = token.scope.vars.get(LIFECYCLE_SIGNAL_KEY);
|
|
141
282
|
if (!lifecycle) {
|
|
142
|
-
io.setOutput("out", createFalseSignal("
|
|
283
|
+
io.setOutput("out", createFalseSignal(dslMessage("lifecycleSignalMissing")));
|
|
143
284
|
} else if (lifecycle.phase === "blueprintActivated") {
|
|
144
285
|
io.setOutput(
|
|
145
286
|
"out",
|
|
@@ -974,7 +1115,7 @@ function hasExplicitUrlScheme(url) {
|
|
|
974
1115
|
function resolveFetchRequestUrl(config) {
|
|
975
1116
|
const rawUrl = config.url?.trim() ?? "";
|
|
976
1117
|
if (!rawUrl) {
|
|
977
|
-
throw new Error("
|
|
1118
|
+
throw new Error(dslMessage("fetchUrlMissing"));
|
|
978
1119
|
}
|
|
979
1120
|
if (hasExplicitUrlScheme(rawUrl)) {
|
|
980
1121
|
return rawUrl;
|
|
@@ -1004,7 +1145,7 @@ function linkAbortSignal(controller, external) {
|
|
|
1004
1145
|
async function executeFetch(config, options) {
|
|
1005
1146
|
const rawUrl = config.url?.trim();
|
|
1006
1147
|
if (!rawUrl) {
|
|
1007
|
-
throw new Error("
|
|
1148
|
+
throw new Error(dslMessage("fetchUrlMissing"));
|
|
1008
1149
|
}
|
|
1009
1150
|
const url = resolveFetchRequestUrl(config);
|
|
1010
1151
|
const method = config.method ?? "GET";
|
|
@@ -1015,7 +1156,9 @@ async function executeFetch(config, options) {
|
|
|
1015
1156
|
JSON.parse(body);
|
|
1016
1157
|
} catch (error) {
|
|
1017
1158
|
throw new Error(
|
|
1018
|
-
|
|
1159
|
+
dslMessage("fetchBodyInvalidJson", {
|
|
1160
|
+
reason: error instanceof Error ? error.message : dslMessage("invalidFormat")
|
|
1161
|
+
})
|
|
1019
1162
|
);
|
|
1020
1163
|
}
|
|
1021
1164
|
}
|
|
@@ -1056,7 +1199,7 @@ async function executeFetch(config, options) {
|
|
|
1056
1199
|
if (options?.allowHttpError) {
|
|
1057
1200
|
data = text;
|
|
1058
1201
|
} else {
|
|
1059
|
-
throw new Error("
|
|
1202
|
+
throw new Error(dslMessage("fetchResponseInvalidJson"));
|
|
1060
1203
|
}
|
|
1061
1204
|
}
|
|
1062
1205
|
}
|
|
@@ -1076,9 +1219,9 @@ async function executeFetch(config, options) {
|
|
|
1076
1219
|
} catch (error) {
|
|
1077
1220
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1078
1221
|
if (options?.signal?.aborted) {
|
|
1079
|
-
throw new Error("
|
|
1222
|
+
throw new Error(dslMessage("fetchAborted"));
|
|
1080
1223
|
}
|
|
1081
|
-
throw new Error(
|
|
1224
|
+
throw new Error(dslMessage("fetchTimeout", { ms: timeoutMs }));
|
|
1082
1225
|
}
|
|
1083
1226
|
throw error;
|
|
1084
1227
|
} finally {
|
|
@@ -1424,7 +1567,7 @@ function parseJsonText(text) {
|
|
|
1424
1567
|
} catch (error) {
|
|
1425
1568
|
return {
|
|
1426
1569
|
ok: false,
|
|
1427
|
-
error: error instanceof Error ? error.message : "
|
|
1570
|
+
error: error instanceof Error ? error.message : dslMessage("jsonInvalid")
|
|
1428
1571
|
};
|
|
1429
1572
|
}
|
|
1430
1573
|
}
|
|
@@ -1432,7 +1575,7 @@ function validateFetchJsonText(text, options) {
|
|
|
1432
1575
|
const trimmed = text.trim();
|
|
1433
1576
|
if (!trimmed) {
|
|
1434
1577
|
if (options?.allowEmpty === false) {
|
|
1435
|
-
return { ok: false, error: "
|
|
1578
|
+
return { ok: false, error: dslMessage("contentRequired") };
|
|
1436
1579
|
}
|
|
1437
1580
|
return { ok: true };
|
|
1438
1581
|
}
|
|
@@ -1477,13 +1620,13 @@ function getFetchHeadersValidationError(config, scope) {
|
|
|
1477
1620
|
if (isWholeScopeExpression(raw) || hasScopeTemplate(raw)) {
|
|
1478
1621
|
if (scope === void 0) return null;
|
|
1479
1622
|
const parsed2 = parseFetchHeadersJson(raw, scope);
|
|
1480
|
-
if (!parsed2) return "
|
|
1623
|
+
if (!parsed2) return dslMessage("headersTemplateNotObject");
|
|
1481
1624
|
return null;
|
|
1482
1625
|
}
|
|
1483
1626
|
const result = validateFetchJsonText(raw);
|
|
1484
1627
|
if (!result.ok) return result.error;
|
|
1485
1628
|
const parsed = parseFetchHeadersJson(raw, scope);
|
|
1486
|
-
if (!parsed) return "
|
|
1629
|
+
if (!parsed) return dslMessage("headersNotObject");
|
|
1487
1630
|
return null;
|
|
1488
1631
|
}
|
|
1489
1632
|
function isWholeScopeExpression(text) {
|
|
@@ -1808,7 +1951,7 @@ function lintJsonString(jsonString) {
|
|
|
1808
1951
|
const raw = jsonString ?? "";
|
|
1809
1952
|
const trimmed = raw.trim();
|
|
1810
1953
|
if (!trimmed) {
|
|
1811
|
-
return { ok: false, error: "
|
|
1954
|
+
return { ok: false, error: dslMessage("jsonEmpty"), ranges: [] };
|
|
1812
1955
|
}
|
|
1813
1956
|
const suspectRanges = findSuspectCharRanges(raw);
|
|
1814
1957
|
const trimStart = raw.indexOf(trimmed);
|
|
@@ -1818,13 +1961,13 @@ function lintJsonString(jsonString) {
|
|
|
1818
1961
|
if (value === null || typeof value !== "object") {
|
|
1819
1962
|
return {
|
|
1820
1963
|
ok: false,
|
|
1821
|
-
error: "
|
|
1964
|
+
error: dslMessage("jsonRootMustBeContainer"),
|
|
1822
1965
|
ranges: mergeRanges(suspectRanges)
|
|
1823
1966
|
};
|
|
1824
1967
|
}
|
|
1825
1968
|
return { ok: true, value };
|
|
1826
1969
|
} catch (error) {
|
|
1827
|
-
const message = error instanceof Error ? error.message : "
|
|
1970
|
+
const message = error instanceof Error ? error.message : dslMessage("jsonInvalid");
|
|
1828
1971
|
const ranges = [...suspectRanges];
|
|
1829
1972
|
const fromEngine = extractJsonErrorPosition(message, trimmed);
|
|
1830
1973
|
const fromScan = findJsonSyntaxErrorOffset(trimmed);
|
|
@@ -2025,7 +2168,7 @@ function requireStorage(accessors, kind) {
|
|
|
2025
2168
|
const target = kind === "session" ? accessors?.session : accessors?.local;
|
|
2026
2169
|
if (!target) {
|
|
2027
2170
|
throw new Error(
|
|
2028
|
-
kind === "session" ? "
|
|
2171
|
+
kind === "session" ? dslMessage("storageUnsupported", { storage: "sessionStorage" }) : dslMessage("storageUnsupported", { storage: "localStorage" })
|
|
2029
2172
|
);
|
|
2030
2173
|
}
|
|
2031
2174
|
return target;
|
|
@@ -2038,7 +2181,7 @@ function executeStorageConfig(config, incomingScope, accessors) {
|
|
|
2038
2181
|
const serialized = serializeStorageValue(value);
|
|
2039
2182
|
const key = resolveStorageKey(normalized.set.key, incomingScope);
|
|
2040
2183
|
if (!key) {
|
|
2041
|
-
throw new Error("
|
|
2184
|
+
throw new Error(dslMessage("storageKeyEmpty"));
|
|
2042
2185
|
}
|
|
2043
2186
|
for (const kind of normalized.set.storages) {
|
|
2044
2187
|
requireStorage(store, kind).setItem(key, serialized);
|
|
@@ -2078,7 +2221,7 @@ function compileLogicRunner(sourceCode) {
|
|
|
2078
2221
|
`"use strict";
|
|
2079
2222
|
${sourceCode}
|
|
2080
2223
|
if (typeof update !== "function") {
|
|
2081
|
-
throw new TypeError(
|
|
2224
|
+
throw new TypeError(dslMessage("logicUpdateRequired"));
|
|
2082
2225
|
}
|
|
2083
2226
|
return update(input);`
|
|
2084
2227
|
);
|
|
@@ -2086,7 +2229,7 @@ return update(input);`
|
|
|
2086
2229
|
function validateLogicSourceCode(sourceCode) {
|
|
2087
2230
|
const raw = sourceCode?.trim();
|
|
2088
2231
|
if (!raw) {
|
|
2089
|
-
return { ok: false, error: "
|
|
2232
|
+
return { ok: false, error: dslMessage("codeRequired") };
|
|
2090
2233
|
}
|
|
2091
2234
|
try {
|
|
2092
2235
|
compileLogicRunner(raw);
|
|
@@ -2094,7 +2237,7 @@ function validateLogicSourceCode(sourceCode) {
|
|
|
2094
2237
|
} catch (error) {
|
|
2095
2238
|
return {
|
|
2096
2239
|
ok: false,
|
|
2097
|
-
error: error instanceof Error ? error.message : "
|
|
2240
|
+
error: error instanceof Error ? error.message : dslMessage("javascriptSyntaxError")
|
|
2098
2241
|
};
|
|
2099
2242
|
}
|
|
2100
2243
|
}
|
|
@@ -2130,11 +2273,11 @@ function normalizeClockConfig(config) {
|
|
|
2130
2273
|
function validateClockScheduleConfig(config) {
|
|
2131
2274
|
const normalized = normalizeClockConfig(config);
|
|
2132
2275
|
if (normalized.outputCount <= 0) {
|
|
2133
|
-
return { ok: false, error: "
|
|
2276
|
+
return { ok: false, error: dslMessage("clockCountPositive") };
|
|
2134
2277
|
}
|
|
2135
2278
|
const needsInterval = normalized.outputCount > 1 || normalized.outputCount === 1 && !normalized.emitImmediately;
|
|
2136
2279
|
if (needsInterval && normalized.intervalSeconds <= 0) {
|
|
2137
|
-
return { ok: false, error: "
|
|
2280
|
+
return { ok: false, error: dslMessage("clockIntervalPositive") };
|
|
2138
2281
|
}
|
|
2139
2282
|
return { ok: true };
|
|
2140
2283
|
}
|
|
@@ -2423,24 +2566,24 @@ function parseSwaggerV2(spec, docsUrl) {
|
|
|
2423
2566
|
}
|
|
2424
2567
|
function parseSwaggerDocument(spec, docsUrl) {
|
|
2425
2568
|
if (!spec || typeof spec !== "object") {
|
|
2426
|
-
throw new Error("
|
|
2569
|
+
throw new Error(dslMessage("swaggerInvalid"));
|
|
2427
2570
|
}
|
|
2428
2571
|
const document2 = spec;
|
|
2429
2572
|
if (typeof document2.openapi === "string") {
|
|
2430
2573
|
const parsed = parseOpenApiV3(document2, docsUrl);
|
|
2431
2574
|
if (parsed.endpoints.length === 0) {
|
|
2432
|
-
throw new Error("
|
|
2575
|
+
throw new Error(dslMessage("openApiNoOperations"));
|
|
2433
2576
|
}
|
|
2434
2577
|
return parsed;
|
|
2435
2578
|
}
|
|
2436
2579
|
if (document2.swagger === "2.0" || document2.swagger === 2) {
|
|
2437
2580
|
const parsed = parseSwaggerV2(document2, docsUrl);
|
|
2438
2581
|
if (parsed.endpoints.length === 0) {
|
|
2439
|
-
throw new Error("
|
|
2582
|
+
throw new Error(dslMessage("swagger2NoOperations"));
|
|
2440
2583
|
}
|
|
2441
2584
|
return parsed;
|
|
2442
2585
|
}
|
|
2443
|
-
throw new Error("
|
|
2586
|
+
throw new Error(dslMessage("swaggerUnsupported"));
|
|
2444
2587
|
}
|
|
2445
2588
|
function buildEndpointFullUrl(apiBaseUrl, pathOrEndpoint) {
|
|
2446
2589
|
const path = typeof pathOrEndpoint === "string" ? pathOrEndpoint : pathOrEndpoint.path;
|
|
@@ -2480,28 +2623,28 @@ function isPlainStringRecord(value) {
|
|
|
2480
2623
|
}
|
|
2481
2624
|
function normalizeEndpoint(raw, index) {
|
|
2482
2625
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
2483
|
-
return
|
|
2626
|
+
return dslMessage("apiItemMustBeObject", { index });
|
|
2484
2627
|
}
|
|
2485
2628
|
const item = raw;
|
|
2486
2629
|
const name = typeof item.name === "string" ? item.name.trim() : "";
|
|
2487
|
-
if (!name) return
|
|
2630
|
+
if (!name) return dslMessage("apiItemFieldRequired", { index, field: "name" });
|
|
2488
2631
|
const url = typeof item.url === "string" ? item.url.trim() : "";
|
|
2489
|
-
if (!url) return
|
|
2632
|
+
if (!url) return dslMessage("apiItemFieldRequired", { index, field: "url" });
|
|
2490
2633
|
const methodRaw = typeof item.method === "string" ? item.method.trim().toUpperCase() : "";
|
|
2491
2634
|
if (!HTTP_METHOD_SET.has(methodRaw)) {
|
|
2492
|
-
return
|
|
2635
|
+
return dslMessage("apiItemMethodInvalid", { index, methods: FETCH_HTTP_METHODS.join(" / ") });
|
|
2493
2636
|
}
|
|
2494
2637
|
if (item.params !== void 0 && !isPlainStringRecord(item.params)) {
|
|
2495
|
-
return
|
|
2638
|
+
return dslMessage("apiItemFieldStringMap", { index, field: "params" });
|
|
2496
2639
|
}
|
|
2497
2640
|
if (item.headers !== void 0 && !isPlainStringRecord(item.headers)) {
|
|
2498
|
-
return
|
|
2641
|
+
return dslMessage("apiItemFieldStringMap", { index, field: "headers" });
|
|
2499
2642
|
}
|
|
2500
2643
|
if (item.body !== void 0 && typeof item.body !== "string") {
|
|
2501
|
-
return
|
|
2644
|
+
return dslMessage("apiItemFieldString", { index, field: "body" });
|
|
2502
2645
|
}
|
|
2503
2646
|
if (item.description !== void 0 && typeof item.description !== "string") {
|
|
2504
|
-
return
|
|
2647
|
+
return dslMessage("apiItemFieldString", { index, field: "description" });
|
|
2505
2648
|
}
|
|
2506
2649
|
return {
|
|
2507
2650
|
name,
|
|
@@ -2515,26 +2658,26 @@ function normalizeEndpoint(raw, index) {
|
|
|
2515
2658
|
}
|
|
2516
2659
|
function validateApiCollectionDocument(input) {
|
|
2517
2660
|
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
2518
|
-
return { ok: false, error: "
|
|
2661
|
+
return { ok: false, error: dslMessage("apiRootMustBeObject") };
|
|
2519
2662
|
}
|
|
2520
2663
|
const root = input;
|
|
2521
2664
|
const version = root.version;
|
|
2522
2665
|
if (version !== API_COLLECTION_DOCUMENT_VERSION && version !== "1") {
|
|
2523
2666
|
return {
|
|
2524
2667
|
ok: false,
|
|
2525
|
-
error:
|
|
2668
|
+
error: dslMessage("apiVersionMismatch", { version: API_COLLECTION_DOCUMENT_VERSION })
|
|
2526
2669
|
};
|
|
2527
2670
|
}
|
|
2528
2671
|
const name = typeof root.name === "string" ? root.name.trim() : "";
|
|
2529
|
-
if (!name) return { ok: false, error: "
|
|
2672
|
+
if (!name) return { ok: false, error: dslMessage("apiNameRequired") };
|
|
2530
2673
|
if (root.baseUrl !== void 0 && typeof root.baseUrl !== "string") {
|
|
2531
|
-
return { ok: false, error: "
|
|
2674
|
+
return { ok: false, error: dslMessage("apiBaseUrlString") };
|
|
2532
2675
|
}
|
|
2533
2676
|
if (!Array.isArray(root.apis)) {
|
|
2534
|
-
return { ok: false, error: "
|
|
2677
|
+
return { ok: false, error: dslMessage("apiListMustBeArray") };
|
|
2535
2678
|
}
|
|
2536
2679
|
if (root.apis.length === 0) {
|
|
2537
|
-
return { ok: false, error: "
|
|
2680
|
+
return { ok: false, error: dslMessage("apiListEmpty") };
|
|
2538
2681
|
}
|
|
2539
2682
|
const apis = [];
|
|
2540
2683
|
const nameSet = /* @__PURE__ */ new Set();
|
|
@@ -2544,7 +2687,7 @@ function validateApiCollectionDocument(input) {
|
|
|
2544
2687
|
return { ok: false, error: normalized };
|
|
2545
2688
|
}
|
|
2546
2689
|
if (nameSet.has(normalized.name)) {
|
|
2547
|
-
return { ok: false, error:
|
|
2690
|
+
return { ok: false, error: dslMessage("apiNameDuplicated", { name: normalized.name }) };
|
|
2548
2691
|
}
|
|
2549
2692
|
nameSet.add(normalized.name);
|
|
2550
2693
|
apis.push(normalized);
|
|
@@ -2561,14 +2704,16 @@ function validateApiCollectionDocument(input) {
|
|
|
2561
2704
|
}
|
|
2562
2705
|
function parseApiCollectionJson(text) {
|
|
2563
2706
|
const trimmed = text.trim();
|
|
2564
|
-
if (!trimmed) return { ok: false, error: "
|
|
2707
|
+
if (!trimmed) return { ok: false, error: dslMessage("contentEmpty") };
|
|
2565
2708
|
let parsed;
|
|
2566
2709
|
try {
|
|
2567
2710
|
parsed = JSON.parse(trimmed);
|
|
2568
2711
|
} catch (error) {
|
|
2569
2712
|
return {
|
|
2570
2713
|
ok: false,
|
|
2571
|
-
error:
|
|
2714
|
+
error: dslMessage("invalidJson", {
|
|
2715
|
+
reason: error instanceof Error ? error.message : dslMessage("invalidFormat")
|
|
2716
|
+
})
|
|
2572
2717
|
};
|
|
2573
2718
|
}
|
|
2574
2719
|
const validated = validateApiCollectionDocument(parsed);
|
|
@@ -2594,11 +2739,11 @@ function apiCollectionToListItem(record) {
|
|
|
2594
2739
|
function getApiCollectionTemplateDocument() {
|
|
2595
2740
|
return {
|
|
2596
2741
|
version: API_COLLECTION_DOCUMENT_VERSION,
|
|
2597
|
-
name: "
|
|
2742
|
+
name: dslMessage("apiTemplateName"),
|
|
2598
2743
|
baseUrl: "https://api.example.com",
|
|
2599
2744
|
apis: [
|
|
2600
2745
|
{
|
|
2601
|
-
name: "
|
|
2746
|
+
name: dslMessage("apiTemplateListUsers"),
|
|
2602
2747
|
method: "GET",
|
|
2603
2748
|
url: "/users",
|
|
2604
2749
|
params: {
|
|
@@ -2610,22 +2755,22 @@ function getApiCollectionTemplateDocument() {
|
|
|
2610
2755
|
Accept: "application/json",
|
|
2611
2756
|
Authorization: "Bearer {scope?.value?.token}"
|
|
2612
2757
|
},
|
|
2613
|
-
description: "
|
|
2758
|
+
description: dslMessage("apiTemplateListUsersDesc")
|
|
2614
2759
|
},
|
|
2615
2760
|
{
|
|
2616
|
-
name: "
|
|
2761
|
+
name: dslMessage("apiTemplateCreateUser"),
|
|
2617
2762
|
method: "POST",
|
|
2618
2763
|
url: "/tenants/{scope?.value?.tenant}/users",
|
|
2619
2764
|
headers: { "Content-Type": "application/json" },
|
|
2620
2765
|
body: '{\n "name": "{scope?.value?.name}",\n "role": "member"\n}',
|
|
2621
|
-
description: "
|
|
2766
|
+
description: dslMessage("apiTemplateCreateUserDesc")
|
|
2622
2767
|
},
|
|
2623
2768
|
{
|
|
2624
|
-
name: "
|
|
2769
|
+
name: dslMessage("apiTemplateGetUser"),
|
|
2625
2770
|
method: "GET",
|
|
2626
2771
|
url: "/users/{scope?.value?.id}",
|
|
2627
2772
|
headers: { Accept: "application/json" },
|
|
2628
|
-
description: "
|
|
2773
|
+
description: dslMessage("apiTemplateGetUserDesc")
|
|
2629
2774
|
}
|
|
2630
2775
|
]
|
|
2631
2776
|
};
|
|
@@ -2930,7 +3075,7 @@ function collectBlueprintLibraryRefs(graph) {
|
|
|
2930
3075
|
}
|
|
2931
3076
|
function formatBlueprintCycleMessage(cycleIds, resolveName) {
|
|
2932
3077
|
const labels = cycleIds.map((id) => resolveName?.(id) ?? id);
|
|
2933
|
-
return
|
|
3078
|
+
return dslMessage("blueprintCycle", { path: labels.join(" \u2192 ") });
|
|
2934
3079
|
}
|
|
2935
3080
|
async function detectBlueprintReferenceCycle(options) {
|
|
2936
3081
|
const {
|
|
@@ -3390,7 +3535,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3390
3535
|
stopAllClockSchedules();
|
|
3391
3536
|
const node = this.requireNode(lifecycleNodeId);
|
|
3392
3537
|
if (node.nodeType !== LIFECYCLE_NODE_TYPE) {
|
|
3393
|
-
throw new Error("
|
|
3538
|
+
throw new Error(dslMessage("debugMustStartFromLifecycle"));
|
|
3394
3539
|
}
|
|
3395
3540
|
this.outputs.clear();
|
|
3396
3541
|
this.traceEntries = [];
|
|
@@ -3591,7 +3736,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3591
3736
|
const runExecutor = executor ?? this.debugExecutor ?? this.createExecutor(this.debugQueue ?? []);
|
|
3592
3737
|
if (!this.syncTokenFromGraph(token)) {
|
|
3593
3738
|
return this.appendDebugTraceEntry(token, nodeLabelById, startedAt, {
|
|
3594
|
-
error: "
|
|
3739
|
+
error: dslMessage("nodeRemoved")
|
|
3595
3740
|
});
|
|
3596
3741
|
}
|
|
3597
3742
|
try {
|
|
@@ -3652,7 +3797,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3652
3797
|
}
|
|
3653
3798
|
if (!isTrueSignal(input)) {
|
|
3654
3799
|
return finishWithOutput(
|
|
3655
|
-
createFalseSignal("
|
|
3800
|
+
createFalseSignal(dslMessage("clockNeedsTrue"))
|
|
3656
3801
|
);
|
|
3657
3802
|
}
|
|
3658
3803
|
const validation = validateClockScheduleConfig(normalized);
|
|
@@ -3727,19 +3872,19 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3727
3872
|
if (!isTrueSignal(input)) {
|
|
3728
3873
|
io.setOutput(
|
|
3729
3874
|
"out",
|
|
3730
|
-
createFalseSignal("
|
|
3875
|
+
createFalseSignal(dslMessage("blueprintNeedsTrue"))
|
|
3731
3876
|
);
|
|
3732
3877
|
io.emitFlow("out");
|
|
3733
3878
|
return;
|
|
3734
3879
|
}
|
|
3735
3880
|
const libraryId = node.libraryBlueprintId;
|
|
3736
3881
|
if (!libraryId) {
|
|
3737
|
-
io.setOutput("out", createFalseSignal("
|
|
3882
|
+
io.setOutput("out", createFalseSignal(dslMessage("blueprintNotSelected")));
|
|
3738
3883
|
io.emitFlow("out");
|
|
3739
3884
|
return;
|
|
3740
3885
|
}
|
|
3741
3886
|
if (!runner.resolveLibraryBlueprint) {
|
|
3742
|
-
io.setOutput("out", createFalseSignal("
|
|
3887
|
+
io.setOutput("out", createFalseSignal(dslMessage("blueprintResolverMissing")));
|
|
3743
3888
|
io.emitFlow("out");
|
|
3744
3889
|
return;
|
|
3745
3890
|
}
|
|
@@ -3762,7 +3907,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3762
3907
|
if (!nestedGraph) {
|
|
3763
3908
|
io.setOutput(
|
|
3764
3909
|
"out",
|
|
3765
|
-
createFalseSignal(
|
|
3910
|
+
createFalseSignal(dslMessage("blueprintRecordMissing", { id: libraryId }))
|
|
3766
3911
|
);
|
|
3767
3912
|
io.emitFlow("out");
|
|
3768
3913
|
return;
|
|
@@ -3814,7 +3959,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3814
3959
|
io.setOutput(
|
|
3815
3960
|
"out",
|
|
3816
3961
|
createFalseSignal(
|
|
3817
|
-
input === void 0 ? "
|
|
3962
|
+
input === void 0 ? dslMessage("fetchNoUpstream") : dslMessage("fetchNeedsTrue")
|
|
3818
3963
|
)
|
|
3819
3964
|
);
|
|
3820
3965
|
io.emitFlow("out");
|
|
@@ -3835,7 +3980,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3835
3980
|
}
|
|
3836
3981
|
const bodyError = getFetchBodyValidationError(config.body, config.body);
|
|
3837
3982
|
if (bodyError) {
|
|
3838
|
-
throw new Error(
|
|
3983
|
+
throw new Error(dslMessage("fetchBodyInvalidJson", { reason: bodyError }));
|
|
3839
3984
|
}
|
|
3840
3985
|
resolveFetchRequestUrl(config);
|
|
3841
3986
|
const result = await executeFetch(config, {
|
|
@@ -3891,7 +4036,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3891
4036
|
if (!isTrueSignal(input)) {
|
|
3892
4037
|
io.setOutput(
|
|
3893
4038
|
"out",
|
|
3894
|
-
createFalseSignal("
|
|
4039
|
+
createFalseSignal(dslMessage("jsonNeedsTrue"))
|
|
3895
4040
|
);
|
|
3896
4041
|
io.emitFlow("out");
|
|
3897
4042
|
return;
|
|
@@ -3933,7 +4078,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3933
4078
|
if (!isTrueSignal(input)) {
|
|
3934
4079
|
io.setOutput(
|
|
3935
4080
|
"out",
|
|
3936
|
-
createFalseSignal("
|
|
4081
|
+
createFalseSignal(dslMessage("storageNeedsTrue"))
|
|
3937
4082
|
);
|
|
3938
4083
|
io.emitFlow("out");
|
|
3939
4084
|
return;
|
|
@@ -3978,7 +4123,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
3978
4123
|
if (!isTrueSignal(input)) {
|
|
3979
4124
|
io.setOutput(
|
|
3980
4125
|
"out",
|
|
3981
|
-
createFalseSignal("
|
|
4126
|
+
createFalseSignal(dslMessage("clockNeedsTrue"))
|
|
3982
4127
|
);
|
|
3983
4128
|
io.emitFlow("out");
|
|
3984
4129
|
return;
|
|
@@ -4016,7 +4161,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
|
|
|
4016
4161
|
} else {
|
|
4017
4162
|
io.setOutput(
|
|
4018
4163
|
"out",
|
|
4019
|
-
createFalseSignal("
|
|
4164
|
+
createFalseSignal(dslMessage("andNeedsBothTrue"))
|
|
4020
4165
|
);
|
|
4021
4166
|
}
|
|
4022
4167
|
io.emitFlow("out");
|
|
@@ -4297,6 +4442,7 @@ exports.detectBlueprintReferenceCycle = detectBlueprintReferenceCycle;
|
|
|
4297
4442
|
exports.detectRuntimeBlueprintCycle = detectRuntimeBlueprintCycle;
|
|
4298
4443
|
exports.downloadApiCollectionTemplate = downloadApiCollectionTemplate;
|
|
4299
4444
|
exports.draftFetchHeadersText = draftFetchHeadersText;
|
|
4445
|
+
exports.dslMessage = dslMessage;
|
|
4300
4446
|
exports.evaluateScopeExpression = evaluateScopeExpression;
|
|
4301
4447
|
exports.evaluateScopeTemplate = evaluateScopeTemplate;
|
|
4302
4448
|
exports.evaluateScopeTemplateInJson = evaluateScopeTemplateInJson;
|
|
@@ -4315,6 +4461,7 @@ exports.formatClockTime = formatClockTime;
|
|
|
4315
4461
|
exports.getActiveClockNodeIds = getActiveClockNodeIds;
|
|
4316
4462
|
exports.getApiCollectionTemplateDocument = getApiCollectionTemplateDocument;
|
|
4317
4463
|
exports.getApiCollectionTemplateJson = getApiCollectionTemplateJson;
|
|
4464
|
+
exports.getBlueprintDslLocale = getBlueprintDslLocale;
|
|
4318
4465
|
exports.getClockTickDelayOffsetMs = getClockTickDelayOffsetMs;
|
|
4319
4466
|
exports.getClockTickWaitMs = getClockTickWaitMs;
|
|
4320
4467
|
exports.getFetchBodyValidationError = getFetchBodyValidationError;
|
|
@@ -4367,6 +4514,7 @@ exports.resolveStorageWriteValue = resolveStorageWriteValue;
|
|
|
4367
4514
|
exports.scheduleClockOutputs = scheduleClockOutputs;
|
|
4368
4515
|
exports.serializeStorageValue = serializeStorageValue;
|
|
4369
4516
|
exports.serializeTraceValue = serializeTraceValue;
|
|
4517
|
+
exports.setBlueprintDslLocale = setBlueprintDslLocale;
|
|
4370
4518
|
exports.snapshotDomEvent = snapshotDomEvent;
|
|
4371
4519
|
exports.snapshotViewEventNode = snapshotViewEventNode;
|
|
4372
4520
|
exports.startClockSchedule = startClockSchedule;
|