@hideyukimori/nene2-client 0.1.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/LICENSE +21 -0
- package/README.md +138 -0
- package/dist/client/config.d.ts +26 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +19 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/create-nene2-client.d.ts +92 -0
- package/dist/client/create-nene2-client.d.ts.map +1 -0
- package/dist/client/create-nene2-client.js +54 -0
- package/dist/client/create-nene2-client.js.map +1 -0
- package/dist/client/errors.d.ts +17 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +20 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/path.d.ts +5 -0
- package/dist/client/path.d.ts.map +1 -0
- package/dist/client/path.js +17 -0
- package/dist/client/path.js.map +1 -0
- package/dist/client/request.d.ts +23 -0
- package/dist/client/request.d.ts.map +1 -0
- package/dist/client/request.js +99 -0
- package/dist/client/request.js.map +1 -0
- package/dist/client/validation-errors.d.ts +11 -0
- package/dist/client/validation-errors.d.ts.map +1 -0
- package/dist/client/validation-errors.js +28 -0
- package/dist/client/validation-errors.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/problem/constants.d.ts +7 -0
- package/dist/problem/constants.d.ts.map +1 -0
- package/dist/problem/constants.js +7 -0
- package/dist/problem/constants.js.map +1 -0
- package/dist/problem/guards.d.ts +38 -0
- package/dist/problem/guards.d.ts.map +1 -0
- package/dist/problem/guards.js +111 -0
- package/dist/problem/guards.js.map +1 -0
- package/dist/problem/index.d.ts +4 -0
- package/dist/problem/index.d.ts.map +1 -0
- package/dist/problem/index.js +3 -0
- package/dist/problem/index.js.map +1 -0
- package/dist/problem/types.d.ts +26 -0
- package/dist/problem/types.d.ts.map +1 -0
- package/dist/problem/types.js +6 -0
- package/dist/problem/types.js.map +1 -0
- package/dist/types/examples/index.d.ts +7 -0
- package/dist/types/examples/index.d.ts.map +1 -0
- package/dist/types/examples/index.js +4 -0
- package/dist/types/examples/index.js.map +1 -0
- package/dist/types/examples/notes.d.ts +28 -0
- package/dist/types/examples/notes.d.ts.map +1 -0
- package/dist/types/examples/notes.js +37 -0
- package/dist/types/examples/notes.js.map +1 -0
- package/dist/types/examples/protected.d.ts +10 -0
- package/dist/types/examples/protected.d.ts.map +1 -0
- package/dist/types/examples/protected.js +15 -0
- package/dist/types/examples/protected.js.map +1 -0
- package/dist/types/examples/tags.d.ts +23 -0
- package/dist/types/examples/tags.d.ts.map +1 -0
- package/dist/types/examples/tags.js +31 -0
- package/dist/types/examples/tags.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/system.d.ts +36 -0
- package/dist/types/system.d.ts.map +1 -0
- package/dist/types/system.js +54 -0
- package/dist/types/system.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isNene2ValidationFailedProblem } from '../problem/guards.js';
|
|
2
|
+
import { Nene2ClientError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extract RFC 9457 validation `errors` from a {@link Nene2ClientError} when present.
|
|
5
|
+
* Useful for mapping API validation failures to form fields (Persona A DX).
|
|
6
|
+
*/
|
|
7
|
+
export function validationErrorsFromClientError(error) {
|
|
8
|
+
if (!(error instanceof Nene2ClientError) || error.problem === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!isNene2ValidationFailedProblem(error.problem)) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return error.problem.errors;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Map validation errors to a plain object keyed by field name (first error per field).
|
|
18
|
+
*/
|
|
19
|
+
export function validationErrorsByField(errors) {
|
|
20
|
+
const out = {};
|
|
21
|
+
for (const item of errors) {
|
|
22
|
+
if (out[item.field] === undefined) {
|
|
23
|
+
out[item.field] = item.message;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=validation-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-errors.js","sourceRoot":"","sources":["../../src/client/validation-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAc;IAEd,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACxE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAkC;IAElC,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;YAClC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hideyukimori/nene2-client — TypeScript client for NENE2 JSON APIs.
|
|
3
|
+
* @see docs/roadmap.md
|
|
4
|
+
*/
|
|
5
|
+
export declare const NENE2_CLIENT_PACKAGE: "@hideyukimori/nene2-client";
|
|
6
|
+
export { NENE2_PROBLEM_TYPE_VALIDATION_FAILED, isNene2ValidationFailedProblem, isNene2ValidationFailedType, isProblemDetails, isValidationError, isValidationProblemDetails, parseProblemDetails, parseProblemDetailsResponse, parseValidationProblemDetails, problemDetailsExtensions, } from './problem/index.js';
|
|
7
|
+
export type { ProblemDetails, ProblemDetailsDocument, ValidationError, ValidationProblemDetails, ValidationProblemDetailsDocument, } from './problem/index.js';
|
|
8
|
+
export { createNene2Client, isNene2ClientError, Nene2ClientError, validationErrorsByField, validationErrorsFromClientError, type HealthOptions, type Nene2Client, type Nene2ClientConfig, } from './client/index.js';
|
|
9
|
+
export type { CreateNoteRequest, CreateTagRequest, ExampleNote, ExampleNoteListResponse, ExamplePingResponse, ExampleTag, ExampleTagListResponse, FrameworkSmokeResponse, HealthResponse, HealthStatus, ListNotesParams, ListTagsParams, MachineHealthResponse, ProtectedResponse, SmokeCheckResult, } from './types/index.js';
|
|
10
|
+
export { isCreateNoteRequest, isCreateTagRequest, isExampleNoteListResponse, isExampleNoteResponse, isExamplePingResponse, isExampleTagListResponse, isExampleTagResponse, isFrameworkSmokeResponse, isHealthResponse, isMachineHealthResponse, isProtectedResponse, } from './types/index.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAG,4BAAqC,CAAC;AAE1E,OAAO,EACL,oCAAoC,EACpC,8BAA8B,EAC9B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,+BAA+B,EAC/B,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hideyukimori/nene2-client — TypeScript client for NENE2 JSON APIs.
|
|
3
|
+
* @see docs/roadmap.md
|
|
4
|
+
*/
|
|
5
|
+
export const NENE2_CLIENT_PACKAGE = '@hideyukimori/nene2-client';
|
|
6
|
+
export { NENE2_PROBLEM_TYPE_VALIDATION_FAILED, isNene2ValidationFailedProblem, isNene2ValidationFailedType, isProblemDetails, isValidationError, isValidationProblemDetails, parseProblemDetails, parseProblemDetailsResponse, parseValidationProblemDetails, problemDetailsExtensions, } from './problem/index.js';
|
|
7
|
+
export { createNene2Client, isNene2ClientError, Nene2ClientError, validationErrorsByField, validationErrorsFromClientError, } from './client/index.js';
|
|
8
|
+
export { isCreateNoteRequest, isCreateTagRequest, isExampleNoteListResponse, isExampleNoteResponse, isExamplePingResponse, isExampleTagListResponse, isExampleTagResponse, isFrameworkSmokeResponse, isHealthResponse, isMachineHealthResponse, isProtectedResponse, } from './types/index.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAAqC,CAAC;AAE1E,OAAO,EACL,oCAAoC,EACpC,8BAA8B,EAC9B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,+BAA+B,GAIhC,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable NENE2 problem type URIs from the OpenAPI contract.
|
|
3
|
+
* @see contracts/openapi.yaml
|
|
4
|
+
*/
|
|
5
|
+
/** `ValidationFailed` response example (`operationId` family, HTTP 422). */
|
|
6
|
+
export declare const NENE2_PROBLEM_TYPE_VALIDATION_FAILED: "https://nene2.dev/problems/validation-failed";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/problem/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,oCAAoC,EAC/C,8CAAuD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable NENE2 problem type URIs from the OpenAPI contract.
|
|
3
|
+
* @see contracts/openapi.yaml
|
|
4
|
+
*/
|
|
5
|
+
/** `ValidationFailed` response example (`operationId` family, HTTP 422). */
|
|
6
|
+
export const NENE2_PROBLEM_TYPE_VALIDATION_FAILED = 'https://nene2.dev/problems/validation-failed';
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/problem/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oCAAoC,GAC/C,8CAAuD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ProblemDetails, ProblemDetailsDocument, ValidationError, ValidationProblemDetails, ValidationProblemDetailsDocument } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for NENE2 {@link ProblemDetails} (RFC 9457 subset).
|
|
4
|
+
*/
|
|
5
|
+
export declare function isProblemDetails(value: unknown): value is ProblemDetailsDocument;
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for a single NENE2 {@link ValidationError}.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidationError(value: unknown): value is ValidationError;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard for NENE2 {@link ValidationProblemDetails} (`errors` array, min 1 item).
|
|
12
|
+
*/
|
|
13
|
+
export declare function isValidationProblemDetails(value: unknown): value is ValidationProblemDetailsDocument;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true when `type` is NENE2 `validation-failed`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isNene2ValidationFailedType(type: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Narrows {@link ProblemDetails} to {@link ValidationProblemDetails} when validation-failed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isNene2ValidationFailedProblem(problem: ProblemDetails): problem is ValidationProblemDetails;
|
|
22
|
+
/**
|
|
23
|
+
* Parse JSON (already decoded) into Problem Details when shape matches.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseProblemDetails(value: unknown): ProblemDetailsDocument | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Parse JSON into Validation Problem Details when shape matches.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseValidationProblemDetails(value: unknown): ValidationProblemDetailsDocument | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Parse a `application/problem+json` (or JSON) response body.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseProblemDetailsResponse(response: Response): Promise<ProblemDetailsDocument | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* List extension members (non-reserved top-level fields).
|
|
36
|
+
*/
|
|
37
|
+
export declare function problemDetailsExtensions(problem: ProblemDetailsDocument): Record<string, unknown>;
|
|
38
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/problem/guards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,gCAAgC,EACjC,MAAM,YAAY,CAAC;AAYpB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAoBhF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAiB1E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,gCAAgC,CAW3C;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,cAAc,GACtB,OAAO,IAAI,wBAAwB,CAErC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAEtF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,gCAAgC,GAAG,SAAS,CAE9C;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAe7C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQjG"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { NENE2_PROBLEM_TYPE_VALIDATION_FAILED } from './constants.js';
|
|
2
|
+
const RESERVED_KEYS = new Set(['type', 'title', 'status', 'detail', 'instance', 'errors']);
|
|
3
|
+
function isPlainObject(value) {
|
|
4
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function isHttpStatus(value) {
|
|
7
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 400 && value <= 599;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Type guard for NENE2 {@link ProblemDetails} (RFC 9457 subset).
|
|
11
|
+
*/
|
|
12
|
+
export function isProblemDetails(value) {
|
|
13
|
+
if (!isPlainObject(value)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const { type, title, status, detail, instance } = value;
|
|
17
|
+
if (typeof type !== 'string' || typeof title !== 'string' || !isHttpStatus(status)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (detail !== undefined && typeof detail !== 'string') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (instance !== undefined && typeof instance !== 'string') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Type guard for a single NENE2 {@link ValidationError}.
|
|
30
|
+
*/
|
|
31
|
+
export function isValidationError(value) {
|
|
32
|
+
if (!isPlainObject(value)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const keys = Object.keys(value);
|
|
36
|
+
if (keys.length !== 3 ||
|
|
37
|
+
!keys.includes('field') ||
|
|
38
|
+
!keys.includes('message') ||
|
|
39
|
+
!keys.includes('code')) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const { field, message, code } = value;
|
|
43
|
+
return typeof field === 'string' && typeof message === 'string' && typeof code === 'string';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Type guard for NENE2 {@link ValidationProblemDetails} (`errors` array, min 1 item).
|
|
47
|
+
*/
|
|
48
|
+
export function isValidationProblemDetails(value) {
|
|
49
|
+
if (!isProblemDetails(value)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const { errors } = value;
|
|
53
|
+
if (!Array.isArray(errors) || errors.length < 1) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return errors.every(isValidationError);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns true when `type` is NENE2 `validation-failed`.
|
|
60
|
+
*/
|
|
61
|
+
export function isNene2ValidationFailedType(type) {
|
|
62
|
+
return type === NENE2_PROBLEM_TYPE_VALIDATION_FAILED;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Narrows {@link ProblemDetails} to {@link ValidationProblemDetails} when validation-failed.
|
|
66
|
+
*/
|
|
67
|
+
export function isNene2ValidationFailedProblem(problem) {
|
|
68
|
+
return isNene2ValidationFailedType(problem.type) && isValidationProblemDetails(problem);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse JSON (already decoded) into Problem Details when shape matches.
|
|
72
|
+
*/
|
|
73
|
+
export function parseProblemDetails(value) {
|
|
74
|
+
return isProblemDetails(value) ? value : undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parse JSON into Validation Problem Details when shape matches.
|
|
78
|
+
*/
|
|
79
|
+
export function parseValidationProblemDetails(value) {
|
|
80
|
+
return isValidationProblemDetails(value) ? value : undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Parse a `application/problem+json` (or JSON) response body.
|
|
84
|
+
*/
|
|
85
|
+
export async function parseProblemDetailsResponse(response) {
|
|
86
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
87
|
+
if (!contentType.includes('application/problem+json') &&
|
|
88
|
+
!contentType.includes('application/json')) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const body = await response.json();
|
|
93
|
+
return parseProblemDetails(body);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* List extension members (non-reserved top-level fields).
|
|
101
|
+
*/
|
|
102
|
+
export function problemDetailsExtensions(problem) {
|
|
103
|
+
const out = {};
|
|
104
|
+
for (const [key, value] of Object.entries(problem)) {
|
|
105
|
+
if (!RESERVED_KEYS.has(key)) {
|
|
106
|
+
out[key] = value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/problem/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AAStE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,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C;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAAc;IAEd,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,QAAkB;IAElB,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC/D,IACE,CAAC,WAAW,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACjD,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EACzC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAA+B;IACtE,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { NENE2_PROBLEM_TYPE_VALIDATION_FAILED } from './constants.js';
|
|
2
|
+
export { isNene2ValidationFailedProblem, isNene2ValidationFailedType, isProblemDetails, isValidationError, isValidationProblemDetails, parseProblemDetails, parseProblemDetailsResponse, parseValidationProblemDetails, problemDetailsExtensions, } from './guards.js';
|
|
3
|
+
export type { ProblemDetails, ProblemDetailsDocument, ValidationError, ValidationProblemDetails, ValidationProblemDetailsDocument, } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/problem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NENE2_PROBLEM_TYPE_VALIDATION_FAILED } from './constants.js';
|
|
2
|
+
export { isNene2ValidationFailedProblem, isNene2ValidationFailedType, isProblemDetails, isValidationError, isValidationProblemDetails, parseProblemDetails, parseProblemDetailsResponse, parseValidationProblemDetails, problemDetailsExtensions, } from './guards.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/problem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 9457 Problem Details types aligned with NENE2 OpenAPI schemas.
|
|
3
|
+
* @see contracts/openapi.yaml — ProblemDetails, ValidationProblemDetails, ValidationError
|
|
4
|
+
*/
|
|
5
|
+
/** NENE2 `ValidationError` schema (additionalProperties: false). */
|
|
6
|
+
export interface ValidationError {
|
|
7
|
+
readonly field: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly code: string;
|
|
10
|
+
}
|
|
11
|
+
/** NENE2 base Problem Details (required: type, title, status). */
|
|
12
|
+
export interface ProblemDetails {
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly title: string;
|
|
15
|
+
readonly status: number;
|
|
16
|
+
readonly detail?: string | undefined;
|
|
17
|
+
readonly instance?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Problem Details with `errors` (HTTP 422 validation-failed). */
|
|
20
|
+
export interface ValidationProblemDetails extends ProblemDetails {
|
|
21
|
+
readonly errors: readonly ValidationError[];
|
|
22
|
+
}
|
|
23
|
+
/** Parsed body may include RFC 9457 extension members at the top level. */
|
|
24
|
+
export type ProblemDetailsDocument = ProblemDetails & Record<string, unknown>;
|
|
25
|
+
export type ValidationProblemDetailsDocument = ValidationProblemDetails & Record<string, unknown>;
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/problem/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,kEAAkE;AAClE,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C;AAED,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9E,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/problem/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { CreateNoteRequest, ExampleNote, ExampleNoteListResponse, ListNotesParams, } from './notes.js';
|
|
2
|
+
export { isCreateNoteRequest, isExampleNoteListResponse, isExampleNoteResponse } from './notes.js';
|
|
3
|
+
export type { ProtectedResponse } from './protected.js';
|
|
4
|
+
export { isProtectedResponse } from './protected.js';
|
|
5
|
+
export type { CreateTagRequest, ExampleTag, ExampleTagListResponse, ListTagsParams, } from './tags.js';
|
|
6
|
+
export { isCreateTagRequest, isExampleTagListResponse, isExampleTagResponse } from './tags.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/examples/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnG,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,sBAAsB,EACtB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { isCreateNoteRequest, isExampleNoteListResponse, isExampleNoteResponse } from './notes.js';
|
|
2
|
+
export { isProtectedResponse } from './protected.js';
|
|
3
|
+
export { isCreateTagRequest, isExampleTagListResponse, isExampleTagResponse } from './tags.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/examples/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOrD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example notes types (OpenAPI `ExampleNote*` schemas).
|
|
3
|
+
*/
|
|
4
|
+
export interface ExampleNote {
|
|
5
|
+
readonly id: number;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly body: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ExampleNoteListResponse {
|
|
10
|
+
readonly items: readonly ExampleNote[];
|
|
11
|
+
readonly limit: number;
|
|
12
|
+
readonly offset: number;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateNoteRequest {
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly body: string;
|
|
17
|
+
}
|
|
18
|
+
export type ListNotesParams = {
|
|
19
|
+
readonly limit?: number;
|
|
20
|
+
readonly offset?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Type guard for {@link ExampleNote}. */
|
|
23
|
+
export declare function isExampleNoteResponse(value: unknown): value is ExampleNote;
|
|
24
|
+
/** Type guard for {@link ExampleNoteListResponse}. */
|
|
25
|
+
export declare function isExampleNoteListResponse(value: unknown): value is ExampleNoteListResponse;
|
|
26
|
+
/** Type guard for create-note request body (client-side validation before POST). */
|
|
27
|
+
export declare function isCreateNoteRequest(value: unknown): value is CreateNoteRequest;
|
|
28
|
+
//# sourceMappingURL=notes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../../src/types/examples/notes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAeF,0CAA0C;AAC1C,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAE1E;AAED,sDAAsD;AACtD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAS1F;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAQ9E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example notes types (OpenAPI `ExampleNote*` schemas).
|
|
3
|
+
*/
|
|
4
|
+
function isExampleNote(value) {
|
|
5
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const { id, title, body } = value;
|
|
9
|
+
return (typeof id === 'number' &&
|
|
10
|
+
Number.isInteger(id) &&
|
|
11
|
+
typeof title === 'string' &&
|
|
12
|
+
typeof body === 'string');
|
|
13
|
+
}
|
|
14
|
+
/** Type guard for {@link ExampleNote}. */
|
|
15
|
+
export function isExampleNoteResponse(value) {
|
|
16
|
+
return isExampleNote(value);
|
|
17
|
+
}
|
|
18
|
+
/** Type guard for {@link ExampleNoteListResponse}. */
|
|
19
|
+
export function isExampleNoteListResponse(value) {
|
|
20
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const { items, limit, offset } = value;
|
|
24
|
+
if (!Array.isArray(items) || !items.every(isExampleNote)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return typeof limit === 'number' && typeof offset === 'number';
|
|
28
|
+
}
|
|
29
|
+
/** Type guard for create-note request body (client-side validation before POST). */
|
|
30
|
+
export function isCreateNoteRequest(value) {
|
|
31
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const { title, body } = value;
|
|
35
|
+
return (typeof title === 'string' && title.length > 0 && typeof body === 'string' && body.length > 0);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL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,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAgC,CAAC;IACzD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAC7F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected example response (OpenAPI `ProtectedResponse`).
|
|
3
|
+
*/
|
|
4
|
+
export interface ProtectedResponse {
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly claims: Readonly<Record<string, unknown>>;
|
|
7
|
+
}
|
|
8
|
+
/** Type guard for {@link ProtectedResponse}. */
|
|
9
|
+
export declare function isProtectedResponse(value: unknown): value is ProtectedResponse;
|
|
10
|
+
//# sourceMappingURL=protected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected.d.ts","sourceRoot":"","sources":["../../../src/types/examples/protected.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED,gDAAgD;AAChD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAW9E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected example response (OpenAPI `ProtectedResponse`).
|
|
3
|
+
*/
|
|
4
|
+
/** Type guard for {@link ProtectedResponse}. */
|
|
5
|
+
export function isProtectedResponse(value) {
|
|
6
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const { message, claims } = value;
|
|
10
|
+
return (typeof message === 'string' &&
|
|
11
|
+
typeof claims === 'object' &&
|
|
12
|
+
claims !== null &&
|
|
13
|
+
!Array.isArray(claims));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=protected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected.js","sourceRoot":"","sources":["../../../src/types/examples/protected.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,gDAAgD;AAChD,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAgC,CAAC;IAC7D,OAAO,CACL,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example tags types (OpenAPI `ExampleTag*` schemas).
|
|
3
|
+
*/
|
|
4
|
+
export interface ExampleTag {
|
|
5
|
+
readonly id: number;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ExampleTagListResponse {
|
|
9
|
+
readonly items: readonly ExampleTag[];
|
|
10
|
+
readonly limit: number;
|
|
11
|
+
readonly offset: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateTagRequest {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
export type ListTagsParams = {
|
|
17
|
+
readonly limit?: number;
|
|
18
|
+
readonly offset?: number;
|
|
19
|
+
};
|
|
20
|
+
export declare function isExampleTagResponse(value: unknown): value is ExampleTag;
|
|
21
|
+
export declare function isExampleTagListResponse(value: unknown): value is ExampleTagListResponse;
|
|
22
|
+
export declare function isCreateTagRequest(value: unknown): value is CreateTagRequest;
|
|
23
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/types/examples/tags.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAUF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAExE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CASxF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAM5E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example tags types (OpenAPI `ExampleTag*` schemas).
|
|
3
|
+
*/
|
|
4
|
+
function isExampleTag(value) {
|
|
5
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const { id, name } = value;
|
|
9
|
+
return typeof id === 'number' && Number.isInteger(id) && typeof name === 'string';
|
|
10
|
+
}
|
|
11
|
+
export function isExampleTagResponse(value) {
|
|
12
|
+
return isExampleTag(value);
|
|
13
|
+
}
|
|
14
|
+
export function isExampleTagListResponse(value) {
|
|
15
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const { items, limit, offset } = value;
|
|
19
|
+
if (!Array.isArray(items) || !items.every(isExampleTag)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return typeof limit === 'number' && typeof offset === 'number';
|
|
23
|
+
}
|
|
24
|
+
export function isCreateTagRequest(value) {
|
|
25
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const { name } = value;
|
|
29
|
+
return typeof name === 'string' && name.length > 0;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/types/examples/tags.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsBH,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,KAAgC,CAAC;IACtD,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAgC,CAAC;IAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAgC,CAAC;IAClD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { ExamplePingResponse, FrameworkSmokeResponse, HealthResponse, HealthStatus, MachineHealthResponse, SmokeCheckResult, } from './system.js';
|
|
2
|
+
export { isExamplePingResponse, isFrameworkSmokeResponse, isHealthResponse, isMachineHealthResponse, } from './system.js';
|
|
3
|
+
export type { CreateNoteRequest, ExampleNote, ExampleNoteListResponse, ListNotesParams, } from './examples/index.js';
|
|
4
|
+
export { isCreateNoteRequest, isExampleNoteListResponse, isExampleNoteResponse, isProtectedResponse, } from './examples/index.js';
|
|
5
|
+
export type { ProtectedResponse } from './examples/index.js';
|
|
6
|
+
export type { CreateTagRequest, ExampleTag, ExampleTagListResponse, ListTagsParams, } from './examples/index.js';
|
|
7
|
+
export { isCreateTagRequest, isExampleTagListResponse, isExampleTagResponse, } from './examples/index.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,sBAAsB,EACtB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { isExamplePingResponse, isFrameworkSmokeResponse, isHealthResponse, isMachineHealthResponse, } from './system.js';
|
|
2
|
+
export { isCreateNoteRequest, isExampleNoteListResponse, isExampleNoteResponse, isProtectedResponse, } from './examples/index.js';
|
|
3
|
+
export { isCreateTagRequest, isExampleTagListResponse, isExampleTagResponse, } from './examples/index.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System endpoint response types (OpenAPI-aligned).
|
|
3
|
+
*/
|
|
4
|
+
export type HealthStatus = 'ok' | 'degraded';
|
|
5
|
+
export interface HealthResponse {
|
|
6
|
+
readonly status: HealthStatus;
|
|
7
|
+
readonly service: string;
|
|
8
|
+
readonly checks?: Readonly<Record<string, 'ok' | 'error'>>;
|
|
9
|
+
}
|
|
10
|
+
export interface ExamplePingResponse {
|
|
11
|
+
readonly message: 'pong';
|
|
12
|
+
readonly status: 'ok';
|
|
13
|
+
}
|
|
14
|
+
export interface FrameworkSmokeResponse {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly status: 'ok';
|
|
18
|
+
}
|
|
19
|
+
export interface MachineHealthResponse {
|
|
20
|
+
readonly status: 'ok';
|
|
21
|
+
readonly service: string;
|
|
22
|
+
readonly credential_type: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SmokeCheckResult {
|
|
25
|
+
readonly health: HealthResponse;
|
|
26
|
+
readonly ping: ExamplePingResponse;
|
|
27
|
+
}
|
|
28
|
+
/** Type guard for {@link HealthResponse}. */
|
|
29
|
+
export declare function isHealthResponse(value: unknown): value is HealthResponse;
|
|
30
|
+
/** Type guard for {@link ExamplePingResponse}. */
|
|
31
|
+
export declare function isExamplePingResponse(value: unknown): value is ExamplePingResponse;
|
|
32
|
+
/** Type guard for {@link FrameworkSmokeResponse}. */
|
|
33
|
+
export declare function isFrameworkSmokeResponse(value: unknown): value is FrameworkSmokeResponse;
|
|
34
|
+
/** Type guard for {@link MachineHealthResponse}. */
|
|
35
|
+
export declare function isMachineHealthResponse(value: unknown): value is MachineHealthResponse;
|
|
36
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/types/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,UAAU,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACpC;AASD,6CAA6C;AAC7C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