@xube/kit-destination 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/confirm.d.ts +5 -0
- package/dist/confirm.js +32 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +9 -0
- package/dist/generated/index.d.ts +4 -0
- package/dist/generated/index.js +23 -0
- package/dist/generated/types/confirmationRequest.d.ts +14 -0
- package/dist/generated/types/confirmationRequest.js +23 -0
- package/dist/generated/types/destinationHeaders.d.ts +13 -0
- package/dist/generated/types/destinationHeaders.js +23 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -0
- package/dist/schemas/confirmation-request.d.ts +18 -0
- package/dist/schemas/confirmation-request.js +11 -0
- package/dist/schemas/headers.d.ts +14 -0
- package/dist/schemas/headers.js +10 -0
- package/package.json +31 -0
- package/src/confirm.ts +41 -0
- package/src/constants.ts +7 -0
- package/src/generated/index.ts +4 -0
- package/src/generated/types/confirmationRequest.ts +29 -0
- package/src/generated/types/destinationHeaders.ts +28 -0
- package/src/generated/validators/confirmationRequest.js +1 -0
- package/src/generated/validators/destinationHeaders.js +1 -0
- package/src/generator.ts +22 -0
- package/src/index.ts +0 -0
- package/src/schemas/confirmation-request.ts +10 -0
- package/src/schemas/headers.ts +8 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfirmationRequest } from "./generated";
|
|
2
|
+
import { XubeLog } from "@xube/kit-log";
|
|
3
|
+
import { XubeResponse } from "@xube/kit-request";
|
|
4
|
+
export declare const isConfirmation: (headers: Record<string, string>, body: Record<string, any>) => boolean;
|
|
5
|
+
export declare const confirmDestination: (confirmationRequest: ConfirmationRequest, log?: XubeLog) => Promise<XubeResponse<boolean>>;
|
package/dist/confirm.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.confirmDestination = exports.isConfirmation = void 0;
|
|
4
|
+
const generated_1 = require("./generated");
|
|
5
|
+
// import { XubeResponse } from "@xube/common";
|
|
6
|
+
const kit_constants_1 = require("@xube/kit-constants");
|
|
7
|
+
const kit_log_1 = require("@xube/kit-log");
|
|
8
|
+
const kit_request_1 = require("@xube/kit-request");
|
|
9
|
+
const isConfirmation = (headers, body) => (0, generated_1.isDestinationHeaders)(headers) &&
|
|
10
|
+
headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
|
|
11
|
+
(0, generated_1.isConfirmationRequest)(body);
|
|
12
|
+
exports.isConfirmation = isConfirmation;
|
|
13
|
+
const confirmDestination = async (confirmationRequest, log = kit_log_1.XubeLog.getInstance()) => {
|
|
14
|
+
const response = await fetch(confirmationRequest.enableUrl, {
|
|
15
|
+
method: "GET",
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
log.info(response.statusText);
|
|
22
|
+
return new kit_request_1.XubeResponse({
|
|
23
|
+
statusCode: kit_constants_1.StatusCode.BadRequest,
|
|
24
|
+
error: "Failed to confirm destination",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return new kit_request_1.XubeResponse({
|
|
28
|
+
statusCode: kit_constants_1.StatusCode.OK,
|
|
29
|
+
data: true,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.confirmDestination = confirmDestination;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RulesEngineMessageTypesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const confirmation_request_1 = require("./schemas/confirmation-request");
|
|
6
|
+
exports.RulesEngineMessageTypesSchema = zod_1.z.union([
|
|
7
|
+
zod_1.z.literal(confirmation_request_1.DestinationConfirmationMessageType),
|
|
8
|
+
zod_1.z.string(), //Change to literal when more types are added
|
|
9
|
+
]);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { validate as validateDestinationHeaders } from './validators/destinationHeaders';
|
|
2
|
+
export * from './types/destinationHeaders';
|
|
3
|
+
export { validate as validateConfirmationRequest } from './validators/confirmationRequest';
|
|
4
|
+
export * from './types/confirmationRequest';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.validateConfirmationRequest = exports.validateDestinationHeaders = void 0;
|
|
18
|
+
var destinationHeaders_1 = require("./validators/destinationHeaders");
|
|
19
|
+
Object.defineProperty(exports, "validateDestinationHeaders", { enumerable: true, get: function () { return destinationHeaders_1.validate; } });
|
|
20
|
+
__exportStar(require("./types/destinationHeaders"), exports);
|
|
21
|
+
var confirmationRequest_1 = require("./validators/confirmationRequest");
|
|
22
|
+
Object.defineProperty(exports, "validateConfirmationRequest", { enumerable: true, get: function () { return confirmationRequest_1.validate; } });
|
|
23
|
+
__exportStar(require("./types/confirmationRequest"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I am a generated file.
|
|
3
|
+
*
|
|
4
|
+
* If you change me, you and other developers will be sad.
|
|
5
|
+
*
|
|
6
|
+
* #StayGeneratedStayHappy
|
|
7
|
+
*/
|
|
8
|
+
export type ConfirmationRequest = {
|
|
9
|
+
arn: string;
|
|
10
|
+
confirmationToken: string;
|
|
11
|
+
enableUrl: string;
|
|
12
|
+
messageType: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const isConfirmationRequest: (item: unknown) => item is ConfirmationRequest;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* I am a generated file.
|
|
4
|
+
*
|
|
5
|
+
* If you change me, you and other developers will be sad.
|
|
6
|
+
*
|
|
7
|
+
* #StayGeneratedStayHappy
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.isConfirmationRequest = void 0;
|
|
14
|
+
const kit_log_1 = require("@xube/kit-log");
|
|
15
|
+
const confirmationRequest_1 = __importDefault(require("../validators/confirmationRequest"));
|
|
16
|
+
const isConfirmationRequest = (item) => {
|
|
17
|
+
const isValid = (0, confirmationRequest_1.default)(item);
|
|
18
|
+
if (!isValid) {
|
|
19
|
+
kit_log_1.XubeLog.getInstance().info(JSON.stringify(confirmationRequest_1.default.errors, null, 2));
|
|
20
|
+
}
|
|
21
|
+
return isValid;
|
|
22
|
+
};
|
|
23
|
+
exports.isConfirmationRequest = isConfirmationRequest;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I am a generated file.
|
|
3
|
+
*
|
|
4
|
+
* If you change me, you and other developers will be sad.
|
|
5
|
+
*
|
|
6
|
+
* #StayGeneratedStayHappy
|
|
7
|
+
*/
|
|
8
|
+
export type DestinationHeaders = {
|
|
9
|
+
"x-amz-rules-engine-message-type": "DestinationConfirmation" | string;
|
|
10
|
+
"x-amz-rules-engine-destination-arn": string;
|
|
11
|
+
"content-type": "application/json";
|
|
12
|
+
};
|
|
13
|
+
export declare const isDestinationHeaders: (item: unknown) => item is DestinationHeaders;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* I am a generated file.
|
|
4
|
+
*
|
|
5
|
+
* If you change me, you and other developers will be sad.
|
|
6
|
+
*
|
|
7
|
+
* #StayGeneratedStayHappy
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.isDestinationHeaders = void 0;
|
|
14
|
+
const kit_log_1 = require("@xube/kit-log");
|
|
15
|
+
const destinationHeaders_1 = __importDefault(require("../validators/destinationHeaders"));
|
|
16
|
+
const isDestinationHeaders = (item) => {
|
|
17
|
+
const isValid = (0, destinationHeaders_1.default)(item);
|
|
18
|
+
if (!isValid) {
|
|
19
|
+
kit_log_1.XubeLog.getInstance().info(JSON.stringify(destinationHeaders_1.default.errors, null, 2));
|
|
20
|
+
}
|
|
21
|
+
return isValid;
|
|
22
|
+
};
|
|
23
|
+
exports.isDestinationHeaders = isDestinationHeaders;
|
package/dist/index.d.ts
ADDED
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DestinationConfirmationMessageType = "DestinationConfirmation";
|
|
3
|
+
export declare const ConfirmationRequestSchema: z.ZodObject<{
|
|
4
|
+
arn: z.ZodString;
|
|
5
|
+
confirmationToken: z.ZodString;
|
|
6
|
+
enableUrl: z.ZodString;
|
|
7
|
+
messageType: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
arn: string;
|
|
10
|
+
confirmationToken: string;
|
|
11
|
+
enableUrl: string;
|
|
12
|
+
messageType: string;
|
|
13
|
+
}, {
|
|
14
|
+
arn: string;
|
|
15
|
+
confirmationToken: string;
|
|
16
|
+
enableUrl: string;
|
|
17
|
+
messageType: string;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfirmationRequestSchema = exports.DestinationConfirmationMessageType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.DestinationConfirmationMessageType = "DestinationConfirmation";
|
|
6
|
+
exports.ConfirmationRequestSchema = zod_1.z.object({
|
|
7
|
+
arn: zod_1.z.string(),
|
|
8
|
+
confirmationToken: zod_1.z.string(),
|
|
9
|
+
enableUrl: zod_1.z.string(),
|
|
10
|
+
messageType: zod_1.z.string(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DestinationHeadersSchema: z.ZodObject<{
|
|
3
|
+
"x-amz-rules-engine-message-type": z.ZodUnion<[z.ZodLiteral<"DestinationConfirmation">, z.ZodString]>;
|
|
4
|
+
"x-amz-rules-engine-destination-arn": z.ZodString;
|
|
5
|
+
"content-type": z.ZodLiteral<"application/json">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
"x-amz-rules-engine-message-type": string;
|
|
8
|
+
"x-amz-rules-engine-destination-arn": string;
|
|
9
|
+
"content-type": "application/json";
|
|
10
|
+
}, {
|
|
11
|
+
"x-amz-rules-engine-message-type": string;
|
|
12
|
+
"x-amz-rules-engine-destination-arn": string;
|
|
13
|
+
"content-type": "application/json";
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DestinationHeadersSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
exports.DestinationHeadersSchema = zod_1.z.object({
|
|
7
|
+
"x-amz-rules-engine-message-type": constants_1.RulesEngineMessageTypesSchema,
|
|
8
|
+
"x-amz-rules-engine-destination-arn": zod_1.z.string(),
|
|
9
|
+
"content-type": zod_1.z.literal("application/json"),
|
|
10
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xube/kit-destination",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"generate": "npx ts-node src/generator.ts"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+ssh://git@github.com/XubeLtd/dev-kit.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Xube Pty Ltd",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/XubeLtd/dev-kit/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/XubeLtd/dev-kit#readme",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.4.7",
|
|
22
|
+
"@xube/kit-build": "^0.0.1",
|
|
23
|
+
"ts-node": "^10.9.1",
|
|
24
|
+
"typescript": "^5.1.6"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@xube/kit-generator": "^0.0.1",
|
|
28
|
+
"@xube/kit-log": "^0.0.1",
|
|
29
|
+
"@xube/kit-request": "^0.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/confirm.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfirmationRequest,
|
|
3
|
+
isConfirmationRequest,
|
|
4
|
+
isDestinationHeaders,
|
|
5
|
+
} from "./generated";
|
|
6
|
+
// import { XubeResponse } from "@xube/common";
|
|
7
|
+
import { StatusCode } from "@xube/kit-constants";
|
|
8
|
+
import { XubeLog } from "@xube/kit-log";
|
|
9
|
+
import { XubeResponse } from "@xube/kit-request";
|
|
10
|
+
|
|
11
|
+
export const isConfirmation = (
|
|
12
|
+
headers: Record<string, string>,
|
|
13
|
+
body: Record<string, any>
|
|
14
|
+
): boolean =>
|
|
15
|
+
isDestinationHeaders(headers) &&
|
|
16
|
+
headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
|
|
17
|
+
isConfirmationRequest(body);
|
|
18
|
+
|
|
19
|
+
export const confirmDestination = async (
|
|
20
|
+
confirmationRequest: ConfirmationRequest,
|
|
21
|
+
log: XubeLog = XubeLog.getInstance()
|
|
22
|
+
): Promise<XubeResponse<boolean>> => {
|
|
23
|
+
const response = await fetch(confirmationRequest.enableUrl, {
|
|
24
|
+
method: "GET",
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
log.info(response.statusText);
|
|
32
|
+
return new XubeResponse({
|
|
33
|
+
statusCode: StatusCode.BadRequest,
|
|
34
|
+
error: "Failed to confirm destination",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return new XubeResponse({
|
|
38
|
+
statusCode: StatusCode.OK,
|
|
39
|
+
data: true,
|
|
40
|
+
});
|
|
41
|
+
};
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DestinationConfirmationMessageType } from "./schemas/confirmation-request";
|
|
3
|
+
|
|
4
|
+
export const RulesEngineMessageTypesSchema = z.union([
|
|
5
|
+
z.literal(DestinationConfirmationMessageType),
|
|
6
|
+
z.string(), //Change to literal when more types are added
|
|
7
|
+
]);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* I am a generated file.
|
|
4
|
+
*
|
|
5
|
+
* If you change me, you and other developers will be sad.
|
|
6
|
+
*
|
|
7
|
+
* #StayGeneratedStayHappy
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type ConfirmationRequest = {
|
|
11
|
+
arn: string;
|
|
12
|
+
confirmationToken: string;
|
|
13
|
+
enableUrl: string;
|
|
14
|
+
messageType: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
import { XubeLog } from "@xube/kit-log";
|
|
20
|
+
import validate from "../validators/confirmationRequest";
|
|
21
|
+
|
|
22
|
+
export const isConfirmationRequest = (item: unknown): item is ConfirmationRequest => {
|
|
23
|
+
const isValid: boolean = validate(item);
|
|
24
|
+
if(!isValid){
|
|
25
|
+
XubeLog.getInstance().info(JSON.stringify((validate as typeof validate & {errors: object}).errors, null, 2));
|
|
26
|
+
}
|
|
27
|
+
return isValid;
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* I am a generated file.
|
|
4
|
+
*
|
|
5
|
+
* If you change me, you and other developers will be sad.
|
|
6
|
+
*
|
|
7
|
+
* #StayGeneratedStayHappy
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type DestinationHeaders = {
|
|
11
|
+
"x-amz-rules-engine-message-type": "DestinationConfirmation" | string;
|
|
12
|
+
"x-amz-rules-engine-destination-arn": string;
|
|
13
|
+
"content-type": "application/json";
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
import { XubeLog } from "@xube/kit-log";
|
|
19
|
+
import validate from "../validators/destinationHeaders";
|
|
20
|
+
|
|
21
|
+
export const isDestinationHeaders = (item: unknown): item is DestinationHeaders => {
|
|
22
|
+
const isValid: boolean = validate(item);
|
|
23
|
+
if(!isValid){
|
|
24
|
+
XubeLog.getInstance().info(JSON.stringify((validate as typeof validate & {errors: object}).errors, null, 2));
|
|
25
|
+
}
|
|
26
|
+
return isValid;
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const validate = validate10;export default validate10;const schema27 = {"$ref":"#/definitions/confirmationrequestJsonSchema","definitions":{"confirmationrequestJsonSchema":{"type":"object","properties":{"arn":{"type":"string"},"confirmationToken":{"type":"string"},"enableUrl":{"type":"string"},"messageType":{"type":"string"}},"required":["arn","confirmationToken","enableUrl","messageType"],"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"};const schema28 = {"type":"object","properties":{"arn":{"type":"string"},"confirmationToken":{"type":"string"},"enableUrl":{"type":"string"},"messageType":{"type":"string"}},"required":["arn","confirmationToken","enableUrl","messageType"],"additionalProperties":false};function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(data && typeof data == "object" && !Array.isArray(data)){if(data.arn === undefined){const err0 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/required",keyword:"required",params:{missingProperty: "arn"},message:"must have required property '"+"arn"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.confirmationToken === undefined){const err1 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/required",keyword:"required",params:{missingProperty: "confirmationToken"},message:"must have required property '"+"confirmationToken"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.enableUrl === undefined){const err2 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/required",keyword:"required",params:{missingProperty: "enableUrl"},message:"must have required property '"+"enableUrl"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.messageType === undefined){const err3 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/required",keyword:"required",params:{missingProperty: "messageType"},message:"must have required property '"+"messageType"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((key0 === "arn") || (key0 === "confirmationToken")) || (key0 === "enableUrl")) || (key0 === "messageType"))){const err4 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.arn !== undefined){if(typeof data.arn !== "string"){const err5 = {instancePath:instancePath+"/arn",schemaPath:"#/definitions/confirmationrequestJsonSchema/properties/arn/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.confirmationToken !== undefined){if(typeof data.confirmationToken !== "string"){const err6 = {instancePath:instancePath+"/confirmationToken",schemaPath:"#/definitions/confirmationrequestJsonSchema/properties/confirmationToken/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.enableUrl !== undefined){if(typeof data.enableUrl !== "string"){const err7 = {instancePath:instancePath+"/enableUrl",schemaPath:"#/definitions/confirmationrequestJsonSchema/properties/enableUrl/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.messageType !== undefined){if(typeof data.messageType !== "string"){const err8 = {instancePath:instancePath+"/messageType",schemaPath:"#/definitions/confirmationrequestJsonSchema/properties/messageType/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}}else {const err9 = {instancePath,schemaPath:"#/definitions/confirmationrequestJsonSchema/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}validate10.errors = vErrors;return errors === 0;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const validate = validate10;export default validate10;const schema27 = {"$ref":"#/definitions/destinationheadersJsonSchema","definitions":{"destinationheadersJsonSchema":{"type":"object","properties":{"x-amz-rules-engine-message-type":{"anyOf":[{"type":"string","const":"DestinationConfirmation"},{"type":"string"}]},"x-amz-rules-engine-destination-arn":{"type":"string"},"content-type":{"type":"string","const":"application/json"}},"required":["x-amz-rules-engine-message-type","x-amz-rules-engine-destination-arn","content-type"],"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"};const schema28 = {"type":"object","properties":{"x-amz-rules-engine-message-type":{"anyOf":[{"type":"string","const":"DestinationConfirmation"},{"type":"string"}]},"x-amz-rules-engine-destination-arn":{"type":"string"},"content-type":{"type":"string","const":"application/json"}},"required":["x-amz-rules-engine-message-type","x-amz-rules-engine-destination-arn","content-type"],"additionalProperties":false};function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(data && typeof data == "object" && !Array.isArray(data)){if(data["x-amz-rules-engine-message-type"] === undefined){const err0 = {instancePath,schemaPath:"#/definitions/destinationheadersJsonSchema/required",keyword:"required",params:{missingProperty: "x-amz-rules-engine-message-type"},message:"must have required property '"+"x-amz-rules-engine-message-type"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data["x-amz-rules-engine-destination-arn"] === undefined){const err1 = {instancePath,schemaPath:"#/definitions/destinationheadersJsonSchema/required",keyword:"required",params:{missingProperty: "x-amz-rules-engine-destination-arn"},message:"must have required property '"+"x-amz-rules-engine-destination-arn"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data["content-type"] === undefined){const err2 = {instancePath,schemaPath:"#/definitions/destinationheadersJsonSchema/required",keyword:"required",params:{missingProperty: "content-type"},message:"must have required property '"+"content-type"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!(((key0 === "x-amz-rules-engine-message-type") || (key0 === "x-amz-rules-engine-destination-arn")) || (key0 === "content-type"))){const err3 = {instancePath,schemaPath:"#/definitions/destinationheadersJsonSchema/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data["x-amz-rules-engine-message-type"] !== undefined){let data0 = data["x-amz-rules-engine-message-type"];const _errs4 = errors;let valid2 = false;const _errs5 = errors;if(typeof data0 !== "string"){const err4 = {instancePath:instancePath+"/x-amz-rules-engine-message-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/x-amz-rules-engine-message-type/anyOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if("DestinationConfirmation" !== data0){const err5 = {instancePath:instancePath+"/x-amz-rules-engine-message-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/x-amz-rules-engine-message-type/anyOf/0/const",keyword:"const",params:{allowedValue: "DestinationConfirmation"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}var _valid0 = _errs5 === errors;valid2 = valid2 || _valid0;if(!valid2){const _errs7 = errors;if(typeof data0 !== "string"){const err6 = {instancePath:instancePath+"/x-amz-rules-engine-message-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/x-amz-rules-engine-message-type/anyOf/1/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}var _valid0 = _errs7 === errors;valid2 = valid2 || _valid0;}if(!valid2){const err7 = {instancePath:instancePath+"/x-amz-rules-engine-message-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/x-amz-rules-engine-message-type/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}else {errors = _errs4;if(vErrors !== null){if(_errs4){vErrors.length = _errs4;}else {vErrors = null;}}}}if(data["x-amz-rules-engine-destination-arn"] !== undefined){if(typeof data["x-amz-rules-engine-destination-arn"] !== "string"){const err8 = {instancePath:instancePath+"/x-amz-rules-engine-destination-arn",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/x-amz-rules-engine-destination-arn/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data["content-type"] !== undefined){let data2 = data["content-type"];if(typeof data2 !== "string"){const err9 = {instancePath:instancePath+"/content-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/content-type/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if("application/json" !== data2){const err10 = {instancePath:instancePath+"/content-type",schemaPath:"#/definitions/destinationheadersJsonSchema/properties/content-type/const",keyword:"const",params:{allowedValue: "application/json"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}}else {const err11 = {instancePath,schemaPath:"#/definitions/destinationheadersJsonSchema/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}validate10.errors = vErrors;return errors === 0;}
|
package/src/generator.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateExportIndex,
|
|
3
|
+
generateTypeSchemaFiles,
|
|
4
|
+
} from "@xube/kit-generator";
|
|
5
|
+
|
|
6
|
+
import { ConfirmationRequestSchema } from "./schemas/confirmation-request";
|
|
7
|
+
import { DestinationHeadersSchema } from "./schemas/headers";
|
|
8
|
+
|
|
9
|
+
const generatedFilePaths: string[] = [
|
|
10
|
+
...generateTypeSchemaFiles(
|
|
11
|
+
"destinationHeaders",
|
|
12
|
+
DestinationHeadersSchema,
|
|
13
|
+
__dirname
|
|
14
|
+
),
|
|
15
|
+
...generateTypeSchemaFiles(
|
|
16
|
+
"confirmationRequest",
|
|
17
|
+
ConfirmationRequestSchema,
|
|
18
|
+
__dirname
|
|
19
|
+
),
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
generateExportIndex(generatedFilePaths, __dirname);
|
package/src/index.ts
ADDED
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const DestinationConfirmationMessageType = "DestinationConfirmation";
|
|
4
|
+
|
|
5
|
+
export const ConfirmationRequestSchema = z.object({
|
|
6
|
+
arn: z.string(),
|
|
7
|
+
confirmationToken: z.string(),
|
|
8
|
+
enableUrl: z.string(),
|
|
9
|
+
messageType: z.string(),
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RulesEngineMessageTypesSchema } from "../constants";
|
|
3
|
+
|
|
4
|
+
export const DestinationHeadersSchema = z.object({
|
|
5
|
+
"x-amz-rules-engine-message-type": RulesEngineMessageTypesSchema,
|
|
6
|
+
"x-amz-rules-engine-destination-arn": z.string(),
|
|
7
|
+
"content-type": z.literal("application/json"),
|
|
8
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../kit-build/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist"
|
|
6
|
+
},
|
|
7
|
+
"exclude": ["**/*.test.ts", "**/*.mock.ts", "dist", "./src/generator.ts"],
|
|
8
|
+
"references": [
|
|
9
|
+
{
|
|
10
|
+
"path": "../kit-generator"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "../kit-constants"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "../kit-request"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|