@snyk/error-catalog-nodejs-public 3.16.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/README.md +7 -0
- package/package.json +15 -0
- package/src/catalogs/Fix-error-catalog.d.ts +100 -0
- package/src/catalogs/Fix-error-catalog.js +180 -0
- package/src/catalogs/Fix-error-catalog.js.map +1 -0
- package/src/catalogs/IsolatedBuilds-error-catalog.d.ts +32 -0
- package/src/catalogs/IsolatedBuilds-error-catalog.js +60 -0
- package/src/catalogs/IsolatedBuilds-error-catalog.js.map +1 -0
- package/src/catalogs/OpenAPI-error-catalog.d.ts +119 -0
- package/src/catalogs/OpenAPI-error-catalog.js +215 -0
- package/src/catalogs/OpenAPI-error-catalog.js.map +1 -0
- package/src/catalogs/OpenSourceEcosystems-error-catalog.d.ts +771 -0
- package/src/catalogs/OpenSourceEcosystems-error-catalog.js +1371 -0
- package/src/catalogs/OpenSourceEcosystems-error-catalog.js.map +1 -0
- package/src/catalogs/OpenSourceProjectIssues-error-catalog.d.ts +71 -0
- package/src/catalogs/OpenSourceProjectIssues-error-catalog.js +130 -0
- package/src/catalogs/OpenSourceProjectIssues-error-catalog.js.map +1 -0
- package/src/catalogs/OpenSourceProjectSnapshots-error-catalog.d.ts +71 -0
- package/src/catalogs/OpenSourceProjectSnapshots-error-catalog.js +130 -0
- package/src/catalogs/OpenSourceProjectSnapshots-error-catalog.js.map +1 -0
- package/src/catalogs/OpenSourceUnmanaged-error-catalog.d.ts +36 -0
- package/src/catalogs/OpenSourceUnmanaged-error-catalog.js +67 -0
- package/src/catalogs/OpenSourceUnmanaged-error-catalog.js.map +1 -0
- package/src/catalogs/PurlVulnerabilityFetching-error-catalog.d.ts +290 -0
- package/src/catalogs/PurlVulnerabilityFetching-error-catalog.js +520 -0
- package/src/catalogs/PurlVulnerabilityFetching-error-catalog.js.map +1 -0
- package/src/catalogs/SbomExport-error-catalog.d.ts +130 -0
- package/src/catalogs/SbomExport-error-catalog.js +235 -0
- package/src/catalogs/SbomExport-error-catalog.js.map +1 -0
- package/src/catalogs/Snyk-error-catalog.d.ts +94 -0
- package/src/catalogs/Snyk-error-catalog.js +170 -0
- package/src/catalogs/Snyk-error-catalog.js.map +1 -0
- package/src/catalogs/error-catalog.d.ts +10 -0
- package/src/catalogs/error-catalog.js +14 -0
- package/src/catalogs/error-catalog.js.map +1 -0
- package/src/catalogs/error-codes.d.ts +138 -0
- package/src/catalogs/error-codes.js +140 -0
- package/src/catalogs/error-codes.js.map +1 -0
- package/src/composite-error.d.ts +13 -0
- package/src/composite-error.js +27 -0
- package/src/composite-error.js.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +7 -0
- package/src/index.js.map +1 -0
- package/src/problem-error.d.ts +20 -0
- package/src/problem-error.js +78 -0
- package/src/problem-error.js.map +1 -0
- package/src/types.d.ts +66 -0
- package/src/types.js +35 -0
- package/src/types.js.map +1 -0
- package/src/util/index.d.ts +1 -0
- package/src/util/index.js +5 -0
- package/src/util/index.js.map +1 -0
- package/src/util/json-api.d.ts +7 -0
- package/src/util/json-api.js +70 -0
- package/src/util/json-api.js.map +1 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
Snyk: {
|
|
3
|
+
TooManyRequests: string;
|
|
4
|
+
NotImplemented: string;
|
|
5
|
+
BadRequest: string;
|
|
6
|
+
Timeout: string;
|
|
7
|
+
Unauthorised: string;
|
|
8
|
+
Server: string;
|
|
9
|
+
};
|
|
10
|
+
OpenSourceEcosystems: {
|
|
11
|
+
UnsupportedEcosystem: string;
|
|
12
|
+
UnparseableManifest: string;
|
|
13
|
+
LockFileOutOfSync: string;
|
|
14
|
+
UnparseableLockFile: string;
|
|
15
|
+
UnknownDependencyVersion: string;
|
|
16
|
+
MissingPayload: string;
|
|
17
|
+
UnprocessableFile: string;
|
|
18
|
+
SourceNotSupported: string;
|
|
19
|
+
CannotGetFileFromSource: string;
|
|
20
|
+
NoReleasedVersionForVersionsRange: string;
|
|
21
|
+
TimeoutWhenProcessingTheDepTree: string;
|
|
22
|
+
TooManyManifestFiles: string;
|
|
23
|
+
FailedToApplyDependencyUpdates: string;
|
|
24
|
+
UnknownBlobEncodingOnGithub: string;
|
|
25
|
+
NoResultsFromForkerProcesses: string;
|
|
26
|
+
ChildProcessExecution: string;
|
|
27
|
+
NoValidPackageUpgrades: string;
|
|
28
|
+
NoDependencyUpdates: string;
|
|
29
|
+
MissingRequiredRequestHeader: string;
|
|
30
|
+
CouldNotParseJSONFile: string;
|
|
31
|
+
Base64Encode: string;
|
|
32
|
+
Base64Decode: string;
|
|
33
|
+
MissingSupportedFile: string;
|
|
34
|
+
MissingEnvironmentVariable: string;
|
|
35
|
+
NoOutputFromIsolatedBuilds: string;
|
|
36
|
+
FailedToRelock: string;
|
|
37
|
+
InvalidConfiguration: string;
|
|
38
|
+
UnsupportedManifestFile: string;
|
|
39
|
+
UnsupportedTargetFramework: string;
|
|
40
|
+
PrivateModule: string;
|
|
41
|
+
GoModFileMissing: string;
|
|
42
|
+
SsoReAuthRequired: string;
|
|
43
|
+
IncompleteProject: string;
|
|
44
|
+
MissingRequirementFromPom: string;
|
|
45
|
+
UnableToResolveValueForProperty: string;
|
|
46
|
+
UnableToResolveVersionForProperty: string;
|
|
47
|
+
CyclicPropertyDetectedInPomFile: string;
|
|
48
|
+
UnableToParseXML: string;
|
|
49
|
+
InvalidCoordinates: string;
|
|
50
|
+
SkippedGroup: string;
|
|
51
|
+
PomFileNotFound: string;
|
|
52
|
+
MissingProjectFromPom: string;
|
|
53
|
+
CannotResolveTargetPomFromXml: string;
|
|
54
|
+
CannotResolveTargetPomFromRepo: string;
|
|
55
|
+
CannotGetBuildFileFromRepo: string;
|
|
56
|
+
CannotCreateGitHost: string;
|
|
57
|
+
NoRepoFoundForTheNPMPackage: string;
|
|
58
|
+
CouldNotParseNPMRegistryURL: string;
|
|
59
|
+
CouldNotFindBrokerURL: string;
|
|
60
|
+
UnableToReplaceBrokerURL: string;
|
|
61
|
+
BadNPMVersion: string;
|
|
62
|
+
UnsupportedRequirementsFile: string;
|
|
63
|
+
};
|
|
64
|
+
PurlVulnerabilityFetching: {
|
|
65
|
+
OrganizationNotWhitelisted: string;
|
|
66
|
+
AuthorizationRequestFailure: string;
|
|
67
|
+
InvalidPurl: string;
|
|
68
|
+
NamespaceNotProvided: string;
|
|
69
|
+
UnsupportedEcosystem: string;
|
|
70
|
+
MissingComponent: string;
|
|
71
|
+
ComponentNotSupported: string;
|
|
72
|
+
UnsupportedGoVersionFormat: string;
|
|
73
|
+
PackageNotFound: string;
|
|
74
|
+
VulnerabilityServiceUnavailable: string;
|
|
75
|
+
VulnDBInvalidResponse: string;
|
|
76
|
+
VulndbNext: string;
|
|
77
|
+
InternalServer: string;
|
|
78
|
+
InvalidPaginationParameters: string;
|
|
79
|
+
TooManyPurls: string;
|
|
80
|
+
TooManyIssues: string;
|
|
81
|
+
UndefinedContainerDistro: string;
|
|
82
|
+
UnsupportedDebianDistro: string;
|
|
83
|
+
UndefinedContainerVendor: string;
|
|
84
|
+
UnsupportedContainerVendor: string;
|
|
85
|
+
};
|
|
86
|
+
IsolatedBuilds: {
|
|
87
|
+
InvalidRequest: string;
|
|
88
|
+
BuildEnvironmentNotFound: string;
|
|
89
|
+
};
|
|
90
|
+
OpenSourceProjectSnapshots: {
|
|
91
|
+
InvalidRequest: string;
|
|
92
|
+
InvalidResponse: string;
|
|
93
|
+
DataTransformation: string;
|
|
94
|
+
StorageFailure: string;
|
|
95
|
+
InternalServer: string;
|
|
96
|
+
};
|
|
97
|
+
OpenSourceProjectIssues: {
|
|
98
|
+
InvalidRequest: string;
|
|
99
|
+
InvalidResponse: string;
|
|
100
|
+
DataTransformation: string;
|
|
101
|
+
StorageFailure: string;
|
|
102
|
+
InternalServer: string;
|
|
103
|
+
};
|
|
104
|
+
OpenAPI: {
|
|
105
|
+
BadRequest: string;
|
|
106
|
+
Forbidden: string;
|
|
107
|
+
NotAcceptable: string;
|
|
108
|
+
NotFound: string;
|
|
109
|
+
MethodNotAllowed: string;
|
|
110
|
+
RequestEntityTooLarge: string;
|
|
111
|
+
Unauthorized: string;
|
|
112
|
+
UnsupportedMediaType: string;
|
|
113
|
+
};
|
|
114
|
+
OpenSourceUnmanaged: {
|
|
115
|
+
MavenSearchServiceUnavailable: string;
|
|
116
|
+
Sha1NotFound: string;
|
|
117
|
+
};
|
|
118
|
+
SbomExport: {
|
|
119
|
+
InternalServer: string;
|
|
120
|
+
UnexpectedDepGraphResponse: string;
|
|
121
|
+
UnexpectedParseDepGraph: string;
|
|
122
|
+
IaCOrSASTProject: string;
|
|
123
|
+
UnsupportedProject: string;
|
|
124
|
+
DepGraphResponse: string;
|
|
125
|
+
MissingAuthToken: string;
|
|
126
|
+
EmptyRequestBody: string;
|
|
127
|
+
InvalidDepGraph: string;
|
|
128
|
+
};
|
|
129
|
+
Fix: {
|
|
130
|
+
FailedToGetPullRequestAttributes: string;
|
|
131
|
+
PullRequestTemplateNotFound: string;
|
|
132
|
+
FailedToCompilePrTemplate: string;
|
|
133
|
+
FailedToParsePullRequestAttributes: string;
|
|
134
|
+
FailedToLoadCompiledYaml: string;
|
|
135
|
+
FailedToGenerateHash: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
export default _default;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
Snyk: {
|
|
5
|
+
TooManyRequests: 'SNYK-0001',
|
|
6
|
+
NotImplemented: 'SNYK-0002',
|
|
7
|
+
BadRequest: 'SNYK-0003',
|
|
8
|
+
Timeout: 'SNYK-0004',
|
|
9
|
+
Unauthorised: 'SNYK-0005',
|
|
10
|
+
Server: 'SNYK-9999',
|
|
11
|
+
},
|
|
12
|
+
OpenSourceEcosystems: {
|
|
13
|
+
UnsupportedEcosystem: 'SNYK-OS-0001',
|
|
14
|
+
UnparseableManifest: 'SNYK-OS-0002',
|
|
15
|
+
LockFileOutOfSync: 'SNYK-OS-0003',
|
|
16
|
+
UnparseableLockFile: 'SNYK-OS-0004',
|
|
17
|
+
UnknownDependencyVersion: 'SNYK-OS-0005',
|
|
18
|
+
MissingPayload: 'SNYK-OS-0006',
|
|
19
|
+
UnprocessableFile: 'SNYK-OS-0007',
|
|
20
|
+
SourceNotSupported: 'SNYK-OS-0008',
|
|
21
|
+
CannotGetFileFromSource: 'SNYK-OS-0009',
|
|
22
|
+
NoReleasedVersionForVersionsRange: 'SNYK-OS-0010',
|
|
23
|
+
TimeoutWhenProcessingTheDepTree: 'SNYK-OS-0011',
|
|
24
|
+
TooManyManifestFiles: 'SNYK-OS-0012',
|
|
25
|
+
FailedToApplyDependencyUpdates: 'SNYK-OS-0013',
|
|
26
|
+
UnknownBlobEncodingOnGithub: 'SNYK-OS-0014',
|
|
27
|
+
NoResultsFromForkerProcesses: 'SNYK-OS-0015',
|
|
28
|
+
ChildProcessExecution: 'SNYK-OS-0016',
|
|
29
|
+
NoValidPackageUpgrades: 'SNYK-OS-0017',
|
|
30
|
+
NoDependencyUpdates: 'SNYK-OS-0018',
|
|
31
|
+
MissingRequiredRequestHeader: 'SNYK-OS-0019',
|
|
32
|
+
CouldNotParseJSONFile: 'SNYK-OS-0020',
|
|
33
|
+
Base64Encode: 'SNYK-OS-0021',
|
|
34
|
+
Base64Decode: 'SNYK-OS-0022',
|
|
35
|
+
MissingSupportedFile: 'SNYK-OS-0023',
|
|
36
|
+
MissingEnvironmentVariable: 'SNYK-OS-0024',
|
|
37
|
+
NoOutputFromIsolatedBuilds: 'SNYK-OS-0025',
|
|
38
|
+
FailedToRelock: 'SNYK-OS-0026',
|
|
39
|
+
InvalidConfiguration: 'SNYK-OS-0027',
|
|
40
|
+
UnsupportedManifestFile: 'SNYK-OS-DOTNET-0001',
|
|
41
|
+
UnsupportedTargetFramework: 'SNYK-OS-DOTNET-0002',
|
|
42
|
+
PrivateModule: 'SNYK-OS-GO-0001',
|
|
43
|
+
GoModFileMissing: 'SNYK-OS-GO-0002',
|
|
44
|
+
SsoReAuthRequired: 'SNYK-OS-GO-0003',
|
|
45
|
+
IncompleteProject: 'SNYK-OS-GO-0004',
|
|
46
|
+
MissingRequirementFromPom: 'SNYK-OS-MAVEN-0001',
|
|
47
|
+
UnableToResolveValueForProperty: 'SNYK-OS-MAVEN-0002',
|
|
48
|
+
UnableToResolveVersionForProperty: 'SNYK-OS-MAVEN-0003',
|
|
49
|
+
CyclicPropertyDetectedInPomFile: 'SNYK-OS-MAVEN-0004',
|
|
50
|
+
UnableToParseXML: 'SNYK-OS-MAVEN-0005',
|
|
51
|
+
InvalidCoordinates: 'SNYK-OS-MAVEN-0006',
|
|
52
|
+
SkippedGroup: 'SNYK-OS-MAVEN-0007',
|
|
53
|
+
PomFileNotFound: 'SNYK-OS-MAVEN-0008',
|
|
54
|
+
MissingProjectFromPom: 'SNYK-OS-MAVEN-0009',
|
|
55
|
+
CannotResolveTargetPomFromXml: 'SNYK-OS-MAVEN-0010',
|
|
56
|
+
CannotResolveTargetPomFromRepo: 'SNYK-OS-MAVEN-0011',
|
|
57
|
+
CannotGetBuildFileFromRepo: 'SNYK-OS-MAVEN-0012',
|
|
58
|
+
CannotCreateGitHost: 'SNYK-OS-MAVEN-0013',
|
|
59
|
+
NoRepoFoundForTheNPMPackage: 'SNYK-OS-NODEJS-0001',
|
|
60
|
+
CouldNotParseNPMRegistryURL: 'SNYK-OS-NODEJS-0002',
|
|
61
|
+
CouldNotFindBrokerURL: 'SNYK-OS-NODEJS-0003',
|
|
62
|
+
UnableToReplaceBrokerURL: 'SNYK-OS-NODEJS-0004',
|
|
63
|
+
BadNPMVersion: 'SNYK-OS-NODEJS-0005',
|
|
64
|
+
UnsupportedRequirementsFile: 'SNYK-OS-PIP-0001',
|
|
65
|
+
},
|
|
66
|
+
PurlVulnerabilityFetching: {
|
|
67
|
+
OrganizationNotWhitelisted: 'SNYK-OSSI-1040',
|
|
68
|
+
AuthorizationRequestFailure: 'SNYK-OSSI-1050',
|
|
69
|
+
InvalidPurl: 'SNYK-OSSI-2010',
|
|
70
|
+
NamespaceNotProvided: 'SNYK-OSSI-2011',
|
|
71
|
+
UnsupportedEcosystem: 'SNYK-OSSI-2020',
|
|
72
|
+
MissingComponent: 'SNYK-OSSI-2021',
|
|
73
|
+
ComponentNotSupported: 'SNYK-OSSI-2022',
|
|
74
|
+
UnsupportedGoVersionFormat: 'SNYK-OSSI-2023',
|
|
75
|
+
PackageNotFound: 'SNYK-OSSI-2030',
|
|
76
|
+
VulnerabilityServiceUnavailable: 'SNYK-OSSI-2031',
|
|
77
|
+
VulnDBInvalidResponse: 'SNYK-OSSI-2032',
|
|
78
|
+
VulndbNext: 'SNYK-OSSI-2033',
|
|
79
|
+
InternalServer: 'SNYK-OSSI-2040',
|
|
80
|
+
InvalidPaginationParameters: 'SNYK-OSSI-2041',
|
|
81
|
+
TooManyPurls: 'SNYK-OSSI-2042',
|
|
82
|
+
TooManyIssues: 'SNYK-OSSI-2043',
|
|
83
|
+
UndefinedContainerDistro: 'SNYK-OSSI-2044',
|
|
84
|
+
UnsupportedDebianDistro: 'SNYK-OSSI-2045',
|
|
85
|
+
UndefinedContainerVendor: 'SNYK-OSSI-2046',
|
|
86
|
+
UnsupportedContainerVendor: 'SNYK-OSSI-2047',
|
|
87
|
+
},
|
|
88
|
+
IsolatedBuilds: {
|
|
89
|
+
InvalidRequest: 'SNYK-OS-8001',
|
|
90
|
+
BuildEnvironmentNotFound: 'SNYK-OS-8002',
|
|
91
|
+
},
|
|
92
|
+
OpenSourceProjectSnapshots: {
|
|
93
|
+
InvalidRequest: 'SNYK-OSSI-OSPSS-1001',
|
|
94
|
+
InvalidResponse: 'SNYK-OSSI-OSPSS-1002',
|
|
95
|
+
DataTransformation: 'SNYK-OSSI-OSPSS-2001',
|
|
96
|
+
StorageFailure: 'SNYK-OSSI-OSPSS-3001',
|
|
97
|
+
InternalServer: 'SNYK-OSSI-OSPSS-4001',
|
|
98
|
+
},
|
|
99
|
+
OpenSourceProjectIssues: {
|
|
100
|
+
InvalidRequest: 'SNYK-OSSI-OSPI-1001',
|
|
101
|
+
InvalidResponse: 'SNYK-OSSI-OSPI-1002',
|
|
102
|
+
DataTransformation: 'SNYK-OSSI-OSPI-2001',
|
|
103
|
+
StorageFailure: 'SNYK-OSSI-OSPI-3001',
|
|
104
|
+
InternalServer: 'SNYK-OSSI-OSPI-4001',
|
|
105
|
+
},
|
|
106
|
+
OpenAPI: {
|
|
107
|
+
BadRequest: 'SNYK-OPENAPI-0001',
|
|
108
|
+
Forbidden: 'SNYK-OPENAPI-0002',
|
|
109
|
+
NotAcceptable: 'SNYK-OPENAPI-0003',
|
|
110
|
+
NotFound: 'SNYK-OPENAPI-0004',
|
|
111
|
+
MethodNotAllowed: 'SNYK-OPENAPI-0005',
|
|
112
|
+
RequestEntityTooLarge: 'SNYK-OPENAPI-0006',
|
|
113
|
+
Unauthorized: 'SNYK-OPENAPI-0007',
|
|
114
|
+
UnsupportedMediaType: 'SNYK-OPENAPI-0008',
|
|
115
|
+
},
|
|
116
|
+
OpenSourceUnmanaged: {
|
|
117
|
+
MavenSearchServiceUnavailable: 'SNYK-OSJVM-001',
|
|
118
|
+
Sha1NotFound: 'SNYK-OSJVM-002',
|
|
119
|
+
},
|
|
120
|
+
SbomExport: {
|
|
121
|
+
InternalServer: 'SNYK-OS-9000',
|
|
122
|
+
UnexpectedDepGraphResponse: 'SNYK-OS-9001',
|
|
123
|
+
UnexpectedParseDepGraph: 'SNYK-OS-9002',
|
|
124
|
+
IaCOrSASTProject: 'SNYK-OS-9003',
|
|
125
|
+
UnsupportedProject: 'SNYK-OS-9004',
|
|
126
|
+
DepGraphResponse: 'SNYK-OS-9005',
|
|
127
|
+
MissingAuthToken: 'SNYK-OS-9006',
|
|
128
|
+
EmptyRequestBody: 'SNYK-OS-9007',
|
|
129
|
+
InvalidDepGraph: 'SNYK-OS-9008',
|
|
130
|
+
},
|
|
131
|
+
Fix: {
|
|
132
|
+
FailedToGetPullRequestAttributes: 'SNYK-PR-TEMPLATE-0001',
|
|
133
|
+
PullRequestTemplateNotFound: 'SNYK-PR-TEMPLATE-0002',
|
|
134
|
+
FailedToCompilePrTemplate: 'SNYK-PR-TEMPLATE-0003',
|
|
135
|
+
FailedToParsePullRequestAttributes: 'SNYK-PR-TEMPLATE-0004',
|
|
136
|
+
FailedToLoadCompiledYaml: 'SNYK-PR-TEMPLATE-0005',
|
|
137
|
+
FailedToGenerateHash: 'SNYK-PR-TEMPLATE-0006',
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../../../../../packages/error-catalog-nodejs-public/src/catalogs/error-codes.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACX,IAAI,EAAE;QACJ,eAAe,EAAE,WAAW;QAC5B,cAAc,EAAE,WAAW;QAC3B,UAAU,EAAE,WAAW;QACvB,OAAO,EAAE,WAAW;QACpB,YAAY,EAAE,WAAW;QACzB,MAAM,EAAE,WAAW;KACpB;IACD,oBAAoB,EAAE;QACpB,oBAAoB,EAAE,cAAc;QACpC,mBAAmB,EAAE,cAAc;QACnC,iBAAiB,EAAE,cAAc;QACjC,mBAAmB,EAAE,cAAc;QACnC,wBAAwB,EAAE,cAAc;QACxC,cAAc,EAAE,cAAc;QAC9B,iBAAiB,EAAE,cAAc;QACjC,kBAAkB,EAAE,cAAc;QAClC,uBAAuB,EAAE,cAAc;QACvC,iCAAiC,EAAE,cAAc;QACjD,+BAA+B,EAAE,cAAc;QAC/C,oBAAoB,EAAE,cAAc;QACpC,8BAA8B,EAAE,cAAc;QAC9C,2BAA2B,EAAE,cAAc;QAC3C,4BAA4B,EAAE,cAAc;QAC5C,qBAAqB,EAAE,cAAc;QACrC,sBAAsB,EAAE,cAAc;QACtC,mBAAmB,EAAE,cAAc;QACn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ChC,gBAAgB,EAAE,cAAc;QAChC,gBAAgB,EAAE,cAAc;QAChC,eAAe,EAAE,cAAc;KAChC;IACD,GAAG,EAAE;QACH,gCAAgC,EAAE,uBAAuB;QACzD,2BAA2B,EAAE,uBAAuB;QACpD,yBAAyB,EAAE,uBAAuB;QAClD,kCAAkC,EAAE,uBAAuB;QAC3D,wBAAwB,EAAE,uBAAuB;QACjD,oBAAoB,EAAE,uBAAuB;KAC9C;CACJ,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JsonApi } from './types';
|
|
2
|
+
import { ProblemError } from './problem-error';
|
|
3
|
+
export declare class CompositeError extends Error {
|
|
4
|
+
readonly errors: Array<ProblemError>;
|
|
5
|
+
constructor(errors: Array<ProblemError>);
|
|
6
|
+
/**
|
|
7
|
+
* Convert this CompositeError to JsonApi.
|
|
8
|
+
* If the error was created with 'instance' metadata then that will be used by default for all errors.
|
|
9
|
+
* @param instance string the instance to use for the errors in this CompositeError. Overrides 'instance' metadata
|
|
10
|
+
* @returns JsonApi a JsonApi object representing this CompositeError
|
|
11
|
+
*/
|
|
12
|
+
toJsonApi(instance?: string): JsonApi;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositeError = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
class CompositeError extends Error {
|
|
6
|
+
constructor(errors) {
|
|
7
|
+
super('CompositeError');
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Convert this CompositeError to JsonApi.
|
|
12
|
+
* If the error was created with 'instance' metadata then that will be used by default for all errors.
|
|
13
|
+
* @param instance string the instance to use for the errors in this CompositeError. Overrides 'instance' metadata
|
|
14
|
+
* @returns JsonApi a JsonApi object representing this CompositeError
|
|
15
|
+
*/
|
|
16
|
+
toJsonApi(instance) {
|
|
17
|
+
const payload = {
|
|
18
|
+
jsonapi: {
|
|
19
|
+
version: '1.0',
|
|
20
|
+
},
|
|
21
|
+
errors: this.errors.map((error) => error.toJsonApiErrorObject(instance)),
|
|
22
|
+
};
|
|
23
|
+
return new types_1.JsonApi(payload);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CompositeError = CompositeError;
|
|
27
|
+
//# sourceMappingURL=composite-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-error.js","sourceRoot":"","sources":["../../../../packages/error-catalog-nodejs-public/src/composite-error.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AAGrE,MAAa,cAAe,SAAQ,KAAK;IAEvC,YAAY,MAA2B;QACrC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,QAAiB;QACzB,MAAM,OAAO,GAAkB;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;aACf;YACD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAChC,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CACb;SAC1B,CAAC;QAEF,OAAO,IAAI,eAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AAzBD,wCAyBC"}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./problem-error"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./catalogs/error-catalog"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./composite-error"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/error-catalog-nodejs-public/src/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,mEAAyC;AACzC,4DAAkC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ErrorFormats, ErrorMetadata, JsonApi, JsonApiErrorObject, ProblemJson } from './types';
|
|
2
|
+
export declare class ProblemError extends Error {
|
|
3
|
+
readonly metadata: ErrorMetadata;
|
|
4
|
+
readonly detail: string;
|
|
5
|
+
readonly additionalData?: Record<string, any> | undefined;
|
|
6
|
+
readonly cause?: Error | undefined;
|
|
7
|
+
private id;
|
|
8
|
+
readonly isErrorCatalogError = true;
|
|
9
|
+
constructor(metadata: ErrorMetadata, detail: string, additionalData?: Record<string, any> | undefined, cause?: Error | undefined);
|
|
10
|
+
format(instance: string, formatType: ErrorFormats): ProblemJson | JsonApi;
|
|
11
|
+
toProblemJson(instance: string): ProblemJson;
|
|
12
|
+
/**
|
|
13
|
+
* Convert this ProblemError to a JsonApiErrorObject.
|
|
14
|
+
* If the error was created with 'instance' metadata then that will be used by default.
|
|
15
|
+
* @param instance string the instance to use for this error. Overrides 'instance' metadata
|
|
16
|
+
* @returns JsonApiErrorObject a JsonApiErrorObject representing this ProblemError
|
|
17
|
+
*/
|
|
18
|
+
toJsonApiErrorObject(instance?: string): JsonApiErrorObject;
|
|
19
|
+
toJsonApi(instance?: string): JsonApi;
|
|
20
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProblemError = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const util_1 = require("./util");
|
|
7
|
+
class ProblemError extends Error {
|
|
8
|
+
constructor(metadata, detail, additionalData, cause) {
|
|
9
|
+
super(metadata.title);
|
|
10
|
+
this.metadata = metadata;
|
|
11
|
+
this.detail = detail;
|
|
12
|
+
this.additionalData = additionalData;
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
// Since `instanceof` cannot be relied upon for class checks in situations where the `ProblemError` was thrown from a dependency of the executing app, we need a more viable solution.
|
|
15
|
+
// See: https://stackoverflow.com/questions/41587865/using-instanceof-on-objects-created-with-constructors-from-deep-npm-dependenci/41592087#41592087
|
|
16
|
+
this.isErrorCatalogError = true;
|
|
17
|
+
if (additionalData && additionalData['overrideErrorId']) {
|
|
18
|
+
this.id = additionalData['overrideErrorId'];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.id = (0, uuid_1.v4)();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
format(instance, formatType) {
|
|
25
|
+
switch (formatType) {
|
|
26
|
+
case types_1.ErrorFormats.JsonApi:
|
|
27
|
+
return this.toJsonApi(instance);
|
|
28
|
+
case types_1.ErrorFormats.ProblemJson:
|
|
29
|
+
return this.toProblemJson(instance);
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('invalid format type');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
toProblemJson(instance) {
|
|
35
|
+
const payload = Object.assign({ type: this.metadata.type, title: this.metadata.title, status: this.metadata.status, errorCode: this.metadata.errorCode, detail: this.detail, instance }, this.additionalData);
|
|
36
|
+
return new types_1.ProblemJson(payload);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Convert this ProblemError to a JsonApiErrorObject.
|
|
40
|
+
* If the error was created with 'instance' metadata then that will be used by default.
|
|
41
|
+
* @param instance string the instance to use for this error. Overrides 'instance' metadata
|
|
42
|
+
* @returns JsonApiErrorObject a JsonApiErrorObject representing this ProblemError
|
|
43
|
+
*/
|
|
44
|
+
toJsonApiErrorObject(instance) {
|
|
45
|
+
let source;
|
|
46
|
+
// Get the instance from either the member or the parameter
|
|
47
|
+
const theinstance = instance || this.metadata.instance;
|
|
48
|
+
if (typeof theinstance === 'string') {
|
|
49
|
+
source = (0, util_1.instanceToJsonApiSource)(theinstance);
|
|
50
|
+
}
|
|
51
|
+
const jsonApiErrorObject = {
|
|
52
|
+
id: this.id,
|
|
53
|
+
links: {
|
|
54
|
+
about: this.metadata.type,
|
|
55
|
+
},
|
|
56
|
+
status: String(this.metadata.status),
|
|
57
|
+
code: this.metadata.errorCode,
|
|
58
|
+
title: this.metadata.title,
|
|
59
|
+
detail: this.detail,
|
|
60
|
+
meta: Object.assign({}, this.additionalData),
|
|
61
|
+
};
|
|
62
|
+
if (source) {
|
|
63
|
+
jsonApiErrorObject.source = source;
|
|
64
|
+
}
|
|
65
|
+
return jsonApiErrorObject;
|
|
66
|
+
}
|
|
67
|
+
toJsonApi(instance) {
|
|
68
|
+
const payload = {
|
|
69
|
+
jsonapi: {
|
|
70
|
+
version: '1.0',
|
|
71
|
+
},
|
|
72
|
+
errors: [this.toJsonApiErrorObject(instance)],
|
|
73
|
+
};
|
|
74
|
+
return new types_1.JsonApi(payload);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.ProblemError = ProblemError;
|
|
78
|
+
//# sourceMappingURL=problem-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem-error.js","sourceRoot":"","sources":["../../../../packages/error-catalog-nodejs-public/src/problem-error.ts"],"names":[],"mappings":";;;AAAA,mCAQiB;AACjB,+BAA0B;AAC1B,iCAAiD;AAEjD,MAAa,YAAa,SAAQ,KAAK;IAOrC,YACkB,QAAuB,EACvB,MAAc,EACd,cAAoC,EACpC,KAAa;QAE7B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QALN,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAQ;QACd,mBAAc,GAAd,cAAc,CAAsB;QACpC,UAAK,GAAL,KAAK,CAAQ;QAR/B,sLAAsL;QACtL,qJAAqJ;QACrI,wBAAmB,GAAG,IAAI,CAAC;QASzC,IAAI,cAAc,IAAI,cAAc,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AK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;aAC1B;YACD,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS;YAC7B,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,oBACC,IAAI,CAAC,cAAc,CACvB;SACF,CAAC;QACF,IAAI,MAAM,EAAE;YACV,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAC;SACpC;QACD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,SAAS,CAAC,QAAiB;QACzB,MAAM,OAAO,GAAkB;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;aACf;YACD,MAAM,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;SAC9C,CAAC;QAEF,OAAO,IAAI,eAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AA1FD,oCA0FC"}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type Problem = {
|
|
2
|
+
/** A URI reference that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type. */
|
|
3
|
+
type: string;
|
|
4
|
+
/** A short, human-readable summary of the problem type. This should not chance from occurrence to occurrence of the problem.*/
|
|
5
|
+
title: string;
|
|
6
|
+
/** A human-readable explanation specific to this occurrence of the problem. */
|
|
7
|
+
detail: string;
|
|
8
|
+
/** The HTTP status code generated by the origin server for this occurrence of the problem. */
|
|
9
|
+
status: number;
|
|
10
|
+
/** An internal code for the error that occurred. */
|
|
11
|
+
errorCode: string;
|
|
12
|
+
/** A URI that identifies the specific occurrence of the problem. */
|
|
13
|
+
instance?: string;
|
|
14
|
+
/** The level of this error */
|
|
15
|
+
level?: string;
|
|
16
|
+
/** Additional properties. */
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export type ErrorMetadata = Pick<Problem, 'type' | 'title' | 'status' | 'errorCode' | 'level' | 'instance'>;
|
|
20
|
+
export declare enum ErrorFormats {
|
|
21
|
+
JsonApi = 0,
|
|
22
|
+
ProblemJson = 1
|
|
23
|
+
}
|
|
24
|
+
export interface ErrorFormat {
|
|
25
|
+
headers(): Record<string, string>;
|
|
26
|
+
body(): Problem | JsonApiErrors;
|
|
27
|
+
}
|
|
28
|
+
export declare class ProblemJson implements ErrorFormat {
|
|
29
|
+
private readonly payload;
|
|
30
|
+
constructor(payload: Problem);
|
|
31
|
+
headers(): Record<string, string>;
|
|
32
|
+
body(): Problem | JsonApiErrors;
|
|
33
|
+
}
|
|
34
|
+
export type JsonApiErrorSource = {
|
|
35
|
+
pointer: string;
|
|
36
|
+
} | {
|
|
37
|
+
parameter: string;
|
|
38
|
+
} | {
|
|
39
|
+
header: string;
|
|
40
|
+
};
|
|
41
|
+
export type JsonApiErrorObject = {
|
|
42
|
+
id?: string;
|
|
43
|
+
links?: {
|
|
44
|
+
about?: string;
|
|
45
|
+
};
|
|
46
|
+
status: string;
|
|
47
|
+
code: string;
|
|
48
|
+
title: string;
|
|
49
|
+
detail: string;
|
|
50
|
+
source?: JsonApiErrorSource;
|
|
51
|
+
meta?: {
|
|
52
|
+
[x: string]: any;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type JsonApiErrors = {
|
|
56
|
+
jsonapi: {
|
|
57
|
+
version: string;
|
|
58
|
+
};
|
|
59
|
+
errors: [JsonApiErrorObject];
|
|
60
|
+
};
|
|
61
|
+
export declare class JsonApi implements ErrorFormat {
|
|
62
|
+
private readonly payload;
|
|
63
|
+
constructor(payload: JsonApiErrors);
|
|
64
|
+
headers(): Record<string, string>;
|
|
65
|
+
body(): Problem | JsonApiErrors;
|
|
66
|
+
}
|
package/src/types.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonApi = exports.ProblemJson = exports.ErrorFormats = void 0;
|
|
4
|
+
var ErrorFormats;
|
|
5
|
+
(function (ErrorFormats) {
|
|
6
|
+
ErrorFormats[ErrorFormats["JsonApi"] = 0] = "JsonApi";
|
|
7
|
+
ErrorFormats[ErrorFormats["ProblemJson"] = 1] = "ProblemJson";
|
|
8
|
+
})(ErrorFormats || (exports.ErrorFormats = ErrorFormats = {}));
|
|
9
|
+
class ProblemJson {
|
|
10
|
+
constructor(payload) {
|
|
11
|
+
this.payload = payload;
|
|
12
|
+
}
|
|
13
|
+
headers() {
|
|
14
|
+
return {
|
|
15
|
+
'Content-Type': 'application/problem+json;',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
body() {
|
|
19
|
+
return this.payload;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ProblemJson = ProblemJson;
|
|
23
|
+
class JsonApi {
|
|
24
|
+
constructor(payload) {
|
|
25
|
+
this.payload = payload;
|
|
26
|
+
}
|
|
27
|
+
headers() {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
body() {
|
|
31
|
+
return this.payload;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.JsonApi = JsonApi;
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
package/src/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/error-catalog-nodejs-public/src/types.ts"],"names":[],"mappings":";;;AAwBA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qDAAO,CAAA;IACP,6DAAW,CAAA;AACb,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAQD,MAAa,WAAW;IACtB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEjD,OAAO;QACL,OAAO;YACL,cAAc,EAAE,2BAA2B;SAC5C,CAAC;IACJ,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAZD,kCAYC;AA6BD,MAAa,OAAO;IAClB,YAA6B,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAEvD,OAAO;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AATD,0BASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './json-api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/error-catalog-nodejs-public/src/util/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonApiErrorSource } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts the instance string from an error into a JsonApiErrorSource
|
|
4
|
+
* @param instance the instance string to convert
|
|
5
|
+
* @returns A JsonApiErrorSource if appropriate, or undefined if not
|
|
6
|
+
*/
|
|
7
|
+
export declare const instanceToJsonApiSource: (instance: string) => JsonApiErrorSource | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instanceToJsonApiSource = void 0;
|
|
4
|
+
const SOURCE_REGEXP = /^\/(query|params|body|headers)\/.*/;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the instance string from an error into a JsonApiErrorSource
|
|
7
|
+
* @param instance the instance string to convert
|
|
8
|
+
* @returns A JsonApiErrorSource if appropriate, or undefined if not
|
|
9
|
+
*/
|
|
10
|
+
const instanceToJsonApiSource = (instance) => {
|
|
11
|
+
let source;
|
|
12
|
+
// See if the instance conforms to one of the source formats
|
|
13
|
+
const matchErrorPath = instance.match(SOURCE_REGEXP);
|
|
14
|
+
// If the match captures the path type and parameter,
|
|
15
|
+
if (matchErrorPath !== null && matchErrorPath.length > 0) {
|
|
16
|
+
// Convert the instance into a source
|
|
17
|
+
switch (matchErrorPath[1]) {
|
|
18
|
+
case 'query':
|
|
19
|
+
case 'params':
|
|
20
|
+
source = paramsInstanceToJsonApiSource(instance);
|
|
21
|
+
break;
|
|
22
|
+
case 'body':
|
|
23
|
+
source = bodyInstanceToJsonApiSource(instance);
|
|
24
|
+
break;
|
|
25
|
+
case 'headers':
|
|
26
|
+
source = headerInstanceToJsonApiSource(instance);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return source;
|
|
31
|
+
};
|
|
32
|
+
exports.instanceToJsonApiSource = instanceToJsonApiSource;
|
|
33
|
+
// For a parameter, do not include the leading slash
|
|
34
|
+
const PARAMETER_REGEXP = /^\/(?:params|query)\/(.*)/;
|
|
35
|
+
const paramsInstanceToJsonApiSource = (instance) => {
|
|
36
|
+
let parameter = '';
|
|
37
|
+
// The source is the name of the parameter, and is not a json path
|
|
38
|
+
const matches = instance.match(PARAMETER_REGEXP);
|
|
39
|
+
if (matches !== null && matches.length > 0) {
|
|
40
|
+
parameter = matches[1];
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
parameter,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// For a pointer, capture the JSON path, including the leading slash
|
|
47
|
+
const POINTER_REGEXP = /^\/body(\/.*)/;
|
|
48
|
+
const bodyInstanceToJsonApiSource = (instance) => {
|
|
49
|
+
let pointer = '';
|
|
50
|
+
const matches = instance.match(POINTER_REGEXP);
|
|
51
|
+
if (matches !== null && matches.length > 0) {
|
|
52
|
+
pointer = matches[1];
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
pointer,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
// The source is the name of the header, and is not a json path
|
|
59
|
+
const HEADER_REGEXP = /^\/headers\/(.*)/;
|
|
60
|
+
const headerInstanceToJsonApiSource = (instance) => {
|
|
61
|
+
let header = '';
|
|
62
|
+
const matches = instance.match(HEADER_REGEXP);
|
|
63
|
+
if (matches !== null && matches.length > 0) {
|
|
64
|
+
header = matches[1];
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
header,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=json-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../../packages/error-catalog-nodejs-public/src/util/json-api.ts"],"names":[],"mappings":";;;AAEA,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAE3D;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,CACrC,QAAgB,EACgB,EAAE;IAClC,IAAI,MAAM,CAAC;IAEX,4DAA4D;IAC5D,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACrD,qDAAqD;IACrD,IAAI,cAAc,KAAK,IAAI,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACxD,qCAAqC;QACrC,QAAQ,cAAc,CAAC,CAAC,CAAC,EAAE;YACzB,KAAK,OAAO,CAAC;YACb,KAAK,QAAQ;gBACX,MAAM,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;gBACjD,MAAM;YACR,KAAK,MAAM;gBACT,MAAM,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAC;gBAC/C,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;gBACjD,MAAM;SACT;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAzBW,QAAA,uBAAuB,2BAyBlC;AAEF,oDAAoD;AACpD,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAErD,MAAM,6BAA6B,GAAG,CACpC,QAAgB,EACI,EAAE;IACtB,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,kEAAkE;IAClE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