@degenerate/endpoints 0.1.7 → 0.4.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 +18 -0
- package/dist/cors/authority/jwt/build-validate-jwt-for-audience.d.ts +41 -0
- package/dist/cors/authority/jwt/build-validate-jwt-for-audience.d.ts.map +1 -0
- package/dist/cors/authority/jwt/build-validate-jwt-for-audience.js +75 -0
- package/dist/cors/authority/jwt/validate-jwt-authorities.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-authorities.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-authorities.js +7 -27
- package/dist/cors/authority/jwt/validate-jwt-endpoints.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-endpoints.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-endpoints.js +7 -27
- package/dist/cors/authority/jwt/validate-jwt-events.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-events.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-events.js +7 -27
- package/dist/cors/authority/jwt/validate-jwt-functions.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-functions.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-functions.js +7 -27
- package/dist/cors/authority/jwt/validate-jwt-rules.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-rules.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-rules.js +7 -27
- package/dist/cors/authority/jwt/validate-jwt-share-data.d.ts +5 -13
- package/dist/cors/authority/jwt/validate-jwt-share-data.d.ts.map +1 -1
- package/dist/cors/authority/jwt/validate-jwt-share-data.js +7 -27
- package/dist/cors/endpoints/helpers/validate-incoming-request-data.d.ts.map +1 -1
- package/dist/cors/endpoints/helpers/validate-incoming-request-data.js +1 -1
- package/dist/cors/index.d.ts +1 -0
- package/dist/cors/index.d.ts.map +1 -1
- package/dist/cors/index.js +1 -0
- package/dist/examples/express-server/app.d.ts +20 -2
- package/dist/examples/express-server/app.d.ts.map +1 -1
- package/dist/examples/express-server/app.js +42 -21
- package/dist/examples/express-server/authenticate-realtime.d.ts +27 -0
- package/dist/examples/express-server/authenticate-realtime.d.ts.map +1 -0
- package/dist/examples/express-server/authenticate-realtime.js +23 -0
- package/dist/examples/express-server/server.d.ts +32 -1
- package/dist/examples/express-server/server.d.ts.map +1 -1
- package/dist/examples/express-server/server.js +61 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/openapi/build-openapi-document.d.ts +27 -0
- package/dist/openapi/build-openapi-document.d.ts.map +1 -0
- package/dist/openapi/build-openapi-document.js +223 -0
- package/dist/openapi/domain-schemas.d.ts +16 -0
- package/dist/openapi/domain-schemas.d.ts.map +1 -0
- package/dist/openapi/domain-schemas.js +39 -0
- package/dist/openapi/index.d.ts +6 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +21 -0
- package/dist/openapi/operations.d.ts +8 -0
- package/dist/openapi/operations.d.ts.map +1 -0
- package/dist/openapi/operations.js +22 -0
- package/dist/openapi/response-schemas.d.ts +32 -0
- package/dist/openapi/response-schemas.d.ts.map +1 -0
- package/dist/openapi/response-schemas.js +30 -0
- package/dist/openapi/types.d.ts +29 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/types.js +2 -0
- package/dist/routes/authorities/v1.openapi.d.ts +4 -0
- package/dist/routes/authorities/v1.openapi.d.ts.map +1 -0
- package/dist/routes/authorities/v1.openapi.js +68 -0
- package/dist/routes/events/v1.openapi.d.ts +4 -0
- package/dist/routes/events/v1.openapi.d.ts.map +1 -0
- package/dist/routes/events/v1.openapi.js +54 -0
- package/dist/routes/events/v1.routes.d.ts.map +1 -1
- package/dist/routes/events/v1.routes.js +5 -3
- package/dist/routes/events.routes.d.ts.map +1 -1
- package/dist/routes/events.routes.js +10 -60
- package/dist/routes/functions/v1.openapi.d.ts +4 -0
- package/dist/routes/functions/v1.openapi.d.ts.map +1 -0
- package/dist/routes/functions/v1.openapi.js +68 -0
- package/dist/routes/functions.routes.d.ts.map +1 -1
- package/dist/routes/functions.routes.js +10 -60
- package/dist/routes/rules/v1/rule-set.openapi.d.ts +4 -0
- package/dist/routes/rules/v1/rule-set.openapi.d.ts.map +1 -0
- package/dist/routes/rules/v1/rule-set.openapi.js +72 -0
- package/dist/routes/rules/v1/rule-set.routes.js +3 -3
- package/dist/routes/share-data.routes.d.ts.map +1 -1
- package/dist/routes/share-data.routes.js +17 -59
- package/dist/routes/sharedata/v1.openapi.d.ts +8 -0
- package/dist/routes/sharedata/v1.openapi.d.ts.map +1 -0
- package/dist/routes/sharedata/v1.openapi.js +60 -0
- package/dist/routes/sharedata/v1.routes.d.ts.map +1 -1
- package/dist/routes/sharedata/v1.routes.js +195 -9
- package/dist/routes/validation/rules/validate-rules.openapi.d.ts +8 -0
- package/dist/routes/validation/rules/validate-rules.openapi.d.ts.map +1 -0
- package/dist/routes/validation/rules/validate-rules.openapi.js +76 -0
- package/package.json +28 -15
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OperationDescriptor } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Every mounted SAFE HTTP operation, one descriptor each. This is the single
|
|
4
|
+
* feed for `buildOpenApiDocument` and the subject the coverage test reconciles
|
|
5
|
+
* against the live Express route table.
|
|
6
|
+
*/
|
|
7
|
+
export declare const operations: OperationDescriptor[];
|
|
8
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/openapi/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,mBAAmB,EAO3C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.operations = void 0;
|
|
4
|
+
const v1_openapi_1 = require("../routes/authorities/v1.openapi");
|
|
5
|
+
const v1_openapi_2 = require("../routes/events/v1.openapi");
|
|
6
|
+
const v1_openapi_3 = require("../routes/functions/v1.openapi");
|
|
7
|
+
const rule_set_openapi_1 = require("../routes/rules/v1/rule-set.openapi");
|
|
8
|
+
const v1_openapi_4 = require("../routes/sharedata/v1.openapi");
|
|
9
|
+
const validate_rules_openapi_1 = require("../routes/validation/rules/validate-rules.openapi");
|
|
10
|
+
/**
|
|
11
|
+
* Every mounted SAFE HTTP operation, one descriptor each. This is the single
|
|
12
|
+
* feed for `buildOpenApiDocument` and the subject the coverage test reconciles
|
|
13
|
+
* against the live Express route table.
|
|
14
|
+
*/
|
|
15
|
+
exports.operations = [
|
|
16
|
+
...v1_openapi_1.authorityOperations,
|
|
17
|
+
...v1_openapi_2.eventOperations,
|
|
18
|
+
...v1_openapi_3.functionOperations,
|
|
19
|
+
...rule_set_openapi_1.ruleSetOperations,
|
|
20
|
+
...v1_openapi_4.shareDataOperations,
|
|
21
|
+
...validate_rules_openapi_1.validateRulesOperations,
|
|
22
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP response envelopes for the SAFE endpoints surface. These describe the
|
|
4
|
+
* transport shape (`{ successful, … }`) the route handlers actually return —
|
|
5
|
+
* an HTTP concern specific to this API, deliberately kept out of
|
|
6
|
+
* `@degenerate/generic` (domain models). Payloads inside an envelope reuse
|
|
7
|
+
* generic domain schemas where one exists; otherwise the envelope is documented
|
|
8
|
+
* and the payload left loosely typed rather than fabricated.
|
|
9
|
+
*
|
|
10
|
+
* Define each schema once and reuse the instance so the OpenAPI generator
|
|
11
|
+
* dedupes it to a single `components.schemas` entry.
|
|
12
|
+
*/
|
|
13
|
+
/** Uniform error body emitted by the three error handlers at 400 / 403 / 404 / 500 / 501. */
|
|
14
|
+
export declare const ErrorResponseSchema: z.ZodObject<{
|
|
15
|
+
successful: z.ZodLiteral<false>;
|
|
16
|
+
error: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
|
|
19
|
+
/** Bare success body: `{ successful: true }` with no additional payload. */
|
|
20
|
+
export declare const SuccessResponseSchema: z.ZodObject<{
|
|
21
|
+
successful: z.ZodLiteral<true>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type SuccessResponse = z.infer<typeof SuccessResponseSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Build a success envelope that carries extra fields alongside
|
|
26
|
+
* `successful: true`. Define the result as a module-level const in the group's
|
|
27
|
+
* descriptor file so the generator sees one stable instance per shape.
|
|
28
|
+
*/
|
|
29
|
+
export declare const successEnvelope: <Shape extends z.ZodRawShape>(payload: Shape) => z.ZodObject<{
|
|
30
|
+
successful: z.ZodLiteral<true>;
|
|
31
|
+
} & Shape extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>;
|
|
32
|
+
//# sourceMappingURL=response-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-schemas.d.ts","sourceRoot":"","sources":["../../src/openapi/response-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB;;;iBAEE,CAAC;AACnC,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB;;iBAEE,CAAC;AACrC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,SAAS,CAAC,CAAC,WAAW,EAAE,SAAS,KAAK;;uFAClB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.successEnvelope = exports.SuccessResponseSchema = exports.ErrorResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* HTTP response envelopes for the SAFE endpoints surface. These describe the
|
|
7
|
+
* transport shape (`{ successful, … }`) the route handlers actually return —
|
|
8
|
+
* an HTTP concern specific to this API, deliberately kept out of
|
|
9
|
+
* `@degenerate/generic` (domain models). Payloads inside an envelope reuse
|
|
10
|
+
* generic domain schemas where one exists; otherwise the envelope is documented
|
|
11
|
+
* and the payload left loosely typed rather than fabricated.
|
|
12
|
+
*
|
|
13
|
+
* Define each schema once and reuse the instance so the OpenAPI generator
|
|
14
|
+
* dedupes it to a single `components.schemas` entry.
|
|
15
|
+
*/
|
|
16
|
+
/** Uniform error body emitted by the three error handlers at 400 / 403 / 404 / 500 / 501. */
|
|
17
|
+
exports.ErrorResponseSchema = zod_1.z
|
|
18
|
+
.object({ successful: zod_1.z.literal(false), error: zod_1.z.string() })
|
|
19
|
+
.meta({ id: 'ErrorResponse' });
|
|
20
|
+
/** Bare success body: `{ successful: true }` with no additional payload. */
|
|
21
|
+
exports.SuccessResponseSchema = zod_1.z
|
|
22
|
+
.object({ successful: zod_1.z.literal(true) })
|
|
23
|
+
.meta({ id: 'SuccessResponse' });
|
|
24
|
+
/**
|
|
25
|
+
* Build a success envelope that carries extra fields alongside
|
|
26
|
+
* `successful: true`. Define the result as a module-level const in the group's
|
|
27
|
+
* descriptor file so the generator sees one stable instance per shape.
|
|
28
|
+
*/
|
|
29
|
+
const successEnvelope = (payload) => zod_1.z.object({ successful: zod_1.z.literal(true), ...payload });
|
|
30
|
+
exports.successEnvelope = successEnvelope;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AuthorizationAudience } from '@degenerate/generic';
|
|
3
|
+
/**
|
|
4
|
+
* One descriptor per mounted HTTP operation. This is the single place that
|
|
5
|
+
* records everything OpenAPI needs about an operation that Express does not
|
|
6
|
+
* expose introspectively: human summary, the JWT audience that gates it, and
|
|
7
|
+
* the Zod schemas bound to its request body and each response status.
|
|
8
|
+
*
|
|
9
|
+
* Descriptors live beside the route files they describe (one array per group,
|
|
10
|
+
* e.g. `routes/sharedata/v1.openapi.ts`) and are aggregated into a single
|
|
11
|
+
* `operations[]`. A coverage test reconciles `operations[]` against the live
|
|
12
|
+
* Express route table so the two cannot silently drift.
|
|
13
|
+
*/
|
|
14
|
+
export interface OperationDescriptor {
|
|
15
|
+
method: 'get' | 'post' | 'patch' | 'delete';
|
|
16
|
+
/** OpenAPI path template, e.g. `/share-data/v1/{sharedataid}`. */
|
|
17
|
+
path: string;
|
|
18
|
+
/** JWT audience that gates the operation, or `'public'` for no auth. */
|
|
19
|
+
security: AuthorizationAudience | 'public';
|
|
20
|
+
summary: string;
|
|
21
|
+
/** Request body schema; omit for operations that take no body. */
|
|
22
|
+
request?: z.ZodType;
|
|
23
|
+
/** Response schema per HTTP status — at minimum the success status. */
|
|
24
|
+
response: {
|
|
25
|
+
[status: number]: z.ZodType;
|
|
26
|
+
};
|
|
27
|
+
deprecated?: boolean;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/openapi/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,QAAQ,EAAE,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAA;KAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.openapi.d.ts","sourceRoot":"","sources":["../../../src/routes/authorities/v1.openapi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAW/D,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,EAyDpD,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authorityOperations = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const generic_1 = require("@degenerate/generic");
|
|
6
|
+
const response_schemas_1 = require("../../openapi/response-schemas");
|
|
7
|
+
const AuthorityIdResponseSchema = (0, response_schemas_1.successEnvelope)({ authorityId: zod_1.z.string() }).meta({
|
|
8
|
+
id: 'AuthorityIdResponse',
|
|
9
|
+
});
|
|
10
|
+
/** Operations under `/authorities` — all gated by the AUTHORITIES JWT audience. */
|
|
11
|
+
exports.authorityOperations = [
|
|
12
|
+
{
|
|
13
|
+
method: 'post',
|
|
14
|
+
path: '/authorities/v1',
|
|
15
|
+
security: generic_1.AuthorizationAudience.AUTHORITIES,
|
|
16
|
+
summary: 'Create an authority.',
|
|
17
|
+
request: generic_1.ISAFETransactionAuthorityAddSchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
20
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
21
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
method: 'get',
|
|
26
|
+
path: '/authorities/v1',
|
|
27
|
+
security: generic_1.AuthorizationAudience.AUTHORITIES,
|
|
28
|
+
summary: 'List authorities.',
|
|
29
|
+
response: {
|
|
30
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
31
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
method: 'get',
|
|
36
|
+
path: '/authorities/v1/{authorityid}',
|
|
37
|
+
security: generic_1.AuthorizationAudience.AUTHORITIES,
|
|
38
|
+
summary: 'Get an authority by id.',
|
|
39
|
+
response: {
|
|
40
|
+
200: AuthorityIdResponseSchema,
|
|
41
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
method: 'patch',
|
|
46
|
+
path: '/authorities/v1/{authorityid}',
|
|
47
|
+
security: generic_1.AuthorizationAudience.AUTHORITIES,
|
|
48
|
+
summary: 'Update an authority by id.',
|
|
49
|
+
request: generic_1.ISAFETransactionAuthorityUpdateSchema,
|
|
50
|
+
response: {
|
|
51
|
+
200: AuthorityIdResponseSchema,
|
|
52
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
53
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
method: 'delete',
|
|
58
|
+
path: '/authorities/v1/{authorityid}',
|
|
59
|
+
security: generic_1.AuthorizationAudience.AUTHORITIES,
|
|
60
|
+
summary: 'Delete an authority by id.',
|
|
61
|
+
request: generic_1.ISAFETransactionAuthorityDeleteSchema,
|
|
62
|
+
response: {
|
|
63
|
+
200: AuthorityIdResponseSchema,
|
|
64
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
65
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.openapi.d.ts","sourceRoot":"","sources":["../../../src/routes/events/v1.openapi.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,yEAAyE;AACzE,eAAO,MAAM,eAAe,EAAE,mBAAmB,EA+ChD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventOperations = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const response_schemas_1 = require("../../openapi/response-schemas");
|
|
6
|
+
/** Operations under `/events` — all gated by the EVENTS JWT audience. */
|
|
7
|
+
exports.eventOperations = [
|
|
8
|
+
{
|
|
9
|
+
method: 'post',
|
|
10
|
+
path: '/events/v1',
|
|
11
|
+
security: generic_1.AuthorizationAudience.EVENTS,
|
|
12
|
+
summary: 'Create an event.',
|
|
13
|
+
request: generic_1.ISAFETransactionEventAddSchema,
|
|
14
|
+
response: {
|
|
15
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
16
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
17
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
method: 'get',
|
|
22
|
+
path: '/events/v1',
|
|
23
|
+
security: generic_1.AuthorizationAudience.EVENTS,
|
|
24
|
+
summary: 'Get events.',
|
|
25
|
+
response: {
|
|
26
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
27
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
method: 'patch',
|
|
32
|
+
path: '/events/v1',
|
|
33
|
+
security: generic_1.AuthorizationAudience.EVENTS,
|
|
34
|
+
summary: 'Update an event.',
|
|
35
|
+
request: generic_1.ISAFETransactionEventUpdateSchema,
|
|
36
|
+
response: {
|
|
37
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
38
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
39
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
method: 'delete',
|
|
44
|
+
path: '/events/v1',
|
|
45
|
+
security: generic_1.AuthorizationAudience.EVENTS,
|
|
46
|
+
summary: 'Delete an event.',
|
|
47
|
+
request: generic_1.ISAFETransactionEventDeleteSchema,
|
|
48
|
+
response: {
|
|
49
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
50
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
51
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.routes.d.ts","sourceRoot":"","sources":["../../../src/routes/events/v1.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v1.routes.d.ts","sourceRoot":"","sources":["../../../src/routes/events/v1.routes.ts"],"names":[],"mappings":"AAqEA,eAAO,MAAM,EAAE,4CAAS,CAAC"}
|
|
@@ -47,9 +47,6 @@ const generic_1 = require("@degenerate/generic");
|
|
|
47
47
|
const router = express.Router({ mergeParams: true });
|
|
48
48
|
router.use(add_unique_tracking_1.addUniqueTracking); // add the unique tracking id to the request
|
|
49
49
|
router.use(validate_jwt_events_1.validateJWTEvents); // validate the JWT token
|
|
50
|
-
router.use(unauthorized_handler_1.unauthorizedHandler); // the unauthorized handler should be the first error handler
|
|
51
|
-
router.use(bad_request_handler_1.badRequestHandler); // the bad request handler should be the second error handler
|
|
52
|
-
router.use(all_error_handler_1.allErrorHandler); // the all error handler catches all remaining errors
|
|
53
50
|
/**
|
|
54
51
|
* This creates a new event object.
|
|
55
52
|
*/
|
|
@@ -82,4 +79,9 @@ router.delete(// https://{hostname}/events/v1
|
|
|
82
79
|
(0, validate_incoming_request_data_1.validateIncomingRequestData)(generic_1.ISAFETransactionEventDeleteSchema), async (req, res) => {
|
|
83
80
|
return res.status(200).send({ successful: true });
|
|
84
81
|
});
|
|
82
|
+
// Error handlers must be registered AFTER routes — express only routes
|
|
83
|
+
// errors to handlers that follow the throwing middleware in the chain.
|
|
84
|
+
router.use(unauthorized_handler_1.unauthorizedHandler); // the unauthorized handler should be the first error handler
|
|
85
|
+
router.use(bad_request_handler_1.badRequestHandler); // the bad request handler should be the second error handler
|
|
86
|
+
router.use(all_error_handler_1.allErrorHandler); // the all error handler catches all remaining errors
|
|
85
87
|
exports.v1 = router; // https://{hostname}/events/v1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.routes.d.ts","sourceRoot":"","sources":["../../src/routes/events.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.routes.d.ts","sourceRoot":"","sources":["../../src/routes/events.routes.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,MAAM,4CAAS,CAAC"}
|
|
@@ -1,66 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.events = void 0;
|
|
37
|
-
const
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
38
8
|
const get_set_audiences_1 = require("../cors/authority/audience/get-set-audiences");
|
|
9
|
+
const request_logging_1 = require("../cors/logging/request-logging");
|
|
10
|
+
const v1_routes_1 = require("./events/v1.routes");
|
|
39
11
|
// eslint-disable-next-line new-cap
|
|
40
|
-
const router =
|
|
41
|
-
router.use(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
router.post('/', async (req, res) => {
|
|
46
|
-
return res.status(200).send({ successful: true });
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* This gets the event object.
|
|
50
|
-
*/
|
|
51
|
-
router.get('/', async (req, res) => {
|
|
52
|
-
return res.status(200).send({ successful: true });
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* This updates the event object.
|
|
56
|
-
*/
|
|
57
|
-
router.patch('/', async (req, res) => {
|
|
58
|
-
return res.status(200).send({ successful: true });
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* This deletes the event object.
|
|
62
|
-
*/
|
|
63
|
-
router.delete('/', async (req, res) => {
|
|
64
|
-
return res.status(200).send({ successful: true });
|
|
65
|
-
});
|
|
12
|
+
const router = express_1.default.Router({ mergeParams: true });
|
|
13
|
+
router.use(request_logging_1.requestLogging); // log the request
|
|
14
|
+
router.use(get_set_audiences_1.setAudienceEvents); // set the audience to events
|
|
15
|
+
router.use('/v1', v1_routes_1.v1); // JWT validation + handlers + error handlers live in v1
|
|
66
16
|
exports.events = router;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.openapi.d.ts","sourceRoot":"","sources":["../../../src/routes/functions/v1.openapi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAW/D,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,EAAE,mBAAmB,EAyDnD,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functionOperations = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const generic_1 = require("@degenerate/generic");
|
|
6
|
+
const response_schemas_1 = require("../../openapi/response-schemas");
|
|
7
|
+
const FunctionIdResponseSchema = (0, response_schemas_1.successEnvelope)({ functionId: zod_1.z.string() }).meta({
|
|
8
|
+
id: 'FunctionIdResponse',
|
|
9
|
+
});
|
|
10
|
+
/** Operations under `/functions` — all gated by the FUNCTIONS JWT audience. */
|
|
11
|
+
exports.functionOperations = [
|
|
12
|
+
{
|
|
13
|
+
method: 'post',
|
|
14
|
+
path: '/functions/v1',
|
|
15
|
+
security: generic_1.AuthorizationAudience.FUNCTIONS,
|
|
16
|
+
summary: 'Create a function.',
|
|
17
|
+
request: generic_1.ISAFETransactionFunctionAddSchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
20
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
21
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
method: 'get',
|
|
26
|
+
path: '/functions/v1',
|
|
27
|
+
security: generic_1.AuthorizationAudience.FUNCTIONS,
|
|
28
|
+
summary: 'List functions.',
|
|
29
|
+
response: {
|
|
30
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
31
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
method: 'get',
|
|
36
|
+
path: '/functions/v1/{functionid}',
|
|
37
|
+
security: generic_1.AuthorizationAudience.FUNCTIONS,
|
|
38
|
+
summary: 'Get a function by id.',
|
|
39
|
+
response: {
|
|
40
|
+
200: FunctionIdResponseSchema,
|
|
41
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
method: 'patch',
|
|
46
|
+
path: '/functions/v1/{functionid}',
|
|
47
|
+
security: generic_1.AuthorizationAudience.FUNCTIONS,
|
|
48
|
+
summary: 'Update a function by id.',
|
|
49
|
+
request: generic_1.ISAFETransactionFunctionUpdateSchema,
|
|
50
|
+
response: {
|
|
51
|
+
200: FunctionIdResponseSchema,
|
|
52
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
53
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
method: 'delete',
|
|
58
|
+
path: '/functions/v1/{functionid}',
|
|
59
|
+
security: generic_1.AuthorizationAudience.FUNCTIONS,
|
|
60
|
+
summary: 'Delete a function by id.',
|
|
61
|
+
request: generic_1.ISAFETransactionFunctionDeleteSchema,
|
|
62
|
+
response: {
|
|
63
|
+
200: FunctionIdResponseSchema,
|
|
64
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
65
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.routes.d.ts","sourceRoot":"","sources":["../../src/routes/functions.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions.routes.d.ts","sourceRoot":"","sources":["../../src/routes/functions.routes.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS,4CAAS,CAAC"}
|
|
@@ -1,66 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.functions = void 0;
|
|
37
|
-
const
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
38
8
|
const get_set_audiences_1 = require("../cors/authority/audience/get-set-audiences");
|
|
9
|
+
const request_logging_1 = require("../cors/logging/request-logging");
|
|
10
|
+
const v1_routes_1 = require("./functions/v1.routes");
|
|
39
11
|
// eslint-disable-next-line new-cap
|
|
40
|
-
const router =
|
|
41
|
-
router.use(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
router.post('/', async (req, res) => {
|
|
46
|
-
return res.status(200).send({ successful: true });
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* This gets the sharedata object.
|
|
50
|
-
*/
|
|
51
|
-
router.get('/', async (req, res) => {
|
|
52
|
-
return res.status(200).send({ successful: true });
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* This updates the sharedata object.
|
|
56
|
-
*/
|
|
57
|
-
router.patch('/', async (req, res) => {
|
|
58
|
-
return res.status(200).send({ successful: true });
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* This deletes the sharedata object.
|
|
62
|
-
*/
|
|
63
|
-
router.delete('/', async (req, res) => {
|
|
64
|
-
return res.status(200).send({ successful: true });
|
|
65
|
-
});
|
|
12
|
+
const router = express_1.default.Router({ mergeParams: true });
|
|
13
|
+
router.use(request_logging_1.requestLogging); // log the request
|
|
14
|
+
router.use(get_set_audiences_1.setAudienceFunctions); // set the audience to functions
|
|
15
|
+
router.use('/v1', v1_routes_1.v1); // JWT validation + handlers + error handlers live in v1
|
|
66
16
|
exports.functions = router;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-set.openapi.d.ts","sourceRoot":"","sources":["../../../../src/routes/rules/v1/rule-set.openapi.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAelE,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,EAyDlD,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleSetOperations = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const generic_1 = require("@degenerate/generic");
|
|
6
|
+
const response_schemas_1 = require("../../../openapi/response-schemas");
|
|
7
|
+
const RuleSetListResponseSchema = (0, response_schemas_1.successEnvelope)({ ruleSets: zod_1.z.array(generic_1.IShareRuleSetSchema) }).meta({
|
|
8
|
+
id: 'RuleSetListResponse',
|
|
9
|
+
});
|
|
10
|
+
const RuleSetItemResponseSchema = (0, response_schemas_1.successEnvelope)({ ruleSet: generic_1.IShareRuleSetSchema.optional() }).meta({
|
|
11
|
+
id: 'RuleSetItemResponse',
|
|
12
|
+
});
|
|
13
|
+
const RulesIdResponseSchema = (0, response_schemas_1.successEnvelope)({ rulesId: zod_1.z.string() }).meta({ id: 'RulesIdResponse' });
|
|
14
|
+
/** Operations under `/rules/v1/rule-sets` — all gated by the RULES JWT audience. */
|
|
15
|
+
exports.ruleSetOperations = [
|
|
16
|
+
{
|
|
17
|
+
method: 'post',
|
|
18
|
+
path: '/rules/v1/rule-sets',
|
|
19
|
+
security: generic_1.AuthorizationAudience.RULES,
|
|
20
|
+
summary: 'Create a rule set.',
|
|
21
|
+
request: generic_1.ISAFETransactionRuleSetAddSchema,
|
|
22
|
+
response: {
|
|
23
|
+
200: response_schemas_1.SuccessResponseSchema,
|
|
24
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
25
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
method: 'get',
|
|
30
|
+
path: '/rules/v1/rule-sets',
|
|
31
|
+
security: generic_1.AuthorizationAudience.RULES,
|
|
32
|
+
summary: 'List rule sets.',
|
|
33
|
+
response: {
|
|
34
|
+
200: RuleSetListResponseSchema,
|
|
35
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
method: 'get',
|
|
40
|
+
path: '/rules/v1/rule-sets/{rulesetsid}',
|
|
41
|
+
security: generic_1.AuthorizationAudience.RULES,
|
|
42
|
+
summary: 'Get a rule set by id.',
|
|
43
|
+
response: {
|
|
44
|
+
200: RuleSetItemResponseSchema,
|
|
45
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
method: 'patch',
|
|
50
|
+
path: '/rules/v1/rule-sets/{rulesetsid}',
|
|
51
|
+
security: generic_1.AuthorizationAudience.RULES,
|
|
52
|
+
summary: 'Update a rule set by id.',
|
|
53
|
+
request: generic_1.ISAFETransactionRuleSetUpdateSchema,
|
|
54
|
+
response: {
|
|
55
|
+
200: RulesIdResponseSchema,
|
|
56
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
57
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
method: 'delete',
|
|
62
|
+
path: '/rules/v1/rule-sets/{rulesetsid}',
|
|
63
|
+
security: generic_1.AuthorizationAudience.RULES,
|
|
64
|
+
summary: 'Delete a rule set by id.',
|
|
65
|
+
request: generic_1.ISAFETransactionRuleSetDeleteSchema,
|
|
66
|
+
response: {
|
|
67
|
+
200: RulesIdResponseSchema,
|
|
68
|
+
400: response_schemas_1.ErrorResponseSchema,
|
|
69
|
+
403: response_schemas_1.ErrorResponseSchema,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
];
|