silgi 0.4.11 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +9 -3
- package/dist/core/index.d.mts +185 -38
- package/dist/core/index.d.ts +185 -38
- package/dist/core/index.mjs +314 -108
- package/dist/kit/index.d.mts +6 -3
- package/dist/kit/index.d.ts +6 -3
- package/dist/kit/index.mjs +24 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/presets/_types.gen.d.ts +1 -1
- package/dist/runtime/internal/nitro.mjs +46 -35
- package/dist/runtime/internal/nuxt.d.ts +4 -4
- package/dist/shared/{silgi.yr8vHHvd.d.ts → silgi.CN_giHTc.d.mts} +67 -267
- package/dist/shared/{silgi.DQSwjP5u.d.mts → silgi.CN_giHTc.d.ts} +67 -267
- package/dist/shared/{silgi.40ZJYm8F.d.mts → silgi.DGmIWx95.d.mts} +2 -2
- package/dist/shared/{silgi.40ZJYm8F.d.ts → silgi.DGmIWx95.d.ts} +2 -2
- package/dist/types/index.d.mts +196 -9
- package/dist/types/index.d.ts +196 -9
- package/package.json +1 -1
package/dist/core/index.mjs
CHANGED
|
@@ -818,48 +818,195 @@ function normalizeResult(result) {
|
|
|
818
818
|
return result;
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
-
var
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
821
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
822
|
+
HttpStatus2[HttpStatus2["CONTINUE"] = 100] = "CONTINUE";
|
|
823
|
+
HttpStatus2[HttpStatus2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
824
|
+
HttpStatus2[HttpStatus2["PROCESSING"] = 102] = "PROCESSING";
|
|
825
|
+
HttpStatus2[HttpStatus2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
826
|
+
HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
|
|
827
|
+
HttpStatus2[HttpStatus2["CREATED"] = 201] = "CREATED";
|
|
828
|
+
HttpStatus2[HttpStatus2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
829
|
+
HttpStatus2[HttpStatus2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
830
|
+
HttpStatus2[HttpStatus2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
831
|
+
HttpStatus2[HttpStatus2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
832
|
+
HttpStatus2[HttpStatus2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
833
|
+
HttpStatus2[HttpStatus2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
834
|
+
HttpStatus2[HttpStatus2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
835
|
+
HttpStatus2[HttpStatus2["IM_USED"] = 226] = "IM_USED";
|
|
836
|
+
HttpStatus2[HttpStatus2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
837
|
+
HttpStatus2[HttpStatus2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
838
|
+
HttpStatus2[HttpStatus2["FOUND"] = 302] = "FOUND";
|
|
839
|
+
HttpStatus2[HttpStatus2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
840
|
+
HttpStatus2[HttpStatus2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
841
|
+
HttpStatus2[HttpStatus2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
842
|
+
HttpStatus2[HttpStatus2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
843
|
+
HttpStatus2[HttpStatus2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
844
|
+
HttpStatus2[HttpStatus2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
845
|
+
HttpStatus2[HttpStatus2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
846
|
+
HttpStatus2[HttpStatus2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
847
|
+
HttpStatus2[HttpStatus2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
848
|
+
HttpStatus2[HttpStatus2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
849
|
+
HttpStatus2[HttpStatus2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
850
|
+
HttpStatus2[HttpStatus2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
851
|
+
HttpStatus2[HttpStatus2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
852
|
+
HttpStatus2[HttpStatus2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
853
|
+
HttpStatus2[HttpStatus2["CONFLICT"] = 409] = "CONFLICT";
|
|
854
|
+
HttpStatus2[HttpStatus2["GONE"] = 410] = "GONE";
|
|
855
|
+
HttpStatus2[HttpStatus2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
856
|
+
HttpStatus2[HttpStatus2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
857
|
+
HttpStatus2[HttpStatus2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
858
|
+
HttpStatus2[HttpStatus2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
859
|
+
HttpStatus2[HttpStatus2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
860
|
+
HttpStatus2[HttpStatus2["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
861
|
+
HttpStatus2[HttpStatus2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
862
|
+
HttpStatus2[HttpStatus2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
|
|
863
|
+
HttpStatus2[HttpStatus2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
864
|
+
HttpStatus2[HttpStatus2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
865
|
+
HttpStatus2[HttpStatus2["LOCKED"] = 423] = "LOCKED";
|
|
866
|
+
HttpStatus2[HttpStatus2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
867
|
+
HttpStatus2[HttpStatus2["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
868
|
+
HttpStatus2[HttpStatus2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
869
|
+
HttpStatus2[HttpStatus2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
870
|
+
HttpStatus2[HttpStatus2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
871
|
+
HttpStatus2[HttpStatus2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
872
|
+
HttpStatus2[HttpStatus2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
873
|
+
HttpStatus2[HttpStatus2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
874
|
+
HttpStatus2[HttpStatus2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
875
|
+
HttpStatus2[HttpStatus2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
876
|
+
HttpStatus2[HttpStatus2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
877
|
+
HttpStatus2[HttpStatus2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
878
|
+
HttpStatus2[HttpStatus2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
879
|
+
HttpStatus2[HttpStatus2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
880
|
+
HttpStatus2[HttpStatus2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
881
|
+
HttpStatus2[HttpStatus2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
882
|
+
HttpStatus2[HttpStatus2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
883
|
+
HttpStatus2[HttpStatus2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
884
|
+
return HttpStatus2;
|
|
885
|
+
})(HttpStatus || {});
|
|
886
|
+
var ErrorSeverity = /* @__PURE__ */ ((ErrorSeverity2) => {
|
|
887
|
+
ErrorSeverity2["DEBUG"] = "DEBUG";
|
|
888
|
+
ErrorSeverity2["INFO"] = "INFO";
|
|
889
|
+
ErrorSeverity2["WARNING"] = "WARNING";
|
|
890
|
+
ErrorSeverity2["ERROR"] = "ERROR";
|
|
891
|
+
ErrorSeverity2["CRITICAL"] = "CRITICAL";
|
|
892
|
+
return ErrorSeverity2;
|
|
893
|
+
})(ErrorSeverity || {});
|
|
894
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
895
|
+
ErrorCategory2["AUTHENTICATION"] = "auth";
|
|
896
|
+
ErrorCategory2["AUTHORIZATION"] = "authorization";
|
|
897
|
+
ErrorCategory2["VALIDATION"] = "validation";
|
|
898
|
+
ErrorCategory2["BUSINESS"] = "business";
|
|
899
|
+
ErrorCategory2["INFRASTRUCTURE"] = "infrastructure";
|
|
900
|
+
ErrorCategory2["EXTERNAL"] = "external";
|
|
901
|
+
ErrorCategory2["UNKNOWN"] = "unknown";
|
|
902
|
+
return ErrorCategory2;
|
|
903
|
+
})(ErrorCategory || {});
|
|
904
|
+
class ErrorFactory {
|
|
905
|
+
static createMetadata(metadata) {
|
|
906
|
+
return {
|
|
907
|
+
timestamp: Date.now(),
|
|
908
|
+
...metadata
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
static create(options) {
|
|
912
|
+
return new SilgiError({
|
|
913
|
+
code: options.code ?? options.httpStatus ?? 500 /* INTERNAL_SERVER_ERROR */,
|
|
914
|
+
message: options.message,
|
|
915
|
+
category: options.category ?? "unknown" /* UNKNOWN */,
|
|
916
|
+
severity: options.severity ?? "ERROR" /* ERROR */,
|
|
917
|
+
httpStatus: options.httpStatus ?? 500 /* INTERNAL_SERVER_ERROR */,
|
|
918
|
+
metadata: this.createMetadata(options.metadata),
|
|
919
|
+
cause: options.cause,
|
|
920
|
+
context: options.context
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
// Predefined error creators
|
|
924
|
+
static authenticationError(message, context) {
|
|
925
|
+
return this.create({
|
|
926
|
+
message,
|
|
927
|
+
code: 401,
|
|
928
|
+
category: "auth" /* AUTHENTICATION */,
|
|
929
|
+
severity: "ERROR" /* ERROR */,
|
|
930
|
+
httpStatus: 401 /* UNAUTHORIZED */,
|
|
931
|
+
context
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
static authorizationError(message, context) {
|
|
935
|
+
return this.create({
|
|
936
|
+
message,
|
|
937
|
+
code: 403,
|
|
938
|
+
category: "authorization" /* AUTHORIZATION */,
|
|
939
|
+
severity: "ERROR" /* ERROR */,
|
|
940
|
+
httpStatus: 403 /* FORBIDDEN */,
|
|
941
|
+
context
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
static validationError(message, context) {
|
|
945
|
+
return this.create({
|
|
946
|
+
message,
|
|
947
|
+
code: 400,
|
|
948
|
+
category: "validation" /* VALIDATION */,
|
|
949
|
+
severity: "WARNING" /* WARNING */,
|
|
950
|
+
httpStatus: 400 /* BAD_REQUEST */,
|
|
951
|
+
context
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
static notFoundError(message, context) {
|
|
955
|
+
return this.create({
|
|
956
|
+
message,
|
|
957
|
+
code: 404,
|
|
958
|
+
category: "business" /* BUSINESS */,
|
|
959
|
+
severity: "WARNING" /* WARNING */,
|
|
960
|
+
httpStatus: 404 /* NOT_FOUND */,
|
|
961
|
+
context
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
static internalError(message, cause) {
|
|
965
|
+
return this.create({
|
|
966
|
+
message,
|
|
967
|
+
code: 500,
|
|
968
|
+
category: "infrastructure" /* INFRASTRUCTURE */,
|
|
969
|
+
severity: "CRITICAL" /* CRITICAL */,
|
|
970
|
+
httpStatus: 500 /* INTERNAL_SERVER_ERROR */,
|
|
971
|
+
cause
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}
|
|
835
975
|
class SilgiError extends Error {
|
|
836
976
|
code;
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
977
|
+
category;
|
|
978
|
+
severity;
|
|
979
|
+
httpStatus;
|
|
980
|
+
metadata;
|
|
981
|
+
context;
|
|
840
982
|
cause;
|
|
841
|
-
constructor(
|
|
842
|
-
super(
|
|
983
|
+
constructor(error) {
|
|
984
|
+
super(error.message);
|
|
843
985
|
this.name = "SilgiError";
|
|
844
|
-
this.code =
|
|
845
|
-
this.
|
|
846
|
-
this.
|
|
847
|
-
this.
|
|
848
|
-
this.
|
|
986
|
+
this.code = error.code;
|
|
987
|
+
this.category = error.category;
|
|
988
|
+
this.severity = error.severity;
|
|
989
|
+
this.httpStatus = error.httpStatus;
|
|
990
|
+
this.metadata = error.metadata ?? { timestamp: Date.now() };
|
|
991
|
+
this.context = error.context;
|
|
992
|
+
this.cause = error.cause;
|
|
849
993
|
if (Error.captureStackTrace) {
|
|
850
994
|
Error.captureStackTrace(this, this.constructor);
|
|
851
995
|
}
|
|
852
996
|
}
|
|
853
|
-
// Improve error formatting
|
|
854
997
|
toString() {
|
|
855
|
-
let str = `${this.name} [${this.code}]: ${this.message}`;
|
|
856
|
-
|
|
998
|
+
let str = `${this.name} [${this.code}] ${this.severity}: ${this.message}`;
|
|
999
|
+
str += `
|
|
1000
|
+
Category: ${this.category}`;
|
|
1001
|
+
str += `
|
|
1002
|
+
HTTP Status: ${this.httpStatus}`;
|
|
1003
|
+
if (this.context) {
|
|
857
1004
|
str += `
|
|
858
|
-
|
|
1005
|
+
Context: ${JSON.stringify(this.context, null, 2)}`;
|
|
859
1006
|
}
|
|
860
|
-
if (this.
|
|
1007
|
+
if (this.metadata) {
|
|
861
1008
|
str += `
|
|
862
|
-
|
|
1009
|
+
Metadata: ${JSON.stringify(this.metadata, null, 2)}`;
|
|
863
1010
|
}
|
|
864
1011
|
if (this.stack) {
|
|
865
1012
|
str += `
|
|
@@ -872,38 +1019,50 @@ ${this.stack}`;
|
|
|
872
1019
|
name: this.name,
|
|
873
1020
|
code: this.code,
|
|
874
1021
|
message: this.message,
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1022
|
+
category: this.category,
|
|
1023
|
+
severity: this.severity,
|
|
1024
|
+
httpStatus: this.httpStatus,
|
|
1025
|
+
metadata: this.metadata,
|
|
1026
|
+
context: this.context,
|
|
878
1027
|
stack: this.stack
|
|
879
1028
|
};
|
|
880
1029
|
}
|
|
881
|
-
static
|
|
1030
|
+
static isError(error) {
|
|
1031
|
+
return error instanceof SilgiError;
|
|
1032
|
+
}
|
|
1033
|
+
static from(error) {
|
|
882
1034
|
if (error instanceof SilgiError) {
|
|
883
1035
|
return error;
|
|
884
1036
|
}
|
|
885
|
-
return
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
static isSilgiError(error) {
|
|
892
|
-
return error instanceof SilgiError;
|
|
1037
|
+
return ErrorFactory.internalError(
|
|
1038
|
+
error instanceof Error ? error.message : String(error),
|
|
1039
|
+
error instanceof Error ? error : undefined
|
|
1040
|
+
);
|
|
893
1041
|
}
|
|
894
1042
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
throw new SilgiError({
|
|
898
|
-
code: `URI_PARSE_ERROR_${code}`,
|
|
899
|
-
message
|
|
900
|
-
});
|
|
1043
|
+
function isBaseError(error) {
|
|
1044
|
+
return typeof error === "object" && error !== null && "code" in error && "message" in error && "category" in error && "severity" in error && "httpStatus" in error;
|
|
901
1045
|
}
|
|
1046
|
+
|
|
902
1047
|
function parseURI(uri, uris) {
|
|
903
|
-
if (!uri)
|
|
904
|
-
throw
|
|
905
|
-
|
|
906
|
-
|
|
1048
|
+
if (!uri) {
|
|
1049
|
+
throw ErrorFactory.create({
|
|
1050
|
+
message: "URI cannot be empty",
|
|
1051
|
+
httpStatus: HttpStatus.BAD_REQUEST,
|
|
1052
|
+
context: {
|
|
1053
|
+
uri
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
if (!uris) {
|
|
1058
|
+
throw ErrorFactory.create({
|
|
1059
|
+
message: "URIs configuration is not provided",
|
|
1060
|
+
httpStatus: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
1061
|
+
context: {
|
|
1062
|
+
uri
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
907
1066
|
const cleanUri = uri.replace(/^\/*(srn\/)?/, "").replace(/\/*$/, "");
|
|
908
1067
|
const [path, queryString] = cleanUri.split("?");
|
|
909
1068
|
const parts = path.split("/");
|
|
@@ -911,29 +1070,76 @@ function parseURI(uri, uris) {
|
|
|
911
1070
|
queryString.split("&").map((param) => param.split("="))
|
|
912
1071
|
) : undefined;
|
|
913
1072
|
const method = query?.method ? query?.method.toLowerCase() : undefined;
|
|
914
|
-
if (method && parts.length < 3 || !method && parts.length < 4)
|
|
915
|
-
throw
|
|
1073
|
+
if (method && parts.length < 3 || !method && parts.length < 4) {
|
|
1074
|
+
throw ErrorFactory.create({
|
|
1075
|
+
message: "Invalid URI format: Insufficient path segments",
|
|
1076
|
+
httpStatus: HttpStatus.BAD_REQUEST,
|
|
1077
|
+
context: {
|
|
1078
|
+
uri,
|
|
1079
|
+
cleanUri,
|
|
1080
|
+
partsLength: parts.length,
|
|
1081
|
+
method,
|
|
1082
|
+
expectedMinLength: method ? 3 : 4
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
916
1086
|
const namespaceName = parts[0];
|
|
917
1087
|
const serviceName = parts[1];
|
|
918
1088
|
const methodName = method || parts[2];
|
|
919
1089
|
const actionName = method ? parts[2] : parts[3];
|
|
920
|
-
if (!namespaceName || !serviceName || !methodName || !actionName)
|
|
921
|
-
throw
|
|
1090
|
+
if (!namespaceName || !serviceName || !methodName || !actionName) {
|
|
1091
|
+
throw ErrorFactory.create({
|
|
1092
|
+
message: "Invalid URI format: Missing required path segments",
|
|
1093
|
+
httpStatus: HttpStatus.BAD_REQUEST,
|
|
1094
|
+
context: {
|
|
1095
|
+
uri,
|
|
1096
|
+
namespaceName,
|
|
1097
|
+
serviceName,
|
|
1098
|
+
methodName,
|
|
1099
|
+
actionName
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
922
1103
|
const hasParameters = parts.length > 4;
|
|
923
1104
|
const baseUri = `${namespaceName}/${serviceName}/${methodName}/${actionName}`;
|
|
924
1105
|
const template = uris[baseUri];
|
|
925
1106
|
if (template === "") {
|
|
926
|
-
if (hasParameters)
|
|
927
|
-
throw
|
|
1107
|
+
if (hasParameters) {
|
|
1108
|
+
throw ErrorFactory.create({
|
|
1109
|
+
message: "Parameters are not allowed for this route",
|
|
1110
|
+
httpStatus: HttpStatus.BAD_REQUEST,
|
|
1111
|
+
context: {
|
|
1112
|
+
uri,
|
|
1113
|
+
baseUri,
|
|
1114
|
+
extraParams: parts.slice(4)
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
928
1118
|
} else if (!template) {
|
|
929
|
-
throw
|
|
1119
|
+
throw ErrorFactory.create({
|
|
1120
|
+
message: "Route not found",
|
|
1121
|
+
httpStatus: HttpStatus.NOT_FOUND,
|
|
1122
|
+
context: {
|
|
1123
|
+
uri,
|
|
1124
|
+
baseUri
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
930
1127
|
}
|
|
931
1128
|
const routeTemplate = typeof template === "string" ? template : template.pattern;
|
|
932
1129
|
const validators = typeof template === "string" ? undefined : template.validators;
|
|
933
1130
|
const routerParams = {};
|
|
934
1131
|
if (routeTemplate === "") {
|
|
935
|
-
if (parts.length > 4)
|
|
936
|
-
throw
|
|
1132
|
+
if (parts.length > 4) {
|
|
1133
|
+
throw ErrorFactory.create({
|
|
1134
|
+
message: "Parameters are not allowed for this route",
|
|
1135
|
+
httpStatus: HttpStatus.BAD_REQUEST,
|
|
1136
|
+
context: {
|
|
1137
|
+
uri,
|
|
1138
|
+
baseUri,
|
|
1139
|
+
extraParams: parts.slice(4)
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
937
1143
|
} else {
|
|
938
1144
|
const templateParts = routeTemplate.split("/").filter(Boolean);
|
|
939
1145
|
const paramValues = parts.slice(4);
|
|
@@ -944,7 +1150,16 @@ function parseURI(uri, uris) {
|
|
|
944
1150
|
const paramValue = paramValues[valueIndex];
|
|
945
1151
|
if (validators?.[paramName] && paramValue) {
|
|
946
1152
|
if (!validators[paramName](paramValue)) {
|
|
947
|
-
throw
|
|
1153
|
+
throw ErrorFactory.create({
|
|
1154
|
+
message: `Invalid parameter value: ${paramName}`,
|
|
1155
|
+
httpStatus: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
1156
|
+
context: {
|
|
1157
|
+
uri,
|
|
1158
|
+
paramName,
|
|
1159
|
+
paramValue,
|
|
1160
|
+
validatorName: paramName
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
948
1163
|
}
|
|
949
1164
|
}
|
|
950
1165
|
routerParams[paramName] = paramValue || undefined;
|
|
@@ -1036,9 +1251,16 @@ async function generateStorageKey(params) {
|
|
|
1036
1251
|
].filter(Boolean);
|
|
1037
1252
|
if (storageOptions?.scope === "request") {
|
|
1038
1253
|
if (!requestId) {
|
|
1039
|
-
throw
|
|
1040
|
-
code:
|
|
1041
|
-
message: "Request ID is required for request-scoped cache"
|
|
1254
|
+
throw ErrorFactory.create({
|
|
1255
|
+
code: HttpStatus.BAD_REQUEST,
|
|
1256
|
+
message: "Request ID is required for request-scoped cache",
|
|
1257
|
+
context: {
|
|
1258
|
+
requestId,
|
|
1259
|
+
operation,
|
|
1260
|
+
input,
|
|
1261
|
+
storageOptions,
|
|
1262
|
+
keyGenerator
|
|
1263
|
+
}
|
|
1042
1264
|
});
|
|
1043
1265
|
}
|
|
1044
1266
|
parts.push(requestId);
|
|
@@ -1143,8 +1365,13 @@ function getFetch(url, opts, localFetch) {
|
|
|
1143
1365
|
return globalThis.$fetch;
|
|
1144
1366
|
}
|
|
1145
1367
|
function fillPath(path, params) {
|
|
1146
|
-
if (!params)
|
|
1368
|
+
if (!params) {
|
|
1369
|
+
if (path.includes(":"))
|
|
1370
|
+
throw new Error("Parametreler dogru kullanmal\u0131s\u0131n\u0131z");
|
|
1147
1371
|
return path;
|
|
1372
|
+
}
|
|
1373
|
+
if (!path.includes(":"))
|
|
1374
|
+
throw new Error("Path parametler : ile belirtilmelidir");
|
|
1148
1375
|
let result = path;
|
|
1149
1376
|
for (const [key, value] of Object.entries(params)) {
|
|
1150
1377
|
result = result.replace(`:${key}`, value);
|
|
@@ -1294,34 +1521,25 @@ function silgi(event) {
|
|
|
1294
1521
|
async function execute(uriString, input, event) {
|
|
1295
1522
|
const silgiCtx = useSilgi();
|
|
1296
1523
|
if (event) {
|
|
1297
|
-
silgiCtx.callHook("event:before", event);
|
|
1524
|
+
await silgiCtx.callHook("event:before", event);
|
|
1298
1525
|
}
|
|
1299
1526
|
let success = false;
|
|
1300
1527
|
let cached = false;
|
|
1301
|
-
let error;
|
|
1302
1528
|
let result;
|
|
1303
|
-
const operation = parseURI(uriString, silgiCtx.uris);
|
|
1304
|
-
if (!operation) {
|
|
1305
|
-
throw new SilgiError({
|
|
1306
|
-
code: "INVALID_URI",
|
|
1307
|
-
message: `Invalid URI: ${uriString}`
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
const hookContext = {
|
|
1311
|
-
operation,
|
|
1312
|
-
input,
|
|
1313
|
-
event
|
|
1314
|
-
};
|
|
1315
1529
|
try {
|
|
1530
|
+
const operation = parseURI(uriString, silgiCtx.uris);
|
|
1531
|
+
if (!operation) {
|
|
1532
|
+
throw ErrorFactory.create({ message: "Invalid URI", httpStatus: HttpStatus.BAD_REQUEST });
|
|
1533
|
+
}
|
|
1316
1534
|
const handler = silgiCtx.scannedHandlers.get(operation.uri);
|
|
1317
1535
|
if (!handler) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1536
|
+
throw ErrorFactory.create({
|
|
1537
|
+
message: "Action not found",
|
|
1538
|
+
httpStatus: HttpStatus.NOT_FOUND,
|
|
1539
|
+
context: {
|
|
1540
|
+
uri: uriString
|
|
1323
1541
|
}
|
|
1324
|
-
};
|
|
1542
|
+
});
|
|
1325
1543
|
}
|
|
1326
1544
|
await silgiCtx.callHook("action:before", {
|
|
1327
1545
|
operation,
|
|
@@ -1357,31 +1575,19 @@ async function execute(uriString, input, event) {
|
|
|
1357
1575
|
await useStorage(handler.storage.base).setItem(cacheData.cachedKey, result, handler.storage.options);
|
|
1358
1576
|
}
|
|
1359
1577
|
}
|
|
1360
|
-
return
|
|
1578
|
+
return result;
|
|
1361
1579
|
} catch (err) {
|
|
1362
|
-
error = err instanceof Error ? err : new Error("Unknown error");
|
|
1363
|
-
if (error instanceof SilgiError) {
|
|
1364
|
-
return {
|
|
1365
|
-
success: false,
|
|
1366
|
-
error: {
|
|
1367
|
-
code: error.code,
|
|
1368
|
-
message: error.message,
|
|
1369
|
-
details: error.details
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
1580
|
await silgiCtx.callHook("action:error", {
|
|
1374
|
-
|
|
1375
|
-
|
|
1581
|
+
input,
|
|
1582
|
+
event,
|
|
1583
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
1376
1584
|
timestamp: Date.now()
|
|
1377
1585
|
});
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1384
|
-
};
|
|
1586
|
+
silgiCtx.captureError(SilgiError.from(err), {
|
|
1587
|
+
event,
|
|
1588
|
+
tags: ["execute"]
|
|
1589
|
+
});
|
|
1590
|
+
throw err;
|
|
1385
1591
|
}
|
|
1386
1592
|
}
|
|
1387
1593
|
async function cacheExecute(input, operation, handler, event) {
|
|
@@ -1453,4 +1659,4 @@ function createShared(shared) {
|
|
|
1453
1659
|
return shared;
|
|
1454
1660
|
}
|
|
1455
1661
|
|
|
1456
|
-
export { SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, createStorage, getEvent, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgi, silgiGenerateType, useSilgi };
|
|
1662
|
+
export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, createStorage, getEvent, isBaseError, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgi, silgiGenerateType, useSilgi };
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import { GraphQLSchema } from 'graphql';
|
|
3
3
|
import { SilgiCLI, GraphQLJSON, SilgiPreset, SilgiPresetMeta } from 'silgi/types';
|
|
4
|
-
import {
|
|
4
|
+
import { M as ModuleOptions, a as ModuleDefinition, S as SilgiModule } from '../shared/silgi.CN_giHTc.mjs';
|
|
5
5
|
import 'defu';
|
|
6
6
|
import '@graphql-tools/utils';
|
|
7
7
|
import 'pkg-types';
|
|
@@ -17,7 +17,6 @@ import 'chokidar';
|
|
|
17
17
|
import 'compatx';
|
|
18
18
|
import 'unimport/unplugin';
|
|
19
19
|
import 'std-env';
|
|
20
|
-
import '../shared/silgi.40ZJYm8F.mjs';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
@@ -34,6 +33,10 @@ declare function exportGraphQLInterfaceType(silgi: SilgiCLI, schema: GraphQLSche
|
|
|
34
33
|
|
|
35
34
|
declare function extractGraphQLSchemaToJSON(schema: GraphQLSchema): GraphQLJSON;
|
|
36
35
|
|
|
36
|
+
declare function isNuxt(): boolean;
|
|
37
|
+
declare function isNitro(): boolean;
|
|
38
|
+
declare function isH3(): boolean;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Define a Silgi module, automatically merging defaults with user provided options, installing
|
|
39
42
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
@@ -87,4 +90,4 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
|
|
|
87
90
|
|
|
88
91
|
declare function relativeWithDot(from: string, to: string): string;
|
|
89
92
|
|
|
90
|
-
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
|
93
|
+
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory, isH3, isNitro, isNuxt, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import { GraphQLSchema } from 'graphql';
|
|
3
3
|
import { SilgiCLI, GraphQLJSON, SilgiPreset, SilgiPresetMeta } from 'silgi/types';
|
|
4
|
-
import {
|
|
4
|
+
import { M as ModuleOptions, a as ModuleDefinition, S as SilgiModule } from '../shared/silgi.CN_giHTc.js';
|
|
5
5
|
import 'defu';
|
|
6
6
|
import '@graphql-tools/utils';
|
|
7
7
|
import 'pkg-types';
|
|
@@ -17,7 +17,6 @@ import 'chokidar';
|
|
|
17
17
|
import 'compatx';
|
|
18
18
|
import 'unimport/unplugin';
|
|
19
19
|
import 'std-env';
|
|
20
|
-
import '../shared/silgi.40ZJYm8F.js';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
@@ -34,6 +33,10 @@ declare function exportGraphQLInterfaceType(silgi: SilgiCLI, schema: GraphQLSche
|
|
|
34
33
|
|
|
35
34
|
declare function extractGraphQLSchemaToJSON(schema: GraphQLSchema): GraphQLJSON;
|
|
36
35
|
|
|
36
|
+
declare function isNuxt(): boolean;
|
|
37
|
+
declare function isNitro(): boolean;
|
|
38
|
+
declare function isH3(): boolean;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Define a Silgi module, automatically merging defaults with user provided options, installing
|
|
39
42
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
@@ -87,4 +90,4 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
|
|
|
87
90
|
|
|
88
91
|
declare function relativeWithDot(from: string, to: string): string;
|
|
89
92
|
|
|
90
|
-
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
|
93
|
+
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory, isH3, isNitro, isNuxt, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { relative, resolve, dirname, normalize, isAbsolute, join } from 'pathe';
|
|
|
5
5
|
import { colors } from 'consola/utils';
|
|
6
6
|
import { getProperty } from 'dot-prop';
|
|
7
7
|
import { extractGraphQLSchemaToJSON as extractGraphQLSchemaToJSON$1 } from 'silgi/kit';
|
|
8
|
+
import { useSilgi } from 'silgi/core';
|
|
8
9
|
import { defu } from 'defu';
|
|
9
10
|
import { u as useSilgiCLI, c as checkSilgiCompatibility, t as tryUseSilgiCLI } from '../cli/compatibility.mjs';
|
|
10
11
|
import { existsSync, promises } from 'node:fs';
|
|
@@ -164,6 +165,28 @@ function extractGraphQLSchemaToJSON(schema) {
|
|
|
164
165
|
return result;
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
function isNuxt() {
|
|
169
|
+
const silgi = useSilgi();
|
|
170
|
+
if (silgi.options.present === "nitro" || silgi.options.present === "h3" || silgi.options.present === "nuxt") {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function isNitro() {
|
|
176
|
+
const silgi = useSilgi();
|
|
177
|
+
if (silgi.options.present === "nitro" || silgi.options.present === "h3") {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
function isH3() {
|
|
183
|
+
const silgi = useSilgi();
|
|
184
|
+
if (silgi.options.present === "h3") {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
|
|
167
190
|
function defineSilgiModule(definition) {
|
|
168
191
|
if (definition) {
|
|
169
192
|
return _defineSilgiModule(definition);
|
|
@@ -313,4 +336,4 @@ function relativeWithDot(from, to) {
|
|
|
313
336
|
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
|
|
314
337
|
}
|
|
315
338
|
|
|
316
|
-
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory$1 as isDirectory, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
|
339
|
+
export { createResolver, defineSilgiModule, defineSilgiPreset, exportGraphQLInterfaceType, extractGraphQLSchemaToJSON, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, tryResolveModule, writeFile };
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export interface PresetOptions {
|
|
|
2
2
|
}
|
|
3
3
|
export declare const presetsWithConfig: readonly [];
|
|
4
4
|
export type PresetName = "h3" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
-
export type PresetNameInput = "h3" | "nitro" | "npm-package" | "
|
|
5
|
+
export type PresetNameInput = "h3" | "nitro" | "npm-package" | "nuxt" | (string & {});
|