@uipath/data-fabric-tool 1.206.0-preview.306 → 1.207.0-preview.307
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/choice-sets-inline-1gv2mydg.js +173 -0
- package/dist/{entities-inline-6cz4y6gd.js → entities-inline-k0qggbgm.js} +429 -824
- package/dist/{federated-payload-1dcd1mck.js → federated-payload-d82r8jsd.js} +309 -7
- package/dist/index.js +9 -6
- package/dist/{packager-tool-8h3n7zh5.js → packager-tool-0whbpj17.js} +255 -248
- package/dist/packager-tool-34pcyhns.js +11 -0
- package/dist/packager-tool-3wzz1wn4.js +37 -0
- package/dist/{packager-tool-0j0r03b9.js → packager-tool-4amqsjff.js} +46 -1077
- package/dist/packager-tool-745zeysc.js +52 -0
- package/dist/{packager-tool-jy2jp2xx.js → packager-tool-7gac4cbd.js} +384 -97
- package/dist/packager-tool-kt0mxbv8.js +1455 -0
- package/dist/{packager-tool-gj7vsn2f.js → packager-tool-skeew4e3.js} +2741 -2566
- package/dist/{packager-tool-b1anyew3.js → packager-tool-spr308qr.js} +13043 -13001
- package/dist/packager-tool-yxv0qfms.js +64 -0
- package/dist/packager-tool-zwqkr7z9.js +2197 -0
- package/dist/packager-tool.js +5 -3
- package/dist/sdk-client-d91ez016.js +13 -0
- package/dist/tool.js +9 -6
- package/package.json +2 -2
- package/dist/packager-tool-cbbznax3.js +0 -101
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
catchError
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
catchError
|
|
3
|
+
} from "./packager-tool-0whbpj17.js";
|
|
4
|
+
import {
|
|
5
|
+
isLocallyAuthored,
|
|
6
|
+
validateEntity,
|
|
7
|
+
referenceIssues,
|
|
8
|
+
entityGraphIssues,
|
|
9
|
+
ENTITY_EXTENSION_CONST,
|
|
10
|
+
ENTITY_VALIDATION_FAILED,
|
|
11
|
+
PACK_DIAGNOSTIC_CODES,
|
|
12
|
+
verifyPair,
|
|
13
|
+
findSolutionRoot,
|
|
14
|
+
withoutOneOccurrence,
|
|
15
|
+
collectSolutionEntityNames,
|
|
16
|
+
readSolutionNativeEntitiesAsync,
|
|
17
|
+
readSolutionChoiceSetsAsync
|
|
18
|
+
} from "./packager-tool-zwqkr7z9.js";
|
|
8
19
|
|
|
9
20
|
// ../packager/packager-core/src/services/tools-factory-repository.ts
|
|
10
21
|
class ToolsFactoryRepository {
|
|
@@ -108,6 +119,8 @@ class Path {
|
|
|
108
119
|
return entries;
|
|
109
120
|
}
|
|
110
121
|
}
|
|
122
|
+
// ../packager/packager-core/src/services/project-identity.ts
|
|
123
|
+
var MAX_IDENTITY_FILE_BYTES = 1024 * 1024;
|
|
111
124
|
// ../packager/packager-core/src/models/tool-result.ts
|
|
112
125
|
class ToolResult {
|
|
113
126
|
errorCode;
|
|
@@ -998,1073 +1011,6 @@ I18nManager.registerTranslations("zh-cn", zh_CN);
|
|
|
998
1011
|
I18nManager.registerTranslations("zh-tw", zh_TW);
|
|
999
1012
|
I18nManager.registerTranslations("zu", zu);
|
|
1000
1013
|
I18nManager.setLocale("en");
|
|
1001
|
-
// ../../node_modules/@uipath/entity-modeler/dist/chunk-7VKIHCI7.js
|
|
1002
|
-
var SqlTypeName = {
|
|
1003
|
-
UNIQUEIDENTIFIER: "UNIQUEIDENTIFIER",
|
|
1004
|
-
NVARCHAR: "NVARCHAR",
|
|
1005
|
-
INT: "INT",
|
|
1006
|
-
DATETIME2: "DATETIME2",
|
|
1007
|
-
DATETIMEOFFSET: "DATETIMEOFFSET",
|
|
1008
|
-
FLOAT: "FLOAT",
|
|
1009
|
-
REAL: "REAL",
|
|
1010
|
-
BIGINT: "BIGINT",
|
|
1011
|
-
DATE: "DATE",
|
|
1012
|
-
BIT: "BIT",
|
|
1013
|
-
DECIMAL: "DECIMAL",
|
|
1014
|
-
MULTILINE: "MULTILINE",
|
|
1015
|
-
MULTILINE_MAX: "MULTILINE_MAX",
|
|
1016
|
-
UNKNOWN: "UNKNOWN"
|
|
1017
|
-
};
|
|
1018
|
-
var FieldDisplayType = {
|
|
1019
|
-
Basic: "Basic",
|
|
1020
|
-
Relationship: "Relationship",
|
|
1021
|
-
File: "File",
|
|
1022
|
-
ChoiceSetSingle: "ChoiceSetSingle",
|
|
1023
|
-
ChoiceSetMultiple: "ChoiceSetMultiple",
|
|
1024
|
-
AutoNumber: "AutoNumber",
|
|
1025
|
-
MultiLineText: "MultiLineText"
|
|
1026
|
-
};
|
|
1027
|
-
var DEFAULT_REFERENCE_TYPE = "ManyToOne";
|
|
1028
|
-
var CSHARP_RESERVED_WORDS = [
|
|
1029
|
-
"__arglist",
|
|
1030
|
-
"__makeref",
|
|
1031
|
-
"__reftype",
|
|
1032
|
-
"__refvalue",
|
|
1033
|
-
"abstract",
|
|
1034
|
-
"as",
|
|
1035
|
-
"base",
|
|
1036
|
-
"bool",
|
|
1037
|
-
"break",
|
|
1038
|
-
"byte",
|
|
1039
|
-
"case",
|
|
1040
|
-
"catch",
|
|
1041
|
-
"char",
|
|
1042
|
-
"checked",
|
|
1043
|
-
"class",
|
|
1044
|
-
"const",
|
|
1045
|
-
"continue",
|
|
1046
|
-
"decimal",
|
|
1047
|
-
"default",
|
|
1048
|
-
"delegate",
|
|
1049
|
-
"do",
|
|
1050
|
-
"double",
|
|
1051
|
-
"else",
|
|
1052
|
-
"enum",
|
|
1053
|
-
"event",
|
|
1054
|
-
"explicit",
|
|
1055
|
-
"extern",
|
|
1056
|
-
"false",
|
|
1057
|
-
"finally",
|
|
1058
|
-
"fixed",
|
|
1059
|
-
"float",
|
|
1060
|
-
"for",
|
|
1061
|
-
"foreach",
|
|
1062
|
-
"goto",
|
|
1063
|
-
"if",
|
|
1064
|
-
"implicit",
|
|
1065
|
-
"in",
|
|
1066
|
-
"int",
|
|
1067
|
-
"interface",
|
|
1068
|
-
"internal",
|
|
1069
|
-
"is",
|
|
1070
|
-
"lock",
|
|
1071
|
-
"long",
|
|
1072
|
-
"namespace",
|
|
1073
|
-
"new",
|
|
1074
|
-
"null",
|
|
1075
|
-
"object",
|
|
1076
|
-
"operator",
|
|
1077
|
-
"out",
|
|
1078
|
-
"override",
|
|
1079
|
-
"params",
|
|
1080
|
-
"partial",
|
|
1081
|
-
"private",
|
|
1082
|
-
"protected",
|
|
1083
|
-
"public",
|
|
1084
|
-
"readonly",
|
|
1085
|
-
"ref",
|
|
1086
|
-
"return",
|
|
1087
|
-
"sbyte",
|
|
1088
|
-
"sealed",
|
|
1089
|
-
"short",
|
|
1090
|
-
"sizeof",
|
|
1091
|
-
"stackalloc",
|
|
1092
|
-
"static",
|
|
1093
|
-
"string",
|
|
1094
|
-
"struct",
|
|
1095
|
-
"switch",
|
|
1096
|
-
"this",
|
|
1097
|
-
"throw",
|
|
1098
|
-
"true",
|
|
1099
|
-
"try",
|
|
1100
|
-
"typeof",
|
|
1101
|
-
"uint",
|
|
1102
|
-
"ulong",
|
|
1103
|
-
"unchecked",
|
|
1104
|
-
"unsafe",
|
|
1105
|
-
"ushort",
|
|
1106
|
-
"using",
|
|
1107
|
-
"virtual",
|
|
1108
|
-
"void",
|
|
1109
|
-
"volatile",
|
|
1110
|
-
"where",
|
|
1111
|
-
"while",
|
|
1112
|
-
"yield"
|
|
1113
|
-
];
|
|
1114
|
-
var VB_RESERVED_WORDS = [
|
|
1115
|
-
"addhandler",
|
|
1116
|
-
"addressof",
|
|
1117
|
-
"alias",
|
|
1118
|
-
"and",
|
|
1119
|
-
"andalso",
|
|
1120
|
-
"ansi",
|
|
1121
|
-
"as",
|
|
1122
|
-
"assembly",
|
|
1123
|
-
"auto",
|
|
1124
|
-
"boolean",
|
|
1125
|
-
"byref",
|
|
1126
|
-
"byte",
|
|
1127
|
-
"byval",
|
|
1128
|
-
"call",
|
|
1129
|
-
"case",
|
|
1130
|
-
"catch",
|
|
1131
|
-
"cbool",
|
|
1132
|
-
"cbyte",
|
|
1133
|
-
"cchar",
|
|
1134
|
-
"cdate",
|
|
1135
|
-
"cdbl",
|
|
1136
|
-
"cdec",
|
|
1137
|
-
"char",
|
|
1138
|
-
"cint",
|
|
1139
|
-
"class",
|
|
1140
|
-
"class_finalize",
|
|
1141
|
-
"class_initialize",
|
|
1142
|
-
"clng",
|
|
1143
|
-
"cobj",
|
|
1144
|
-
"const",
|
|
1145
|
-
"continue",
|
|
1146
|
-
"csbyte",
|
|
1147
|
-
"cshort",
|
|
1148
|
-
"csng",
|
|
1149
|
-
"cstr",
|
|
1150
|
-
"ctype",
|
|
1151
|
-
"cuint",
|
|
1152
|
-
"culng",
|
|
1153
|
-
"cushort",
|
|
1154
|
-
"date",
|
|
1155
|
-
"decimal",
|
|
1156
|
-
"declare",
|
|
1157
|
-
"default",
|
|
1158
|
-
"delegate",
|
|
1159
|
-
"dim",
|
|
1160
|
-
"directcast",
|
|
1161
|
-
"do",
|
|
1162
|
-
"double",
|
|
1163
|
-
"each",
|
|
1164
|
-
"else",
|
|
1165
|
-
"elseif",
|
|
1166
|
-
"end",
|
|
1167
|
-
"endif",
|
|
1168
|
-
"enum",
|
|
1169
|
-
"erase",
|
|
1170
|
-
"error",
|
|
1171
|
-
"event",
|
|
1172
|
-
"exit",
|
|
1173
|
-
"false",
|
|
1174
|
-
"finally",
|
|
1175
|
-
"for",
|
|
1176
|
-
"friend",
|
|
1177
|
-
"function",
|
|
1178
|
-
"get",
|
|
1179
|
-
"gettype",
|
|
1180
|
-
"global",
|
|
1181
|
-
"gosub",
|
|
1182
|
-
"goto",
|
|
1183
|
-
"handles",
|
|
1184
|
-
"if",
|
|
1185
|
-
"implements",
|
|
1186
|
-
"imports",
|
|
1187
|
-
"in",
|
|
1188
|
-
"inherits",
|
|
1189
|
-
"integer",
|
|
1190
|
-
"interface",
|
|
1191
|
-
"is",
|
|
1192
|
-
"isnot",
|
|
1193
|
-
"let",
|
|
1194
|
-
"lib",
|
|
1195
|
-
"like",
|
|
1196
|
-
"long",
|
|
1197
|
-
"loop",
|
|
1198
|
-
"me",
|
|
1199
|
-
"mod",
|
|
1200
|
-
"module",
|
|
1201
|
-
"mustinherit",
|
|
1202
|
-
"mustoverride",
|
|
1203
|
-
"mybase",
|
|
1204
|
-
"myclass",
|
|
1205
|
-
"namespace",
|
|
1206
|
-
"narrowing",
|
|
1207
|
-
"new",
|
|
1208
|
-
"next",
|
|
1209
|
-
"not",
|
|
1210
|
-
"nothing",
|
|
1211
|
-
"notinheritable",
|
|
1212
|
-
"notoverridable",
|
|
1213
|
-
"object",
|
|
1214
|
-
"of",
|
|
1215
|
-
"on",
|
|
1216
|
-
"operator",
|
|
1217
|
-
"option",
|
|
1218
|
-
"optional",
|
|
1219
|
-
"or",
|
|
1220
|
-
"orelse",
|
|
1221
|
-
"overloads",
|
|
1222
|
-
"overridable",
|
|
1223
|
-
"overrides",
|
|
1224
|
-
"paramarray",
|
|
1225
|
-
"partial",
|
|
1226
|
-
"preserve",
|
|
1227
|
-
"private",
|
|
1228
|
-
"property",
|
|
1229
|
-
"protected",
|
|
1230
|
-
"public",
|
|
1231
|
-
"raiseevent",
|
|
1232
|
-
"readonly",
|
|
1233
|
-
"redim",
|
|
1234
|
-
"rem",
|
|
1235
|
-
"removehandler",
|
|
1236
|
-
"resume",
|
|
1237
|
-
"return",
|
|
1238
|
-
"sbyte",
|
|
1239
|
-
"select",
|
|
1240
|
-
"set",
|
|
1241
|
-
"shadows",
|
|
1242
|
-
"shared",
|
|
1243
|
-
"short",
|
|
1244
|
-
"single",
|
|
1245
|
-
"static",
|
|
1246
|
-
"step",
|
|
1247
|
-
"stop",
|
|
1248
|
-
"string",
|
|
1249
|
-
"structure",
|
|
1250
|
-
"sub",
|
|
1251
|
-
"synclock",
|
|
1252
|
-
"then",
|
|
1253
|
-
"throw",
|
|
1254
|
-
"to",
|
|
1255
|
-
"true",
|
|
1256
|
-
"try",
|
|
1257
|
-
"trycast",
|
|
1258
|
-
"typeof",
|
|
1259
|
-
"uinteger",
|
|
1260
|
-
"ulong",
|
|
1261
|
-
"unicode",
|
|
1262
|
-
"until",
|
|
1263
|
-
"ushort",
|
|
1264
|
-
"using",
|
|
1265
|
-
"variant",
|
|
1266
|
-
"wend",
|
|
1267
|
-
"when",
|
|
1268
|
-
"while",
|
|
1269
|
-
"widening",
|
|
1270
|
-
"with",
|
|
1271
|
-
"withevents",
|
|
1272
|
-
"writeonly",
|
|
1273
|
-
"xor"
|
|
1274
|
-
];
|
|
1275
|
-
var CSHARP_RESERVED = new Set(CSHARP_RESERVED_WORDS);
|
|
1276
|
-
var VB_RESERVED = new Set(VB_RESERVED_WORDS);
|
|
1277
|
-
var GA_TYPE_PAIRS = [
|
|
1278
|
-
[FieldDisplayType.Basic, SqlTypeName.NVARCHAR],
|
|
1279
|
-
[FieldDisplayType.Basic, SqlTypeName.DECIMAL],
|
|
1280
|
-
[FieldDisplayType.Basic, SqlTypeName.FLOAT],
|
|
1281
|
-
[FieldDisplayType.Basic, SqlTypeName.BIT],
|
|
1282
|
-
[FieldDisplayType.Basic, SqlTypeName.DATE],
|
|
1283
|
-
[FieldDisplayType.Basic, SqlTypeName.DATETIMEOFFSET],
|
|
1284
|
-
[FieldDisplayType.Basic, SqlTypeName.UNIQUEIDENTIFIER],
|
|
1285
|
-
[FieldDisplayType.AutoNumber, SqlTypeName.DECIMAL],
|
|
1286
|
-
[FieldDisplayType.Basic, SqlTypeName.MULTILINE],
|
|
1287
|
-
[FieldDisplayType.Basic, SqlTypeName.MULTILINE_MAX],
|
|
1288
|
-
[FieldDisplayType.File, SqlTypeName.UNIQUEIDENTIFIER]
|
|
1289
|
-
];
|
|
1290
|
-
var ALLOWED_TYPE_PAIRS = new Set(GA_TYPE_PAIRS.map(([display, sql]) => `${display}:${sql}`));
|
|
1291
|
-
// ../packager/packager-tool-datafabric/src/sort-names.ts
|
|
1292
|
-
function byName(a, b) {
|
|
1293
|
-
return a.localeCompare(b, "en");
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
// ../packager/packager-tool-datafabric/src/schema/author-field.ts
|
|
1297
|
-
var TYPE_MAP = {
|
|
1298
|
-
STRING: [FieldDisplayType.Basic, SqlTypeName.NVARCHAR],
|
|
1299
|
-
DECIMAL: [FieldDisplayType.Basic, SqlTypeName.DECIMAL],
|
|
1300
|
-
BOOLEAN: [FieldDisplayType.Basic, SqlTypeName.BIT],
|
|
1301
|
-
DATE: [FieldDisplayType.Basic, SqlTypeName.DATE],
|
|
1302
|
-
DATETIME_WITH_TZ: [FieldDisplayType.Basic, SqlTypeName.DATETIMEOFFSET],
|
|
1303
|
-
MULTILINE_TEXT: [FieldDisplayType.Basic, SqlTypeName.MULTILINE],
|
|
1304
|
-
MULTILINE_MAX: [FieldDisplayType.Basic, SqlTypeName.MULTILINE_MAX],
|
|
1305
|
-
AUTO_NUMBER: [FieldDisplayType.AutoNumber, SqlTypeName.DECIMAL],
|
|
1306
|
-
FILE: [FieldDisplayType.File, SqlTypeName.UNIQUEIDENTIFIER]
|
|
1307
|
-
};
|
|
1308
|
-
var AUTHORABLE_FIELD_TYPES = Object.freeze(Object.keys(TYPE_MAP).sort(byName));
|
|
1309
|
-
var UNAUTHORABLE_TYPES = {
|
|
1310
|
-
CHOICE_SET_SINGLE: "choice-set fields are not authorable locally — add the field in Data Fabric",
|
|
1311
|
-
CHOICE_SET_MULTIPLE: "choice-set fields are not authorable locally — add the field in Data Fabric",
|
|
1312
|
-
RELATIONSHIP: "relationship fields are not authorable locally — add the field in Data Fabric",
|
|
1313
|
-
INTEGER: "use DECIMAL with decimalPrecision: 0",
|
|
1314
|
-
BIG_INTEGER: "use DECIMAL with decimalPrecision: 0",
|
|
1315
|
-
FLOAT: "use DECIMAL with a decimalPrecision",
|
|
1316
|
-
DOUBLE: "use DECIMAL with a decimalPrecision",
|
|
1317
|
-
UUID: "use STRING",
|
|
1318
|
-
DATETIME: "use DATETIME_WITH_TZ"
|
|
1319
|
-
};
|
|
1320
|
-
|
|
1321
|
-
class AuthoredFieldError extends Error {
|
|
1322
|
-
instructions;
|
|
1323
|
-
constructor(message, instructions) {
|
|
1324
|
-
super(message);
|
|
1325
|
-
this.instructions = instructions;
|
|
1326
|
-
this.name = "AuthoredFieldError";
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
function buildSqlType(name, spec) {
|
|
1330
|
-
const sqlType = { Name: name };
|
|
1331
|
-
if (spec.lengthLimit != null)
|
|
1332
|
-
sqlType.LengthLimit = spec.lengthLimit;
|
|
1333
|
-
if (spec.decimalPrecision != null)
|
|
1334
|
-
sqlType.DecimalPrecision = spec.decimalPrecision;
|
|
1335
|
-
if (spec.maxValue != null)
|
|
1336
|
-
sqlType.MaxValue = spec.maxValue;
|
|
1337
|
-
if (spec.minValue != null)
|
|
1338
|
-
sqlType.MinValue = spec.minValue;
|
|
1339
|
-
return sqlType;
|
|
1340
|
-
}
|
|
1341
|
-
var DEFAULT_VALUE_SHAPES = {
|
|
1342
|
-
BOOLEAN: '"true" or "false"',
|
|
1343
|
-
DECIMAL: 'a number in quotes, e.g. "0"',
|
|
1344
|
-
AUTO_NUMBER: 'a number in quotes, e.g. "0"'
|
|
1345
|
-
};
|
|
1346
|
-
function assertDefaultValue(spec, checkContent) {
|
|
1347
|
-
const value = spec.defaultValue;
|
|
1348
|
-
if (value === undefined || value === null) {
|
|
1349
|
-
return;
|
|
1350
|
-
}
|
|
1351
|
-
if (!checkContent) {
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
if (typeof value !== "string") {
|
|
1355
|
-
const shape = DEFAULT_VALUE_SHAPES[spec.type] ?? "a string";
|
|
1356
|
-
throw new AuthoredFieldError(`Field '${spec.name}': 'defaultValue' must be a string or null`, `Received ${JSON.stringify(value)}. Entity documents store every default as text, whatever the field type — for ${spec.type} pass ${shape}, or null to clear it.`);
|
|
1357
|
-
}
|
|
1358
|
-
if (spec.type === "BOOLEAN" && value.toLowerCase() !== "true" && value.toLowerCase() !== "false") {
|
|
1359
|
-
throw new AuthoredFieldError(`Field '${spec.name}': 'defaultValue' ${JSON.stringify(value)} is not a boolean`, 'A BOOLEAN default is the text "true" or "false".');
|
|
1360
|
-
}
|
|
1361
|
-
if ((spec.type === "DECIMAL" || spec.type === "AUTO_NUMBER") && (value.trim() === "" || !Number.isFinite(Number(value)))) {
|
|
1362
|
-
throw new AuthoredFieldError(`Field '${spec.name}': 'defaultValue' ${JSON.stringify(value)} is not a number`, `A ${spec.type} default is a number written as text, e.g. "0".`);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
function authorField(spec, options = {}) {
|
|
1366
|
-
const pair = TYPE_MAP[spec.type];
|
|
1367
|
-
if (pair === undefined) {
|
|
1368
|
-
const redirect = UNAUTHORABLE_TYPES[spec.type];
|
|
1369
|
-
throw new AuthoredFieldError(`Field '${spec.name}' has unsupported type '${spec.type}'`, redirect === undefined ? `Supported types: ${AUTHORABLE_FIELD_TYPES.join(", ")}.` : `${redirect}. Supported types: ${AUTHORABLE_FIELD_TYPES.join(", ")}.`);
|
|
1370
|
-
}
|
|
1371
|
-
const [fieldDisplayType, sqlTypeName] = pair;
|
|
1372
|
-
const pairKey = `${fieldDisplayType}:${sqlTypeName}`;
|
|
1373
|
-
if (!ALLOWED_TYPE_PAIRS.has(pairKey)) {
|
|
1374
|
-
throw new AuthoredFieldError(`Internal: type '${spec.type}' maps to ${pairKey}, which is not an allowed pair`, "This is a defect in author-field.ts — the type map has drifted from GA_TYPE_PAIRS.");
|
|
1375
|
-
}
|
|
1376
|
-
for (const [key, value] of [
|
|
1377
|
-
["isRequired", spec.isRequired],
|
|
1378
|
-
["isUnique", spec.isUnique]
|
|
1379
|
-
]) {
|
|
1380
|
-
if (value !== undefined && typeof value !== "boolean") {
|
|
1381
|
-
throw new AuthoredFieldError(`Field '${spec.name}': '${key}' must be true or false`, `Received ${JSON.stringify(value)}. Use a JSON boolean, not a string.`);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
for (const [key, value] of [
|
|
1385
|
-
["displayName", spec.displayName],
|
|
1386
|
-
["description", spec.description]
|
|
1387
|
-
]) {
|
|
1388
|
-
if (value !== undefined && typeof value !== "string") {
|
|
1389
|
-
throw new AuthoredFieldError(`Field '${spec.name}': '${key}' must be a string`, `Received ${JSON.stringify(value)}.`);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
assertDefaultValue(spec, options.defaultValueFromCaller !== false);
|
|
1393
|
-
const constraintError = findInvalidFieldConstraints([
|
|
1394
|
-
{
|
|
1395
|
-
name: spec.name,
|
|
1396
|
-
type: spec.type,
|
|
1397
|
-
...spec.lengthLimit != null && {
|
|
1398
|
-
lengthLimit: spec.lengthLimit
|
|
1399
|
-
},
|
|
1400
|
-
...spec.decimalPrecision != null && {
|
|
1401
|
-
decimalPrecision: spec.decimalPrecision
|
|
1402
|
-
},
|
|
1403
|
-
...spec.maxValue != null && { maxValue: spec.maxValue },
|
|
1404
|
-
...spec.minValue != null && { minValue: spec.minValue }
|
|
1405
|
-
}
|
|
1406
|
-
]);
|
|
1407
|
-
if (constraintError) {
|
|
1408
|
-
throw new AuthoredFieldError(constraintError.message, constraintError.instructions);
|
|
1409
|
-
}
|
|
1410
|
-
return {
|
|
1411
|
-
Name: spec.name,
|
|
1412
|
-
DisplayName: spec.displayName ?? spec.name,
|
|
1413
|
-
SqlType: buildSqlType(sqlTypeName, spec),
|
|
1414
|
-
IsRequired: spec.isRequired ?? false,
|
|
1415
|
-
IsUnique: spec.isUnique ?? false,
|
|
1416
|
-
IsPrimaryKey: false,
|
|
1417
|
-
IsForeignKey: false,
|
|
1418
|
-
IsExternalField: false,
|
|
1419
|
-
IsHiddenField: false,
|
|
1420
|
-
FieldCategoryId: 0,
|
|
1421
|
-
ReferenceType: DEFAULT_REFERENCE_TYPE,
|
|
1422
|
-
Transformation: null,
|
|
1423
|
-
IsEncrypted: false,
|
|
1424
|
-
Description: spec.description ?? "",
|
|
1425
|
-
IsSystemField: false,
|
|
1426
|
-
FieldDisplayType: fieldDisplayType,
|
|
1427
|
-
DefaultValue: spec.defaultValue ?? null,
|
|
1428
|
-
IsAttachment: false,
|
|
1429
|
-
IsRbacEnabled: false,
|
|
1430
|
-
IsModelReserved: false,
|
|
1431
|
-
ReferenceChoiceSet: null,
|
|
1432
|
-
ReferenceEntity: null,
|
|
1433
|
-
ReferenceField: null,
|
|
1434
|
-
ReferenceName: null
|
|
1435
|
-
};
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
// ../packager/packager-tool-datafabric/src/missing-path.ts
|
|
1439
|
-
function isMissingPathError(error) {
|
|
1440
|
-
if (!(error instanceof Error) || !("code" in error))
|
|
1441
|
-
return false;
|
|
1442
|
-
const { code } = error;
|
|
1443
|
-
return code === "ENOENT" || code === "ENOTDIR" || code === "PathNotFound";
|
|
1444
|
-
}
|
|
1445
|
-
function isFilesystemError(error) {
|
|
1446
|
-
const code = error?.code;
|
|
1447
|
-
return typeof code === "string" && /^E[A-Z]+$/.test(code);
|
|
1448
|
-
}
|
|
1449
|
-
function isUnreadablePathError(error) {
|
|
1450
|
-
return isFilesystemError(error) && !isMissingPathError(error);
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
// ../packager/packager-tool-datafabric/src/pack/constants.ts
|
|
1454
|
-
var ENTITY_EXTENSION_CONST = ".entity";
|
|
1455
|
-
var ENTITY_VALIDATION_FAILED = "ENTITY_VALIDATION_FAILED";
|
|
1456
|
-
var PACK_DIAGNOSTIC_CODES = {
|
|
1457
|
-
misplacedMainFile: "MISPLACED_MAIN_FILE",
|
|
1458
|
-
noParentSolution: "NO_PARENT_SOLUTION",
|
|
1459
|
-
solutionRootUnreadable: "SOLUTION_ROOT_UNREADABLE"
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1462
|
-
// ../packager/packager-tool-datafabric/src/schema/solution-entity-names.ts
|
|
1463
|
-
function withoutOneOccurrence(names, name) {
|
|
1464
|
-
const siblings = [...names];
|
|
1465
|
-
const self = siblings.indexOf(name);
|
|
1466
|
-
if (self >= 0) {
|
|
1467
|
-
siblings.splice(self, 1);
|
|
1468
|
-
}
|
|
1469
|
-
return siblings;
|
|
1470
|
-
}
|
|
1471
|
-
function isMissingPath(error) {
|
|
1472
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "PathNotFound");
|
|
1473
|
-
}
|
|
1474
|
-
async function collectSolutionEntityNames(solutionDir, fs) {
|
|
1475
|
-
const names = [];
|
|
1476
|
-
let topLevel = [];
|
|
1477
|
-
try {
|
|
1478
|
-
topLevel = await fs.readdir(solutionDir);
|
|
1479
|
-
} catch (error) {
|
|
1480
|
-
if (!isMissingPath(error)) {
|
|
1481
|
-
throw error;
|
|
1482
|
-
}
|
|
1483
|
-
return names;
|
|
1484
|
-
}
|
|
1485
|
-
for (const entry of topLevel) {
|
|
1486
|
-
if (entry === "resources" || entry.startsWith(".")) {
|
|
1487
|
-
continue;
|
|
1488
|
-
}
|
|
1489
|
-
const dir = fs.path.join(solutionDir, entry);
|
|
1490
|
-
try {
|
|
1491
|
-
const stat = await fs.stat(dir);
|
|
1492
|
-
if (!stat?.isDirectory()) {
|
|
1493
|
-
continue;
|
|
1494
|
-
}
|
|
1495
|
-
for (const file of await fs.readdir(dir)) {
|
|
1496
|
-
if (file.endsWith(ENTITY_EXTENSION_CONST)) {
|
|
1497
|
-
names.push(fs.path.basename(file, ENTITY_EXTENSION_CONST));
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
} catch (error) {
|
|
1501
|
-
if (!isMissingPath(error)) {
|
|
1502
|
-
throw error;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
return names;
|
|
1507
|
-
}
|
|
1508
|
-
async function siblingNamesFor(solutionDir, entityName, fs) {
|
|
1509
|
-
return withoutOneOccurrence(await collectSolutionEntityNames(solutionDir, fs), entityName);
|
|
1510
|
-
}
|
|
1511
|
-
async function findProjectsOwningEntity(solutionDir, entityName, fs) {
|
|
1512
|
-
const owners = [];
|
|
1513
|
-
const wanted = `${entityName}${ENTITY_EXTENSION_CONST}`.toLowerCase();
|
|
1514
|
-
let topLevel = [];
|
|
1515
|
-
try {
|
|
1516
|
-
topLevel = await fs.readdir(solutionDir);
|
|
1517
|
-
} catch (error) {
|
|
1518
|
-
if (isMissingPathError(error))
|
|
1519
|
-
return owners;
|
|
1520
|
-
throw error;
|
|
1521
|
-
}
|
|
1522
|
-
for (const entry of topLevel) {
|
|
1523
|
-
if (entry === "resources" || entry.startsWith(".")) {
|
|
1524
|
-
continue;
|
|
1525
|
-
}
|
|
1526
|
-
const dir = fs.path.join(solutionDir, entry);
|
|
1527
|
-
try {
|
|
1528
|
-
const stat = await fs.stat(dir);
|
|
1529
|
-
if (!stat?.isDirectory()) {
|
|
1530
|
-
continue;
|
|
1531
|
-
}
|
|
1532
|
-
for (const file of await fs.readdir(dir)) {
|
|
1533
|
-
if (file.toLowerCase() === wanted) {
|
|
1534
|
-
owners.push({
|
|
1535
|
-
projectName: entry,
|
|
1536
|
-
entityName: fs.path.basename(file, ENTITY_EXTENSION_CONST)
|
|
1537
|
-
});
|
|
1538
|
-
break;
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
} catch (error) {
|
|
1542
|
-
if (!isMissingPathError(error))
|
|
1543
|
-
throw error;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
return owners;
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
// ../packager/packager-tool-datafabric/src/schema/create-entity-skeleton.ts
|
|
1550
|
-
var UNASSIGNED_FOLDER_ID = "99999999-9999-9999-9999-999999999999";
|
|
1551
|
-
function isLocallyAuthored(entity) {
|
|
1552
|
-
return entity.FolderId === UNASSIGNED_FOLDER_ID;
|
|
1553
|
-
}
|
|
1554
|
-
var SYSTEM_FIELD_DEFAULTS = {
|
|
1555
|
-
IsPrimaryKey: false,
|
|
1556
|
-
IsForeignKey: false,
|
|
1557
|
-
IsExternalField: false,
|
|
1558
|
-
IsHiddenField: true,
|
|
1559
|
-
FieldCategoryId: 0,
|
|
1560
|
-
IsUnique: false,
|
|
1561
|
-
ReferenceType: "ManyToOne",
|
|
1562
|
-
Transformation: null,
|
|
1563
|
-
IsRequired: false,
|
|
1564
|
-
IsEncrypted: false,
|
|
1565
|
-
Description: "",
|
|
1566
|
-
IsSystemField: true,
|
|
1567
|
-
FieldDisplayType: FieldDisplayType.Basic,
|
|
1568
|
-
IsAttachment: false,
|
|
1569
|
-
IsRbacEnabled: false,
|
|
1570
|
-
IsModelReserved: false
|
|
1571
|
-
};
|
|
1572
|
-
var SYSTEM_FIELD_TEMPLATES = [
|
|
1573
|
-
{
|
|
1574
|
-
...SYSTEM_FIELD_DEFAULTS,
|
|
1575
|
-
Name: "Id",
|
|
1576
|
-
DisplayName: "Id",
|
|
1577
|
-
IsPrimaryKey: true,
|
|
1578
|
-
SqlType: { Name: SqlTypeName.UNIQUEIDENTIFIER }
|
|
1579
|
-
},
|
|
1580
|
-
{
|
|
1581
|
-
...SYSTEM_FIELD_DEFAULTS,
|
|
1582
|
-
Name: "CreateTime",
|
|
1583
|
-
DisplayName: "CreateTime",
|
|
1584
|
-
SqlType: { Name: SqlTypeName.DATETIMEOFFSET }
|
|
1585
|
-
},
|
|
1586
|
-
{
|
|
1587
|
-
...SYSTEM_FIELD_DEFAULTS,
|
|
1588
|
-
Name: "CreatedBy",
|
|
1589
|
-
DisplayName: "CreatedBy",
|
|
1590
|
-
FieldDisplayType: FieldDisplayType.Relationship,
|
|
1591
|
-
SqlType: { Name: SqlTypeName.UNIQUEIDENTIFIER }
|
|
1592
|
-
},
|
|
1593
|
-
{
|
|
1594
|
-
...SYSTEM_FIELD_DEFAULTS,
|
|
1595
|
-
Name: "UpdateTime",
|
|
1596
|
-
DisplayName: "UpdateTime",
|
|
1597
|
-
SqlType: { Name: SqlTypeName.DATETIMEOFFSET }
|
|
1598
|
-
},
|
|
1599
|
-
{
|
|
1600
|
-
...SYSTEM_FIELD_DEFAULTS,
|
|
1601
|
-
Name: "UpdatedBy",
|
|
1602
|
-
DisplayName: "UpdatedBy",
|
|
1603
|
-
FieldDisplayType: FieldDisplayType.Relationship,
|
|
1604
|
-
SqlType: { Name: SqlTypeName.UNIQUEIDENTIFIER }
|
|
1605
|
-
}
|
|
1606
|
-
];
|
|
1607
|
-
function createEntitySkeleton(name) {
|
|
1608
|
-
return {
|
|
1609
|
-
Id: globalThis.crypto.randomUUID(),
|
|
1610
|
-
Name: name,
|
|
1611
|
-
DisplayName: name,
|
|
1612
|
-
EntityTypeId: 0,
|
|
1613
|
-
EntityType: "Entity",
|
|
1614
|
-
Description: "",
|
|
1615
|
-
FolderId: UNASSIGNED_FOLDER_ID,
|
|
1616
|
-
Fields: SYSTEM_FIELD_TEMPLATES.map((template) => ({
|
|
1617
|
-
...template,
|
|
1618
|
-
SqlType: { ...template.SqlType }
|
|
1619
|
-
})),
|
|
1620
|
-
Data: null,
|
|
1621
|
-
ExternalFields: null,
|
|
1622
|
-
SourceJoinCriterias: null,
|
|
1623
|
-
RecordCount: 0,
|
|
1624
|
-
StorageSizeInMB: null,
|
|
1625
|
-
UsedStorageSizeInMB: null,
|
|
1626
|
-
AttachmentSizeInByte: null,
|
|
1627
|
-
IsRbacEnabled: false,
|
|
1628
|
-
InvalidIdentifiers: [],
|
|
1629
|
-
IsModelReserved: false,
|
|
1630
|
-
CategoryId: null
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function requireAuthoredName(authored, entityName) {
|
|
1634
|
-
if (authored !== undefined && authored.Name !== entityName) {
|
|
1635
|
-
throw new AuthoredFieldError(`Authored entity '${authored.Name}' cannot be written as '${entityName}'`, "Author the document with the name it is created under.");
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
// ../packager/packager-tool-datafabric/src/schema/validate-entity.ts
|
|
1640
|
-
var DIAGNOSTIC_CODES = {
|
|
1641
|
-
entityNameInvalid: "ENTITY_NAME_INVALID",
|
|
1642
|
-
entityNameNotUnique: "ENTITY_NAME_NOT_UNIQUE",
|
|
1643
|
-
fieldNameInvalid: "FIELD_NAME_INVALID",
|
|
1644
|
-
duplicateFieldName: "DUPLICATE_FIELD_NAME",
|
|
1645
|
-
fieldTypeNotAllowed: "FIELD_TYPE_NOT_ALLOWED",
|
|
1646
|
-
nameReserved: "NAME_RESERVED",
|
|
1647
|
-
systemFieldMissing: "SYSTEM_FIELD_MISSING",
|
|
1648
|
-
systemFieldModified: "SYSTEM_FIELD_MODIFIED",
|
|
1649
|
-
fieldsMalformed: "FIELDS_MALFORMED",
|
|
1650
|
-
tooManyMultilineMax: "TOO_MANY_MULTILINE_MAX",
|
|
1651
|
-
propertyTypeInvalid: "PROPERTY_TYPE_INVALID"
|
|
1652
|
-
};
|
|
1653
|
-
function validateEntity(entity, ctx) {
|
|
1654
|
-
const diagnostics = [];
|
|
1655
|
-
if (typeof entity?.Name !== "string") {
|
|
1656
|
-
return [
|
|
1657
|
-
{
|
|
1658
|
-
code: DIAGNOSTIC_CODES.entityNameInvalid,
|
|
1659
|
-
message: "The entity document has no 'Name'. The resource is malformed.",
|
|
1660
|
-
severity: "error"
|
|
1661
|
-
}
|
|
1662
|
-
];
|
|
1663
|
-
}
|
|
1664
|
-
const entityNameFormat = validateNameFormat(entity.Name, "entity");
|
|
1665
|
-
if (entityNameFormat) {
|
|
1666
|
-
diagnostics.push({
|
|
1667
|
-
code: DIAGNOSTIC_CODES.entityNameInvalid,
|
|
1668
|
-
message: `${entityNameFormat.message}. ${entityNameFormat.instructions}`,
|
|
1669
|
-
severity: "error"
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1672
|
-
const reservedEntityName = findReservedNameError(entity.Name, "entity");
|
|
1673
|
-
if (reservedEntityName) {
|
|
1674
|
-
diagnostics.push({
|
|
1675
|
-
code: DIAGNOSTIC_CODES.nameReserved,
|
|
1676
|
-
message: `${reservedEntityName.message}. ${reservedEntityName.instructions}`,
|
|
1677
|
-
severity: "error"
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
|
-
const entityNameLower = entity.Name.toLowerCase();
|
|
1681
|
-
if (ctx.siblingNames.some((sibling) => sibling.toLowerCase() === entityNameLower)) {
|
|
1682
|
-
diagnostics.push({
|
|
1683
|
-
code: DIAGNOSTIC_CODES.entityNameNotUnique,
|
|
1684
|
-
message: `An entity named '${entity.Name}' already exists in this solution. Entity names are solution-wide unique.`,
|
|
1685
|
-
severity: "error"
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
diagnostics.push(...typeProblems(entity, ENTITY_SCALARS).map((problem) => propertyTypeDiagnostic(`Entity '${entity.Name}'`, problem)));
|
|
1689
|
-
if (!Array.isArray(entity.Fields)) {
|
|
1690
|
-
diagnostics.push({
|
|
1691
|
-
code: DIAGNOSTIC_CODES.fieldsMalformed,
|
|
1692
|
-
message: "The entity document has no usable 'Fields' array. The resource is malformed.",
|
|
1693
|
-
severity: "error"
|
|
1694
|
-
});
|
|
1695
|
-
return diagnostics;
|
|
1696
|
-
}
|
|
1697
|
-
const seenFieldNames = new Map;
|
|
1698
|
-
for (const field of entity.Fields) {
|
|
1699
|
-
if (typeof field?.Name !== "string") {
|
|
1700
|
-
diagnostics.push({
|
|
1701
|
-
code: DIAGNOSTIC_CODES.fieldNameInvalid,
|
|
1702
|
-
message: "A field has no 'Name'. Every field needs one, system or custom.",
|
|
1703
|
-
severity: "error"
|
|
1704
|
-
});
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
const isSystem = isSystemField(field);
|
|
1708
|
-
if (!SYSTEM_FIELD_NAMES.has(field.Name)) {
|
|
1709
|
-
diagnostics.push(...fieldTypeDiagnostics(field));
|
|
1710
|
-
}
|
|
1711
|
-
const fieldNameFormat = isSystem ? null : validateNameFormat(field.Name, "field");
|
|
1712
|
-
if (fieldNameFormat) {
|
|
1713
|
-
diagnostics.push({
|
|
1714
|
-
code: DIAGNOSTIC_CODES.fieldNameInvalid,
|
|
1715
|
-
message: `${fieldNameFormat.message}. ${fieldNameFormat.instructions}`,
|
|
1716
|
-
severity: "error",
|
|
1717
|
-
fieldName: field.Name
|
|
1718
|
-
});
|
|
1719
|
-
}
|
|
1720
|
-
if (!isSystem) {
|
|
1721
|
-
const reservedFieldName = findReservedNameError(field.Name, "field");
|
|
1722
|
-
if (reservedFieldName) {
|
|
1723
|
-
diagnostics.push({
|
|
1724
|
-
code: DIAGNOSTIC_CODES.nameReserved,
|
|
1725
|
-
message: `${reservedFieldName.message}. ${reservedFieldName.instructions}`,
|
|
1726
|
-
severity: "error",
|
|
1727
|
-
fieldName: field.Name
|
|
1728
|
-
});
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
const fieldNameLower = field.Name.toLowerCase();
|
|
1732
|
-
if (!isSystem && typeof entity.Name === "string" && fieldNameLower === entity.Name.toLowerCase()) {
|
|
1733
|
-
diagnostics.push({
|
|
1734
|
-
code: DIAGNOSTIC_CODES.fieldNameInvalid,
|
|
1735
|
-
message: `Field name '${field.Name}' cannot match entity name '${entity.Name}' (names are compared case-insensitively).`,
|
|
1736
|
-
severity: "error",
|
|
1737
|
-
fieldName: field.Name
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
const firstWithName = seenFieldNames.get(fieldNameLower);
|
|
1741
|
-
if (firstWithName !== undefined) {
|
|
1742
|
-
diagnostics.push({
|
|
1743
|
-
code: DIAGNOSTIC_CODES.duplicateFieldName,
|
|
1744
|
-
message: `Duplicate field name '${field.Name}' (names are case-insensitive; first defined as '${firstWithName}').`,
|
|
1745
|
-
severity: "error",
|
|
1746
|
-
fieldName: field.Name
|
|
1747
|
-
});
|
|
1748
|
-
} else {
|
|
1749
|
-
seenFieldNames.set(fieldNameLower, field.Name);
|
|
1750
|
-
}
|
|
1751
|
-
if (!isSystem && !ALLOWED_TYPE_PAIRS.has(`${field.FieldDisplayType}:${field.SqlType?.Name}`)) {
|
|
1752
|
-
diagnostics.push({
|
|
1753
|
-
code: DIAGNOSTIC_CODES.fieldTypeNotAllowed,
|
|
1754
|
-
message: `Field '${field.Name}' uses an unsupported type combination ` + `(${field.FieldDisplayType} / ${field.SqlType?.Name}).`,
|
|
1755
|
-
severity: "error",
|
|
1756
|
-
fieldName: field.Name
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
const usableFields = entity.Fields.filter((field) => typeof field === "object" && field !== null);
|
|
1761
|
-
const multilineMax = usableFields.filter((field) => field.SqlType?.Name === SqlTypeName.MULTILINE_MAX);
|
|
1762
|
-
if (multilineMax.length > MAX_MULTILINE_MAX_FIELDS) {
|
|
1763
|
-
diagnostics.push({
|
|
1764
|
-
code: DIAGNOSTIC_CODES.tooManyMultilineMax,
|
|
1765
|
-
message: `Entity '${entity.Name}' defines ${multilineMax.length} MULTILINE_MAX fields; ` + `the maximum is ${MAX_MULTILINE_MAX_FIELDS}. Remove some, or use MULTILINE_TEXT where the content fits.`,
|
|
1766
|
-
severity: "error"
|
|
1767
|
-
});
|
|
1768
|
-
}
|
|
1769
|
-
diagnostics.push(...validateSystemFields(entity, usableFields));
|
|
1770
|
-
return diagnostics;
|
|
1771
|
-
}
|
|
1772
|
-
var SERVER_ASSIGNED_FIELD_PROPS = new Set([
|
|
1773
|
-
"Id",
|
|
1774
|
-
"CreateTime",
|
|
1775
|
-
"CreatedBy",
|
|
1776
|
-
"UpdateTime",
|
|
1777
|
-
"UpdatedBy"
|
|
1778
|
-
]);
|
|
1779
|
-
function isUnmodifiedSystemField(template, actual) {
|
|
1780
|
-
const equal = (left, right) => JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
|
|
1781
|
-
for (const key of Object.keys(template)) {
|
|
1782
|
-
if (!equal(template[key], actual[key])) {
|
|
1783
|
-
return false;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
return Object.keys(actual).every((key) => (key in template) || SERVER_ASSIGNED_FIELD_PROPS.has(key));
|
|
1787
|
-
}
|
|
1788
|
-
function validateSystemFields(entity, usableFields) {
|
|
1789
|
-
const diagnostics = [];
|
|
1790
|
-
for (const template of SYSTEM_FIELD_TEMPLATES) {
|
|
1791
|
-
const actual = usableFields.find((field) => field.Name === template.Name);
|
|
1792
|
-
if (!actual) {
|
|
1793
|
-
diagnostics.push({
|
|
1794
|
-
code: DIAGNOSTIC_CODES.systemFieldMissing,
|
|
1795
|
-
message: `System field '${template.Name}' is missing. System fields cannot be removed.`,
|
|
1796
|
-
severity: "error",
|
|
1797
|
-
fieldName: template.Name
|
|
1798
|
-
});
|
|
1799
|
-
continue;
|
|
1800
|
-
}
|
|
1801
|
-
if (!isUnmodifiedSystemField(template, actual)) {
|
|
1802
|
-
diagnostics.push({
|
|
1803
|
-
code: DIAGNOSTIC_CODES.systemFieldModified,
|
|
1804
|
-
message: `System field '${template.Name}' was modified. System fields are read-only.`,
|
|
1805
|
-
severity: "error",
|
|
1806
|
-
fieldName: template.Name
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
return diagnostics;
|
|
1811
|
-
}
|
|
1812
|
-
function isSystemField(field) {
|
|
1813
|
-
const { IsSystemField: flag, Name: name } = field ?? {};
|
|
1814
|
-
return flag === true || typeof name === "string" && SYSTEM_FIELD_NAMES.has(name);
|
|
1815
|
-
}
|
|
1816
|
-
var SYSTEM_FIELD_NAMES = new Set(SYSTEM_FIELD_TEMPLATES.map((template) => template.Name));
|
|
1817
|
-
var ENTITY_SCALARS = [
|
|
1818
|
-
{ key: "DisplayName", kind: "string" },
|
|
1819
|
-
{ key: "Description", kind: "string" },
|
|
1820
|
-
{ key: "EntityTypeId", kind: "integer" },
|
|
1821
|
-
{ key: "RecordCount", kind: "integer" },
|
|
1822
|
-
{ key: "IsRbacEnabled", kind: "boolean" },
|
|
1823
|
-
{ key: "IsModelReserved", kind: "boolean" }
|
|
1824
|
-
];
|
|
1825
|
-
var FIELD_SCALARS = [
|
|
1826
|
-
{ key: "DisplayName", kind: "string" },
|
|
1827
|
-
{ key: "Description", kind: "string" },
|
|
1828
|
-
{ key: "ReferenceType", kind: "string" },
|
|
1829
|
-
{ key: "FieldCategoryId", kind: "integer" },
|
|
1830
|
-
{ key: "IsRequired", kind: "boolean" },
|
|
1831
|
-
{ key: "IsUnique", kind: "boolean" },
|
|
1832
|
-
{ key: "IsPrimaryKey", kind: "boolean" },
|
|
1833
|
-
{ key: "IsForeignKey", kind: "boolean" },
|
|
1834
|
-
{ key: "IsSystemField", kind: "boolean" },
|
|
1835
|
-
{ key: "IsExternalField", kind: "boolean" },
|
|
1836
|
-
{ key: "IsHiddenField", kind: "boolean" },
|
|
1837
|
-
{ key: "IsEncrypted", kind: "boolean" },
|
|
1838
|
-
{ key: "IsAttachment", kind: "boolean" },
|
|
1839
|
-
{ key: "IsRbacEnabled", kind: "boolean" },
|
|
1840
|
-
{ key: "IsModelReserved", kind: "boolean" }
|
|
1841
|
-
];
|
|
1842
|
-
var SQL_TYPE_SCALARS = [
|
|
1843
|
-
{ key: "LengthLimit", kind: "integer", nullable: true },
|
|
1844
|
-
{ key: "DecimalPrecision", kind: "integer", nullable: true },
|
|
1845
|
-
{ key: "MaxValue", kind: "number", nullable: true },
|
|
1846
|
-
{ key: "MinValue", kind: "number", nullable: true }
|
|
1847
|
-
];
|
|
1848
|
-
function typeProblems(record, rules, prefix = "") {
|
|
1849
|
-
const values = record;
|
|
1850
|
-
return rules.filter(({ key, kind, nullable }) => {
|
|
1851
|
-
const value = values[key];
|
|
1852
|
-
if (value === undefined)
|
|
1853
|
-
return false;
|
|
1854
|
-
if (value === null)
|
|
1855
|
-
return !nullable;
|
|
1856
|
-
if (kind === "integer")
|
|
1857
|
-
return !Number.isInteger(value);
|
|
1858
|
-
return kind === "number" ? !(typeof value === "number" && Number.isFinite(value)) : typeof value !== kind;
|
|
1859
|
-
}).map(({ key, kind, nullable }) => `'${prefix}${key}' must be ${kind === "integer" ? "an" : "a"} ${kind}${nullable ? " or null" : ""}`);
|
|
1860
|
-
}
|
|
1861
|
-
function propertyTypeDiagnostic(subject, problem, fieldName) {
|
|
1862
|
-
return {
|
|
1863
|
-
code: DIAGNOSTIC_CODES.propertyTypeInvalid,
|
|
1864
|
-
message: `${subject}: ${problem}. The resource was edited by hand or is malformed.`,
|
|
1865
|
-
severity: "error",
|
|
1866
|
-
...fieldName !== undefined && { fieldName }
|
|
1867
|
-
};
|
|
1868
|
-
}
|
|
1869
|
-
function fieldTypeDiagnostics(field) {
|
|
1870
|
-
const problems = typeProblems(field, FIELD_SCALARS);
|
|
1871
|
-
if (typeof field.SqlType === "object" && field.SqlType !== null) {
|
|
1872
|
-
problems.push(...typeProblems(field.SqlType, SQL_TYPE_SCALARS, "SqlType."));
|
|
1873
|
-
}
|
|
1874
|
-
const defaultValue = field.DefaultValue;
|
|
1875
|
-
const isYesNo = field.SqlType?.Name === SqlTypeName.BIT;
|
|
1876
|
-
if (defaultValue != null && typeof defaultValue !== "string" && !(isYesNo && typeof defaultValue === "boolean")) {
|
|
1877
|
-
problems.push(isYesNo ? "'DefaultValue' must be a boolean, a string or null" : "'DefaultValue' must be a string or null");
|
|
1878
|
-
}
|
|
1879
|
-
return problems.map((problem) => propertyTypeDiagnostic(`Field '${field.Name}'`, problem, field.Name));
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
// ../packager/packager-tool-datafabric/src/resource/unified-resource-file.ts
|
|
1883
|
-
var ENTITY_RESOURCE_KIND = "entity";
|
|
1884
|
-
var ENTITY_RESOURCE_TYPE = "native";
|
|
1885
|
-
var ENTITY_RESOURCE_API_VERSION = "dataservice.uipath.com/v2";
|
|
1886
|
-
var ENTITY_RESOURCE_DOC_VERSION = "1.0.0";
|
|
1887
|
-
var SOLUTION_FOLDER = "solution_folder";
|
|
1888
|
-
var ENTITY_RESOURCE_DIR = `${ENTITY_RESOURCE_KIND}/${ENTITY_RESOURCE_TYPE}`;
|
|
1889
|
-
function entityResourcePath(entityName) {
|
|
1890
|
-
return `resources/${SOLUTION_FOLDER}/${ENTITY_RESOURCE_DIR}/${entityName}.json`;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
// ../packager/packager-tool-datafabric/src/resource/resource-io.ts
|
|
1894
|
-
function serialize(value) {
|
|
1895
|
-
return `${JSON.stringify(value, null, 2)}
|
|
1896
|
-
`;
|
|
1897
|
-
}
|
|
1898
|
-
function serializeEntityJson(entity) {
|
|
1899
|
-
return JSON.stringify(entity);
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
class EntityResourceError extends Error {
|
|
1903
|
-
failure;
|
|
1904
|
-
constructor(failure, message) {
|
|
1905
|
-
super(message);
|
|
1906
|
-
this.failure = failure;
|
|
1907
|
-
this.name = "EntityResourceError";
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
function wrapEntityJson(entity) {
|
|
1911
|
-
return {
|
|
1912
|
-
docVersion: ENTITY_RESOURCE_DOC_VERSION,
|
|
1913
|
-
resource: {
|
|
1914
|
-
name: entity.Name,
|
|
1915
|
-
kind: ENTITY_RESOURCE_KIND,
|
|
1916
|
-
type: ENTITY_RESOURCE_TYPE,
|
|
1917
|
-
apiVersion: ENTITY_RESOURCE_API_VERSION,
|
|
1918
|
-
isOverridable: true,
|
|
1919
|
-
dependencies: [],
|
|
1920
|
-
runtimeDependencies: [],
|
|
1921
|
-
folders: [{ fullyQualifiedName: SOLUTION_FOLDER }],
|
|
1922
|
-
spec: {
|
|
1923
|
-
resourceJson: serializeEntityJson(entity),
|
|
1924
|
-
name: entity.Name,
|
|
1925
|
-
displayName: entity.DisplayName,
|
|
1926
|
-
description: entity.Description
|
|
1927
|
-
},
|
|
1928
|
-
locks: [],
|
|
1929
|
-
key: entity.Id,
|
|
1930
|
-
files: []
|
|
1931
|
-
}
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
function unwrapResource(file) {
|
|
1935
|
-
if (typeof file !== "object" || file === null || Array.isArray(file)) {
|
|
1936
|
-
throw new EntityResourceError("NotAnObject", "Resource file is not a JSON object.");
|
|
1937
|
-
}
|
|
1938
|
-
const resource = file.resource;
|
|
1939
|
-
if (typeof resource !== "object" || resource === null) {
|
|
1940
|
-
throw new EntityResourceError("MissingResource", "Resource file has no 'resource' object.");
|
|
1941
|
-
}
|
|
1942
|
-
if (resource.kind !== ENTITY_RESOURCE_KIND) {
|
|
1943
|
-
throw new EntityResourceError("NotAnEntityResource", `Resource kind is '${String(resource.kind)}', expected '${ENTITY_RESOURCE_KIND}'.`);
|
|
1944
|
-
}
|
|
1945
|
-
const spec = resource.spec;
|
|
1946
|
-
if (typeof spec !== "object" || spec === null || typeof spec.resourceJson !== "string") {
|
|
1947
|
-
throw new EntityResourceError("MissingSpec", "Resource file has no 'spec.resourceJson' string.");
|
|
1948
|
-
}
|
|
1949
|
-
try {
|
|
1950
|
-
return JSON.parse(spec.resourceJson);
|
|
1951
|
-
} catch {
|
|
1952
|
-
throw new EntityResourceError("ResourceJsonUnparsable", "'spec.resourceJson' is not valid JSON.");
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
function updateResourceSchema(file, entity) {
|
|
1956
|
-
return {
|
|
1957
|
-
...file,
|
|
1958
|
-
resource: {
|
|
1959
|
-
...file.resource,
|
|
1960
|
-
name: entity.Name,
|
|
1961
|
-
spec: {
|
|
1962
|
-
...file.resource.spec,
|
|
1963
|
-
resourceJson: serializeEntityJson(entity),
|
|
1964
|
-
name: entity.Name,
|
|
1965
|
-
displayName: entity.DisplayName,
|
|
1966
|
-
description: entity.Description
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
// ../packager/packager-tool-datafabric/src/pack/verify-pair.ts
|
|
1973
|
-
async function verifyPair(stubFile, solutionDir, fs) {
|
|
1974
|
-
const parsedStub = await readStub(stubFile, fs);
|
|
1975
|
-
if ("failure" in parsedStub) {
|
|
1976
|
-
return { ok: false, failure: parsedStub.failure };
|
|
1977
|
-
}
|
|
1978
|
-
const stub = parsedStub.stub;
|
|
1979
|
-
const baseName = fs.path.basename(stubFile, ENTITY_EXTENSION_CONST);
|
|
1980
|
-
if (baseName !== stub.name) {
|
|
1981
|
-
return fail("StubFileNameMismatch", `Stub file '${baseName}${ENTITY_EXTENSION_CONST}' names entity '${stub.name}' — the filename and the entity name must match.`);
|
|
1982
|
-
}
|
|
1983
|
-
const solutionRoot = fs.path.resolve(solutionDir);
|
|
1984
|
-
const resourceFile = fs.path.resolve(solutionRoot, ...stub.resourcePath.split("/"));
|
|
1985
|
-
const boundary = resourceFile.charAt(solutionRoot.length);
|
|
1986
|
-
if (!resourceFile.startsWith(solutionRoot) || boundary !== "/" && boundary !== "\\") {
|
|
1987
|
-
return fail("ResourcePathEscapes", `'${stub.name}': resourcePath '${stub.resourcePath}' points outside the solution.`);
|
|
1988
|
-
}
|
|
1989
|
-
const parsedResource = await readResource(resourceFile, stub.name, stub.resourcePath, fs);
|
|
1990
|
-
if ("failure" in parsedResource) {
|
|
1991
|
-
return { ok: false, failure: parsedResource.failure };
|
|
1992
|
-
}
|
|
1993
|
-
const resourceRaw = parsedResource.raw;
|
|
1994
|
-
let entity;
|
|
1995
|
-
try {
|
|
1996
|
-
entity = unwrapResource(resourceRaw);
|
|
1997
|
-
} catch (error) {
|
|
1998
|
-
const detail = error instanceof EntityResourceError ? ` (${error.failure})` : "";
|
|
1999
|
-
return fail("ResourceInvalid", `'${stub.name}': resource '${stub.resourcePath}' is not a valid entity resource${detail}.`);
|
|
2000
|
-
}
|
|
2001
|
-
if (entity.Name !== stub.name) {
|
|
2002
|
-
return fail("NameCoupling", `Stub '${stub.name}' points at a resource defining entity '${entity.Name}' — the names must match.`);
|
|
2003
|
-
}
|
|
2004
|
-
return { ok: true, entityName: stub.name, resourceFile, entity };
|
|
2005
|
-
}
|
|
2006
|
-
function fail(code, message) {
|
|
2007
|
-
return { ok: false, failure: { code, message } };
|
|
2008
|
-
}
|
|
2009
|
-
async function readStub(stubFile, fs) {
|
|
2010
|
-
let parsed;
|
|
2011
|
-
try {
|
|
2012
|
-
const raw = await fs.readFile(stubFile);
|
|
2013
|
-
if (raw === null) {
|
|
2014
|
-
return failure("StubUnparsable", `'${stubFile}' could not be read.`);
|
|
2015
|
-
}
|
|
2016
|
-
parsed = JSON.parse(decode(raw));
|
|
2017
|
-
} catch {
|
|
2018
|
-
return failure("StubUnparsable", `'${stubFile}' is not valid JSON.`);
|
|
2019
|
-
}
|
|
2020
|
-
if (typeof parsed !== "object" || parsed === null || typeof parsed.name !== "string" || typeof parsed.resourcePath !== "string") {
|
|
2021
|
-
return failure("StubUnparsable", `'${stubFile}' must be an object with string 'name' and 'resourcePath'.`);
|
|
2022
|
-
}
|
|
2023
|
-
return { stub: { name: parsed.name, resourcePath: parsed.resourcePath } };
|
|
2024
|
-
}
|
|
2025
|
-
async function readResource(resourceFile, entityName, resourcePath, fs) {
|
|
2026
|
-
const missing = failure("ResourceMissing", `'${entityName}': definition resource '${resourcePath}' is missing. Restore it (check trash/backup) or delete the entity.`);
|
|
2027
|
-
try {
|
|
2028
|
-
const raw = await fs.readFile(resourceFile);
|
|
2029
|
-
if (raw === null) {
|
|
2030
|
-
return missing;
|
|
2031
|
-
}
|
|
2032
|
-
return { raw: JSON.parse(decode(raw)) };
|
|
2033
|
-
} catch (error) {
|
|
2034
|
-
if (error instanceof SyntaxError) {
|
|
2035
|
-
return failure("ResourceInvalid", `'${entityName}': resource '${resourcePath}' is not valid JSON.`);
|
|
2036
|
-
}
|
|
2037
|
-
return missing;
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
function decode(raw) {
|
|
2041
|
-
return typeof raw === "string" ? raw : new TextDecoder().decode(raw);
|
|
2042
|
-
}
|
|
2043
|
-
function failure(code, message) {
|
|
2044
|
-
return { failure: { code, message } };
|
|
2045
|
-
}
|
|
2046
|
-
async function findSolutionRoot(startDir, fs) {
|
|
2047
|
-
let dir = fs.path.resolve(startDir);
|
|
2048
|
-
let unreadable;
|
|
2049
|
-
for (;; ) {
|
|
2050
|
-
const [error, entries] = await catchError(fs.readdir(dir));
|
|
2051
|
-
if (error && isUnreadablePathError(error)) {
|
|
2052
|
-
unreadable ??= error;
|
|
2053
|
-
}
|
|
2054
|
-
if (entries?.some((name) => name.endsWith(".uipx"))) {
|
|
2055
|
-
if (unreadable) {
|
|
2056
|
-
throw Object.assign(new Error(`Could not locate the solution from '${startDir}': ${unreadable.message}. A directory between here and the nearest .uipx cannot be read, and it may be the solution itself — fix read access and retry.`, { cause: unreadable }), { code: unreadable.code });
|
|
2057
|
-
}
|
|
2058
|
-
return dir;
|
|
2059
|
-
}
|
|
2060
|
-
const parent = fs.path.dirname(dir);
|
|
2061
|
-
if (parent === dir) {
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
dir = parent;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
1014
|
// ../packager/packager-tool-datafabric/src/pack/entity-project-tool.ts
|
|
2069
1015
|
class EntityProjectTool extends ProjectTool {
|
|
2070
1016
|
async validateAsync(options, _cancellationToken) {
|
|
@@ -2125,6 +1071,8 @@ class EntityProjectTool extends ProjectTool {
|
|
|
2125
1071
|
const fs = this.fileSystem;
|
|
2126
1072
|
const diagnostics = [];
|
|
2127
1073
|
const allEntityNames = await collectSolutionEntityNames(solutionDir, fs);
|
|
1074
|
+
const natives = await readSolutionNativeEntitiesAsync(solutionDir, fs);
|
|
1075
|
+
const choiceSets = await readSolutionChoiceSetsAsync(solutionDir, fs);
|
|
2128
1076
|
for (const stubName of stubs) {
|
|
2129
1077
|
const stubFile = fs.path.join(projectPath, stubName);
|
|
2130
1078
|
const pair = await verifyPair(stubFile, solutionDir, fs);
|
|
@@ -2136,9 +1084,10 @@ class EntityProjectTool extends ProjectTool {
|
|
|
2136
1084
|
});
|
|
2137
1085
|
continue;
|
|
2138
1086
|
}
|
|
2139
|
-
|
|
1087
|
+
const schema = validateEntity(pair.entity, {
|
|
2140
1088
|
siblingNames: withoutOneOccurrence(allEntityNames, pair.entityName)
|
|
2141
|
-
})
|
|
1089
|
+
});
|
|
1090
|
+
for (const diagnostic of schema) {
|
|
2142
1091
|
diagnostics.push({
|
|
2143
1092
|
file: pair.resourceFile,
|
|
2144
1093
|
code: diagnostic.code,
|
|
@@ -2146,6 +1095,26 @@ class EntityProjectTool extends ProjectTool {
|
|
|
2146
1095
|
fieldName: diagnostic.fieldName
|
|
2147
1096
|
});
|
|
2148
1097
|
}
|
|
1098
|
+
if (schema.length > 0 || !isLocallyAuthored(pair.entity))
|
|
1099
|
+
continue;
|
|
1100
|
+
const name = pair.entity.Name.toLowerCase();
|
|
1101
|
+
const others = natives.filter((each) => each.entity.Name.toLowerCase() !== name);
|
|
1102
|
+
for (const issue of [
|
|
1103
|
+
...referenceIssues(pair.entity, {
|
|
1104
|
+
entities: others,
|
|
1105
|
+
choiceSets
|
|
1106
|
+
}),
|
|
1107
|
+
...entityGraphIssues(pair.entity, others, choiceSets)
|
|
1108
|
+
]) {
|
|
1109
|
+
diagnostics.push({
|
|
1110
|
+
file: pair.resourceFile,
|
|
1111
|
+
code: issue.code,
|
|
1112
|
+
message: issue.message,
|
|
1113
|
+
...issue.fieldName !== "" && {
|
|
1114
|
+
fieldName: issue.fieldName
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
2149
1118
|
}
|
|
2150
1119
|
return diagnostics;
|
|
2151
1120
|
}
|
|
@@ -2167,6 +1136,6 @@ class EntityToolFactory {
|
|
|
2167
1136
|
return new EntityProjectTool(fileSystem, logger);
|
|
2168
1137
|
}
|
|
2169
1138
|
}
|
|
2170
|
-
export { toolsFactoryRepository,
|
|
1139
|
+
export { toolsFactoryRepository, EntityToolFactory };
|
|
2171
1140
|
|
|
2172
|
-
//# debugId=
|
|
1141
|
+
//# debugId=F2D40CCA92F03F4664756E2164756E21
|