@diagonal-hq/cli 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -11
- package/dist/cli.mjs +1285 -684
- package/dist/fields.generated.d.ts +7 -1
- package/dist/index.d.ts +85 -9
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -101,7 +101,7 @@ var require_jsesc = __commonJS({
|
|
|
101
101
|
var isBuffer = (value) => {
|
|
102
102
|
return typeof Buffer === "function" && Buffer.isBuffer(value);
|
|
103
103
|
};
|
|
104
|
-
var
|
|
104
|
+
var isObject = (value) => {
|
|
105
105
|
return toString.call(value) == "[object Object]";
|
|
106
106
|
};
|
|
107
107
|
var isString = (value) => {
|
|
@@ -261,7 +261,7 @@ var require_jsesc = __commonJS({
|
|
|
261
261
|
return JSON.stringify(Number(argument));
|
|
262
262
|
}
|
|
263
263
|
return argument + "n";
|
|
264
|
-
} else if (!
|
|
264
|
+
} else if (!isObject(argument)) {
|
|
265
265
|
if (json) {
|
|
266
266
|
return JSON.stringify(argument) || "null";
|
|
267
267
|
}
|
|
@@ -23059,8 +23059,8 @@ ${lanes.join("\n")}
|
|
|
23059
23059
|
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
23060
23060
|
}
|
|
23061
23061
|
function forEachReturnStatement(body, visitor) {
|
|
23062
|
-
return
|
|
23063
|
-
function
|
|
23062
|
+
return traverse6(body);
|
|
23063
|
+
function traverse6(node) {
|
|
23064
23064
|
switch (node.kind) {
|
|
23065
23065
|
case 254:
|
|
23066
23066
|
return visitor(node);
|
|
@@ -23079,13 +23079,13 @@ ${lanes.join("\n")}
|
|
|
23079
23079
|
case 257:
|
|
23080
23080
|
case 259:
|
|
23081
23081
|
case 300:
|
|
23082
|
-
return forEachChild(node,
|
|
23082
|
+
return forEachChild(node, traverse6);
|
|
23083
23083
|
}
|
|
23084
23084
|
}
|
|
23085
23085
|
}
|
|
23086
23086
|
function forEachYieldExpression(body, visitor) {
|
|
23087
|
-
return
|
|
23088
|
-
function
|
|
23087
|
+
return traverse6(body);
|
|
23088
|
+
function traverse6(node) {
|
|
23089
23089
|
switch (node.kind) {
|
|
23090
23090
|
case 230:
|
|
23091
23091
|
const value = visitor(node);
|
|
@@ -23096,7 +23096,7 @@ ${lanes.join("\n")}
|
|
|
23096
23096
|
if (!operand) {
|
|
23097
23097
|
return;
|
|
23098
23098
|
}
|
|
23099
|
-
return
|
|
23099
|
+
return traverse6(operand);
|
|
23100
23100
|
case 267:
|
|
23101
23101
|
case 265:
|
|
23102
23102
|
case 268:
|
|
@@ -23105,10 +23105,10 @@ ${lanes.join("\n")}
|
|
|
23105
23105
|
default:
|
|
23106
23106
|
if (isFunctionLike(node)) {
|
|
23107
23107
|
if (node.name && node.name.kind === 168) {
|
|
23108
|
-
return
|
|
23108
|
+
return traverse6(node.name.expression);
|
|
23109
23109
|
}
|
|
23110
23110
|
} else if (!isPartOfTypeNode(node)) {
|
|
23111
|
-
return forEachChild(node,
|
|
23111
|
+
return forEachChild(node, traverse6);
|
|
23112
23112
|
}
|
|
23113
23113
|
}
|
|
23114
23114
|
}
|
|
@@ -25723,9 +25723,9 @@ ${lanes.join("\n")}
|
|
|
25723
25723
|
} else {
|
|
25724
25724
|
forEach(declarations, (member) => {
|
|
25725
25725
|
if (isAccessor2(member) && isStatic2(member) === isStatic2(accessor)) {
|
|
25726
|
-
const
|
|
25726
|
+
const memberName2 = getPropertyNameForPropertyNameNode(member.name);
|
|
25727
25727
|
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
|
25728
|
-
if (
|
|
25728
|
+
if (memberName2 === accessorName) {
|
|
25729
25729
|
if (!firstAccessor) {
|
|
25730
25730
|
firstAccessor = member;
|
|
25731
25731
|
} else if (!secondAccessor) {
|
|
@@ -35869,7 +35869,7 @@ ${lanes.join("\n")}
|
|
|
35869
35869
|
/* AdviseOnEmitNode */
|
|
35870
35870
|
);
|
|
35871
35871
|
}
|
|
35872
|
-
function createDecorateHelper(decoratorExpressions, target,
|
|
35872
|
+
function createDecorateHelper(decoratorExpressions, target, memberName2, descriptor) {
|
|
35873
35873
|
context.requestEmitHelper(decorateHelper);
|
|
35874
35874
|
const argumentsArray = [];
|
|
35875
35875
|
argumentsArray.push(factory2.createArrayLiteralExpression(
|
|
@@ -35878,8 +35878,8 @@ ${lanes.join("\n")}
|
|
|
35878
35878
|
true
|
|
35879
35879
|
));
|
|
35880
35880
|
argumentsArray.push(target);
|
|
35881
|
-
if (
|
|
35882
|
-
argumentsArray.push(
|
|
35881
|
+
if (memberName2) {
|
|
35882
|
+
argumentsArray.push(memberName2);
|
|
35883
35883
|
if (descriptor) {
|
|
35884
35884
|
argumentsArray.push(descriptor);
|
|
35885
35885
|
}
|
|
@@ -37646,13 +37646,13 @@ ${lanes.join("\n")}
|
|
|
37646
37646
|
void 0
|
|
37647
37647
|
);
|
|
37648
37648
|
}
|
|
37649
|
-
function createMemberAccessForPropertyName(factory2, target,
|
|
37650
|
-
if (isComputedPropertyName(
|
|
37651
|
-
return setTextRange(factory2.createElementAccessExpression(target,
|
|
37649
|
+
function createMemberAccessForPropertyName(factory2, target, memberName2, location) {
|
|
37650
|
+
if (isComputedPropertyName(memberName2)) {
|
|
37651
|
+
return setTextRange(factory2.createElementAccessExpression(target, memberName2.expression), location);
|
|
37652
37652
|
} else {
|
|
37653
37653
|
const expression2 = setTextRange(
|
|
37654
|
-
isMemberName2(
|
|
37655
|
-
|
|
37654
|
+
isMemberName2(memberName2) ? factory2.createPropertyAccessExpression(target, memberName2) : factory2.createElementAccessExpression(target, memberName2),
|
|
37655
|
+
memberName2
|
|
37656
37656
|
);
|
|
37657
37657
|
addEmitFlags(
|
|
37658
37658
|
expression2,
|
|
@@ -37783,13 +37783,13 @@ ${lanes.join("\n")}
|
|
|
37783
37783
|
return setParent(setTextRange(factory2.cloneNode(node), node), node.parent);
|
|
37784
37784
|
}
|
|
37785
37785
|
}
|
|
37786
|
-
function createExpressionForPropertyName(factory2,
|
|
37787
|
-
if (isIdentifier5(
|
|
37788
|
-
return factory2.createStringLiteralFromNode(
|
|
37789
|
-
} else if (isComputedPropertyName(
|
|
37790
|
-
return setParent(setTextRange(factory2.cloneNode(
|
|
37786
|
+
function createExpressionForPropertyName(factory2, memberName2) {
|
|
37787
|
+
if (isIdentifier5(memberName2)) {
|
|
37788
|
+
return factory2.createStringLiteralFromNode(memberName2);
|
|
37789
|
+
} else if (isComputedPropertyName(memberName2)) {
|
|
37790
|
+
return setParent(setTextRange(factory2.cloneNode(memberName2.expression), memberName2.expression), memberName2.expression.parent);
|
|
37791
37791
|
} else {
|
|
37792
|
-
return setParent(setTextRange(factory2.cloneNode(
|
|
37792
|
+
return setParent(setTextRange(factory2.cloneNode(memberName2), memberName2), memberName2.parent);
|
|
37793
37793
|
}
|
|
37794
37794
|
}
|
|
37795
37795
|
function createExpressionForAccessorDeclaration(factory2, properties, property, receiver, multiLine) {
|
|
@@ -62933,14 +62933,14 @@ ${lanes.join("\n")}
|
|
|
62933
62933
|
}
|
|
62934
62934
|
}
|
|
62935
62935
|
}
|
|
62936
|
-
function tryGetMemberInModuleExports(
|
|
62936
|
+
function tryGetMemberInModuleExports(memberName2, moduleSymbol) {
|
|
62937
62937
|
const symbolTable = getExportsOfModule(moduleSymbol);
|
|
62938
62938
|
if (symbolTable) {
|
|
62939
|
-
return symbolTable.get(
|
|
62939
|
+
return symbolTable.get(memberName2);
|
|
62940
62940
|
}
|
|
62941
62941
|
}
|
|
62942
|
-
function tryGetMemberInModuleExportsAndProperties(
|
|
62943
|
-
const symbol = tryGetMemberInModuleExports(
|
|
62942
|
+
function tryGetMemberInModuleExportsAndProperties(memberName2, moduleSymbol) {
|
|
62943
|
+
const symbol = tryGetMemberInModuleExports(memberName2, moduleSymbol);
|
|
62944
62944
|
if (symbol) {
|
|
62945
62945
|
return symbol;
|
|
62946
62946
|
}
|
|
@@ -62949,7 +62949,7 @@ ${lanes.join("\n")}
|
|
|
62949
62949
|
return void 0;
|
|
62950
62950
|
}
|
|
62951
62951
|
const type = getTypeOfSymbol(exportEquals);
|
|
62952
|
-
return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type,
|
|
62952
|
+
return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName2) : void 0;
|
|
62953
62953
|
}
|
|
62954
62954
|
function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) {
|
|
62955
62955
|
return !(resolvedExternalModuleType.flags & 12713980 || getObjectFlags(resolvedExternalModuleType) & 1 || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path
|
|
@@ -64591,16 +64591,16 @@ ${lanes.join("\n")}
|
|
|
64591
64591
|
if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
|
|
64592
64592
|
return parentName;
|
|
64593
64593
|
}
|
|
64594
|
-
const
|
|
64594
|
+
const memberName2 = symbolName(type.symbol);
|
|
64595
64595
|
if (isIdentifierText(
|
|
64596
|
-
|
|
64596
|
+
memberName2,
|
|
64597
64597
|
99
|
|
64598
64598
|
/* ESNext */
|
|
64599
64599
|
)) {
|
|
64600
64600
|
return appendReferenceToType(
|
|
64601
64601
|
parentName,
|
|
64602
64602
|
factory.createTypeReferenceNode(
|
|
64603
|
-
|
|
64603
|
+
memberName2,
|
|
64604
64604
|
/*typeArguments*/
|
|
64605
64605
|
void 0
|
|
64606
64606
|
)
|
|
@@ -64608,9 +64608,9 @@ ${lanes.join("\n")}
|
|
|
64608
64608
|
}
|
|
64609
64609
|
if (isImportTypeNode(parentName)) {
|
|
64610
64610
|
parentName.isTypeOf = true;
|
|
64611
|
-
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(
|
|
64611
|
+
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(memberName2)));
|
|
64612
64612
|
} else if (isTypeReferenceNode(parentName)) {
|
|
64613
|
-
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(
|
|
64613
|
+
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(memberName2)));
|
|
64614
64614
|
} else {
|
|
64615
64615
|
return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
|
|
64616
64616
|
}
|
|
@@ -67948,9 +67948,9 @@ ${lanes.join("\n")}
|
|
|
67948
67948
|
const last22 = memberProps[memberProps.length - 1];
|
|
67949
67949
|
const initializedValue = last22.declarations && last22.declarations[0] && isEnumMember2(last22.declarations[0]) ? getConstantValue2(last22.declarations[0]) : void 0;
|
|
67950
67950
|
const initializer2 = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
67951
|
-
const
|
|
67951
|
+
const memberName22 = unescapeLeadingUnderscores(last22.escapedName);
|
|
67952
67952
|
const member2 = factory.createEnumMember(
|
|
67953
|
-
|
|
67953
|
+
memberName22,
|
|
67954
67954
|
initializer2
|
|
67955
67955
|
);
|
|
67956
67956
|
members.push(member2);
|
|
@@ -67967,10 +67967,10 @@ ${lanes.join("\n")}
|
|
|
67967
67967
|
initializer = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
67968
67968
|
initializerLength = (initializer == null ? void 0 : initializer.text.length) ?? 0;
|
|
67969
67969
|
}
|
|
67970
|
-
const
|
|
67971
|
-
context.approximateLength += 4 +
|
|
67970
|
+
const memberName2 = unescapeLeadingUnderscores(p.escapedName);
|
|
67971
|
+
context.approximateLength += 4 + memberName2.length + initializerLength;
|
|
67972
67972
|
const member = factory.createEnumMember(
|
|
67973
|
-
|
|
67973
|
+
memberName2,
|
|
67974
67974
|
initializer
|
|
67975
67975
|
);
|
|
67976
67976
|
members.push(member);
|
|
@@ -71457,24 +71457,24 @@ ${lanes.join("\n")}
|
|
|
71457
71457
|
const declName = isBinaryExpression2(decl) ? decl.left : decl.name;
|
|
71458
71458
|
const type = isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
|
|
71459
71459
|
if (isTypeUsableAsPropertyName(type)) {
|
|
71460
|
-
const
|
|
71460
|
+
const memberName2 = getPropertyNameFromType(type);
|
|
71461
71461
|
const symbolFlags = decl.symbol.flags;
|
|
71462
|
-
let lateSymbol = lateSymbols.get(
|
|
71463
|
-
if (!lateSymbol) lateSymbols.set(
|
|
71462
|
+
let lateSymbol = lateSymbols.get(memberName2);
|
|
71463
|
+
if (!lateSymbol) lateSymbols.set(memberName2, lateSymbol = createSymbol(
|
|
71464
71464
|
0,
|
|
71465
|
-
|
|
71465
|
+
memberName2,
|
|
71466
71466
|
4096
|
|
71467
71467
|
/* Late */
|
|
71468
71468
|
));
|
|
71469
|
-
const earlySymbol = earlySymbols && earlySymbols.get(
|
|
71469
|
+
const earlySymbol = earlySymbols && earlySymbols.get(memberName2);
|
|
71470
71470
|
if (!(parent2.flags & 32) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
71471
71471
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
71472
|
-
const name = !(type.flags & 16384) && unescapeLeadingUnderscores(
|
|
71472
|
+
const name = !(type.flags & 16384) && unescapeLeadingUnderscores(memberName2) || declarationNameToString(declName);
|
|
71473
71473
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
71474
71474
|
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
71475
71475
|
lateSymbol = createSymbol(
|
|
71476
71476
|
0,
|
|
71477
|
-
|
|
71477
|
+
memberName2,
|
|
71478
71478
|
4096
|
|
71479
71479
|
/* Late */
|
|
71480
71480
|
);
|
|
@@ -73315,14 +73315,14 @@ ${lanes.join("\n")}
|
|
|
73315
73315
|
if (type.arrayFallbackSignatures) {
|
|
73316
73316
|
return type.arrayFallbackSignatures;
|
|
73317
73317
|
}
|
|
73318
|
-
let
|
|
73318
|
+
let memberName2;
|
|
73319
73319
|
if (everyType(type, (t) => {
|
|
73320
73320
|
var _a;
|
|
73321
|
-
return !!((_a = t.symbol) == null ? void 0 : _a.parent) && isArrayOrTupleSymbol(t.symbol.parent) && (!
|
|
73321
|
+
return !!((_a = t.symbol) == null ? void 0 : _a.parent) && isArrayOrTupleSymbol(t.symbol.parent) && (!memberName2 ? (memberName2 = t.symbol.escapedName, true) : memberName2 === t.symbol.escapedName);
|
|
73322
73322
|
})) {
|
|
73323
73323
|
const arrayArg = mapType(type, (t) => getMappedType((isReadonlyArraySymbol(t.symbol.parent) ? globalReadonlyArrayType : globalArrayType).typeParameters[0], t.mapper));
|
|
73324
73324
|
const arrayType = createArrayType(arrayArg, someType(type, (t) => isReadonlyArraySymbol(t.symbol.parent)));
|
|
73325
|
-
return type.arrayFallbackSignatures = getSignaturesOfType(getTypeOfPropertyOfType(arrayType,
|
|
73325
|
+
return type.arrayFallbackSignatures = getSignaturesOfType(getTypeOfPropertyOfType(arrayType, memberName2), kind);
|
|
73326
73326
|
}
|
|
73327
73327
|
type.arrayFallbackSignatures = result;
|
|
73328
73328
|
}
|
|
@@ -73633,11 +73633,11 @@ ${lanes.join("\n")}
|
|
|
73633
73633
|
if (links.flags & 512) {
|
|
73634
73634
|
links.containsArgumentsReference = true;
|
|
73635
73635
|
} else {
|
|
73636
|
-
links.containsArgumentsReference =
|
|
73636
|
+
links.containsArgumentsReference = traverse6(declaration.body);
|
|
73637
73637
|
}
|
|
73638
73638
|
}
|
|
73639
73639
|
return links.containsArgumentsReference;
|
|
73640
|
-
function
|
|
73640
|
+
function traverse6(node) {
|
|
73641
73641
|
if (!node) return false;
|
|
73642
73642
|
switch (node.kind) {
|
|
73643
73643
|
case 80:
|
|
@@ -73646,14 +73646,14 @@ ${lanes.join("\n")}
|
|
|
73646
73646
|
case 175:
|
|
73647
73647
|
case 178:
|
|
73648
73648
|
case 179:
|
|
73649
|
-
return node.name.kind === 168 &&
|
|
73649
|
+
return node.name.kind === 168 && traverse6(node.name);
|
|
73650
73650
|
case 212:
|
|
73651
73651
|
case 213:
|
|
73652
|
-
return
|
|
73652
|
+
return traverse6(node.expression);
|
|
73653
73653
|
case 304:
|
|
73654
|
-
return
|
|
73654
|
+
return traverse6(node.initializer);
|
|
73655
73655
|
default:
|
|
73656
|
-
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node,
|
|
73656
|
+
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node, traverse6);
|
|
73657
73657
|
}
|
|
73658
73658
|
}
|
|
73659
73659
|
}
|
|
@@ -96888,20 +96888,20 @@ ${lanes.join("\n")}
|
|
|
96888
96888
|
const isPrivate2 = isPrivateIdentifier(name);
|
|
96889
96889
|
const privateStaticFlags = isPrivate2 && isStaticMember ? 16 : 0;
|
|
96890
96890
|
const names2 = isPrivate2 ? privateIdentifiers : isStaticMember ? staticNames : instanceNames;
|
|
96891
|
-
const
|
|
96892
|
-
if (
|
|
96891
|
+
const memberName2 = name && getEffectivePropertyNameForPropertyNameNode(name);
|
|
96892
|
+
if (memberName2) {
|
|
96893
96893
|
switch (member.kind) {
|
|
96894
96894
|
case 178:
|
|
96895
|
-
addName(names2, name,
|
|
96895
|
+
addName(names2, name, memberName2, 1 | privateStaticFlags);
|
|
96896
96896
|
break;
|
|
96897
96897
|
case 179:
|
|
96898
|
-
addName(names2, name,
|
|
96898
|
+
addName(names2, name, memberName2, 2 | privateStaticFlags);
|
|
96899
96899
|
break;
|
|
96900
96900
|
case 173:
|
|
96901
|
-
addName(names2, name,
|
|
96901
|
+
addName(names2, name, memberName2, 3 | privateStaticFlags);
|
|
96902
96902
|
break;
|
|
96903
96903
|
case 175:
|
|
96904
|
-
addName(names2, name,
|
|
96904
|
+
addName(names2, name, memberName2, 8 | privateStaticFlags);
|
|
96905
96905
|
break;
|
|
96906
96906
|
}
|
|
96907
96907
|
}
|
|
@@ -96935,8 +96935,8 @@ ${lanes.join("\n")}
|
|
|
96935
96935
|
const memberNameNode = member.name;
|
|
96936
96936
|
const isStaticMember = isStatic2(member);
|
|
96937
96937
|
if (isStaticMember && memberNameNode) {
|
|
96938
|
-
const
|
|
96939
|
-
switch (
|
|
96938
|
+
const memberName2 = getEffectivePropertyNameForPropertyNameNode(memberNameNode);
|
|
96939
|
+
switch (memberName2) {
|
|
96940
96940
|
case "name":
|
|
96941
96941
|
case "length":
|
|
96942
96942
|
case "caller":
|
|
@@ -96948,7 +96948,7 @@ ${lanes.join("\n")}
|
|
|
96948
96948
|
case "prototype":
|
|
96949
96949
|
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
|
|
96950
96950
|
const className = getNameOfSymbolAsWritten(getSymbolOfDeclaration(node));
|
|
96951
|
-
error2(memberNameNode, message,
|
|
96951
|
+
error2(memberNameNode, message, memberName2, className);
|
|
96952
96952
|
break;
|
|
96953
96953
|
}
|
|
96954
96954
|
}
|
|
@@ -96958,24 +96958,24 @@ ${lanes.join("\n")}
|
|
|
96958
96958
|
const names2 = /* @__PURE__ */ new Map();
|
|
96959
96959
|
for (const member of node.members) {
|
|
96960
96960
|
if (member.kind === 172) {
|
|
96961
|
-
let
|
|
96961
|
+
let memberName2;
|
|
96962
96962
|
const name = member.name;
|
|
96963
96963
|
switch (name.kind) {
|
|
96964
96964
|
case 11:
|
|
96965
96965
|
case 9:
|
|
96966
|
-
|
|
96966
|
+
memberName2 = name.text;
|
|
96967
96967
|
break;
|
|
96968
96968
|
case 80:
|
|
96969
|
-
|
|
96969
|
+
memberName2 = idText(name);
|
|
96970
96970
|
break;
|
|
96971
96971
|
default:
|
|
96972
96972
|
continue;
|
|
96973
96973
|
}
|
|
96974
|
-
if (names2.get(
|
|
96975
|
-
error2(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0,
|
|
96976
|
-
error2(member.name, Diagnostics.Duplicate_identifier_0,
|
|
96974
|
+
if (names2.get(memberName2)) {
|
|
96975
|
+
error2(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0, memberName2);
|
|
96976
|
+
error2(member.name, Diagnostics.Duplicate_identifier_0, memberName2);
|
|
96977
96977
|
} else {
|
|
96978
|
-
names2.set(
|
|
96978
|
+
names2.set(memberName2, true);
|
|
96979
96979
|
}
|
|
96980
96980
|
}
|
|
96981
96981
|
}
|
|
@@ -115759,7 +115759,7 @@ ${lanes.join("\n")}
|
|
|
115759
115759
|
return void 0;
|
|
115760
115760
|
}
|
|
115761
115761
|
const prefix2 = getClassMemberPrefix(node, member);
|
|
115762
|
-
const
|
|
115762
|
+
const memberName2 = getExpressionForPropertyName(
|
|
115763
115763
|
member,
|
|
115764
115764
|
/*generateNameForComputedPropertyName*/
|
|
115765
115765
|
!hasSyntacticModifier(
|
|
@@ -115772,7 +115772,7 @@ ${lanes.join("\n")}
|
|
|
115772
115772
|
const helper = emitHelpers().createDecorateHelper(
|
|
115773
115773
|
decoratorExpressions,
|
|
115774
115774
|
prefix2,
|
|
115775
|
-
|
|
115775
|
+
memberName2,
|
|
115776
115776
|
descriptor
|
|
115777
115777
|
);
|
|
115778
115778
|
setEmitFlags(
|
|
@@ -123613,14 +123613,14 @@ ${lanes.join("\n")}
|
|
|
123613
123613
|
const name = isComputedPropertyName(propertyName) ? propertyName.expression : isIdentifier5(propertyName) ? factory2.createStringLiteral(unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName;
|
|
123614
123614
|
e = factory2.createObjectDefinePropertyCall(receiver, name, factory2.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
|
|
123615
123615
|
} else {
|
|
123616
|
-
const
|
|
123616
|
+
const memberName2 = createMemberAccessForPropertyName(
|
|
123617
123617
|
factory2,
|
|
123618
123618
|
receiver,
|
|
123619
123619
|
propertyName,
|
|
123620
123620
|
/*location*/
|
|
123621
123621
|
member.name
|
|
123622
123622
|
);
|
|
123623
|
-
e = factory2.createAssignment(
|
|
123623
|
+
e = factory2.createAssignment(memberName2, memberFunction);
|
|
123624
123624
|
}
|
|
123625
123625
|
setEmitFlags(
|
|
123626
123626
|
memberFunction,
|
|
@@ -156340,8 +156340,8 @@ ${lanes.join("\n")}
|
|
|
156340
156340
|
}
|
|
156341
156341
|
function quote(sourceFile, preferences, text) {
|
|
156342
156342
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
156343
|
-
const
|
|
156344
|
-
return quotePreference === 0 ? `'${stripQuotes(
|
|
156343
|
+
const quoted2 = JSON.stringify(text);
|
|
156344
|
+
return quotePreference === 0 ? `'${stripQuotes(quoted2).replace(/'/g, () => "\\'").replace(/\\"/g, '"')}'` : quoted2;
|
|
156345
156345
|
}
|
|
156346
156346
|
function isEqualityOperatorKind(kind) {
|
|
156347
156347
|
switch (kind) {
|
|
@@ -160993,10 +160993,10 @@ interface Symbol {
|
|
|
160993
160993
|
case 9: {
|
|
160994
160994
|
const defineCall = node;
|
|
160995
160995
|
const className = special === 7 ? defineCall.arguments[0] : defineCall.arguments[0].expression;
|
|
160996
|
-
const
|
|
160996
|
+
const memberName2 = defineCall.arguments[1];
|
|
160997
160997
|
const [depth, classNameIdentifier] = startNestedNodes(node, className);
|
|
160998
160998
|
startNode(node, classNameIdentifier);
|
|
160999
|
-
startNode(node, setTextRange(factory.createIdentifier(
|
|
160999
|
+
startNode(node, setTextRange(factory.createIdentifier(memberName2.text), memberName2));
|
|
161000
161000
|
addChildrenRecursively(node.arguments[2]);
|
|
161001
161001
|
endNode();
|
|
161002
161002
|
endNode();
|
|
@@ -176591,14 +176591,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
176591
176591
|
return factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(obj, propertyName), createUndefined()));
|
|
176592
176592
|
}
|
|
176593
176593
|
function createActionsForAddMissingMemberInTypeScriptFile(context, { parentDeclaration, declSourceFile, modifierFlags, token }) {
|
|
176594
|
-
const
|
|
176594
|
+
const memberName2 = token.text;
|
|
176595
176595
|
const isStatic22 = modifierFlags & 256;
|
|
176596
176596
|
const typeNode = getTypeNode2(context.program.getTypeChecker(), parentDeclaration, token);
|
|
176597
|
-
const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration,
|
|
176597
|
+
const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName2, typeNode, modifierFlags2));
|
|
176598
176598
|
const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(
|
|
176599
176599
|
modifierFlags & 256
|
|
176600
176600
|
/* Static */
|
|
176601
|
-
), [isStatic22 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0,
|
|
176601
|
+
), [isStatic22 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName2], fixMissingMember, Diagnostics.Add_all_missing_members)];
|
|
176602
176602
|
if (isStatic22 || isPrivateIdentifier(token)) {
|
|
176603
176603
|
return actions2;
|
|
176604
176604
|
}
|
|
@@ -176606,7 +176606,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
176606
176606
|
actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(
|
|
176607
176607
|
2
|
|
176608
176608
|
/* Private */
|
|
176609
|
-
), [Diagnostics.Declare_private_property_0,
|
|
176609
|
+
), [Diagnostics.Declare_private_property_0, memberName2]));
|
|
176610
176610
|
}
|
|
176611
176611
|
actions2.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode));
|
|
176612
176612
|
return actions2;
|
|
@@ -183036,7 +183036,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
183036
183036
|
return void 0;
|
|
183037
183037
|
}
|
|
183038
183038
|
}
|
|
183039
|
-
function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs,
|
|
183039
|
+
function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options2, preferences, tabstopCounter) {
|
|
183040
183040
|
if (isSnippet) {
|
|
183041
183041
|
Debug.assertIsDefined(tabstopCounter);
|
|
183042
183042
|
}
|
|
@@ -183048,7 +183048,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
183048
183048
|
}
|
|
183049
183049
|
if (isJs) {
|
|
183050
183050
|
let type = "*";
|
|
183051
|
-
if (
|
|
183051
|
+
if (isObject) {
|
|
183052
183052
|
Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
|
|
183053
183053
|
type = "Object";
|
|
183054
183054
|
} else {
|
|
@@ -183084,7 +183084,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
183084
183084
|
type = `\${${tabstopCounter.tabstop++}:${type}}`;
|
|
183085
183085
|
}
|
|
183086
183086
|
}
|
|
183087
|
-
const dotDotDot = !
|
|
183087
|
+
const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
|
|
183088
183088
|
const description3 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
|
|
183089
183089
|
return `@param {${dotDotDot}${type}} ${paramName} ${description3}`;
|
|
183090
183090
|
} else {
|
|
@@ -251060,13 +251060,13 @@ var FlowErrorTemplates = {
|
|
|
251060
251060
|
DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
|
|
251061
251061
|
DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
|
|
251062
251062
|
EnumBooleanMemberNotInitialized: ({
|
|
251063
|
-
memberName,
|
|
251063
|
+
memberName: memberName2,
|
|
251064
251064
|
enumName
|
|
251065
|
-
}) => `Boolean enum members need to be initialized. Use either \`${
|
|
251065
|
+
}) => `Boolean enum members need to be initialized. Use either \`${memberName2} = true,\` or \`${memberName2} = false,\` in enum \`${enumName}\`.`,
|
|
251066
251066
|
EnumDuplicateMemberName: ({
|
|
251067
|
-
memberName,
|
|
251067
|
+
memberName: memberName2,
|
|
251068
251068
|
enumName
|
|
251069
|
-
}) => `Enum member names need to be unique, but the name \`${
|
|
251069
|
+
}) => `Enum member names need to be unique, but the name \`${memberName2}\` has already been used before in enum \`${enumName}\`.`,
|
|
251070
251070
|
EnumInconsistentMemberValues: ({
|
|
251071
251071
|
enumName
|
|
251072
251072
|
}) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
|
|
@@ -251079,26 +251079,26 @@ var FlowErrorTemplates = {
|
|
|
251079
251079
|
}) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
|
|
251080
251080
|
EnumInvalidMemberInitializerPrimaryType: ({
|
|
251081
251081
|
enumName,
|
|
251082
|
-
memberName,
|
|
251082
|
+
memberName: memberName2,
|
|
251083
251083
|
explicitType
|
|
251084
|
-
}) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${
|
|
251084
|
+
}) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName2}\` needs to be a ${explicitType} literal.`,
|
|
251085
251085
|
EnumInvalidMemberInitializerSymbolType: ({
|
|
251086
251086
|
enumName,
|
|
251087
|
-
memberName
|
|
251088
|
-
}) => `Symbol enum members cannot be initialized. Use \`${
|
|
251087
|
+
memberName: memberName2
|
|
251088
|
+
}) => `Symbol enum members cannot be initialized. Use \`${memberName2},\` in enum \`${enumName}\`.`,
|
|
251089
251089
|
EnumInvalidMemberInitializerUnknownType: ({
|
|
251090
251090
|
enumName,
|
|
251091
|
-
memberName
|
|
251092
|
-
}) => `The enum member initializer for \`${
|
|
251091
|
+
memberName: memberName2
|
|
251092
|
+
}) => `The enum member initializer for \`${memberName2}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
|
|
251093
251093
|
EnumInvalidMemberName: ({
|
|
251094
251094
|
enumName,
|
|
251095
|
-
memberName,
|
|
251095
|
+
memberName: memberName2,
|
|
251096
251096
|
suggestion
|
|
251097
|
-
}) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${
|
|
251097
|
+
}) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName2}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
|
|
251098
251098
|
EnumNumberMemberNotInitialized: ({
|
|
251099
251099
|
enumName,
|
|
251100
|
-
memberName
|
|
251101
|
-
}) => `Number enum members need to be initialized, e.g. \`${
|
|
251100
|
+
memberName: memberName2
|
|
251101
|
+
}) => `Number enum members need to be initialized, e.g. \`${memberName2} = 1\` in enum \`${enumName}\`.`,
|
|
251102
251102
|
EnumStringMemberInconsistentlyInitialized: ({
|
|
251103
251103
|
enumName
|
|
251104
251104
|
}) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
|
|
@@ -253186,28 +253186,28 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
253186
253186
|
id,
|
|
253187
253187
|
init
|
|
253188
253188
|
} = this.flowEnumMemberRaw();
|
|
253189
|
-
const
|
|
253190
|
-
if (
|
|
253189
|
+
const memberName2 = id.name;
|
|
253190
|
+
if (memberName2 === "") {
|
|
253191
253191
|
continue;
|
|
253192
253192
|
}
|
|
253193
|
-
if (/^[a-z]/.test(
|
|
253193
|
+
if (/^[a-z]/.test(memberName2)) {
|
|
253194
253194
|
this.raise(FlowErrors.EnumInvalidMemberName, id, {
|
|
253195
|
-
memberName,
|
|
253196
|
-
suggestion:
|
|
253195
|
+
memberName: memberName2,
|
|
253196
|
+
suggestion: memberName2[0].toUpperCase() + memberName2.slice(1),
|
|
253197
253197
|
enumName
|
|
253198
253198
|
});
|
|
253199
253199
|
}
|
|
253200
|
-
if (seenNames.has(
|
|
253200
|
+
if (seenNames.has(memberName2)) {
|
|
253201
253201
|
this.raise(FlowErrors.EnumDuplicateMemberName, id, {
|
|
253202
|
-
memberName,
|
|
253202
|
+
memberName: memberName2,
|
|
253203
253203
|
enumName
|
|
253204
253204
|
});
|
|
253205
253205
|
}
|
|
253206
|
-
seenNames.add(
|
|
253206
|
+
seenNames.add(memberName2);
|
|
253207
253207
|
const context = {
|
|
253208
253208
|
enumName,
|
|
253209
253209
|
explicitType,
|
|
253210
|
-
memberName
|
|
253210
|
+
memberName: memberName2
|
|
253211
253211
|
};
|
|
253212
253212
|
memberNode.id = id;
|
|
253213
253213
|
switch (init.type) {
|
|
@@ -260949,14 +260949,14 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
|
|
|
260949
260949
|
const node = this.startNode();
|
|
260950
260950
|
node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
|
|
260951
260951
|
let seenOptionalElement = false;
|
|
260952
|
-
node.elementTypes.forEach((
|
|
260952
|
+
node.elementTypes.forEach((elementNode2) => {
|
|
260953
260953
|
const {
|
|
260954
260954
|
type
|
|
260955
|
-
} =
|
|
260956
|
-
if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" &&
|
|
260957
|
-
this.raise(TSErrors.OptionalTypeBeforeRequired,
|
|
260955
|
+
} = elementNode2;
|
|
260956
|
+
if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode2.optional)) {
|
|
260957
|
+
this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode2);
|
|
260958
260958
|
}
|
|
260959
|
-
seenOptionalElement ||= type === "TSNamedTupleMember" &&
|
|
260959
|
+
seenOptionalElement ||= type === "TSNamedTupleMember" && elementNode2.optional || type === "TSOptionalType";
|
|
260960
260960
|
});
|
|
260961
260961
|
return this.finishNode(node, "TSTupleType");
|
|
260962
260962
|
}
|
|
@@ -264210,17 +264210,44 @@ function fieldBuilderCall(node, options2) {
|
|
|
264210
264210
|
}
|
|
264211
264211
|
function resourceReference(node, options2) {
|
|
264212
264212
|
const binding = options2.resources ?? null;
|
|
264213
|
-
|
|
264213
|
+
const reference = binding === null ? null : resourceMember(node, binding.local);
|
|
264214
|
+
if (reference === null) {
|
|
264214
264215
|
throw new SourceError("MemberExpression is not allowed in static data. Use literal values only", node);
|
|
264215
264216
|
}
|
|
264216
|
-
const
|
|
264217
|
-
|
|
264217
|
+
const { nameNode, propertyNode: propertyNode2 } = reference;
|
|
264218
|
+
const name = `${binding.local}.${nameNode.name}`;
|
|
264219
|
+
if (!binding.slugsByName.has(nameNode.name)) {
|
|
264218
264220
|
throw new SourceError(
|
|
264219
|
-
`Unknown resource "${
|
|
264220
|
-
|
|
264221
|
+
`Unknown resource "${name}". Each name in ${binding.local} is a file in resources/`,
|
|
264222
|
+
nameNode
|
|
264221
264223
|
);
|
|
264222
264224
|
}
|
|
264223
|
-
|
|
264225
|
+
if (propertyNode2 === null) {
|
|
264226
|
+
throw new SourceError(
|
|
264227
|
+
`${name} is the metadata of the resource. Use ${name}.slug to name the resource`,
|
|
264228
|
+
node
|
|
264229
|
+
);
|
|
264230
|
+
}
|
|
264231
|
+
if (propertyNode2.name !== "slug") {
|
|
264232
|
+
throw new SourceError(
|
|
264233
|
+
`Static data cannot read ${name}.${propertyNode2.name}. Use ${name}.slug to name the resource`,
|
|
264234
|
+
propertyNode2
|
|
264235
|
+
);
|
|
264236
|
+
}
|
|
264237
|
+
return binding.slugsByName.get(nameNode.name);
|
|
264238
|
+
}
|
|
264239
|
+
function resourceMember(node, local) {
|
|
264240
|
+
if (node.computed || node.property.type !== "Identifier") {
|
|
264241
|
+
return null;
|
|
264242
|
+
}
|
|
264243
|
+
if (node.object.type === "Identifier") {
|
|
264244
|
+
return node.object.name === local ? { nameNode: node.property, propertyNode: null } : null;
|
|
264245
|
+
}
|
|
264246
|
+
const inner = node.object;
|
|
264247
|
+
if (inner.type !== "MemberExpression" || inner.computed || inner.object.type !== "Identifier" || inner.object.name !== local || inner.property.type !== "Identifier") {
|
|
264248
|
+
return null;
|
|
264249
|
+
}
|
|
264250
|
+
return { nameNode: inner.property, propertyNode: node.property };
|
|
264224
264251
|
}
|
|
264225
264252
|
function staticValue(node, options2 = {}) {
|
|
264226
264253
|
switch (node.type) {
|
|
@@ -264307,6 +264334,33 @@ function staticObject(node, options2 = {}) {
|
|
|
264307
264334
|
}
|
|
264308
264335
|
return { value, nodes };
|
|
264309
264336
|
}
|
|
264337
|
+
function propertyNode(objectNode, key) {
|
|
264338
|
+
const node = objectNode?.value ?? objectNode;
|
|
264339
|
+
if (node?.type !== "ObjectExpression") {
|
|
264340
|
+
return objectNode;
|
|
264341
|
+
}
|
|
264342
|
+
return node.properties.find((property) => (property.key.name ?? property.key.value) === key) ?? objectNode;
|
|
264343
|
+
}
|
|
264344
|
+
function elementNode(listNode, position2) {
|
|
264345
|
+
const node = listNode?.value ?? listNode;
|
|
264346
|
+
return node?.type === "ArrayExpression" ? node.elements[position2] ?? listNode : listNode;
|
|
264347
|
+
}
|
|
264348
|
+
function isPlainObject(value) {
|
|
264349
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
264350
|
+
}
|
|
264351
|
+
function requireString(value, key, node, { optional = false } = {}) {
|
|
264352
|
+
const item = value[key];
|
|
264353
|
+
if (item === void 0 || item === null) {
|
|
264354
|
+
if (optional) {
|
|
264355
|
+
return null;
|
|
264356
|
+
}
|
|
264357
|
+
throw new SourceError(`"${key}" is required`, node);
|
|
264358
|
+
}
|
|
264359
|
+
if (typeof item !== "string" || item === "") {
|
|
264360
|
+
throw new SourceError(`"${key}" must be a non-empty string`, node);
|
|
264361
|
+
}
|
|
264362
|
+
return item;
|
|
264363
|
+
}
|
|
264310
264364
|
|
|
264311
264365
|
// scripts/lib/runtime-build/assets.mjs
|
|
264312
264366
|
var ASSET_KEY = /^[a-z][A-Za-z0-9]*$/;
|
|
@@ -267371,25 +267425,11 @@ var capability_catalog_default = {
|
|
|
267371
267425
|
|
|
267372
267426
|
// scripts/lib/runtime-build/capabilities.mjs
|
|
267373
267427
|
var FIELD_REFERENCE_TYPES = /* @__PURE__ */ new Set(["field_reference", "resource_field_key_reference"]);
|
|
267374
|
-
function isObject(value) {
|
|
267375
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
267376
|
-
}
|
|
267377
|
-
function propertyNode(objectNode, key) {
|
|
267378
|
-
const node = objectNode?.value ?? objectNode;
|
|
267379
|
-
if (node?.type !== "ObjectExpression") {
|
|
267380
|
-
return objectNode;
|
|
267381
|
-
}
|
|
267382
|
-
return node.properties.find((property) => (property.key.name ?? property.key.value) === key) ?? objectNode;
|
|
267383
|
-
}
|
|
267384
|
-
function elementNode(listNode, position2) {
|
|
267385
|
-
const node = listNode?.value ?? listNode;
|
|
267386
|
-
return node?.type === "ArrayExpression" ? node.elements[position2] ?? listNode : listNode;
|
|
267387
|
-
}
|
|
267388
267428
|
function readCapabilities(capabilities, node) {
|
|
267389
267429
|
if (capabilities === void 0) {
|
|
267390
267430
|
return {};
|
|
267391
267431
|
}
|
|
267392
|
-
if (!
|
|
267432
|
+
if (!isPlainObject(capabilities)) {
|
|
267393
267433
|
throw new SourceError('"capabilities" must be an object keyed by capability', node);
|
|
267394
267434
|
}
|
|
267395
267435
|
for (const [identifier4, settings] of Object.entries(capabilities)) {
|
|
@@ -267404,7 +267444,7 @@ function readCapabilities(capabilities, node) {
|
|
|
267404
267444
|
capabilityNode
|
|
267405
267445
|
);
|
|
267406
267446
|
}
|
|
267407
|
-
if (!
|
|
267447
|
+
if (!isPlainObject(settings)) {
|
|
267408
267448
|
throw new SourceError(
|
|
267409
267449
|
`Capability "${identifier4}" must be an object of settings`,
|
|
267410
267450
|
capabilityNode
|
|
@@ -267486,7 +267526,7 @@ function checkSetting(context, setting, value, label, node) {
|
|
|
267486
267526
|
return;
|
|
267487
267527
|
}
|
|
267488
267528
|
if (setting.properties !== null) {
|
|
267489
|
-
if (!
|
|
267529
|
+
if (!isPlainObject(value)) {
|
|
267490
267530
|
problems.push({ message: `${label} must be an object`, node });
|
|
267491
267531
|
return;
|
|
267492
267532
|
}
|
|
@@ -267675,308 +267715,9 @@ function sha256(value) {
|
|
|
267675
267715
|
return createHash("sha256").update(value).digest("hex");
|
|
267676
267716
|
}
|
|
267677
267717
|
|
|
267678
|
-
// scripts/lib/runtime-build/
|
|
267679
|
-
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"]);
|
|
267680
|
-
function resolveFileSpecifier(root, from, specifier) {
|
|
267681
|
-
const request2 = specifier.startsWith(APP_PREFIX) ? specifier.slice(APP_PREFIX.length) : posix2.join(posix2.dirname(from), specifier);
|
|
267682
|
-
const path = posix2.normalize(request2);
|
|
267683
|
-
if (path.startsWith("../") || path === ".." || path.startsWith("/")) {
|
|
267684
|
-
return null;
|
|
267685
|
-
}
|
|
267686
|
-
const file2 = checkoutFile(root, path);
|
|
267687
|
-
return file2 !== null && isExactFile(file2) ? path : null;
|
|
267688
|
-
}
|
|
267689
|
-
function declaredPackages(manifest) {
|
|
267690
|
-
return /* @__PURE__ */ new Set([...Object.keys(manifest?.dependencies ?? {}), ...Object.keys(manifest?.peerDependencies ?? {})]);
|
|
267691
|
-
}
|
|
267692
|
-
function ownExports(ast) {
|
|
267693
|
-
const names2 = /* @__PURE__ */ new Set();
|
|
267694
|
-
const starTargets = [];
|
|
267695
|
-
for (const statement2 of ast.program.body) {
|
|
267696
|
-
if (statement2.type === "ExportDefaultDeclaration") {
|
|
267697
|
-
names2.add("default");
|
|
267698
|
-
} else if (statement2.type === "ExportAllDeclaration") {
|
|
267699
|
-
if (statement2.exportKind === "type") {
|
|
267700
|
-
continue;
|
|
267701
|
-
}
|
|
267702
|
-
if (statement2.exported) {
|
|
267703
|
-
names2.add(statement2.exported.name ?? statement2.exported.value);
|
|
267704
|
-
} else {
|
|
267705
|
-
starTargets.push(statement2.source.value);
|
|
267706
|
-
}
|
|
267707
|
-
} else if (statement2.type === "ExportNamedDeclaration" && statement2.exportKind !== "type") {
|
|
267708
|
-
const declaration = statement2.declaration;
|
|
267709
|
-
if (declaration?.type === "VariableDeclaration") {
|
|
267710
|
-
for (const declarator of declaration.declarations) {
|
|
267711
|
-
for (const name of bindingNames(declarator.id)) {
|
|
267712
|
-
names2.add(name);
|
|
267713
|
-
}
|
|
267714
|
-
}
|
|
267715
|
-
} else if (declaration?.id && declaration.type !== "TSTypeAliasDeclaration" && declaration.type !== "TSInterfaceDeclaration" && !declaration.declare) {
|
|
267716
|
-
names2.add(declaration.id.name);
|
|
267717
|
-
}
|
|
267718
|
-
for (const specifier of statement2.specifiers ?? []) {
|
|
267719
|
-
if (specifier.exportKind !== "type") {
|
|
267720
|
-
names2.add(specifier.exported.name ?? specifier.exported.value);
|
|
267721
|
-
}
|
|
267722
|
-
}
|
|
267723
|
-
}
|
|
267724
|
-
}
|
|
267725
|
-
return { names: names2, starTargets };
|
|
267726
|
-
}
|
|
267727
|
-
function bindingNames(pattern) {
|
|
267728
|
-
switch (pattern?.type) {
|
|
267729
|
-
case "Identifier":
|
|
267730
|
-
return [pattern.name];
|
|
267731
|
-
case "ObjectPattern":
|
|
267732
|
-
return pattern.properties.flatMap(
|
|
267733
|
-
(property) => bindingNames(property.type === "RestElement" ? property.argument : property.value)
|
|
267734
|
-
);
|
|
267735
|
-
case "ArrayPattern":
|
|
267736
|
-
return pattern.elements.flatMap((element) => bindingNames(element));
|
|
267737
|
-
case "AssignmentPattern":
|
|
267738
|
-
return bindingNames(pattern.left);
|
|
267739
|
-
case "RestElement":
|
|
267740
|
-
return bindingNames(pattern.argument);
|
|
267741
|
-
default:
|
|
267742
|
-
return [];
|
|
267743
|
-
}
|
|
267744
|
-
}
|
|
267745
|
-
function requestedNames(statement2) {
|
|
267746
|
-
if (statement2 === null || statement2.importKind === "type" || statement2.exportKind === "type") {
|
|
267747
|
-
return [];
|
|
267748
|
-
}
|
|
267749
|
-
if (statement2.type === "ExportAllDeclaration") {
|
|
267750
|
-
return ["*"];
|
|
267751
|
-
}
|
|
267752
|
-
if (statement2.type === "ExportNamedDeclaration") {
|
|
267753
|
-
return (statement2.specifiers ?? []).filter((specifier) => specifier.exportKind !== "type").map((specifier) => specifier.local.name ?? specifier.local.value);
|
|
267754
|
-
}
|
|
267755
|
-
if (statement2.type !== "ImportDeclaration") {
|
|
267756
|
-
return [];
|
|
267757
|
-
}
|
|
267758
|
-
return statement2.specifiers.flatMap((specifier) => {
|
|
267759
|
-
if (specifier.type === "ImportDefaultSpecifier") {
|
|
267760
|
-
return ["default"];
|
|
267761
|
-
}
|
|
267762
|
-
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
267763
|
-
return ["*"];
|
|
267764
|
-
}
|
|
267765
|
-
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type") {
|
|
267766
|
-
return [specifier.imported.name ?? specifier.imported.value];
|
|
267767
|
-
}
|
|
267768
|
-
return [];
|
|
267769
|
-
});
|
|
267770
|
-
}
|
|
267771
|
-
function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @__PURE__ */ new Set()) {
|
|
267772
|
-
const packages = declaredPackages(manifest);
|
|
267773
|
-
const scannedStyles = /* @__PURE__ */ new Set();
|
|
267774
|
-
const modules = {};
|
|
267775
|
-
const parsed = new Map(entries.map((entry) => [entry.path, entry]));
|
|
267776
|
-
const pending = entries.map((entry) => entry.path);
|
|
267777
|
-
const usedPackages = /* @__PURE__ */ new Set();
|
|
267778
|
-
while (pending.length > 0) {
|
|
267779
|
-
const path = pending.shift();
|
|
267780
|
-
if (Object.hasOwn(modules, path)) {
|
|
267781
|
-
continue;
|
|
267782
|
-
}
|
|
267783
|
-
const kind = importKind(`./${posix2.basename(path)}`);
|
|
267784
|
-
if (STYLE_KINDS.has(kind)) {
|
|
267785
|
-
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
267786
|
-
modules[path] = { kind, source_sha256: sha256(readFileSync(join3(root, path))), imports: [] };
|
|
267787
|
-
continue;
|
|
267788
|
-
}
|
|
267789
|
-
let entry = parsed.get(path);
|
|
267790
|
-
if (entry === void 0) {
|
|
267791
|
-
const source = readFileSync(join3(root, path), "utf8");
|
|
267792
|
-
try {
|
|
267793
|
-
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
267794
|
-
} catch (error) {
|
|
267795
|
-
diagnostics.push(diagnosticAt(path, null, `The module does not parse: ${error.message}`));
|
|
267796
|
-
modules[path] = { kind: "module", source_sha256: sha256(source), imports: [], exports: null };
|
|
267797
|
-
continue;
|
|
267798
|
-
}
|
|
267799
|
-
parsed.set(path, entry);
|
|
267800
|
-
}
|
|
267801
|
-
const comments = entry.ast.comments ?? [];
|
|
267802
|
-
let commentIndex = 0;
|
|
267803
|
-
for (const match of entry.source.matchAll(/url\(\s*['"]?asset:/gi)) {
|
|
267804
|
-
while (commentIndex < comments.length && comments[commentIndex].end <= match.index) {
|
|
267805
|
-
commentIndex++;
|
|
267806
|
-
}
|
|
267807
|
-
if (commentIndex < comments.length && comments[commentIndex].start <= match.index) {
|
|
267808
|
-
continue;
|
|
267809
|
-
}
|
|
267810
|
-
const prefix2 = entry.source.slice(0, match.index);
|
|
267811
|
-
diagnostics.push(
|
|
267812
|
-
diagnostic(
|
|
267813
|
-
path,
|
|
267814
|
-
prefix2.split("\n").length,
|
|
267815
|
-
match.index - prefix2.lastIndexOf("\n"),
|
|
267816
|
-
"asset: URLs work only in CSS files. Move this background into a CSS file"
|
|
267817
|
-
)
|
|
267818
|
-
);
|
|
267819
|
-
}
|
|
267820
|
-
const imports = [];
|
|
267821
|
-
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
267822
|
-
if (found2.specifier === null) {
|
|
267823
|
-
diagnostics.push(diagnosticAt(path, found2.node, "A dynamic import must name its module with a string literal"));
|
|
267824
|
-
continue;
|
|
267825
|
-
}
|
|
267826
|
-
if (found2.typeOnly) {
|
|
267827
|
-
continue;
|
|
267828
|
-
}
|
|
267829
|
-
const importType = importKind(found2.specifier);
|
|
267830
|
-
const refused = unsupportedImportMessage(found2.specifier, importType);
|
|
267831
|
-
if (refused !== null) {
|
|
267832
|
-
diagnostics.push(diagnosticAt(path, found2.node, refused));
|
|
267833
|
-
continue;
|
|
267834
|
-
}
|
|
267835
|
-
if (importType === "host") {
|
|
267836
|
-
imports.push({ specifier: found2.specifier, kind: "host", target: found2.specifier, dynamic: found2.dynamic });
|
|
267837
|
-
continue;
|
|
267838
|
-
}
|
|
267839
|
-
if (importType === "package") {
|
|
267840
|
-
if (!packages.has(packageName(found2.specifier))) {
|
|
267841
|
-
diagnostics.push(
|
|
267842
|
-
diagnosticAt(
|
|
267843
|
-
path,
|
|
267844
|
-
found2.node,
|
|
267845
|
-
`"${packageName(found2.specifier)}" is not a dependency. Add it to "dependencies" in package.json`
|
|
267846
|
-
)
|
|
267847
|
-
);
|
|
267848
|
-
continue;
|
|
267849
|
-
}
|
|
267850
|
-
usedPackages.add(found2.specifier);
|
|
267851
|
-
imports.push({
|
|
267852
|
-
specifier: found2.specifier,
|
|
267853
|
-
kind: "package",
|
|
267854
|
-
target: found2.specifier,
|
|
267855
|
-
dynamic: found2.dynamic,
|
|
267856
|
-
package_names: found2.dynamic ? ["*"] : requestedNames(found2.statement)
|
|
267857
|
-
});
|
|
267858
|
-
continue;
|
|
267859
|
-
}
|
|
267860
|
-
const target = importType === "app" ? resolveLocalSpecifier(root, path, found2.specifier) : resolveFileSpecifier(root, path, found2.specifier);
|
|
267861
|
-
if (target === null) {
|
|
267862
|
-
diagnostics.push(diagnosticAt(path, found2.node, `Cannot find "${found2.specifier}" from ${path}`));
|
|
267863
|
-
continue;
|
|
267864
|
-
}
|
|
267865
|
-
imports.push({
|
|
267866
|
-
specifier: found2.specifier,
|
|
267867
|
-
kind: importType,
|
|
267868
|
-
target,
|
|
267869
|
-
dynamic: found2.dynamic,
|
|
267870
|
-
names: requestedNames(found2.statement),
|
|
267871
|
-
node: found2.node
|
|
267872
|
-
});
|
|
267873
|
-
pending.push(target);
|
|
267874
|
-
}
|
|
267875
|
-
modules[path] = { kind: "module", source_sha256: sha256(entry.source), imports, exports: ownExports(entry.ast) };
|
|
267876
|
-
}
|
|
267877
|
-
checkLinkage(modules, diagnostics);
|
|
267878
|
-
for (const module of Object.values(modules)) {
|
|
267879
|
-
for (const item of module.imports) {
|
|
267880
|
-
delete item.node;
|
|
267881
|
-
}
|
|
267882
|
-
delete module.exports;
|
|
267883
|
-
}
|
|
267884
|
-
return { modules, packages: [...usedPackages].toSorted() };
|
|
267885
|
-
}
|
|
267886
|
-
function checkLinkage(modules, diagnostics) {
|
|
267887
|
-
const resolved = /* @__PURE__ */ new Map();
|
|
267888
|
-
const exportsOf = (path, visiting = /* @__PURE__ */ new Set()) => {
|
|
267889
|
-
if (resolved.has(path)) {
|
|
267890
|
-
return resolved.get(path);
|
|
267891
|
-
}
|
|
267892
|
-
const module = modules[path];
|
|
267893
|
-
if (module?.exports === null || module?.exports === void 0 || visiting.has(path)) {
|
|
267894
|
-
return null;
|
|
267895
|
-
}
|
|
267896
|
-
visiting.add(path);
|
|
267897
|
-
const names2 = new Set(module.exports.names);
|
|
267898
|
-
for (const specifier of module.exports.starTargets) {
|
|
267899
|
-
const item = module.imports.find((candidate) => candidate.specifier === specifier);
|
|
267900
|
-
const target = item?.kind === "app" ? exportsOf(item.target, visiting) : null;
|
|
267901
|
-
if (target === null) {
|
|
267902
|
-
resolved.set(path, null);
|
|
267903
|
-
return null;
|
|
267904
|
-
}
|
|
267905
|
-
for (const name of target) {
|
|
267906
|
-
if (name !== "default") {
|
|
267907
|
-
names2.add(name);
|
|
267908
|
-
}
|
|
267909
|
-
}
|
|
267910
|
-
}
|
|
267911
|
-
resolved.set(path, names2);
|
|
267912
|
-
return names2;
|
|
267913
|
-
};
|
|
267914
|
-
for (const [path, module] of Object.entries(modules)) {
|
|
267915
|
-
for (const item of module.imports) {
|
|
267916
|
-
if (item.kind !== "app" || item.names.length === 0) {
|
|
267917
|
-
continue;
|
|
267918
|
-
}
|
|
267919
|
-
const available = exportsOf(item.target);
|
|
267920
|
-
if (available === null) {
|
|
267921
|
-
continue;
|
|
267922
|
-
}
|
|
267923
|
-
for (const name of item.names) {
|
|
267924
|
-
if (name !== "*" && !available.has(name)) {
|
|
267925
|
-
diagnostics.push(
|
|
267926
|
-
diagnosticAt(
|
|
267927
|
-
path,
|
|
267928
|
-
item.node,
|
|
267929
|
-
name === "default" ? `${item.target} has no default export` : `"${name}" is not exported by ${item.target}`
|
|
267930
|
-
)
|
|
267931
|
-
);
|
|
267932
|
-
}
|
|
267933
|
-
}
|
|
267934
|
-
}
|
|
267935
|
-
}
|
|
267936
|
-
}
|
|
267937
|
-
function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
267938
|
-
if (scanned.has(path)) {
|
|
267939
|
-
return;
|
|
267940
|
-
}
|
|
267941
|
-
scanned.add(path);
|
|
267942
|
-
const { urls, imports } = cssReferences(readFileSync(join3(root, path), "utf8"));
|
|
267943
|
-
for (const url of urls) {
|
|
267944
|
-
const key = assetUrlKey(url.value);
|
|
267945
|
-
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
267946
|
-
diagnostics.push(diagnostic(path, url.line, url.column, `Unknown asset "${key}". Add it to assets.ts`));
|
|
267947
|
-
} else if (!isExternalCssUrl(url.value)) {
|
|
267948
|
-
diagnostics.push(diagnostic(path, url.line, url.column, binaryCssUrlMessage(url.value)));
|
|
267949
|
-
}
|
|
267950
|
-
}
|
|
267951
|
-
for (const target of imports) {
|
|
267952
|
-
if (assetUrlKey(target.value) !== null) {
|
|
267953
|
-
diagnostics.push(
|
|
267954
|
-
diagnostic(path, target.line, target.column, "asset: URLs are only for url() in CSS files")
|
|
267955
|
-
);
|
|
267956
|
-
continue;
|
|
267957
|
-
}
|
|
267958
|
-
if (isExternalCssUrl(target.value)) {
|
|
267959
|
-
continue;
|
|
267960
|
-
}
|
|
267961
|
-
const binary = binaryCssImportMessage(target.value);
|
|
267962
|
-
if (binary !== null) {
|
|
267963
|
-
diagnostics.push(diagnostic(path, target.line, target.column, binary));
|
|
267964
|
-
continue;
|
|
267965
|
-
}
|
|
267966
|
-
const resolved = resolveCssReference(root, path, target.value);
|
|
267967
|
-
if (resolved === null) {
|
|
267968
|
-
diagnostics.push(diagnostic(path, target.line, target.column, `Cannot find "${target.value}" from ${path}`));
|
|
267969
|
-
continue;
|
|
267970
|
-
}
|
|
267971
|
-
checkStylesheet(root, resolved, assetKeys, diagnostics, scanned);
|
|
267972
|
-
}
|
|
267973
|
-
}
|
|
267974
|
-
|
|
267975
|
-
// scripts/lib/runtime-build/page-lint.mjs
|
|
267976
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267977
|
-
|
|
267978
|
-
// scripts/lib/lint-jsx-pipeline.mjs
|
|
267718
|
+
// scripts/lib/runtime-build/resource-references.mjs
|
|
267979
267719
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267720
|
+
import { basename as basename2, extname } from "node:path";
|
|
267980
267721
|
|
|
267981
267722
|
// node_modules/@babel/traverse/lib/index.js
|
|
267982
267723
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -279938,7 +279679,7 @@ var objectToString = Function.call.bind(Object.prototype.toString);
|
|
|
279938
279679
|
function isRegExp(value) {
|
|
279939
279680
|
return objectToString(value) === "[object RegExp]";
|
|
279940
279681
|
}
|
|
279941
|
-
function
|
|
279682
|
+
function isPlainObject2(value) {
|
|
279942
279683
|
if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Object]") {
|
|
279943
279684
|
return false;
|
|
279944
279685
|
}
|
|
@@ -279991,7 +279732,7 @@ function valueToNode(value) {
|
|
|
279991
279732
|
if (Array.isArray(value)) {
|
|
279992
279733
|
return arrayExpression(value.map(valueToNode));
|
|
279993
279734
|
}
|
|
279994
|
-
if (
|
|
279735
|
+
if (isPlainObject2(value)) {
|
|
279995
279736
|
const props = [];
|
|
279996
279737
|
for (const key of Object.keys(value)) {
|
|
279997
279738
|
let nodeKey, computed = false;
|
|
@@ -292222,7 +291963,702 @@ traverse3.hasType = function(tree, type, denylistTypes) {
|
|
|
292222
291963
|
};
|
|
292223
291964
|
traverse3.cache = cache;
|
|
292224
291965
|
|
|
291966
|
+
// scripts/lib/runtime-build/resource-references.mjs
|
|
291967
|
+
var traverse4 = traverse3.default ?? traverse3;
|
|
291968
|
+
var GENERATED_RESOURCES_PATH = "generated/resources.ts";
|
|
291969
|
+
var GENERATED_RESOURCES_MODULE = "@app/generated/resources";
|
|
291970
|
+
var RESOURCES_EXPORT = "Resources";
|
|
291971
|
+
var SLUG_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
291972
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
291973
|
+
function resourceConstName(slug) {
|
|
291974
|
+
return slug.split(/[-_]+/).filter((word) => word !== "").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
291975
|
+
}
|
|
291976
|
+
function resourceNames(paths, diagnostics) {
|
|
291977
|
+
const slugsByName = /* @__PURE__ */ new Map();
|
|
291978
|
+
const namesBySlug = /* @__PURE__ */ new Map();
|
|
291979
|
+
for (const path of paths) {
|
|
291980
|
+
const slug = basename2(path, extname(path));
|
|
291981
|
+
if (!SLUG_PATTERN.test(slug)) {
|
|
291982
|
+
diagnostics.push(
|
|
291983
|
+
diagnosticAt(
|
|
291984
|
+
path,
|
|
291985
|
+
null,
|
|
291986
|
+
`The file name "${slug}" is the resource slug, so it must start with a lowercase letter and contain only a-z, 0-9, _ and -`
|
|
291987
|
+
)
|
|
291988
|
+
);
|
|
291989
|
+
continue;
|
|
291990
|
+
}
|
|
291991
|
+
const name = resourceConstName(slug);
|
|
291992
|
+
const other = slugsByName.get(name);
|
|
291993
|
+
if (other !== void 0) {
|
|
291994
|
+
diagnostics.push(
|
|
291995
|
+
diagnosticAt(
|
|
291996
|
+
path,
|
|
291997
|
+
null,
|
|
291998
|
+
`The slugs "${other}" and "${slug}" both have the name Resources.${name}. Rename one of the files`
|
|
291999
|
+
)
|
|
292000
|
+
);
|
|
292001
|
+
continue;
|
|
292002
|
+
}
|
|
292003
|
+
slugsByName.set(name, slug);
|
|
292004
|
+
namesBySlug.set(slug, name);
|
|
292005
|
+
}
|
|
292006
|
+
return { slugsByName, namesBySlug };
|
|
292007
|
+
}
|
|
292008
|
+
function resourceMetadata(resource) {
|
|
292009
|
+
if (resource.platform) {
|
|
292010
|
+
return { slug: resource.slug, platform: true };
|
|
292011
|
+
}
|
|
292012
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
292013
|
+
for (const field2 of resource.fields) {
|
|
292014
|
+
const metadata = {
|
|
292015
|
+
key: field2.key,
|
|
292016
|
+
type: field2.type,
|
|
292017
|
+
label: field2.label,
|
|
292018
|
+
description: field2.description,
|
|
292019
|
+
required: field2.required
|
|
292020
|
+
};
|
|
292021
|
+
if (field2.type === "select") {
|
|
292022
|
+
metadata.options = field2.settings.options.map(
|
|
292023
|
+
({ label, value, color }) => color === void 0 || color === null ? { label, value } : { label, value, color }
|
|
292024
|
+
);
|
|
292025
|
+
}
|
|
292026
|
+
if (field2.type === "relation") {
|
|
292027
|
+
metadata.resource = field2.settings.resource;
|
|
292028
|
+
}
|
|
292029
|
+
fields[field2.key] = metadata;
|
|
292030
|
+
}
|
|
292031
|
+
return {
|
|
292032
|
+
slug: resource.slug,
|
|
292033
|
+
name: resource.name,
|
|
292034
|
+
singularName: resource.singular_name,
|
|
292035
|
+
displayField: resource.display_field,
|
|
292036
|
+
fields
|
|
292037
|
+
};
|
|
292038
|
+
}
|
|
292039
|
+
function resourceEntries({ slugsByName }, resources) {
|
|
292040
|
+
const resourcesBySlug = new Map(resources.map((resource) => [resource.slug, resource]));
|
|
292041
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
292042
|
+
for (const name of [...slugsByName.keys()].toSorted(byteOrder)) {
|
|
292043
|
+
const slug = slugsByName.get(name);
|
|
292044
|
+
const resource = resourcesBySlug.get(slug);
|
|
292045
|
+
entries[name] = resource === void 0 ? { slug } : resourceMetadata(resource);
|
|
292046
|
+
}
|
|
292047
|
+
return entries;
|
|
292048
|
+
}
|
|
292049
|
+
function generatedResourcesSource(names2, resources) {
|
|
292050
|
+
return `// AUTO-GENERATED by \`diagonal check\`. Do not edit.
|
|
292051
|
+
export const ${RESOURCES_EXPORT} = ${printLiteral(resourceEntries(names2, resources), 0)} as const;
|
|
292052
|
+
`;
|
|
292053
|
+
}
|
|
292054
|
+
function inlineResources(source, ast, isGeneratedModule, entries, { typescript: typescript2 = false } = {}) {
|
|
292055
|
+
const imports = ast.program.body.filter(
|
|
292056
|
+
(statement2) => statement2.type === "ImportDeclaration" && statement2.importKind !== "type" && isGeneratedModule(statement2.source.value)
|
|
292057
|
+
);
|
|
292058
|
+
const specifiers = new Set(
|
|
292059
|
+
imports.flatMap((statement2) => statement2.specifiers.filter((specifier) => specifier.importKind !== "type"))
|
|
292060
|
+
);
|
|
292061
|
+
const locals = new Set([...specifiers].map((specifier) => specifier.local.name));
|
|
292062
|
+
if (locals.size === 0) {
|
|
292063
|
+
return { source, edits: [], problems: [], otherUses: [] };
|
|
292064
|
+
}
|
|
292065
|
+
const parents = /* @__PURE__ */ new Map();
|
|
292066
|
+
const pending = [ast.program];
|
|
292067
|
+
while (pending.length > 0) {
|
|
292068
|
+
const node = pending.pop();
|
|
292069
|
+
for (const child of childNodes(node)) {
|
|
292070
|
+
parents.set(child, node);
|
|
292071
|
+
pending.push(child);
|
|
292072
|
+
}
|
|
292073
|
+
}
|
|
292074
|
+
const identifiers = [];
|
|
292075
|
+
traverse4(ast, {
|
|
292076
|
+
Identifier(path) {
|
|
292077
|
+
if (locals.has(path.node.name) && specifiers.has(path.scope.getBinding(path.node.name)?.path.node)) {
|
|
292078
|
+
identifiers.push(path.node);
|
|
292079
|
+
}
|
|
292080
|
+
}
|
|
292081
|
+
});
|
|
292082
|
+
const replacements = [];
|
|
292083
|
+
const problems = [];
|
|
292084
|
+
const otherUses = [];
|
|
292085
|
+
for (const identifier4 of identifiers) {
|
|
292086
|
+
const parent = parents.get(identifier4);
|
|
292087
|
+
const typeName = isTypeQueryName(identifier4, parent);
|
|
292088
|
+
if (!typeName && !isValueReference(identifier4, parent, parents.get(parent))) {
|
|
292089
|
+
continue;
|
|
292090
|
+
}
|
|
292091
|
+
let node = identifier4;
|
|
292092
|
+
let value = entries;
|
|
292093
|
+
let path = identifier4.name;
|
|
292094
|
+
let problem = null;
|
|
292095
|
+
for (let next = parents.get(node); memberName(next, node) !== null; next = parents.get(node)) {
|
|
292096
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
292097
|
+
break;
|
|
292098
|
+
}
|
|
292099
|
+
const key = memberName(next, node).name;
|
|
292100
|
+
if (!Object.hasOwn(value, key)) {
|
|
292101
|
+
problem = {
|
|
292102
|
+
node: memberName(next, node),
|
|
292103
|
+
message: node === identifier4 ? `Unknown resource "${path}.${key}". Each name in ${path} is a file in resources/` : `${path} has no "${key}"`
|
|
292104
|
+
};
|
|
292105
|
+
break;
|
|
292106
|
+
}
|
|
292107
|
+
value = value[key];
|
|
292108
|
+
path = `${path}.${key}`;
|
|
292109
|
+
node = next;
|
|
292110
|
+
}
|
|
292111
|
+
if (problem !== null) {
|
|
292112
|
+
problems.push(problem);
|
|
292113
|
+
} else if (typeName) {
|
|
292114
|
+
const query = typeQueryReplacement(node, value, parents);
|
|
292115
|
+
if (query !== null) {
|
|
292116
|
+
replacements.push({
|
|
292117
|
+
start: query.node.start,
|
|
292118
|
+
end: query.node.end,
|
|
292119
|
+
text: keepingLayout(source.slice(query.node.start, query.node.end), query.text)
|
|
292120
|
+
});
|
|
292121
|
+
}
|
|
292122
|
+
} else if (node === identifier4 || isWriteTarget(node, parents.get(node))) {
|
|
292123
|
+
otherUses.push(node);
|
|
292124
|
+
} else {
|
|
292125
|
+
replacements.push({
|
|
292126
|
+
start: node.start,
|
|
292127
|
+
end: node.end,
|
|
292128
|
+
text: keepingLayout(
|
|
292129
|
+
source.slice(node.start, node.end),
|
|
292130
|
+
typescript2 && value !== null ? `(${JSON.stringify(value)} as const)` : `(${JSON.stringify(value)})`
|
|
292131
|
+
)
|
|
292132
|
+
});
|
|
292133
|
+
}
|
|
292134
|
+
}
|
|
292135
|
+
if (problems.length === 0 && otherUses.length === 0) {
|
|
292136
|
+
for (const statement2 of imports) {
|
|
292137
|
+
replacements.push({
|
|
292138
|
+
start: statement2.start,
|
|
292139
|
+
end: statement2.end,
|
|
292140
|
+
text: keepingLayout(source.slice(statement2.start, statement2.end), "")
|
|
292141
|
+
});
|
|
292142
|
+
}
|
|
292143
|
+
}
|
|
292144
|
+
const edits = replacements.toSorted((left, right) => left.start - right.start);
|
|
292145
|
+
let result = source;
|
|
292146
|
+
for (const { start, end, text } of edits.toReversed()) {
|
|
292147
|
+
result = `${result.slice(0, start)}${text}${result.slice(end)}`;
|
|
292148
|
+
}
|
|
292149
|
+
return { source: result, edits, problems, otherUses };
|
|
292150
|
+
}
|
|
292151
|
+
function keepingLayout(original, text) {
|
|
292152
|
+
const lines = original.split("\n");
|
|
292153
|
+
if (lines.length > 1) {
|
|
292154
|
+
return `${text}${"\n".repeat(lines.length - 1)}${" ".repeat(lines.at(-1).length)}`;
|
|
292155
|
+
}
|
|
292156
|
+
return text.padEnd(original.length, " ");
|
|
292157
|
+
}
|
|
292158
|
+
function writtenPosition(inlined, original, line, column) {
|
|
292159
|
+
const offset = offsetOf(inlined.source, line, column);
|
|
292160
|
+
let shift = 0;
|
|
292161
|
+
for (const edit of inlined.edits) {
|
|
292162
|
+
const start = edit.start + shift;
|
|
292163
|
+
if (offset < start) {
|
|
292164
|
+
break;
|
|
292165
|
+
}
|
|
292166
|
+
if (offset < start + edit.text.length) {
|
|
292167
|
+
return positionOf(original, edit.start);
|
|
292168
|
+
}
|
|
292169
|
+
shift += edit.text.length - (edit.end - edit.start);
|
|
292170
|
+
}
|
|
292171
|
+
return positionOf(original, offset - shift);
|
|
292172
|
+
}
|
|
292173
|
+
function offsetOf(text, line, column) {
|
|
292174
|
+
let offset = 0;
|
|
292175
|
+
for (let current = 1; current < line; current++) {
|
|
292176
|
+
const next = text.indexOf("\n", offset);
|
|
292177
|
+
if (next === -1) {
|
|
292178
|
+
return text.length;
|
|
292179
|
+
}
|
|
292180
|
+
offset = next + 1;
|
|
292181
|
+
}
|
|
292182
|
+
return offset + column - 1;
|
|
292183
|
+
}
|
|
292184
|
+
function positionOf(text, offset) {
|
|
292185
|
+
const before = text.slice(0, offset);
|
|
292186
|
+
const lineStart = before.lastIndexOf("\n") + 1;
|
|
292187
|
+
return { line: before.split("\n").length, column: offset - lineStart + 1 };
|
|
292188
|
+
}
|
|
292189
|
+
function memberName(node, object) {
|
|
292190
|
+
if ((node?.type === "MemberExpression" || node?.type === "OptionalMemberExpression") && node.object === object && !node.computed && node.property.type === "Identifier") {
|
|
292191
|
+
return node.property;
|
|
292192
|
+
}
|
|
292193
|
+
return node?.type === "TSQualifiedName" && node.left === object ? node.right : null;
|
|
292194
|
+
}
|
|
292195
|
+
function isTypeQueryName(identifier4, parent) {
|
|
292196
|
+
return parent?.type === "TSTypeQuery" && parent.exprName === identifier4 || parent?.type === "TSQualifiedName" && parent.left === identifier4;
|
|
292197
|
+
}
|
|
292198
|
+
function typeQueryReplacement(name, value, parents) {
|
|
292199
|
+
let node = name;
|
|
292200
|
+
let access = "";
|
|
292201
|
+
for (let next = parents.get(node); next?.type === "TSQualifiedName" && next.left === node; next = parents.get(node)) {
|
|
292202
|
+
access = `${access}[${JSON.stringify(next.right.name)}]`;
|
|
292203
|
+
node = next;
|
|
292204
|
+
}
|
|
292205
|
+
const query = parents.get(node);
|
|
292206
|
+
if (query?.type !== "TSTypeQuery" || query.exprName !== node || (query.typeArguments ?? query.typeParameters ?? null) !== null) {
|
|
292207
|
+
return null;
|
|
292208
|
+
}
|
|
292209
|
+
return { node: query, text: `(${constType(value)})${access}` };
|
|
292210
|
+
}
|
|
292211
|
+
function constType(value) {
|
|
292212
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
292213
|
+
return String(value);
|
|
292214
|
+
}
|
|
292215
|
+
if (typeof value === "string") {
|
|
292216
|
+
return JSON.stringify(value);
|
|
292217
|
+
}
|
|
292218
|
+
if (Array.isArray(value)) {
|
|
292219
|
+
return `readonly [${value.map((item) => constType(item)).join(", ")}]`;
|
|
292220
|
+
}
|
|
292221
|
+
const members = Object.keys(value).map(
|
|
292222
|
+
(key) => `readonly ${IDENTIFIER_KEY.test(key) ? key : JSON.stringify(key)}: ${constType(value[key])}`
|
|
292223
|
+
);
|
|
292224
|
+
return members.length === 0 ? "{}" : `{ ${members.join("; ")} }`;
|
|
292225
|
+
}
|
|
292226
|
+
function isValueReference(identifier4, parent, grandparent) {
|
|
292227
|
+
if (parent === void 0 || parent.type === "ImportSpecifier") {
|
|
292228
|
+
return false;
|
|
292229
|
+
}
|
|
292230
|
+
if (parent.type === "ExportSpecifier") {
|
|
292231
|
+
return parent.local === identifier4 && (grandparent?.source ?? null) === null;
|
|
292232
|
+
}
|
|
292233
|
+
if ((parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && parent.property === identifier4 && !parent.computed) {
|
|
292234
|
+
return false;
|
|
292235
|
+
}
|
|
292236
|
+
if ((parent.type === "ObjectProperty" || parent.type === "ObjectMethod") && parent.key === identifier4 && !parent.computed && !parent.shorthand) {
|
|
292237
|
+
return false;
|
|
292238
|
+
}
|
|
292239
|
+
return parent.type !== "TSQualifiedName" && parent.type !== "TSTypeQuery";
|
|
292240
|
+
}
|
|
292241
|
+
function isWriteTarget(node, parent) {
|
|
292242
|
+
return parent?.type === "AssignmentExpression" && parent.left === node || parent?.type === "UpdateExpression" || parent?.type === "UnaryExpression" && parent.operator === "delete";
|
|
292243
|
+
}
|
|
292244
|
+
function byteOrder(left, right) {
|
|
292245
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
292246
|
+
}
|
|
292247
|
+
var IDENTIFIER_KEY = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
292248
|
+
function printLiteral(value, depth) {
|
|
292249
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
292250
|
+
return String(value);
|
|
292251
|
+
}
|
|
292252
|
+
if (typeof value === "string") {
|
|
292253
|
+
return quoted(value);
|
|
292254
|
+
}
|
|
292255
|
+
const indent = " ".repeat(depth + 1);
|
|
292256
|
+
const close = " ".repeat(depth);
|
|
292257
|
+
if (Array.isArray(value)) {
|
|
292258
|
+
return value.length === 0 ? "[]" : `[
|
|
292259
|
+
${value.map((item) => `${indent}${printLiteral(item, depth + 1)}`).join(",\n")}
|
|
292260
|
+
${close}]`;
|
|
292261
|
+
}
|
|
292262
|
+
const keys2 = Object.keys(value);
|
|
292263
|
+
return keys2.length === 0 ? "{}" : `{
|
|
292264
|
+
${keys2.map((key) => `${indent}${IDENTIFIER_KEY.test(key) ? key : quoted(key)}: ${printLiteral(value[key], depth + 1)}`).join(",\n")}
|
|
292265
|
+
${close}}`;
|
|
292266
|
+
}
|
|
292267
|
+
function quoted(text) {
|
|
292268
|
+
const escaped = text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
292269
|
+
const singles = (text.match(/'/g) ?? []).length;
|
|
292270
|
+
const doubles = (text.match(/"/g) ?? []).length;
|
|
292271
|
+
return singles > doubles ? `"${escaped.replace(/"/g, '\\"')}"` : `'${escaped.replace(/'/g, "\\'")}'`;
|
|
292272
|
+
}
|
|
292273
|
+
function resourcesBinding(ast, names2) {
|
|
292274
|
+
for (const statement2 of ast.program.body) {
|
|
292275
|
+
if (statement2.type !== "ImportDeclaration" || statement2.source.value !== GENERATED_RESOURCES_MODULE || statement2.importKind === "type") {
|
|
292276
|
+
continue;
|
|
292277
|
+
}
|
|
292278
|
+
for (const specifier of statement2.specifiers) {
|
|
292279
|
+
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && (specifier.imported.name ?? specifier.imported.value) === RESOURCES_EXPORT) {
|
|
292280
|
+
return { local: specifier.local.name, slugsByName: names2.slugsByName };
|
|
292281
|
+
}
|
|
292282
|
+
}
|
|
292283
|
+
}
|
|
292284
|
+
return null;
|
|
292285
|
+
}
|
|
292286
|
+
function referenceProblem(reference, resources, { namesBySlug }) {
|
|
292287
|
+
if (UUID_PATTERN.test(reference)) {
|
|
292288
|
+
return {
|
|
292289
|
+
kind: "id",
|
|
292290
|
+
message: `"${reference}" is a resource id. Refer to a resource by its slug, with Resources.<Name>.slug from ${GENERATED_RESOURCES_MODULE}`
|
|
292291
|
+
};
|
|
292292
|
+
}
|
|
292293
|
+
const named = resources.find(
|
|
292294
|
+
(resource) => resource.name === reference || resource.singular_name === reference
|
|
292295
|
+
);
|
|
292296
|
+
if (named !== void 0) {
|
|
292297
|
+
return {
|
|
292298
|
+
kind: "name",
|
|
292299
|
+
message: `"${reference}" is a name of the resource "${named.slug}". Use Resources.${namesBySlug.get(named.slug)}.slug`
|
|
292300
|
+
};
|
|
292301
|
+
}
|
|
292302
|
+
return {
|
|
292303
|
+
kind: "unknown",
|
|
292304
|
+
message: `Unknown resource "${reference}". Use Resources.<Name>.slug from ${GENERATED_RESOURCES_MODULE}`
|
|
292305
|
+
};
|
|
292306
|
+
}
|
|
292307
|
+
function slugStringWarnings(path, node, { namesBySlug }, options2 = {}) {
|
|
292308
|
+
const warnings2 = [];
|
|
292309
|
+
const pending = [node];
|
|
292310
|
+
while (pending.length > 0) {
|
|
292311
|
+
const current = pending.pop();
|
|
292312
|
+
if (current.type === "ObjectProperty" && !current.computed && (current.key.name ?? current.key.value) === "resource" && current.value.type === "StringLiteral" && namesBySlug.has(current.value.value)) {
|
|
292313
|
+
warnings2.push(
|
|
292314
|
+
diagnosticAt(
|
|
292315
|
+
path,
|
|
292316
|
+
current.value,
|
|
292317
|
+
`Use Resources.${namesBySlug.get(current.value.value)}.slug from ${GENERATED_RESOURCES_MODULE} in place of the string "${current.value.value}"`,
|
|
292318
|
+
{ ...options2, severity: "warning" }
|
|
292319
|
+
)
|
|
292320
|
+
);
|
|
292321
|
+
}
|
|
292322
|
+
pending.push(...childNodes(current));
|
|
292323
|
+
}
|
|
292324
|
+
return warnings2;
|
|
292325
|
+
}
|
|
292326
|
+
|
|
292327
|
+
// scripts/lib/runtime-build/module-graph.mjs
|
|
292328
|
+
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"]);
|
|
292329
|
+
function resolveFileSpecifier(root, from, specifier) {
|
|
292330
|
+
const request2 = specifier.startsWith(APP_PREFIX) ? specifier.slice(APP_PREFIX.length) : posix2.join(posix2.dirname(from), specifier);
|
|
292331
|
+
const path = posix2.normalize(request2);
|
|
292332
|
+
if (path.startsWith("../") || path === ".." || path.startsWith("/")) {
|
|
292333
|
+
return null;
|
|
292334
|
+
}
|
|
292335
|
+
const file2 = checkoutFile(root, path);
|
|
292336
|
+
return file2 !== null && isExactFile(file2) ? path : null;
|
|
292337
|
+
}
|
|
292338
|
+
function declaredPackages(manifest) {
|
|
292339
|
+
return /* @__PURE__ */ new Set([...Object.keys(manifest?.dependencies ?? {}), ...Object.keys(manifest?.peerDependencies ?? {})]);
|
|
292340
|
+
}
|
|
292341
|
+
function ownExports(ast) {
|
|
292342
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
292343
|
+
const starTargets = [];
|
|
292344
|
+
for (const statement2 of ast.program.body) {
|
|
292345
|
+
if (statement2.type === "ExportDefaultDeclaration") {
|
|
292346
|
+
names2.add("default");
|
|
292347
|
+
} else if (statement2.type === "ExportAllDeclaration") {
|
|
292348
|
+
if (statement2.exportKind === "type") {
|
|
292349
|
+
continue;
|
|
292350
|
+
}
|
|
292351
|
+
if (statement2.exported) {
|
|
292352
|
+
names2.add(statement2.exported.name ?? statement2.exported.value);
|
|
292353
|
+
} else {
|
|
292354
|
+
starTargets.push(statement2.source.value);
|
|
292355
|
+
}
|
|
292356
|
+
} else if (statement2.type === "ExportNamedDeclaration" && statement2.exportKind !== "type") {
|
|
292357
|
+
const declaration = statement2.declaration;
|
|
292358
|
+
if (declaration?.type === "VariableDeclaration") {
|
|
292359
|
+
for (const declarator of declaration.declarations) {
|
|
292360
|
+
for (const name of bindingNames(declarator.id)) {
|
|
292361
|
+
names2.add(name);
|
|
292362
|
+
}
|
|
292363
|
+
}
|
|
292364
|
+
} else if (declaration?.id && declaration.type !== "TSTypeAliasDeclaration" && declaration.type !== "TSInterfaceDeclaration" && !declaration.declare) {
|
|
292365
|
+
names2.add(declaration.id.name);
|
|
292366
|
+
}
|
|
292367
|
+
for (const specifier of statement2.specifiers ?? []) {
|
|
292368
|
+
if (specifier.exportKind !== "type") {
|
|
292369
|
+
names2.add(specifier.exported.name ?? specifier.exported.value);
|
|
292370
|
+
}
|
|
292371
|
+
}
|
|
292372
|
+
}
|
|
292373
|
+
}
|
|
292374
|
+
return { names: names2, starTargets };
|
|
292375
|
+
}
|
|
292376
|
+
function bindingNames(pattern) {
|
|
292377
|
+
switch (pattern?.type) {
|
|
292378
|
+
case "Identifier":
|
|
292379
|
+
return [pattern.name];
|
|
292380
|
+
case "ObjectPattern":
|
|
292381
|
+
return pattern.properties.flatMap(
|
|
292382
|
+
(property) => bindingNames(property.type === "RestElement" ? property.argument : property.value)
|
|
292383
|
+
);
|
|
292384
|
+
case "ArrayPattern":
|
|
292385
|
+
return pattern.elements.flatMap((element) => bindingNames(element));
|
|
292386
|
+
case "AssignmentPattern":
|
|
292387
|
+
return bindingNames(pattern.left);
|
|
292388
|
+
case "RestElement":
|
|
292389
|
+
return bindingNames(pattern.argument);
|
|
292390
|
+
default:
|
|
292391
|
+
return [];
|
|
292392
|
+
}
|
|
292393
|
+
}
|
|
292394
|
+
function requestedNames(statement2) {
|
|
292395
|
+
if (statement2 === null || statement2.importKind === "type" || statement2.exportKind === "type") {
|
|
292396
|
+
return [];
|
|
292397
|
+
}
|
|
292398
|
+
if (statement2.type === "ExportAllDeclaration") {
|
|
292399
|
+
return ["*"];
|
|
292400
|
+
}
|
|
292401
|
+
if (statement2.type === "ExportNamedDeclaration") {
|
|
292402
|
+
return (statement2.specifiers ?? []).filter((specifier) => specifier.exportKind !== "type").map((specifier) => specifier.local.name ?? specifier.local.value);
|
|
292403
|
+
}
|
|
292404
|
+
if (statement2.type !== "ImportDeclaration") {
|
|
292405
|
+
return [];
|
|
292406
|
+
}
|
|
292407
|
+
return statement2.specifiers.flatMap((specifier) => {
|
|
292408
|
+
if (specifier.type === "ImportDefaultSpecifier") {
|
|
292409
|
+
return ["default"];
|
|
292410
|
+
}
|
|
292411
|
+
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
292412
|
+
return ["*"];
|
|
292413
|
+
}
|
|
292414
|
+
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type") {
|
|
292415
|
+
return [specifier.imported.name ?? specifier.imported.value];
|
|
292416
|
+
}
|
|
292417
|
+
return [];
|
|
292418
|
+
});
|
|
292419
|
+
}
|
|
292420
|
+
function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @__PURE__ */ new Set(), resourceEntries2 = {}) {
|
|
292421
|
+
const packages = declaredPackages(manifest);
|
|
292422
|
+
const scannedStyles = /* @__PURE__ */ new Set();
|
|
292423
|
+
const modules = {};
|
|
292424
|
+
const parsed = new Map(entries.map((entry) => [entry.path, entry]));
|
|
292425
|
+
const pending = entries.map((entry) => entry.path);
|
|
292426
|
+
const usedPackages = /* @__PURE__ */ new Set();
|
|
292427
|
+
while (pending.length > 0) {
|
|
292428
|
+
const path = pending.shift();
|
|
292429
|
+
if (Object.hasOwn(modules, path)) {
|
|
292430
|
+
continue;
|
|
292431
|
+
}
|
|
292432
|
+
const kind = importKind(`./${posix2.basename(path)}`);
|
|
292433
|
+
if (STYLE_KINDS.has(kind)) {
|
|
292434
|
+
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
292435
|
+
modules[path] = { kind, source_sha256: sha256(readFileSync(join3(root, path))), imports: [] };
|
|
292436
|
+
continue;
|
|
292437
|
+
}
|
|
292438
|
+
let entry = parsed.get(path);
|
|
292439
|
+
if (entry === void 0) {
|
|
292440
|
+
const source = readFileSync(join3(root, path), "utf8");
|
|
292441
|
+
try {
|
|
292442
|
+
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
292443
|
+
} catch (error) {
|
|
292444
|
+
diagnostics.push(diagnosticAt(path, null, `The module does not parse: ${error.message}`));
|
|
292445
|
+
modules[path] = { kind: "module", source_sha256: sha256(source), imports: [], exports: null };
|
|
292446
|
+
continue;
|
|
292447
|
+
}
|
|
292448
|
+
parsed.set(path, entry);
|
|
292449
|
+
}
|
|
292450
|
+
const comments = entry.ast.comments ?? [];
|
|
292451
|
+
let commentIndex = 0;
|
|
292452
|
+
for (const match of entry.source.matchAll(/url\(\s*['"]?asset:/gi)) {
|
|
292453
|
+
while (commentIndex < comments.length && comments[commentIndex].end <= match.index) {
|
|
292454
|
+
commentIndex++;
|
|
292455
|
+
}
|
|
292456
|
+
if (commentIndex < comments.length && comments[commentIndex].start <= match.index) {
|
|
292457
|
+
continue;
|
|
292458
|
+
}
|
|
292459
|
+
const prefix2 = entry.source.slice(0, match.index);
|
|
292460
|
+
diagnostics.push(
|
|
292461
|
+
diagnostic(
|
|
292462
|
+
path,
|
|
292463
|
+
prefix2.split("\n").length,
|
|
292464
|
+
match.index - prefix2.lastIndexOf("\n"),
|
|
292465
|
+
"asset: URLs work only in CSS files. Move this background into a CSS file"
|
|
292466
|
+
)
|
|
292467
|
+
);
|
|
292468
|
+
}
|
|
292469
|
+
const imports = [];
|
|
292470
|
+
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
292471
|
+
if (found2.specifier === null) {
|
|
292472
|
+
diagnostics.push(diagnosticAt(path, found2.node, "A dynamic import must name its module with a string literal"));
|
|
292473
|
+
continue;
|
|
292474
|
+
}
|
|
292475
|
+
if (found2.typeOnly) {
|
|
292476
|
+
continue;
|
|
292477
|
+
}
|
|
292478
|
+
const importType = importKind(found2.specifier);
|
|
292479
|
+
const refused = unsupportedImportMessage(found2.specifier, importType);
|
|
292480
|
+
if (refused !== null) {
|
|
292481
|
+
diagnostics.push(diagnosticAt(path, found2.node, refused));
|
|
292482
|
+
continue;
|
|
292483
|
+
}
|
|
292484
|
+
if (importType === "host") {
|
|
292485
|
+
imports.push({ specifier: found2.specifier, kind: "host", target: found2.specifier, dynamic: found2.dynamic });
|
|
292486
|
+
continue;
|
|
292487
|
+
}
|
|
292488
|
+
if (importType === "package") {
|
|
292489
|
+
if (!packages.has(packageName(found2.specifier))) {
|
|
292490
|
+
diagnostics.push(
|
|
292491
|
+
diagnosticAt(
|
|
292492
|
+
path,
|
|
292493
|
+
found2.node,
|
|
292494
|
+
`"${packageName(found2.specifier)}" is not a dependency. Add it to "dependencies" in package.json`
|
|
292495
|
+
)
|
|
292496
|
+
);
|
|
292497
|
+
continue;
|
|
292498
|
+
}
|
|
292499
|
+
usedPackages.add(found2.specifier);
|
|
292500
|
+
imports.push({
|
|
292501
|
+
specifier: found2.specifier,
|
|
292502
|
+
kind: "package",
|
|
292503
|
+
target: found2.specifier,
|
|
292504
|
+
dynamic: found2.dynamic,
|
|
292505
|
+
package_names: found2.dynamic ? ["*"] : requestedNames(found2.statement)
|
|
292506
|
+
});
|
|
292507
|
+
continue;
|
|
292508
|
+
}
|
|
292509
|
+
const target = importType === "app" ? resolveLocalSpecifier(root, path, found2.specifier) : resolveFileSpecifier(root, path, found2.specifier);
|
|
292510
|
+
if (target === null) {
|
|
292511
|
+
diagnostics.push(diagnosticAt(path, found2.node, `Cannot find "${found2.specifier}" from ${path}`));
|
|
292512
|
+
continue;
|
|
292513
|
+
}
|
|
292514
|
+
if (target === GENERATED_RESOURCES_PATH) {
|
|
292515
|
+
imports.push({ specifier: found2.specifier, kind: "resources", target, dynamic: found2.dynamic });
|
|
292516
|
+
continue;
|
|
292517
|
+
}
|
|
292518
|
+
imports.push({
|
|
292519
|
+
specifier: found2.specifier,
|
|
292520
|
+
kind: importType,
|
|
292521
|
+
target,
|
|
292522
|
+
dynamic: found2.dynamic,
|
|
292523
|
+
names: requestedNames(found2.statement),
|
|
292524
|
+
node: found2.node
|
|
292525
|
+
});
|
|
292526
|
+
pending.push(target);
|
|
292527
|
+
}
|
|
292528
|
+
if (imports.some((item) => item.kind === "resources")) {
|
|
292529
|
+
checkResourceReferences(root, entry, resourceEntries2, diagnostics);
|
|
292530
|
+
}
|
|
292531
|
+
modules[path] = { kind: "module", source_sha256: sha256(entry.source), imports, exports: ownExports(entry.ast) };
|
|
292532
|
+
}
|
|
292533
|
+
checkLinkage(modules, diagnostics);
|
|
292534
|
+
for (const module of Object.values(modules)) {
|
|
292535
|
+
for (const item of module.imports) {
|
|
292536
|
+
delete item.node;
|
|
292537
|
+
}
|
|
292538
|
+
delete module.exports;
|
|
292539
|
+
}
|
|
292540
|
+
return { modules, packages: [...usedPackages].toSorted() };
|
|
292541
|
+
}
|
|
292542
|
+
function checkResourceReferences(root, entry, resourceEntries2, diagnostics) {
|
|
292543
|
+
const isGeneratedModule = (specifier) => resolveLocalSpecifier(root, entry.path, specifier) === GENERATED_RESOURCES_PATH;
|
|
292544
|
+
const { problems, otherUses } = inlineResources(entry.source, entry.ast, isGeneratedModule, resourceEntries2);
|
|
292545
|
+
for (const problem of problems) {
|
|
292546
|
+
diagnostics.push(diagnosticAt(entry.path, problem.node, problem.message));
|
|
292547
|
+
}
|
|
292548
|
+
for (const node of otherUses) {
|
|
292549
|
+
diagnostics.push(
|
|
292550
|
+
diagnosticAt(
|
|
292551
|
+
entry.path,
|
|
292552
|
+
node,
|
|
292553
|
+
"Read a value such as Resources.<Name>.slug or Resources.<Name>.fields. The build replaces each reference with its value, so a page cannot use Resources as a whole"
|
|
292554
|
+
)
|
|
292555
|
+
);
|
|
292556
|
+
}
|
|
292557
|
+
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
292558
|
+
if (found2.specifier === null || found2.typeOnly || !isGeneratedModule(found2.specifier)) {
|
|
292559
|
+
continue;
|
|
292560
|
+
}
|
|
292561
|
+
if (found2.dynamic) {
|
|
292562
|
+
diagnostics.push(diagnosticAt(entry.path, found2.node, "Import Resources with a static import"));
|
|
292563
|
+
} else if (found2.statement?.type !== "ImportDeclaration") {
|
|
292564
|
+
diagnostics.push(diagnosticAt(entry.path, found2.node, "A page module cannot re-export Resources. Import it where you read it"));
|
|
292565
|
+
}
|
|
292566
|
+
}
|
|
292567
|
+
}
|
|
292568
|
+
function checkLinkage(modules, diagnostics) {
|
|
292569
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
292570
|
+
const exportsOf = (path, visiting = /* @__PURE__ */ new Set()) => {
|
|
292571
|
+
if (resolved.has(path)) {
|
|
292572
|
+
return resolved.get(path);
|
|
292573
|
+
}
|
|
292574
|
+
const module = modules[path];
|
|
292575
|
+
if (module?.exports === null || module?.exports === void 0 || visiting.has(path)) {
|
|
292576
|
+
return null;
|
|
292577
|
+
}
|
|
292578
|
+
visiting.add(path);
|
|
292579
|
+
const names2 = new Set(module.exports.names);
|
|
292580
|
+
for (const specifier of module.exports.starTargets) {
|
|
292581
|
+
const item = module.imports.find((candidate) => candidate.specifier === specifier);
|
|
292582
|
+
const target = item?.kind === "app" ? exportsOf(item.target, visiting) : null;
|
|
292583
|
+
if (target === null) {
|
|
292584
|
+
resolved.set(path, null);
|
|
292585
|
+
return null;
|
|
292586
|
+
}
|
|
292587
|
+
for (const name of target) {
|
|
292588
|
+
if (name !== "default") {
|
|
292589
|
+
names2.add(name);
|
|
292590
|
+
}
|
|
292591
|
+
}
|
|
292592
|
+
}
|
|
292593
|
+
resolved.set(path, names2);
|
|
292594
|
+
return names2;
|
|
292595
|
+
};
|
|
292596
|
+
for (const [path, module] of Object.entries(modules)) {
|
|
292597
|
+
for (const item of module.imports) {
|
|
292598
|
+
if (item.kind !== "app" || item.names.length === 0) {
|
|
292599
|
+
continue;
|
|
292600
|
+
}
|
|
292601
|
+
const available = exportsOf(item.target);
|
|
292602
|
+
if (available === null) {
|
|
292603
|
+
continue;
|
|
292604
|
+
}
|
|
292605
|
+
for (const name of item.names) {
|
|
292606
|
+
if (name !== "*" && !available.has(name)) {
|
|
292607
|
+
diagnostics.push(
|
|
292608
|
+
diagnosticAt(
|
|
292609
|
+
path,
|
|
292610
|
+
item.node,
|
|
292611
|
+
name === "default" ? `${item.target} has no default export` : `"${name}" is not exported by ${item.target}`
|
|
292612
|
+
)
|
|
292613
|
+
);
|
|
292614
|
+
}
|
|
292615
|
+
}
|
|
292616
|
+
}
|
|
292617
|
+
}
|
|
292618
|
+
}
|
|
292619
|
+
function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
292620
|
+
if (scanned.has(path)) {
|
|
292621
|
+
return;
|
|
292622
|
+
}
|
|
292623
|
+
scanned.add(path);
|
|
292624
|
+
const { urls, imports } = cssReferences(readFileSync(join3(root, path), "utf8"));
|
|
292625
|
+
for (const url of urls) {
|
|
292626
|
+
const key = assetUrlKey(url.value);
|
|
292627
|
+
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
292628
|
+
diagnostics.push(diagnostic(path, url.line, url.column, `Unknown asset "${key}". Add it to assets.ts`));
|
|
292629
|
+
} else if (!isExternalCssUrl(url.value)) {
|
|
292630
|
+
diagnostics.push(diagnostic(path, url.line, url.column, binaryCssUrlMessage(url.value)));
|
|
292631
|
+
}
|
|
292632
|
+
}
|
|
292633
|
+
for (const target of imports) {
|
|
292634
|
+
if (assetUrlKey(target.value) !== null) {
|
|
292635
|
+
diagnostics.push(
|
|
292636
|
+
diagnostic(path, target.line, target.column, "asset: URLs are only for url() in CSS files")
|
|
292637
|
+
);
|
|
292638
|
+
continue;
|
|
292639
|
+
}
|
|
292640
|
+
if (isExternalCssUrl(target.value)) {
|
|
292641
|
+
continue;
|
|
292642
|
+
}
|
|
292643
|
+
const binary = binaryCssImportMessage(target.value);
|
|
292644
|
+
if (binary !== null) {
|
|
292645
|
+
diagnostics.push(diagnostic(path, target.line, target.column, binary));
|
|
292646
|
+
continue;
|
|
292647
|
+
}
|
|
292648
|
+
const resolved = resolveCssReference(root, path, target.value);
|
|
292649
|
+
if (resolved === null) {
|
|
292650
|
+
diagnostics.push(diagnostic(path, target.line, target.column, `Cannot find "${target.value}" from ${path}`));
|
|
292651
|
+
continue;
|
|
292652
|
+
}
|
|
292653
|
+
checkStylesheet(root, resolved, assetKeys, diagnostics, scanned);
|
|
292654
|
+
}
|
|
292655
|
+
}
|
|
292656
|
+
|
|
292657
|
+
// scripts/lib/runtime-build/page-lint.mjs
|
|
292658
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
292659
|
+
|
|
292225
292660
|
// scripts/lib/lint-jsx-pipeline.mjs
|
|
292661
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
292226
292662
|
var import_globals = __toESM(require_globals2(), 1);
|
|
292227
292663
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
292228
292664
|
|
|
@@ -295106,7 +295542,7 @@ function unstableQueryInputs(callPath) {
|
|
|
295106
295542
|
}
|
|
295107
295543
|
|
|
295108
295544
|
// scripts/lib/lint-jsx-pipeline.mjs
|
|
295109
|
-
var
|
|
295545
|
+
var traverse5 = traverse3.default ?? traverse3;
|
|
295110
295546
|
var PERMITTED_GLOBALS = /* @__PURE__ */ new Set([
|
|
295111
295547
|
...Object.keys(import_globals.default.browser),
|
|
295112
295548
|
...Object.keys(import_globals.default.es2025)
|
|
@@ -295367,7 +295803,7 @@ function stageScopeAnalysis(source, extraGlobals) {
|
|
|
295367
295803
|
throw failure("Lint error", error);
|
|
295368
295804
|
}
|
|
295369
295805
|
const undefinedRefs = [];
|
|
295370
|
-
|
|
295806
|
+
traverse5(wrappedAst, {
|
|
295371
295807
|
Program(path) {
|
|
295372
295808
|
for (const [name, node] of Object.entries(path.scope.globals)) {
|
|
295373
295809
|
if (PERMITTED_GLOBALS.has(name) || extraGlobals.has(name)) {
|
|
@@ -295432,7 +295868,7 @@ function stageNullableSdkValues(source) {
|
|
|
295432
295868
|
);
|
|
295433
295869
|
}
|
|
295434
295870
|
};
|
|
295435
|
-
|
|
295871
|
+
traverse5(ast, {
|
|
295436
295872
|
CallExpression: recordUrlCall,
|
|
295437
295873
|
OptionalCallExpression: recordUrlCall,
|
|
295438
295874
|
VariableDeclarator: recordMoneyDestructuring,
|
|
@@ -295500,7 +295936,7 @@ function stageHardcodedApiPaths(source) {
|
|
|
295500
295936
|
column: node.loc?.start.column ?? 0
|
|
295501
295937
|
});
|
|
295502
295938
|
};
|
|
295503
|
-
|
|
295939
|
+
traverse5(ast, {
|
|
295504
295940
|
StringLiteral(path) {
|
|
295505
295941
|
if (isInTypeScriptTypeContext(path)) {
|
|
295506
295942
|
return;
|
|
@@ -295539,7 +295975,7 @@ function stageJsxLiteralEscapes(source) {
|
|
|
295539
295975
|
column: node.loc?.start.column ?? 0
|
|
295540
295976
|
});
|
|
295541
295977
|
};
|
|
295542
|
-
|
|
295978
|
+
traverse5(ast, {
|
|
295543
295979
|
JSXText(path) {
|
|
295544
295980
|
record(path.node.value, path.node, "JSX text");
|
|
295545
295981
|
},
|
|
@@ -295586,7 +296022,7 @@ function stageUnstableQueryInputs(source) {
|
|
|
295586
296022
|
});
|
|
295587
296023
|
}
|
|
295588
296024
|
};
|
|
295589
|
-
|
|
296025
|
+
traverse5(ast, { CallExpression: inspect2, OptionalCallExpression: inspect2 });
|
|
295590
296026
|
if (violations.length > 0) {
|
|
295591
296027
|
const messages = violations.map((v) => `Line ${v.line}:${v.column} \u2014 ${v.message}`);
|
|
295592
296028
|
throw failure("Unstable query input", new Error(messages.join("\n")));
|
|
@@ -295741,115 +296177,7 @@ function lintUnit(unit, catalogs) {
|
|
|
295741
296177
|
return [];
|
|
295742
296178
|
}
|
|
295743
296179
|
|
|
295744
|
-
// scripts/lib/runtime-build/
|
|
295745
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
295746
|
-
import { basename as basename2, extname } from "node:path";
|
|
295747
|
-
var GENERATED_RESOURCES_PATH = "generated/resources.ts";
|
|
295748
|
-
var GENERATED_RESOURCES_MODULE = "@app/generated/resources";
|
|
295749
|
-
var RESOURCES_EXPORT = "Resources";
|
|
295750
|
-
var SLUG_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
295751
|
-
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
295752
|
-
function resourceConstName(slug) {
|
|
295753
|
-
return slug.split(/[-_]+/).filter((word) => word !== "").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
295754
|
-
}
|
|
295755
|
-
function resourceNames(paths, diagnostics) {
|
|
295756
|
-
const slugsByName = /* @__PURE__ */ new Map();
|
|
295757
|
-
const namesBySlug = /* @__PURE__ */ new Map();
|
|
295758
|
-
for (const path of paths) {
|
|
295759
|
-
const slug = basename2(path, extname(path));
|
|
295760
|
-
if (!SLUG_PATTERN.test(slug)) {
|
|
295761
|
-
diagnostics.push(
|
|
295762
|
-
diagnosticAt(
|
|
295763
|
-
path,
|
|
295764
|
-
null,
|
|
295765
|
-
`The file name "${slug}" is the resource slug, so it must start with a lowercase letter and contain only a-z, 0-9, _ and -`
|
|
295766
|
-
)
|
|
295767
|
-
);
|
|
295768
|
-
continue;
|
|
295769
|
-
}
|
|
295770
|
-
const name = resourceConstName(slug);
|
|
295771
|
-
const other = slugsByName.get(name);
|
|
295772
|
-
if (other !== void 0) {
|
|
295773
|
-
diagnostics.push(
|
|
295774
|
-
diagnosticAt(
|
|
295775
|
-
path,
|
|
295776
|
-
null,
|
|
295777
|
-
`The slugs "${other}" and "${slug}" both have the name Resources.${name}. Rename one of the files`
|
|
295778
|
-
)
|
|
295779
|
-
);
|
|
295780
|
-
continue;
|
|
295781
|
-
}
|
|
295782
|
-
slugsByName.set(name, slug);
|
|
295783
|
-
namesBySlug.set(slug, name);
|
|
295784
|
-
}
|
|
295785
|
-
return { slugsByName, namesBySlug };
|
|
295786
|
-
}
|
|
295787
|
-
function generatedResourcesSource({ slugsByName }) {
|
|
295788
|
-
const names2 = [...slugsByName.keys()].toSorted(
|
|
295789
|
-
(left, right) => left < right ? -1 : left > right ? 1 : 0
|
|
295790
|
-
);
|
|
295791
|
-
const body = names2.length === 0 ? "{}" : `{
|
|
295792
|
-
${names2.map((name) => ` ${name}: '${slugsByName.get(name)}'`).join(",\n")}
|
|
295793
|
-
}`;
|
|
295794
|
-
return `// AUTO-GENERATED by \`diagonal check\`. Do not edit.
|
|
295795
|
-
export const ${RESOURCES_EXPORT} = ${body} as const;
|
|
295796
|
-
`;
|
|
295797
|
-
}
|
|
295798
|
-
function resourcesBinding(ast, names2) {
|
|
295799
|
-
for (const statement2 of ast.program.body) {
|
|
295800
|
-
if (statement2.type !== "ImportDeclaration" || statement2.source.value !== GENERATED_RESOURCES_MODULE || statement2.importKind === "type") {
|
|
295801
|
-
continue;
|
|
295802
|
-
}
|
|
295803
|
-
for (const specifier of statement2.specifiers) {
|
|
295804
|
-
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && (specifier.imported.name ?? specifier.imported.value) === RESOURCES_EXPORT) {
|
|
295805
|
-
return { local: specifier.local.name, slugsByName: names2.slugsByName };
|
|
295806
|
-
}
|
|
295807
|
-
}
|
|
295808
|
-
}
|
|
295809
|
-
return null;
|
|
295810
|
-
}
|
|
295811
|
-
function referenceProblem(reference, resources, { namesBySlug }) {
|
|
295812
|
-
if (UUID_PATTERN.test(reference)) {
|
|
295813
|
-
return {
|
|
295814
|
-
kind: "id",
|
|
295815
|
-
message: `"${reference}" is a resource id. Refer to a resource by its slug, with Resources.<Name> from ${GENERATED_RESOURCES_MODULE}`
|
|
295816
|
-
};
|
|
295817
|
-
}
|
|
295818
|
-
const named = resources.find(
|
|
295819
|
-
(resource) => resource.name === reference || resource.singular_name === reference
|
|
295820
|
-
);
|
|
295821
|
-
if (named !== void 0) {
|
|
295822
|
-
return {
|
|
295823
|
-
kind: "name",
|
|
295824
|
-
message: `"${reference}" is a name of the resource "${named.slug}". Use Resources.${namesBySlug.get(named.slug)}`
|
|
295825
|
-
};
|
|
295826
|
-
}
|
|
295827
|
-
return {
|
|
295828
|
-
kind: "unknown",
|
|
295829
|
-
message: `Unknown resource "${reference}". Use Resources.<Name> from ${GENERATED_RESOURCES_MODULE}`
|
|
295830
|
-
};
|
|
295831
|
-
}
|
|
295832
|
-
function slugStringWarnings(path, node, { namesBySlug }, options2 = {}) {
|
|
295833
|
-
const warnings2 = [];
|
|
295834
|
-
const pending = [node];
|
|
295835
|
-
while (pending.length > 0) {
|
|
295836
|
-
const current = pending.pop();
|
|
295837
|
-
if (current.type === "ObjectProperty" && !current.computed && (current.key.name ?? current.key.value) === "resource" && current.value.type === "StringLiteral" && namesBySlug.has(current.value.value)) {
|
|
295838
|
-
warnings2.push(
|
|
295839
|
-
diagnosticAt(
|
|
295840
|
-
path,
|
|
295841
|
-
current.value,
|
|
295842
|
-
`Use Resources.${namesBySlug.get(current.value.value)} from ${GENERATED_RESOURCES_MODULE} in place of the string "${current.value.value}"`,
|
|
295843
|
-
{ ...options2, severity: "warning" }
|
|
295844
|
-
)
|
|
295845
|
-
);
|
|
295846
|
-
}
|
|
295847
|
-
pending.push(...childNodes(current));
|
|
295848
|
-
}
|
|
295849
|
-
return warnings2;
|
|
295850
|
-
}
|
|
295851
|
-
|
|
295852
|
-
// scripts/lib/runtime-build/resources.mjs
|
|
296180
|
+
// scripts/lib/runtime-build/policies.mjs
|
|
295853
296181
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
295854
296182
|
|
|
295855
296183
|
// scripts/lib/runtime-build/fields.mjs
|
|
@@ -297524,6 +297852,44 @@ var field_catalog_default = {
|
|
|
297524
297852
|
"update_many",
|
|
297525
297853
|
"upsert",
|
|
297526
297854
|
"upsert_many"
|
|
297855
|
+
],
|
|
297856
|
+
filter_operators: [
|
|
297857
|
+
"all",
|
|
297858
|
+
"between",
|
|
297859
|
+
"contains",
|
|
297860
|
+
"elem_match",
|
|
297861
|
+
"ends_with",
|
|
297862
|
+
"=",
|
|
297863
|
+
"exists",
|
|
297864
|
+
">",
|
|
297865
|
+
">=",
|
|
297866
|
+
"has_value",
|
|
297867
|
+
"in",
|
|
297868
|
+
"is",
|
|
297869
|
+
"is_not",
|
|
297870
|
+
"is_not_null",
|
|
297871
|
+
"is_null",
|
|
297872
|
+
"<",
|
|
297873
|
+
"<=",
|
|
297874
|
+
"missing_value",
|
|
297875
|
+
"mod",
|
|
297876
|
+
"not",
|
|
297877
|
+
"!=",
|
|
297878
|
+
"not_exists",
|
|
297879
|
+
"not_in",
|
|
297880
|
+
"regex",
|
|
297881
|
+
"search",
|
|
297882
|
+
"starts_with"
|
|
297883
|
+
],
|
|
297884
|
+
record_meta_fields: [
|
|
297885
|
+
"id",
|
|
297886
|
+
"workspace_id",
|
|
297887
|
+
"resource_id",
|
|
297888
|
+
"__meta",
|
|
297889
|
+
"created_at",
|
|
297890
|
+
"updated_at",
|
|
297891
|
+
"deleted_at",
|
|
297892
|
+
"cascade_key"
|
|
297527
297893
|
]
|
|
297528
297894
|
};
|
|
297529
297895
|
|
|
@@ -297574,9 +297940,6 @@ function optionNode(builder2, ...path) {
|
|
|
297574
297940
|
}
|
|
297575
297941
|
return node;
|
|
297576
297942
|
}
|
|
297577
|
-
function isPlainObject2(value) {
|
|
297578
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
297579
|
-
}
|
|
297580
297943
|
function humanize2(key) {
|
|
297581
297944
|
const words = key.replaceAll("_", " ");
|
|
297582
297945
|
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
@@ -297596,7 +297959,7 @@ function resolverOption(builder2, key, fieldKey) {
|
|
|
297596
297959
|
if (value === void 0) {
|
|
297597
297960
|
return null;
|
|
297598
297961
|
}
|
|
297599
|
-
if (!
|
|
297962
|
+
if (!isPlainObject(value) || typeof value.$type !== "string" || value.$type === "") {
|
|
297600
297963
|
throw new SourceError(
|
|
297601
297964
|
`"${key}" of field "${fieldKey}" must be a resolver: { $type: '<task>', $value: {...} }`,
|
|
297602
297965
|
optionNode(builder2, key)
|
|
@@ -297636,7 +297999,7 @@ function checkValue(entry, value, describe, node) {
|
|
|
297636
297999
|
}
|
|
297637
298000
|
}
|
|
297638
298001
|
function checkUiSettings(ui, typeCatalog, describe, nodeAt) {
|
|
297639
|
-
if (!
|
|
298002
|
+
if (!isPlainObject(ui)) {
|
|
297640
298003
|
throw new SourceError(`${describe}.ui must be an object`, nodeAt());
|
|
297641
298004
|
}
|
|
297642
298005
|
for (const [key, value] of Object.entries(ui)) {
|
|
@@ -297652,7 +298015,7 @@ function checkUiSettings(ui, typeCatalog, describe, nodeAt) {
|
|
|
297652
298015
|
}
|
|
297653
298016
|
function selectOptions(options2, fieldKey, node) {
|
|
297654
298017
|
if (!Array.isArray(options2) || options2.length === 0 || options2.some(
|
|
297655
|
-
(option) => !
|
|
298018
|
+
(option) => !isPlainObject(option) || typeof option.label !== "string" || typeof option.value !== "string" || Object.keys(option).some((key) => !OPTION_KEYS.has(key)) || option.color !== void 0 && option.color !== null && typeof option.color !== "string"
|
|
297656
298019
|
)) {
|
|
297657
298020
|
throw new SourceError(
|
|
297658
298021
|
`field.select "${fieldKey}" needs "options": [{ label, value, color? }] with string labels and values`,
|
|
@@ -297674,7 +298037,7 @@ function checkInverse(inverse, fieldKey, relationSettings2, nodeAt) {
|
|
|
297674
298037
|
if (inverse === null) {
|
|
297675
298038
|
return;
|
|
297676
298039
|
}
|
|
297677
|
-
if (!
|
|
298040
|
+
if (!isPlainObject(inverse)) {
|
|
297678
298041
|
throw new SourceError(`settings.inverse of field "${fieldKey}" must be an object`, nodeAt());
|
|
297679
298042
|
}
|
|
297680
298043
|
for (const key of Object.keys(inverse)) {
|
|
@@ -297703,7 +298066,7 @@ function checkInverse(inverse, fieldKey, relationSettings2, nodeAt) {
|
|
|
297703
298066
|
if (inverse.settings === void 0) {
|
|
297704
298067
|
return;
|
|
297705
298068
|
}
|
|
297706
|
-
if (!
|
|
298069
|
+
if (!isPlainObject(inverse.settings)) {
|
|
297707
298070
|
throw new SourceError(
|
|
297708
298071
|
`settings.inverse.settings of field "${fieldKey}" must be an object`,
|
|
297709
298072
|
nodeAt("settings")
|
|
@@ -297736,7 +298099,7 @@ function buildSettings(key, builder2, entry, typeCatalog) {
|
|
|
297736
298099
|
const shorthandFor = Object.fromEntries(
|
|
297737
298100
|
Object.entries(entry.shorthands).map(([option, setting]) => [setting, option])
|
|
297738
298101
|
);
|
|
297739
|
-
if (!
|
|
298102
|
+
if (!isPlainObject(authored)) {
|
|
297740
298103
|
throw new SourceError(`"settings" of field "${key}" must be an object`, nodeAt());
|
|
297741
298104
|
}
|
|
297742
298105
|
for (const [setting, value] of Object.entries(authored)) {
|
|
@@ -297799,7 +298162,7 @@ function relationSettings(key, builder2, typeCatalog, settings) {
|
|
|
297799
298162
|
const { resource_id: resource, type: relationType, ...rest } = settings;
|
|
297800
298163
|
if (typeof resource !== "string" || resource === "") {
|
|
297801
298164
|
throw new SourceError(
|
|
297802
|
-
`field.relation "${key}" needs "resource": Resources.<Name
|
|
298165
|
+
`field.relation "${key}" needs "resource": Resources.<Name>.slug`,
|
|
297803
298166
|
optionNode(builder2, "resource")
|
|
297804
298167
|
);
|
|
297805
298168
|
}
|
|
@@ -297923,7 +298286,7 @@ function buildField(key, builder2, keyNode) {
|
|
|
297923
298286
|
return relationNode === null ? field2 : { ...field2, relationNode };
|
|
297924
298287
|
}
|
|
297925
298288
|
|
|
297926
|
-
// scripts/lib/runtime-build/
|
|
298289
|
+
// scripts/lib/runtime-build/policies.mjs
|
|
297927
298290
|
var POLICY_SCOPES = [
|
|
297928
298291
|
"index",
|
|
297929
298292
|
"show",
|
|
@@ -297937,35 +298300,200 @@ var POLICY_SCOPES = [
|
|
|
297937
298300
|
"validate"
|
|
297938
298301
|
];
|
|
297939
298302
|
var POLICY_ACCESS = /* @__PURE__ */ new Set(["public", "protected"]);
|
|
297940
|
-
var
|
|
298303
|
+
var POLICY_KEYS = /* @__PURE__ */ new Set([
|
|
297941
298304
|
"name",
|
|
297942
|
-
"
|
|
297943
|
-
"
|
|
297944
|
-
"
|
|
297945
|
-
"
|
|
297946
|
-
"
|
|
297947
|
-
"
|
|
297948
|
-
"
|
|
297949
|
-
"
|
|
297950
|
-
"static",
|
|
297951
|
-
"policies",
|
|
297952
|
-
"capabilities"
|
|
298305
|
+
"scope",
|
|
298306
|
+
"access",
|
|
298307
|
+
"description",
|
|
298308
|
+
"enabled",
|
|
298309
|
+
"resource",
|
|
298310
|
+
"authorizer",
|
|
298311
|
+
"filter",
|
|
298312
|
+
"fields"
|
|
297953
298313
|
]);
|
|
297954
|
-
var
|
|
297955
|
-
var
|
|
297956
|
-
var
|
|
297957
|
-
|
|
297958
|
-
|
|
297959
|
-
|
|
297960
|
-
|
|
297961
|
-
|
|
298314
|
+
var PUBLIC_REFUSED_KEYS = ["resource", "authorizer"];
|
|
298315
|
+
var GROUP_OPERATORS = /* @__PURE__ */ new Set(["and", "or", "nor"]);
|
|
298316
|
+
var GROUP_KEYS = /* @__PURE__ */ new Set(["operator", "conditions"]);
|
|
298317
|
+
var CONDITION_KEYS = /* @__PURE__ */ new Set(["field", "operator", "value", "case_insensitive"]);
|
|
298318
|
+
var FILTER_OPERATORS = new Set(FIELD_CATALOG.filter_operators);
|
|
298319
|
+
function isResolver(value) {
|
|
298320
|
+
return isPlainObject(value) && typeof value.$type === "string" && value.$type !== "";
|
|
298321
|
+
}
|
|
298322
|
+
function buildScope(policy, label, node) {
|
|
298323
|
+
if (policy.scope === "all") {
|
|
298324
|
+
return [...POLICY_SCOPES];
|
|
298325
|
+
}
|
|
298326
|
+
if (Array.isArray(policy.scope) && policy.scope.length > 0 && policy.scope.every((item) => POLICY_SCOPES.includes(item))) {
|
|
298327
|
+
return [...new Set(policy.scope)];
|
|
298328
|
+
}
|
|
298329
|
+
throw new SourceError(
|
|
298330
|
+
`${label} scope must be "all" or a list of: ${POLICY_SCOPES.join(", ")}`,
|
|
298331
|
+
propertyNode(node, "scope")
|
|
298332
|
+
);
|
|
298333
|
+
}
|
|
298334
|
+
function checkFilterGroup(group, path, node) {
|
|
298335
|
+
if (!isPlainObject(group)) {
|
|
298336
|
+
throw new SourceError(`${path} must be { operator, conditions }`, node);
|
|
298337
|
+
}
|
|
298338
|
+
for (const key of Object.keys(group)) {
|
|
298339
|
+
if (!GROUP_KEYS.has(key)) {
|
|
298340
|
+
throw new SourceError(
|
|
298341
|
+
`${path} has an unknown option "${key}". Use operator or conditions`,
|
|
298342
|
+
propertyNode(node, key)
|
|
298343
|
+
);
|
|
297962
298344
|
}
|
|
297963
|
-
throw new SourceError(`"${key}" is required`, node);
|
|
297964
298345
|
}
|
|
297965
|
-
if (
|
|
297966
|
-
throw new SourceError(
|
|
298346
|
+
if (!GROUP_OPERATORS.has(group.operator)) {
|
|
298347
|
+
throw new SourceError(
|
|
298348
|
+
`${path}.operator must be "and", "or", or "nor"`,
|
|
298349
|
+
propertyNode(node, "operator")
|
|
298350
|
+
);
|
|
297967
298351
|
}
|
|
297968
|
-
|
|
298352
|
+
const conditionsNode = propertyNode(node, "conditions");
|
|
298353
|
+
if (!Array.isArray(group.conditions) || group.conditions.length === 0) {
|
|
298354
|
+
throw new SourceError(`${path}.conditions must be a non-empty list`, conditionsNode);
|
|
298355
|
+
}
|
|
298356
|
+
group.conditions.forEach((condition, position2) => {
|
|
298357
|
+
const conditionPath = `${path}.conditions[${position2}]`;
|
|
298358
|
+
const conditionNode = elementNode(conditionsNode, position2);
|
|
298359
|
+
if (isPlainObject(condition) && Object.hasOwn(condition, "conditions")) {
|
|
298360
|
+
checkFilterGroup(condition, conditionPath, conditionNode);
|
|
298361
|
+
return;
|
|
298362
|
+
}
|
|
298363
|
+
checkFilterCondition(condition, conditionPath, conditionNode);
|
|
298364
|
+
});
|
|
298365
|
+
}
|
|
298366
|
+
function checkFilterCondition(condition, path, node) {
|
|
298367
|
+
if (!isPlainObject(condition)) {
|
|
298368
|
+
throw new SourceError(`${path} must be { field, operator, value } or a nested group`, node);
|
|
298369
|
+
}
|
|
298370
|
+
for (const key of Object.keys(condition)) {
|
|
298371
|
+
if (!CONDITION_KEYS.has(key)) {
|
|
298372
|
+
throw new SourceError(
|
|
298373
|
+
`${path} has an unknown option "${key}". Use field, operator, value, or case_insensitive`,
|
|
298374
|
+
propertyNode(node, key)
|
|
298375
|
+
);
|
|
298376
|
+
}
|
|
298377
|
+
}
|
|
298378
|
+
if (typeof condition.field !== "string" || condition.field === "") {
|
|
298379
|
+
throw new SourceError(`${path}.field must be a field key or path`, propertyNode(node, "field"));
|
|
298380
|
+
}
|
|
298381
|
+
if (!FILTER_OPERATORS.has(condition.operator)) {
|
|
298382
|
+
throw new SourceError(
|
|
298383
|
+
`${path}.operator must be one of: ${FIELD_CATALOG.filter_operators.join(", ")}`,
|
|
298384
|
+
propertyNode(node, "operator")
|
|
298385
|
+
);
|
|
298386
|
+
}
|
|
298387
|
+
if (condition.case_insensitive !== void 0 && typeof condition.case_insensitive !== "boolean") {
|
|
298388
|
+
throw new SourceError(
|
|
298389
|
+
`${path}.case_insensitive must be true or false`,
|
|
298390
|
+
propertyNode(node, "case_insensitive")
|
|
298391
|
+
);
|
|
298392
|
+
}
|
|
298393
|
+
}
|
|
298394
|
+
function buildFilter(policy, key, label, node) {
|
|
298395
|
+
const value = policy[key];
|
|
298396
|
+
if (value === void 0 || value === null) {
|
|
298397
|
+
return null;
|
|
298398
|
+
}
|
|
298399
|
+
checkFilterGroup(value, `${label} ${key}`, propertyNode(node, key));
|
|
298400
|
+
return value;
|
|
298401
|
+
}
|
|
298402
|
+
function buildFields(policy, label, node) {
|
|
298403
|
+
if (policy.fields === void 0 || policy.fields === null) {
|
|
298404
|
+
return null;
|
|
298405
|
+
}
|
|
298406
|
+
const fieldsNode = propertyNode(node, "fields");
|
|
298407
|
+
if (!Array.isArray(policy.fields)) {
|
|
298408
|
+
throw new SourceError(
|
|
298409
|
+
`${label} fields must be a list of field keys or { key, condition }`,
|
|
298410
|
+
fieldsNode
|
|
298411
|
+
);
|
|
298412
|
+
}
|
|
298413
|
+
const seen = /* @__PURE__ */ new Set();
|
|
298414
|
+
return policy.fields.map((item, position2) => {
|
|
298415
|
+
const itemNode = elementNode(fieldsNode, position2);
|
|
298416
|
+
const rule = typeof item === "string" ? { key: item } : item;
|
|
298417
|
+
if (!isPlainObject(rule) || typeof rule.key !== "string" || rule.key === "" || Object.keys(rule).some((key) => key !== "key" && key !== "condition")) {
|
|
298418
|
+
throw new SourceError(
|
|
298419
|
+
`${label} fields must be a list of field keys or { key, condition }`,
|
|
298420
|
+
itemNode
|
|
298421
|
+
);
|
|
298422
|
+
}
|
|
298423
|
+
if (rule.condition !== void 0 && rule.condition !== null && !isResolver(rule.condition)) {
|
|
298424
|
+
throw new SourceError(
|
|
298425
|
+
`${label} field "${rule.key}" condition must be a resolver, for example { $type: 'user.current' }`,
|
|
298426
|
+
itemNode
|
|
298427
|
+
);
|
|
298428
|
+
}
|
|
298429
|
+
if (seen.has(rule.key)) {
|
|
298430
|
+
throw new SourceError(`${label} fields list "${rule.key}" twice`, itemNode);
|
|
298431
|
+
}
|
|
298432
|
+
seen.add(rule.key);
|
|
298433
|
+
return rule.condition === void 0 || rule.condition === null ? { key: rule.key } : { key: rule.key, condition: rule.condition };
|
|
298434
|
+
});
|
|
298435
|
+
}
|
|
298436
|
+
function buildPolicy(policy, node) {
|
|
298437
|
+
if (!isPlainObject(policy)) {
|
|
298438
|
+
throw new SourceError("Each policy must be an object", node);
|
|
298439
|
+
}
|
|
298440
|
+
const name = requireString(policy, "name", propertyNode(node, "name"));
|
|
298441
|
+
const label = `Policy "${name}"`;
|
|
298442
|
+
for (const key of Object.keys(policy)) {
|
|
298443
|
+
if (!POLICY_KEYS.has(key)) {
|
|
298444
|
+
throw new SourceError(
|
|
298445
|
+
`${label} has an unknown option "${key}". Use ${[...POLICY_KEYS].join(", ")}`,
|
|
298446
|
+
propertyNode(node, key)
|
|
298447
|
+
);
|
|
298448
|
+
}
|
|
298449
|
+
}
|
|
298450
|
+
const access = policy.access ?? "protected";
|
|
298451
|
+
if (!POLICY_ACCESS.has(access)) {
|
|
298452
|
+
throw new SourceError(
|
|
298453
|
+
`${label} access must be "public" or "protected"`,
|
|
298454
|
+
propertyNode(node, "access")
|
|
298455
|
+
);
|
|
298456
|
+
}
|
|
298457
|
+
if (access === "public") {
|
|
298458
|
+
const refused = PUBLIC_REFUSED_KEYS.find(
|
|
298459
|
+
(key) => policy[key] !== void 0 && policy[key] !== null
|
|
298460
|
+
);
|
|
298461
|
+
if (refused !== void 0) {
|
|
298462
|
+
throw new SourceError(
|
|
298463
|
+
`${label} is public, so it cannot set "${refused}". Remove it, or make the policy protected`,
|
|
298464
|
+
propertyNode(node, refused)
|
|
298465
|
+
);
|
|
298466
|
+
}
|
|
298467
|
+
}
|
|
298468
|
+
const description = policy.description ?? null;
|
|
298469
|
+
if (description !== null && typeof description !== "string") {
|
|
298470
|
+
throw new SourceError(
|
|
298471
|
+
`${label} description must be a string`,
|
|
298472
|
+
propertyNode(node, "description")
|
|
298473
|
+
);
|
|
298474
|
+
}
|
|
298475
|
+
if (policy.enabled !== void 0 && typeof policy.enabled !== "boolean") {
|
|
298476
|
+
throw new SourceError(`${label} enabled must be true or false`, propertyNode(node, "enabled"));
|
|
298477
|
+
}
|
|
298478
|
+
const resource = policy.resource ?? null;
|
|
298479
|
+
if (resource !== null && (typeof resource !== "string" || resource === "")) {
|
|
298480
|
+
throw new SourceError(
|
|
298481
|
+
`${label} resource must be Resources.<Name>.slug`,
|
|
298482
|
+
propertyNode(node, "resource")
|
|
298483
|
+
);
|
|
298484
|
+
}
|
|
298485
|
+
return {
|
|
298486
|
+
name,
|
|
298487
|
+
scope: buildScope(policy, label, node),
|
|
298488
|
+
access,
|
|
298489
|
+
description,
|
|
298490
|
+
enabled: policy.enabled ?? true,
|
|
298491
|
+
resource,
|
|
298492
|
+
authorizer: buildFilter(policy, "authorizer", label, node),
|
|
298493
|
+
filter: buildFilter(policy, "filter", label, node),
|
|
298494
|
+
fields: buildFields(policy, label, node),
|
|
298495
|
+
resourceNode: resource === null ? void 0 : propertyNode(node, "resource")
|
|
298496
|
+
};
|
|
297969
298497
|
}
|
|
297970
298498
|
function buildPolicies(policies, node) {
|
|
297971
298499
|
if (policies === void 0) {
|
|
@@ -297974,37 +298502,68 @@ function buildPolicies(policies, node) {
|
|
|
297974
298502
|
if (!Array.isArray(policies)) {
|
|
297975
298503
|
throw new SourceError('"policies" must be an array', node);
|
|
297976
298504
|
}
|
|
298505
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
297977
298506
|
return policies.map((policy, position2) => {
|
|
297978
|
-
const
|
|
297979
|
-
|
|
297980
|
-
|
|
297981
|
-
|
|
297982
|
-
const name = requireString(policy, "name", elementNode3);
|
|
297983
|
-
const access = requireString(policy, "access", elementNode3);
|
|
297984
|
-
if (!POLICY_ACCESS.has(access)) {
|
|
297985
|
-
throw new SourceError(`Policy "${name}" access must be "public" or "protected"`, elementNode3);
|
|
297986
|
-
}
|
|
297987
|
-
let scope2;
|
|
297988
|
-
if (policy.scope === "all") {
|
|
297989
|
-
scope2 = [...POLICY_SCOPES];
|
|
297990
|
-
} else if (Array.isArray(policy.scope) && policy.scope.length > 0 && policy.scope.every((item) => POLICY_SCOPES.includes(item))) {
|
|
297991
|
-
scope2 = [...new Set(policy.scope)];
|
|
297992
|
-
} else {
|
|
297993
|
-
throw new SourceError(
|
|
297994
|
-
`Policy "${name}" scope must be "all" or a list of: ${POLICY_SCOPES.join(", ")}`,
|
|
297995
|
-
elementNode3
|
|
297996
|
-
);
|
|
297997
|
-
}
|
|
297998
|
-
const description = policy.description ?? null;
|
|
297999
|
-
if (description !== null && typeof description !== "string") {
|
|
298000
|
-
throw new SourceError(`Policy "${name}" description must be a string`, elementNode3);
|
|
298507
|
+
const policyNode = elementNode(node, position2);
|
|
298508
|
+
const built = buildPolicy(policy, policyNode);
|
|
298509
|
+
if (names2.has(built.name)) {
|
|
298510
|
+
throw new SourceError(`Two policies are named "${built.name}"`, policyNode);
|
|
298001
298511
|
}
|
|
298002
|
-
|
|
298512
|
+
names2.add(built.name);
|
|
298513
|
+
return built;
|
|
298003
298514
|
});
|
|
298004
298515
|
}
|
|
298005
|
-
function
|
|
298006
|
-
|
|
298516
|
+
function checkPolicyResources(resources, platformSlugs, names2, diagnostics) {
|
|
298517
|
+
const resourcesBySlug = new Map(resources.map((resource) => [resource.slug, resource]));
|
|
298518
|
+
for (const resource of resources) {
|
|
298519
|
+
for (const policy of resource.policies) {
|
|
298520
|
+
if (policy.resource === null || platformSlugs.has(policy.resource)) {
|
|
298521
|
+
continue;
|
|
298522
|
+
}
|
|
298523
|
+
const target = resourcesBySlug.get(policy.resource);
|
|
298524
|
+
const label = `Policy "${policy.name}" resource`;
|
|
298525
|
+
if (target === void 0) {
|
|
298526
|
+
diagnostics.push(
|
|
298527
|
+
diagnosticAt(
|
|
298528
|
+
resource.path,
|
|
298529
|
+
policy.resourceNode,
|
|
298530
|
+
`${label}: ${referenceProblem(policy.resource, resources, names2).message}`
|
|
298531
|
+
)
|
|
298532
|
+
);
|
|
298533
|
+
continue;
|
|
298534
|
+
}
|
|
298535
|
+
if (!Object.hasOwn(target.capabilities, "authenticatable")) {
|
|
298536
|
+
diagnostics.push(
|
|
298537
|
+
diagnosticAt(
|
|
298538
|
+
resource.path,
|
|
298539
|
+
policy.resourceNode,
|
|
298540
|
+
`${label}: "${policy.resource}" does not declare the authenticatable capability, so no member signs in as it`
|
|
298541
|
+
)
|
|
298542
|
+
);
|
|
298543
|
+
}
|
|
298544
|
+
}
|
|
298545
|
+
}
|
|
298007
298546
|
}
|
|
298547
|
+
|
|
298548
|
+
// scripts/lib/runtime-build/resources.mjs
|
|
298549
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
298550
|
+
var RESOURCE_KEYS = /* @__PURE__ */ new Set([
|
|
298551
|
+
"name",
|
|
298552
|
+
"singularName",
|
|
298553
|
+
"displayField",
|
|
298554
|
+
"searchableFields",
|
|
298555
|
+
"fieldOrder",
|
|
298556
|
+
"fields",
|
|
298557
|
+
"indexes",
|
|
298558
|
+
"embeddings",
|
|
298559
|
+
"dataApi",
|
|
298560
|
+
"static",
|
|
298561
|
+
"policies",
|
|
298562
|
+
"capabilities"
|
|
298563
|
+
]);
|
|
298564
|
+
var INDEX_KEYS = /* @__PURE__ */ new Set(["fields", "unique"]);
|
|
298565
|
+
var EMBEDDINGS_KEYS = /* @__PURE__ */ new Set(["enabled", "fields"]);
|
|
298566
|
+
var DEFAULT_SEARCHABLE_TYPES = /* @__PURE__ */ new Set(["text", "markdown"]);
|
|
298008
298567
|
function stringList(value, key, node) {
|
|
298009
298568
|
if (!Array.isArray(value)) {
|
|
298010
298569
|
throw new SourceError(`"${key}" must be a list of strings`, node);
|
|
@@ -298012,10 +298571,10 @@ function stringList(value, key, node) {
|
|
|
298012
298571
|
const seen = /* @__PURE__ */ new Set();
|
|
298013
298572
|
value.forEach((item, position2) => {
|
|
298014
298573
|
if (typeof item !== "string" || item === "") {
|
|
298015
|
-
throw new SourceError(`"${key}" must be a list of strings`,
|
|
298574
|
+
throw new SourceError(`"${key}" must be a list of strings`, elementNode(node, position2));
|
|
298016
298575
|
}
|
|
298017
298576
|
if (seen.has(item)) {
|
|
298018
|
-
throw new SourceError(`"${key}" lists "${item}" twice`,
|
|
298577
|
+
throw new SourceError(`"${key}" lists "${item}" twice`, elementNode(node, position2));
|
|
298019
298578
|
}
|
|
298020
298579
|
seen.add(item);
|
|
298021
298580
|
});
|
|
@@ -298030,7 +298589,7 @@ function buildIndexes(indexes, node, fieldsByKey) {
|
|
|
298030
298589
|
}
|
|
298031
298590
|
const patterns = /* @__PURE__ */ new Set();
|
|
298032
298591
|
return indexes.map((index3, position2) => {
|
|
298033
|
-
const indexNode =
|
|
298592
|
+
const indexNode = elementNode(node, position2);
|
|
298034
298593
|
if (index3 === null || typeof index3 !== "object" || Array.isArray(index3) || !Array.isArray(index3.fields) || index3.fields.length === 0) {
|
|
298035
298594
|
throw new SourceError("Each index must be { fields: [...], unique?: boolean }", indexNode);
|
|
298036
298595
|
}
|
|
@@ -298070,7 +298629,7 @@ function orderFields(fields, fieldOrder, node) {
|
|
|
298070
298629
|
if (!fieldsByKey.has(key)) {
|
|
298071
298630
|
throw new SourceError(
|
|
298072
298631
|
`fieldOrder names "${key}", which is not a field of this resource`,
|
|
298073
|
-
|
|
298632
|
+
elementNode(node, position2)
|
|
298074
298633
|
);
|
|
298075
298634
|
}
|
|
298076
298635
|
});
|
|
@@ -298344,7 +298903,11 @@ function checkFieldPaths(resources, diagnostics) {
|
|
|
298344
298903
|
}
|
|
298345
298904
|
function withoutBuildNodes(resource) {
|
|
298346
298905
|
const { pathNodes: _pathNodes, ...rest } = resource;
|
|
298347
|
-
return {
|
|
298906
|
+
return {
|
|
298907
|
+
...rest,
|
|
298908
|
+
fields: rest.fields.map(({ relationNode: _relationNode, ...field2 }) => field2),
|
|
298909
|
+
policies: rest.policies.map(({ resourceNode: _resourceNode, ...policy }) => policy)
|
|
298910
|
+
};
|
|
298348
298911
|
}
|
|
298349
298912
|
|
|
298350
298913
|
// scripts/lib/runtime-build/sdk-packages.mjs
|
|
@@ -298697,7 +299260,7 @@ function bindingFor(statement2, path) {
|
|
|
298697
299260
|
}
|
|
298698
299261
|
return statements2.join(" ");
|
|
298699
299262
|
}
|
|
298700
|
-
function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), { ui = false } = {}) {
|
|
299263
|
+
function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), { ui = false, transform: transform3 = null } = {}) {
|
|
298701
299264
|
const modules = /* @__PURE__ */ new Map();
|
|
298702
299265
|
const pending = imports.map((item) => item.path);
|
|
298703
299266
|
while (pending.length > 0) {
|
|
@@ -298705,7 +299268,8 @@ function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), {
|
|
|
298705
299268
|
if (modules.has(path)) {
|
|
298706
299269
|
continue;
|
|
298707
299270
|
}
|
|
298708
|
-
const
|
|
299271
|
+
const read = readFileSync4(join6(root, path), "utf8");
|
|
299272
|
+
const source = transform3 === null ? read : transform3(path, read);
|
|
298709
299273
|
const ast = parseModule(path, source);
|
|
298710
299274
|
const requires = {};
|
|
298711
299275
|
const references = ui ? moduleSpecifiers2(ast).filter((item) => item.specifier !== null && !item.typeOnly).map((item) => ({ specifier: item.specifier, source: item.node })) : ast.program.body.filter(
|
|
@@ -299202,7 +299766,7 @@ function pageAuthorizer(meta, nodes) {
|
|
|
299202
299766
|
const resource = value.resource ?? null;
|
|
299203
299767
|
const permissions = value.permissions ?? [];
|
|
299204
299768
|
if (resource !== null && (typeof resource !== "string" || resource === "")) {
|
|
299205
|
-
throw new SourceError('"authorizer.resource" must be Resources.<Name
|
|
299769
|
+
throw new SourceError('"authorizer.resource" must be Resources.<Name>.slug or a resource slug', nodes.authorizer);
|
|
299206
299770
|
}
|
|
299207
299771
|
if (!Array.isArray(permissions) || permissions.some((permission) => typeof permission !== "string" || permission === "")) {
|
|
299208
299772
|
throw new SourceError(
|
|
@@ -299240,7 +299804,7 @@ function pageParams(meta, nodes, route) {
|
|
|
299240
299804
|
const { resource = null, lookupField = null, relations = [], scope: scope2 = null } = binding;
|
|
299241
299805
|
if (typeof resource !== "string" || resource === "") {
|
|
299242
299806
|
throw new SourceError(
|
|
299243
|
-
`"params.${key}.resource" must be Resources.<Name
|
|
299807
|
+
`"params.${key}.resource" must be Resources.<Name>.slug or a resource slug`,
|
|
299244
299808
|
nodes.params
|
|
299245
299809
|
);
|
|
299246
299810
|
}
|
|
@@ -299865,7 +300429,7 @@ function builder(method, call, checker, visiting) {
|
|
|
299865
300429
|
if (!type?.isStringLiteral()) {
|
|
299866
300430
|
throw new SchemaError(
|
|
299867
300431
|
call,
|
|
299868
|
-
"v.record() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products from @app/generated/resources in a file-based workspace."
|
|
300432
|
+
"v.record() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products.slug from @app/generated/resources in a file-based workspace."
|
|
299869
300433
|
);
|
|
299870
300434
|
}
|
|
299871
300435
|
return base("record", { resource: type.value });
|
|
@@ -299875,7 +300439,7 @@ function builder(method, call, checker, visiting) {
|
|
|
299875
300439
|
if (!type?.isStringLiteral()) {
|
|
299876
300440
|
throw new SchemaError(
|
|
299877
300441
|
call,
|
|
299878
|
-
"v.recordReference() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products from @app/generated/resources in a file-based workspace."
|
|
300442
|
+
"v.recordReference() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products.slug from @app/generated/resources in a file-based workspace."
|
|
299879
300443
|
);
|
|
299880
300444
|
}
|
|
299881
300445
|
return base("recordReference", {
|
|
@@ -300640,9 +301204,6 @@ function propertyNodes(node) {
|
|
|
300640
301204
|
}
|
|
300641
301205
|
return nodes;
|
|
300642
301206
|
}
|
|
300643
|
-
function isPlainObject3(value) {
|
|
300644
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
300645
|
-
}
|
|
300646
301207
|
function listOf(values) {
|
|
300647
301208
|
return values.map((value) => `'${value}'`).join(", ");
|
|
300648
301209
|
}
|
|
@@ -300742,7 +301303,7 @@ function readWorkflowConfig(path, configNode, context) {
|
|
|
300742
301303
|
report(error.node, error.message);
|
|
300743
301304
|
return { config: null, diagnostics };
|
|
300744
301305
|
}
|
|
300745
|
-
if (!
|
|
301306
|
+
if (!isPlainObject(value)) {
|
|
300746
301307
|
report(configNode, "The config must be an object literal");
|
|
300747
301308
|
return { config: null, diagnostics };
|
|
300748
301309
|
}
|
|
@@ -300783,7 +301344,7 @@ function readWorkflowConfig(path, configNode, context) {
|
|
|
300783
301344
|
}
|
|
300784
301345
|
function resolveResource(reference, node, context, report) {
|
|
300785
301346
|
if (typeof reference !== "string" || reference === "") {
|
|
300786
|
-
report(node, '"resource" must be Resources.<Name
|
|
301347
|
+
report(node, '"resource" must be Resources.<Name>.slug');
|
|
300787
301348
|
return null;
|
|
300788
301349
|
}
|
|
300789
301350
|
const resource = context.findResource(reference);
|
|
@@ -300804,7 +301365,7 @@ function oneOf(trigger, key, allowed, at, report) {
|
|
|
300804
301365
|
return item;
|
|
300805
301366
|
}
|
|
300806
301367
|
function readTrigger(trigger, triggerNode, context, report) {
|
|
300807
|
-
if (!
|
|
301368
|
+
if (!isPlainObject(trigger)) {
|
|
300808
301369
|
report(triggerNode, `"trigger" is required: { type: ${listOf(Object.keys(TRIGGERS))}, ... }`);
|
|
300809
301370
|
return null;
|
|
300810
301371
|
}
|
|
@@ -300977,7 +301538,7 @@ function readRunAs(runAs, node, trigger, context, report) {
|
|
|
300977
301538
|
}
|
|
300978
301539
|
return { mode: "session" };
|
|
300979
301540
|
}
|
|
300980
|
-
if (!
|
|
301541
|
+
if (!isPlainObject(runAs)) {
|
|
300981
301542
|
report(node, "runAs must be 'system', 'session', or { resource, record }");
|
|
300982
301543
|
return null;
|
|
300983
301544
|
}
|
|
@@ -301050,7 +301611,7 @@ function fieldTsType(fieldType) {
|
|
|
301050
301611
|
function propertyKey2(name) {
|
|
301051
301612
|
return IDENTIFIER.test(name) ? name : JSON.stringify(name);
|
|
301052
301613
|
}
|
|
301053
|
-
function
|
|
301614
|
+
function byteOrder2(left, right) {
|
|
301054
301615
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
301055
301616
|
}
|
|
301056
301617
|
function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
@@ -301058,7 +301619,7 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301058
301619
|
...platformResources.map((resource) => [resource.slug, null]),
|
|
301059
301620
|
...resources.map((resource) => [resource.slug, resource])
|
|
301060
301621
|
]);
|
|
301061
|
-
const slugs = [...resourcesBySlug.keys()].toSorted(
|
|
301622
|
+
const slugs = [...resourcesBySlug.keys()].toSorted(byteOrder2);
|
|
301062
301623
|
const types2 = [];
|
|
301063
301624
|
let usesContent = false;
|
|
301064
301625
|
for (const slug of slugs) {
|
|
@@ -301078,7 +301639,7 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301078
301639
|
input.push(`${key}?: ${type} | null`);
|
|
301079
301640
|
record.push(`${key}: ${type} | null`);
|
|
301080
301641
|
}
|
|
301081
|
-
const capabilities = Object.keys(resource.capabilities ?? {}).toSorted(
|
|
301642
|
+
const capabilities = Object.keys(resource.capabilities ?? {}).toSorted(byteOrder2).map((capability) => `'${capability}'`);
|
|
301082
301643
|
types2.push(
|
|
301083
301644
|
` ${propertyKey2(slug)}: { id: '${slug}'; capabilities: ${capabilities.length === 0 ? "never" : capabilities.join(" | ")}; input: { ${input.join("; ")} }; record: { ${record.join("; ")} } & Record<string, unknown> };`
|
|
301084
301645
|
);
|
|
@@ -301099,9 +301660,9 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301099
301660
|
|
|
301100
301661
|
// scripts/lib/runtime-build/workflows.mjs
|
|
301101
301662
|
var WORKFLOW_EXTERNALS = /* @__PURE__ */ new Set(["@diagonal/workflow", "@diagonal/workflow/workspace"]);
|
|
301102
|
-
function compileScript(path,
|
|
301663
|
+
function compileScript(path, writtenSource, script, workspaceDeclarations, app) {
|
|
301103
301664
|
const result = compileWorkflowScript({
|
|
301104
|
-
source:
|
|
301665
|
+
source: script.source,
|
|
301105
301666
|
sdkFiles: SCRIPT_SDK_FILES,
|
|
301106
301667
|
workspaceDeclarations,
|
|
301107
301668
|
appModules: Object.fromEntries(
|
|
@@ -301111,12 +301672,13 @@ function compileScript(path, scriptSource, workspaceDeclarations, app) {
|
|
|
301111
301672
|
if (!result.ok) {
|
|
301112
301673
|
return {
|
|
301113
301674
|
compiled: null,
|
|
301114
|
-
diagnostics: result.diagnostics.map(
|
|
301115
|
-
|
|
301675
|
+
diagnostics: result.diagnostics.map((item) => {
|
|
301676
|
+
const position2 = writtenPosition(script, writtenSource, item.line, item.column);
|
|
301677
|
+
return diagnostic(path, position2.line, position2.column, `${item.message} [${item.code}]`, {
|
|
301116
301678
|
stage: WORKFLOW_STAGE,
|
|
301117
301679
|
severity: item.severity
|
|
301118
|
-
})
|
|
301119
|
-
)
|
|
301680
|
+
});
|
|
301681
|
+
})
|
|
301120
301682
|
};
|
|
301121
301683
|
}
|
|
301122
301684
|
return {
|
|
@@ -301127,18 +301689,38 @@ function compileScript(path, scriptSource, workspaceDeclarations, app) {
|
|
|
301127
301689
|
diagnostics: []
|
|
301128
301690
|
};
|
|
301129
301691
|
}
|
|
301130
|
-
function workflowAppImports(root, path, ast, diagnostics) {
|
|
301692
|
+
function workflowAppImports(root, path, ast, inline, diagnostics) {
|
|
301131
301693
|
if (root === null) {
|
|
301132
301694
|
return { imports: [], modules: /* @__PURE__ */ new Map() };
|
|
301133
301695
|
}
|
|
301134
301696
|
try {
|
|
301135
301697
|
const imports = appImportsOf(root, path, ast);
|
|
301136
|
-
return {
|
|
301698
|
+
return {
|
|
301699
|
+
imports,
|
|
301700
|
+
modules: appModuleClosure(root, imports, WORKFLOW_EXTERNALS, {
|
|
301701
|
+
transform: inline === null ? null : (modulePath, source) => inline(modulePath, source).source
|
|
301702
|
+
})
|
|
301703
|
+
};
|
|
301137
301704
|
} catch (error) {
|
|
301138
301705
|
diagnostics.push({ ...diagnosticFromError(path, error), stage: WORKFLOW_STAGE });
|
|
301139
301706
|
return { imports: [], modules: /* @__PURE__ */ new Map() };
|
|
301140
301707
|
}
|
|
301141
301708
|
}
|
|
301709
|
+
function resourceInliner(root, entries) {
|
|
301710
|
+
return (path, source) => {
|
|
301711
|
+
const isGeneratedModule = (specifier) => root === null ? false : resolveLocalSpecifier(root, path, specifier) === GENERATED_RESOURCES_PATH;
|
|
301712
|
+
let ast;
|
|
301713
|
+
try {
|
|
301714
|
+
ast = parseSource(source, { jsx: false });
|
|
301715
|
+
} catch (error) {
|
|
301716
|
+
if (error instanceof SyntaxError) {
|
|
301717
|
+
return { source, edits: [], problems: [], otherUses: [] };
|
|
301718
|
+
}
|
|
301719
|
+
throw error;
|
|
301720
|
+
}
|
|
301721
|
+
return inlineResources(source, ast, isGeneratedModule, entries, { typescript: /\.tsx?$/.test(path) });
|
|
301722
|
+
};
|
|
301723
|
+
}
|
|
301142
301724
|
function reportDuplicateTriggers(workflows, diagnostics) {
|
|
301143
301725
|
const seen = /* @__PURE__ */ new Map();
|
|
301144
301726
|
for (const workflow of workflows) {
|
|
@@ -301173,6 +301755,7 @@ function buildWorkflows({
|
|
|
301173
301755
|
platformResources = [],
|
|
301174
301756
|
resourcesComplete,
|
|
301175
301757
|
names: names2,
|
|
301758
|
+
resourceEntries: resourceEntries2 = {},
|
|
301176
301759
|
root = null
|
|
301177
301760
|
}) {
|
|
301178
301761
|
const diagnostics = [];
|
|
@@ -301191,14 +301774,27 @@ function buildWorkflows({
|
|
|
301191
301774
|
workflowPaths: new Set(workflows.map((workflow) => workflow.path)),
|
|
301192
301775
|
reportUnknownResources: resourcesComplete
|
|
301193
301776
|
};
|
|
301194
|
-
const
|
|
301777
|
+
const inline = resourceInliner(root, resourceEntries2);
|
|
301778
|
+
const testModules = /* @__PURE__ */ new Map();
|
|
301195
301779
|
const built = workflows.map(({ path, source, ast }) => {
|
|
301196
|
-
const app = workflowAppImports(root, path, ast, diagnostics);
|
|
301197
|
-
for (const [modulePath, module] of app.modules) {
|
|
301198
|
-
appModules.set(modulePath, module);
|
|
301199
|
-
}
|
|
301200
301780
|
const split = splitWorkflowModule(path, source, ast);
|
|
301201
301781
|
diagnostics.push(...split.diagnostics);
|
|
301782
|
+
const script = inline(path, split.scriptSource);
|
|
301783
|
+
for (const problem of script.problems) {
|
|
301784
|
+
diagnostics.push(diagnosticAt(path, problem.node, problem.message, { stage: WORKFLOW_STAGE }));
|
|
301785
|
+
}
|
|
301786
|
+
const app = workflowAppImports(
|
|
301787
|
+
root,
|
|
301788
|
+
path,
|
|
301789
|
+
script.source === split.scriptSource ? ast : parseSource(script.source, { jsx: false }),
|
|
301790
|
+
inline,
|
|
301791
|
+
diagnostics
|
|
301792
|
+
);
|
|
301793
|
+
if (tests.length > 0) {
|
|
301794
|
+
for (const [modulePath, module] of workflowAppImports(root, path, ast, null, []).modules) {
|
|
301795
|
+
testModules.set(modulePath, module);
|
|
301796
|
+
}
|
|
301797
|
+
}
|
|
301202
301798
|
const read = split.configNode === null ? { config: null, diagnostics: [] } : readWorkflowConfig(path, split.configNode, {
|
|
301203
301799
|
...context,
|
|
301204
301800
|
resourcesBinding: resourcesBinding(ast, names2)
|
|
@@ -301209,7 +301805,7 @@ function buildWorkflows({
|
|
|
301209
301805
|
...slugStringWarnings(path, split.configNode, names2, { stage: WORKFLOW_STAGE })
|
|
301210
301806
|
);
|
|
301211
301807
|
}
|
|
301212
|
-
const compiled = resourcesComplete ? compileScript(path, split.scriptSource, workspaceDeclarations, app) : { compiled: null, diagnostics: [] };
|
|
301808
|
+
const compiled = resourcesComplete ? compileScript(path, split.scriptSource, script, workspaceDeclarations, app) : { compiled: null, diagnostics: [] };
|
|
301213
301809
|
diagnostics.push(...compiled.diagnostics);
|
|
301214
301810
|
const config = read.config;
|
|
301215
301811
|
return {
|
|
@@ -301232,7 +301828,7 @@ function buildWorkflows({
|
|
|
301232
301828
|
built.filter((workflow) => workflow.type !== null),
|
|
301233
301829
|
diagnostics
|
|
301234
301830
|
);
|
|
301235
|
-
const testRun = runWorkflowTests({ tests, workflows, root, appModules });
|
|
301831
|
+
const testRun = runWorkflowTests({ tests, workflows, root, appModules: testModules });
|
|
301236
301832
|
diagnostics.push(...testRun.diagnostics);
|
|
301237
301833
|
return { workflows: built, workflowTests: testRun.workflowTests, diagnostics };
|
|
301238
301834
|
}
|
|
@@ -301450,26 +302046,17 @@ function checkPageResources(pages, resources, platformSlugs, names2, diagnostics
|
|
|
301450
302046
|
}
|
|
301451
302047
|
}
|
|
301452
302048
|
}
|
|
301453
|
-
function
|
|
301454
|
-
const expected = generatedResourcesSource(names2);
|
|
302049
|
+
function writeGeneratedResources(root, names2, resources) {
|
|
301455
302050
|
const path = join10(root, GENERATED_RESOURCES_PATH);
|
|
301456
|
-
|
|
301457
|
-
if (current === expected || current === null && names2.slugsByName.size === 0) {
|
|
302051
|
+
if (names2.slugsByName.size === 0 && !existsSync4(path)) {
|
|
301458
302052
|
return;
|
|
301459
302053
|
}
|
|
301460
|
-
|
|
301461
|
-
|
|
301462
|
-
writeFileSync3(path, expected);
|
|
302054
|
+
const source = generatedResourcesSource(names2, resources);
|
|
302055
|
+
if (existsSync4(path) && readFileSync7(path, "utf8") === source) {
|
|
301463
302056
|
return;
|
|
301464
302057
|
}
|
|
301465
|
-
|
|
301466
|
-
|
|
301467
|
-
GENERATED_RESOURCES_PATH,
|
|
301468
|
-
null,
|
|
301469
|
-
`${current === null ? "The file is missing" : "The file does not match the resources/ folder"}. Run \`diagonal check\` to write it, or write this content:
|
|
301470
|
-
${expected.trimEnd()}`
|
|
301471
|
-
)
|
|
301472
|
-
);
|
|
302058
|
+
mkdirSync2(dirname6(path), { recursive: true });
|
|
302059
|
+
writeFileSync3(path, source);
|
|
301473
302060
|
}
|
|
301474
302061
|
function lintUnits(units, resources, components, pages, diagnostics) {
|
|
301475
302062
|
const catalogs = {
|
|
@@ -301519,26 +302106,25 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301519
302106
|
files.filter((path) => classify(path) === "resource"),
|
|
301520
302107
|
diagnostics
|
|
301521
302108
|
);
|
|
301522
|
-
syncGeneratedResources(root, names2, writeSource, diagnostics);
|
|
301523
302109
|
const uiEntries = [];
|
|
301524
302110
|
const failedLayouts = /* @__PURE__ */ new Set();
|
|
301525
302111
|
const failedComponents = /* @__PURE__ */ new Set();
|
|
301526
302112
|
const failedPageKeys = [];
|
|
301527
|
-
|
|
302113
|
+
const buildFile = (path) => {
|
|
301528
302114
|
const kind = classify(path);
|
|
301529
302115
|
if (kind === "ignored") {
|
|
301530
|
-
|
|
302116
|
+
return;
|
|
301531
302117
|
}
|
|
301532
302118
|
if (kind === "unknown") {
|
|
301533
302119
|
diagnostics.push(
|
|
301534
302120
|
diagnosticAt(path, null, BINARY_EXTENSIONS.has(extname2(path).toLowerCase()) ? BINARY_FILE_MESSAGE : "The build does not know this file. Move or rename it")
|
|
301535
302121
|
);
|
|
301536
|
-
|
|
302122
|
+
return;
|
|
301537
302123
|
}
|
|
301538
302124
|
const source = readFileSync7(join10(root, path), "utf8");
|
|
301539
302125
|
if (kind === "skill") {
|
|
301540
302126
|
skillFiles.push({ path, content: source });
|
|
301541
|
-
|
|
302127
|
+
return;
|
|
301542
302128
|
}
|
|
301543
302129
|
try {
|
|
301544
302130
|
const ast = parseSource(source, { jsx: extname2(path) === ".tsx" });
|
|
@@ -301598,6 +302184,28 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301598
302184
|
failedComponents.add(stem(path));
|
|
301599
302185
|
}
|
|
301600
302186
|
}
|
|
302187
|
+
};
|
|
302188
|
+
const resourceFiles = files.filter((path) => topDirectory(path) === "resources");
|
|
302189
|
+
const otherFiles = files.filter((path) => topDirectory(path) !== "resources");
|
|
302190
|
+
for (const path of resourceFiles) {
|
|
302191
|
+
buildFile(path);
|
|
302192
|
+
}
|
|
302193
|
+
const resourcesComplete = !diagnostics.some(
|
|
302194
|
+
(diagnostic2) => diagnostic2.path.startsWith("resources/") && diagnostic2.severity === "error"
|
|
302195
|
+
);
|
|
302196
|
+
const platformSlugs = new Set(output.platform_resources.map((resource) => resource.slug));
|
|
302197
|
+
if (resourcesComplete) {
|
|
302198
|
+
checkRelations(output.resources, platformSlugs, names2, diagnostics);
|
|
302199
|
+
addInverseFields(output.resources, diagnostics);
|
|
302200
|
+
checkFieldPaths(output.resources, diagnostics);
|
|
302201
|
+
checkCapabilities(output.resources, platformSlugs, diagnostics);
|
|
302202
|
+
checkPolicyResources(output.resources, platformSlugs, names2, diagnostics);
|
|
302203
|
+
}
|
|
302204
|
+
output.resources = output.resources.map(withoutBuildNodes);
|
|
302205
|
+
writeGeneratedResources(root, names2, [...output.resources, ...output.platform_resources]);
|
|
302206
|
+
const entries = resourceEntries(names2, [...output.resources, ...output.platform_resources]);
|
|
302207
|
+
for (const path of otherFiles) {
|
|
302208
|
+
buildFile(path);
|
|
301601
302209
|
}
|
|
301602
302210
|
const uidCheck = checkDefinitionUids(root, uidDefinitions, { write: writeSource });
|
|
301603
302211
|
diagnostics.push(...uidCheck.diagnostics);
|
|
@@ -301621,18 +302229,9 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301621
302229
|
"component name",
|
|
301622
302230
|
diagnostics
|
|
301623
302231
|
);
|
|
301624
|
-
const resourcesComplete = !diagnostics.some(
|
|
301625
|
-
(diagnostic2) => diagnostic2.path.startsWith("resources/") && diagnostic2.severity === "error"
|
|
301626
|
-
);
|
|
301627
|
-
const platformSlugs = new Set(output.platform_resources.map((resource) => resource.slug));
|
|
301628
302232
|
if (resourcesComplete) {
|
|
301629
|
-
checkRelations(output.resources, platformSlugs, names2, diagnostics);
|
|
301630
|
-
addInverseFields(output.resources, diagnostics);
|
|
301631
|
-
checkFieldPaths(output.resources, diagnostics);
|
|
301632
|
-
checkCapabilities(output.resources, platformSlugs, diagnostics);
|
|
301633
302233
|
checkPageResources(output.pages, output.resources, platformSlugs, names2, diagnostics);
|
|
301634
302234
|
}
|
|
301635
|
-
output.resources = output.resources.map(withoutBuildNodes);
|
|
301636
302235
|
const packageFiles = readPackageFiles(root, diagnostics);
|
|
301637
302236
|
const assetsComplete = !diagnostics.some((diagnostic2) => diagnostic2.path === "assets.ts");
|
|
301638
302237
|
const assetKeys = assetsComplete ? new Set(output.assets.map((asset2) => asset2.key)) : null;
|
|
@@ -301641,7 +302240,8 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301641
302240
|
uiEntries,
|
|
301642
302241
|
packageFiles.manifest,
|
|
301643
302242
|
diagnostics,
|
|
301644
|
-
assetKeys
|
|
302243
|
+
assetKeys,
|
|
302244
|
+
entries
|
|
301645
302245
|
);
|
|
301646
302246
|
const workflowBuild = buildWorkflows({
|
|
301647
302247
|
workflows: workflowFiles,
|
|
@@ -301650,6 +302250,7 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301650
302250
|
platformResources: output.platform_resources,
|
|
301651
302251
|
resourcesComplete,
|
|
301652
302252
|
names: names2,
|
|
302253
|
+
resourceEntries: entries,
|
|
301653
302254
|
root
|
|
301654
302255
|
});
|
|
301655
302256
|
diagnostics.push(...workflowBuild.diagnostics);
|