@marinade.finance/notifications-staking-rewards-report-status-v1 1.0.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.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * ReportStatus enum
3
+ */
4
+ export type ReportStatusV1 = 'Missing' | 'Requested' | 'Processing' | 'Ready' | 'VerificationSkipped' | 'Verifying' | 'Verified' | 'Error' | 'VerificationFailed';
5
+ export interface StakingRewardsReportStatusV1 {
6
+ /**
7
+ * Solana public key
8
+ */
9
+ withdraw: string;
10
+ /**
11
+ * Modification timestamp
12
+ */
13
+ mtime: number;
14
+ status: ReportStatusV1;
15
+ /**
16
+ * Error message if status indicates error
17
+ */
18
+ error: string;
19
+ /**
20
+ * Target slot
21
+ */
22
+ to_slot: number;
23
+ /**
24
+ * Target block time
25
+ */
26
+ to_block_time: number;
27
+ [k: string]: unknown;
28
+ }
29
+ import type { JsonSchema } from '@marinade.finance/notifications-ts-message';
30
+ export declare const SCHEMA: {
31
+ readonly $id: "staking-rewards-report-status-v1";
32
+ readonly title: "StakingRewardsReportStatusV1";
33
+ readonly type: "object";
34
+ readonly required: readonly ["withdraw", "mtime", "status", "error", "to_slot", "to_block_time"];
35
+ readonly $defs: {
36
+ readonly ReportStatusV1: {
37
+ readonly type: "string";
38
+ readonly enum: readonly ["Missing", "Requested", "Processing", "Ready", "VerificationSkipped", "Verifying", "Verified", "Error", "VerificationFailed"];
39
+ readonly description: "ReportStatus enum";
40
+ };
41
+ };
42
+ readonly properties: {
43
+ readonly withdraw: {
44
+ readonly type: "string";
45
+ readonly description: "Solana public key";
46
+ };
47
+ readonly mtime: {
48
+ readonly type: "integer";
49
+ readonly minimum: 0;
50
+ readonly description: "Modification timestamp";
51
+ };
52
+ readonly status: {
53
+ readonly $ref: "#/$defs/ReportStatusV1";
54
+ };
55
+ readonly error: {
56
+ readonly type: "string";
57
+ readonly description: "Error message if status indicates error";
58
+ };
59
+ readonly to_slot: {
60
+ readonly type: "integer";
61
+ readonly minimum: 0;
62
+ readonly description: "Target slot";
63
+ };
64
+ readonly to_block_time: {
65
+ readonly type: "integer";
66
+ readonly minimum: 0;
67
+ readonly description: "Target block time";
68
+ };
69
+ };
70
+ };
71
+ export declare const MESSAGE_SCHEMA: JsonSchema;
72
+ /**
73
+ * Validator for StakingRewardsReportStatusV1.
74
+ */
75
+ export declare const StakingRewardsReportStatusV1Validator: {
76
+ validate(payload: unknown): asserts payload is StakingRewardsReportStatusV1;
77
+ };
package/dist/index.js ADDED
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ // Generated code - do not edit
3
+ // Schema: staking-rewards-report-status-v1.json
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.StakingRewardsReportStatusV1Validator = exports.MESSAGE_SCHEMA = exports.SCHEMA = void 0;
9
+ const notifications_ts_message_1 = require("@marinade.finance/notifications-ts-message");
10
+ const ajv_1 = __importDefault(require("ajv"));
11
+ const ajv_formats_1 = __importDefault(require("ajv-formats"));
12
+ // Embedded schemas
13
+ exports.SCHEMA = {
14
+ $id: 'staking-rewards-report-status-v1',
15
+ title: 'StakingRewardsReportStatusV1',
16
+ type: 'object',
17
+ required: [
18
+ 'withdraw',
19
+ 'mtime',
20
+ 'status',
21
+ 'error',
22
+ 'to_slot',
23
+ 'to_block_time',
24
+ ],
25
+ $defs: {
26
+ ReportStatusV1: {
27
+ type: 'string',
28
+ enum: [
29
+ 'Missing',
30
+ 'Requested',
31
+ 'Processing',
32
+ 'Ready',
33
+ 'VerificationSkipped',
34
+ 'Verifying',
35
+ 'Verified',
36
+ 'Error',
37
+ 'VerificationFailed',
38
+ ],
39
+ description: 'ReportStatus enum',
40
+ },
41
+ },
42
+ properties: {
43
+ withdraw: {
44
+ type: 'string',
45
+ description: 'Solana public key',
46
+ },
47
+ mtime: {
48
+ type: 'integer',
49
+ minimum: 0,
50
+ description: 'Modification timestamp',
51
+ },
52
+ status: {
53
+ $ref: '#/$defs/ReportStatusV1',
54
+ },
55
+ error: {
56
+ type: 'string',
57
+ description: 'Error message if status indicates error',
58
+ },
59
+ to_slot: {
60
+ type: 'integer',
61
+ minimum: 0,
62
+ description: 'Target slot',
63
+ },
64
+ to_block_time: {
65
+ type: 'integer',
66
+ minimum: 0,
67
+ description: 'Target block time',
68
+ },
69
+ },
70
+ };
71
+ function getMessageSchema() {
72
+ const headerSchema = notifications_ts_message_1.HEADER_SCHEMA;
73
+ const payloadSchema = exports.SCHEMA;
74
+ return (0, notifications_ts_message_1.createMessageSchema)(headerSchema, payloadSchema);
75
+ }
76
+ exports.MESSAGE_SCHEMA = getMessageSchema();
77
+ // Runtime validator
78
+ let ajvInstance = null;
79
+ function getAjv() {
80
+ if (!ajvInstance) {
81
+ ajvInstance = new ajv_1.default({
82
+ allErrors: true,
83
+ schemas: [notifications_ts_message_1.HEADER_SCHEMA, exports.SCHEMA],
84
+ });
85
+ (0, ajv_formats_1.default)(ajvInstance);
86
+ }
87
+ return ajvInstance;
88
+ }
89
+ /**
90
+ * Validator for StakingRewardsReportStatusV1.
91
+ */
92
+ exports.StakingRewardsReportStatusV1Validator = {
93
+ validate(payload) {
94
+ const ajv = getAjv();
95
+ const validateFn = ajv.getSchema('staking-rewards-report-status-v1');
96
+ if (!validateFn) {
97
+ throw new Error('Schema not found');
98
+ }
99
+ const valid = validateFn(payload);
100
+ if (!valid) {
101
+ const errors = validateFn.errors;
102
+ const message = errors?.map(e => `${e.instancePath} ${e.message}`).join(', ') ||
103
+ 'validation failed';
104
+ throw new Error(`payload validation failed: ${message}`);
105
+ }
106
+ },
107
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@marinade.finance/notifications-staking-rewards-report-status-v1",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "dependencies": {
13
+ "ajv": "^8.12.0",
14
+ "ajv-formats": "^2.1.1",
15
+ "@marinade.finance/notifications-ts-message": "1.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.3.3",
19
+ "vitest": "^1.0.0"
20
+ },
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "test": "vitest run"
24
+ }
25
+ }