@open-loyalty/mcp-server 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.
- package/LICENSE +21 -0
- package/README.md +654 -0
- package/dist/client/http.d.ts +8 -0
- package/dist/client/http.js +69 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +334 -0
- package/dist/tools/achievement.d.ts +983 -0
- package/dist/tools/achievement.js +311 -0
- package/dist/tools/admin.d.ts +153 -0
- package/dist/tools/admin.js +193 -0
- package/dist/tools/analytics.d.ts +162 -0
- package/dist/tools/analytics.js +245 -0
- package/dist/tools/apikey.d.ts +72 -0
- package/dist/tools/apikey.js +78 -0
- package/dist/tools/audit.d.ts +107 -0
- package/dist/tools/audit.js +90 -0
- package/dist/tools/badge.d.ts +135 -0
- package/dist/tools/badge.js +165 -0
- package/dist/tools/campaign.d.ts +1775 -0
- package/dist/tools/campaign.js +724 -0
- package/dist/tools/export.d.ts +110 -0
- package/dist/tools/export.js +147 -0
- package/dist/tools/import.d.ts +110 -0
- package/dist/tools/import.js +126 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.js +527 -0
- package/dist/tools/member.d.ts +345 -0
- package/dist/tools/member.js +358 -0
- package/dist/tools/member.test.d.ts +1 -0
- package/dist/tools/member.test.js +213 -0
- package/dist/tools/points.d.ts +188 -0
- package/dist/tools/points.js +306 -0
- package/dist/tools/points.test.d.ts +1 -0
- package/dist/tools/points.test.js +292 -0
- package/dist/tools/reward.d.ts +261 -0
- package/dist/tools/reward.js +371 -0
- package/dist/tools/reward.test.d.ts +1 -0
- package/dist/tools/reward.test.js +240 -0
- package/dist/tools/role.d.ts +161 -0
- package/dist/tools/role.js +160 -0
- package/dist/tools/segment.d.ts +797 -0
- package/dist/tools/segment.js +299 -0
- package/dist/tools/store.d.ts +101 -0
- package/dist/tools/store.js +117 -0
- package/dist/tools/tierset.d.ts +288 -0
- package/dist/tools/tierset.js +244 -0
- package/dist/tools/transaction.d.ts +357 -0
- package/dist/tools/transaction.js +242 -0
- package/dist/tools/transaction.test.d.ts +1 -0
- package/dist/tools/transaction.test.js +235 -0
- package/dist/tools/wallet-type.d.ts +32 -0
- package/dist/tools/wallet-type.js +58 -0
- package/dist/tools/webhook.d.ts +179 -0
- package/dist/tools/webhook.js +171 -0
- package/dist/types/schemas/achievement.d.ts +1116 -0
- package/dist/types/schemas/achievement.js +172 -0
- package/dist/types/schemas/admin.d.ts +263 -0
- package/dist/types/schemas/admin.js +99 -0
- package/dist/types/schemas/analytics.d.ts +542 -0
- package/dist/types/schemas/analytics.js +130 -0
- package/dist/types/schemas/badge.d.ts +131 -0
- package/dist/types/schemas/badge.js +48 -0
- package/dist/types/schemas/campaign.d.ts +2005 -0
- package/dist/types/schemas/campaign.js +189 -0
- package/dist/types/schemas/common.d.ts +52 -0
- package/dist/types/schemas/common.js +26 -0
- package/dist/types/schemas/export.d.ts +127 -0
- package/dist/types/schemas/export.js +43 -0
- package/dist/types/schemas/import.d.ts +344 -0
- package/dist/types/schemas/import.js +68 -0
- package/dist/types/schemas/member.d.ts +443 -0
- package/dist/types/schemas/member.js +92 -0
- package/dist/types/schemas/points.d.ts +188 -0
- package/dist/types/schemas/points.js +54 -0
- package/dist/types/schemas/reward.d.ts +278 -0
- package/dist/types/schemas/reward.js +69 -0
- package/dist/types/schemas/role.d.ts +260 -0
- package/dist/types/schemas/role.js +75 -0
- package/dist/types/schemas/segment.d.ts +592 -0
- package/dist/types/schemas/segment.js +114 -0
- package/dist/types/schemas/tierset.d.ts +552 -0
- package/dist/types/schemas/tierset.js +87 -0
- package/dist/types/schemas/transaction.d.ts +1022 -0
- package/dist/types/schemas/transaction.js +63 -0
- package/dist/types/schemas/wallet-type.d.ts +99 -0
- package/dist/types/schemas/wallet-type.js +17 -0
- package/dist/types/schemas/webhook.d.ts +195 -0
- package/dist/types/schemas/webhook.js +39 -0
- package/dist/utils/cursor.d.ts +84 -0
- package/dist/utils/cursor.js +117 -0
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.js +69 -0
- package/dist/utils/pagination.d.ts +39 -0
- package/dist/utils/pagination.js +77 -0
- package/package.json +65 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TranslationsSchema } from "./common.js";
|
|
3
|
+
/**
|
|
4
|
+
* Achievement Trigger Enum.
|
|
5
|
+
* Defines what events can trigger progress on an achievement.
|
|
6
|
+
*/
|
|
7
|
+
export const AchievementTriggerEnum = z.enum([
|
|
8
|
+
"transaction",
|
|
9
|
+
"custom_event",
|
|
10
|
+
"points_transfer",
|
|
11
|
+
"reward_redemption",
|
|
12
|
+
"referral",
|
|
13
|
+
"achievement",
|
|
14
|
+
"tier_change",
|
|
15
|
+
"registration",
|
|
16
|
+
"profile_update",
|
|
17
|
+
"login",
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Achievement Period Type Enum.
|
|
21
|
+
* Defines the time period for achievement completion rules.
|
|
22
|
+
*/
|
|
23
|
+
export const AchievementPeriodTypeEnum = z.enum([
|
|
24
|
+
"day",
|
|
25
|
+
"week",
|
|
26
|
+
"month",
|
|
27
|
+
"year",
|
|
28
|
+
"forever",
|
|
29
|
+
"calendarDays",
|
|
30
|
+
"calendarWeeks",
|
|
31
|
+
"calendarMonths",
|
|
32
|
+
"calendarYears",
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Achievement Period Schema.
|
|
36
|
+
* Defines the period for tracking achievement progress.
|
|
37
|
+
*/
|
|
38
|
+
export const AchievementPeriodSchema = z.object({
|
|
39
|
+
consecutive: z.number().optional().describe("Number of consecutive periods required."),
|
|
40
|
+
value: z.number().optional().describe("Period value (e.g., 30 for 30 days)."),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Achievement Complete Rule Schema.
|
|
44
|
+
* Defines when an achievement is considered complete.
|
|
45
|
+
*/
|
|
46
|
+
export const AchievementCompleteRuleSchema = z.object({
|
|
47
|
+
periodGoal: z.union([z.number(), z.string()]).describe("Goal value to reach within the period."),
|
|
48
|
+
period: AchievementPeriodSchema.optional().describe("Period configuration."),
|
|
49
|
+
uniqueAttribute: z.string().optional().describe("Attribute for unique counting (e.g., count unique SKUs)."),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Achievement Aggregation Schema.
|
|
53
|
+
* Defines how to aggregate values for achievement progress.
|
|
54
|
+
*/
|
|
55
|
+
export const AchievementAggregationSchema = z.object({
|
|
56
|
+
rule: z.string().optional().describe("Aggregation rule expression."),
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Achievement Limit Interval Schema.
|
|
60
|
+
* Defines the time interval for achievement limits.
|
|
61
|
+
*/
|
|
62
|
+
export const AchievementLimitIntervalSchema = z.object({
|
|
63
|
+
type: z.string().describe("Interval type (e.g., 'calendarYears', 'days')."),
|
|
64
|
+
value: z.number().optional().describe("Interval value."),
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Achievement Limit Schema.
|
|
68
|
+
* Defines limits on achievement completions.
|
|
69
|
+
*/
|
|
70
|
+
export const AchievementLimitSchema = z.object({
|
|
71
|
+
value: z.number().optional().describe("Maximum completions."),
|
|
72
|
+
interval: AchievementLimitIntervalSchema.optional().describe("Time interval for the limit."),
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Achievement Rule Schema.
|
|
76
|
+
* Defines a rule for how to track and complete an achievement.
|
|
77
|
+
*/
|
|
78
|
+
export const AchievementRuleSchema = z.object({
|
|
79
|
+
achievementRuleId: z.string().optional().describe("Rule ID (generated on creation)."),
|
|
80
|
+
translations: TranslationsSchema.optional().describe("Rule name and description translations."),
|
|
81
|
+
trigger: z.string().optional().describe("Event type that triggers rule progress."),
|
|
82
|
+
type: z.string().optional().describe("Rule type."),
|
|
83
|
+
event: z.string().optional().describe("Custom event code for custom_event trigger."),
|
|
84
|
+
completeRule: AchievementCompleteRuleSchema.describe("Completion goal configuration."),
|
|
85
|
+
aggregation: AchievementAggregationSchema.optional().describe("Value aggregation configuration."),
|
|
86
|
+
conditions: z.array(z.record(z.unknown())).optional().describe("Conditions that must be met."),
|
|
87
|
+
limit: AchievementLimitSchema.optional().describe("Per-rule limit configuration."),
|
|
88
|
+
uniqueReferee: z.boolean().optional().describe("Whether referee must be unique for referral achievements."),
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Achievement Activity Schema.
|
|
92
|
+
* Defines when an achievement is active.
|
|
93
|
+
*/
|
|
94
|
+
export const AchievementActivitySchema = z.object({
|
|
95
|
+
startsAt: z.string().optional().describe("ISO datetime when achievement becomes active."),
|
|
96
|
+
endsAt: z.string().optional().describe("ISO datetime when achievement ends."),
|
|
97
|
+
data: z.string().optional().describe("Activity data for condition-based activity."),
|
|
98
|
+
operator: z.string().optional().describe("Operator for activity condition (is_greater, is_before, etc.)."),
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Main Achievement Schema.
|
|
102
|
+
* Represents a complete achievement with all configuration.
|
|
103
|
+
*/
|
|
104
|
+
export const AchievementSchema = z.object({
|
|
105
|
+
achievementId: z.string().describe("Achievement ID (UUID)."),
|
|
106
|
+
translations: TranslationsSchema.describe("Achievement name and description translations."),
|
|
107
|
+
active: z.boolean().describe("Whether achievement is active."),
|
|
108
|
+
activity: AchievementActivitySchema.optional().describe("Time period when achievement is active."),
|
|
109
|
+
limit: AchievementLimitSchema.optional().describe("Overall achievement limit configuration."),
|
|
110
|
+
rules: z.array(AchievementRuleSchema).describe("Achievement rules defining completion criteria."),
|
|
111
|
+
badgeTypeId: z.string().optional().describe("Badge type awarded upon completion."),
|
|
112
|
+
createdAt: z.string().optional().describe("Creation timestamp."),
|
|
113
|
+
completionsCount: z.number().optional().describe("Number of completions across all members."),
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* Achievement List Item Schema.
|
|
117
|
+
* Simplified representation for list responses.
|
|
118
|
+
*/
|
|
119
|
+
export const AchievementListItemSchema = z.object({
|
|
120
|
+
achievementId: z.string(),
|
|
121
|
+
name: z.string().optional(),
|
|
122
|
+
active: z.boolean(),
|
|
123
|
+
createdAt: z.string().optional(),
|
|
124
|
+
badgeTypeId: z.string().optional(),
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Achievement Create Input Schema.
|
|
128
|
+
* Matches the POST /api/{storeCode}/achievement body structure.
|
|
129
|
+
* IMPORTANT: Request must be wrapped as { achievement: {...} }
|
|
130
|
+
*/
|
|
131
|
+
export const AchievementCreateInputSchema = z.object({
|
|
132
|
+
translations: TranslationsSchema.describe("Achievement name and description (at least 'en' required)."),
|
|
133
|
+
active: z.boolean().optional().describe("Whether achievement is active (default: false)."),
|
|
134
|
+
activity: AchievementActivitySchema.optional().describe("Time period configuration."),
|
|
135
|
+
limit: AchievementLimitSchema.optional().describe("Limit configuration."),
|
|
136
|
+
rules: z.array(AchievementRuleSchema).describe("Achievement rules."),
|
|
137
|
+
badgeTypeId: z.string().optional().describe("Badge type to award."),
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Achievement Rule Progress Schema.
|
|
141
|
+
* Tracks a member's progress on a single rule.
|
|
142
|
+
*/
|
|
143
|
+
export const AchievementRuleProgressSchema = z.object({
|
|
144
|
+
achievementRuleId: z.string().describe("Rule ID."),
|
|
145
|
+
periodGoal: z.number().describe("Goal value for the period."),
|
|
146
|
+
currentPeriodValue: z.number().describe("Current progress value."),
|
|
147
|
+
consecutivePeriods: z.number().optional().describe("Required consecutive periods."),
|
|
148
|
+
completedConsecutivePeriods: z.number().optional().describe("Completed consecutive periods."),
|
|
149
|
+
periodType: z.string().optional().describe("Period type."),
|
|
150
|
+
type: z.string().optional().describe("Rule type."),
|
|
151
|
+
trigger: z.string().optional().describe("Trigger type."),
|
|
152
|
+
periodValue: z.number().optional().describe("Period value."),
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* Achievement Member Progress Schema.
|
|
156
|
+
* Tracks a member's overall progress on an achievement.
|
|
157
|
+
*/
|
|
158
|
+
export const AchievementMemberProgressSchema = z.object({
|
|
159
|
+
completedCount: z.number().describe("Number of times completed."),
|
|
160
|
+
rules: z.array(AchievementRuleProgressSchema).describe("Progress on each rule."),
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Achievement Progress Schema.
|
|
164
|
+
* Complete progress data for a member's achievement.
|
|
165
|
+
*/
|
|
166
|
+
export const AchievementProgressSchema = z.object({
|
|
167
|
+
achievementId: z.string().describe("Achievement ID."),
|
|
168
|
+
achievementName: z.string().optional().describe("Achievement name."),
|
|
169
|
+
achievementDescription: z.string().optional().describe("Achievement description."),
|
|
170
|
+
limitReached: z.boolean().optional().describe("Whether member has reached the limit."),
|
|
171
|
+
memberProgress: AchievementMemberProgressSchema.describe("Member's progress details."),
|
|
172
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Admin Role Schema.
|
|
4
|
+
* Represents a role assigned to an admin user.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AdminRoleSchema: z.ZodObject<{
|
|
7
|
+
role: z.ZodOptional<z.ZodString>;
|
|
8
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
9
|
+
name: z.ZodOptional<z.ZodString>;
|
|
10
|
+
master: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
id?: string | number | undefined;
|
|
15
|
+
role?: string | undefined;
|
|
16
|
+
master?: boolean | undefined;
|
|
17
|
+
default?: boolean | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
id?: string | number | undefined;
|
|
21
|
+
role?: string | undefined;
|
|
22
|
+
master?: boolean | undefined;
|
|
23
|
+
default?: boolean | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type AdminRole = z.infer<typeof AdminRoleSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Admin Settings Schema.
|
|
28
|
+
* User-specific settings for an admin.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AdminSettingsSchema: z.ZodObject<{
|
|
31
|
+
notificationsEnabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type AdminSettings = z.infer<typeof AdminSettingsSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Admin User Schema.
|
|
40
|
+
* Full admin user profile from GET /api/admin/data/{adminId}
|
|
41
|
+
*/
|
|
42
|
+
export declare const AdminUserSchema: z.ZodObject<{
|
|
43
|
+
id: z.ZodOptional<z.ZodString>;
|
|
44
|
+
adminId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
username: z.ZodOptional<z.ZodString>;
|
|
46
|
+
email: z.ZodOptional<z.ZodString>;
|
|
47
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
48
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
49
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
50
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
canChangePassword: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
54
|
+
role: z.ZodOptional<z.ZodString>;
|
|
55
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
56
|
+
name: z.ZodOptional<z.ZodString>;
|
|
57
|
+
master: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
name?: string | undefined;
|
|
61
|
+
id?: string | number | undefined;
|
|
62
|
+
role?: string | undefined;
|
|
63
|
+
master?: boolean | undefined;
|
|
64
|
+
default?: boolean | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
name?: string | undefined;
|
|
67
|
+
id?: string | number | undefined;
|
|
68
|
+
role?: string | undefined;
|
|
69
|
+
master?: boolean | undefined;
|
|
70
|
+
default?: boolean | undefined;
|
|
71
|
+
}>, "many">>;
|
|
72
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
notificationsEnabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
76
|
+
}, {
|
|
77
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
78
|
+
}>>;
|
|
79
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
80
|
+
dtype: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
createdAt?: string | undefined;
|
|
83
|
+
id?: string | undefined;
|
|
84
|
+
email?: string | undefined;
|
|
85
|
+
firstName?: string | undefined;
|
|
86
|
+
lastName?: string | undefined;
|
|
87
|
+
phone?: string | undefined;
|
|
88
|
+
adminId?: string | undefined;
|
|
89
|
+
username?: string | undefined;
|
|
90
|
+
isActive?: boolean | undefined;
|
|
91
|
+
external?: boolean | undefined;
|
|
92
|
+
canChangePassword?: boolean | undefined;
|
|
93
|
+
roles?: {
|
|
94
|
+
name?: string | undefined;
|
|
95
|
+
id?: string | number | undefined;
|
|
96
|
+
role?: string | undefined;
|
|
97
|
+
master?: boolean | undefined;
|
|
98
|
+
default?: boolean | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
settings?: {
|
|
101
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
dtype?: string | undefined;
|
|
104
|
+
}, {
|
|
105
|
+
createdAt?: string | undefined;
|
|
106
|
+
id?: string | undefined;
|
|
107
|
+
email?: string | undefined;
|
|
108
|
+
firstName?: string | undefined;
|
|
109
|
+
lastName?: string | undefined;
|
|
110
|
+
phone?: string | undefined;
|
|
111
|
+
adminId?: string | undefined;
|
|
112
|
+
username?: string | undefined;
|
|
113
|
+
isActive?: boolean | undefined;
|
|
114
|
+
external?: boolean | undefined;
|
|
115
|
+
canChangePassword?: boolean | undefined;
|
|
116
|
+
roles?: {
|
|
117
|
+
name?: string | undefined;
|
|
118
|
+
id?: string | number | undefined;
|
|
119
|
+
role?: string | undefined;
|
|
120
|
+
master?: boolean | undefined;
|
|
121
|
+
default?: boolean | undefined;
|
|
122
|
+
}[] | undefined;
|
|
123
|
+
settings?: {
|
|
124
|
+
notificationsEnabled?: string | boolean | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
dtype?: string | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
export type AdminUser = z.infer<typeof AdminUserSchema>;
|
|
129
|
+
/**
|
|
130
|
+
* Admin User List Item Schema.
|
|
131
|
+
* Simplified representation for list responses.
|
|
132
|
+
*/
|
|
133
|
+
export declare const AdminUserListItemSchema: z.ZodObject<{
|
|
134
|
+
id: z.ZodOptional<z.ZodString>;
|
|
135
|
+
username: z.ZodOptional<z.ZodString>;
|
|
136
|
+
email: z.ZodOptional<z.ZodString>;
|
|
137
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
138
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
139
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
140
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
createdAt?: string | undefined;
|
|
143
|
+
id?: string | undefined;
|
|
144
|
+
email?: string | undefined;
|
|
145
|
+
firstName?: string | undefined;
|
|
146
|
+
lastName?: string | undefined;
|
|
147
|
+
username?: string | undefined;
|
|
148
|
+
isActive?: boolean | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
createdAt?: string | undefined;
|
|
151
|
+
id?: string | undefined;
|
|
152
|
+
email?: string | undefined;
|
|
153
|
+
firstName?: string | undefined;
|
|
154
|
+
lastName?: string | undefined;
|
|
155
|
+
username?: string | undefined;
|
|
156
|
+
isActive?: boolean | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
export type AdminUserListItem = z.infer<typeof AdminUserListItemSchema>;
|
|
159
|
+
/**
|
|
160
|
+
* Admin User Create Input Schema.
|
|
161
|
+
* Input for POST /api/admin/data - uses { admin: {...} } wrapper
|
|
162
|
+
*/
|
|
163
|
+
export declare const AdminUserCreateInputSchema: z.ZodObject<{
|
|
164
|
+
email: z.ZodString;
|
|
165
|
+
plainPassword: z.ZodString;
|
|
166
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
167
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
168
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
169
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
170
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
notificationsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
email: string;
|
|
175
|
+
plainPassword: string;
|
|
176
|
+
firstName?: string | undefined;
|
|
177
|
+
lastName?: string | undefined;
|
|
178
|
+
phone?: string | undefined;
|
|
179
|
+
notificationsEnabled?: boolean | undefined;
|
|
180
|
+
isActive?: boolean | undefined;
|
|
181
|
+
external?: boolean | undefined;
|
|
182
|
+
roles?: (string | number)[] | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
email: string;
|
|
185
|
+
plainPassword: string;
|
|
186
|
+
firstName?: string | undefined;
|
|
187
|
+
lastName?: string | undefined;
|
|
188
|
+
phone?: string | undefined;
|
|
189
|
+
notificationsEnabled?: boolean | undefined;
|
|
190
|
+
isActive?: boolean | undefined;
|
|
191
|
+
external?: boolean | undefined;
|
|
192
|
+
roles?: (string | number)[] | undefined;
|
|
193
|
+
}>;
|
|
194
|
+
export type AdminUserCreateInput = z.infer<typeof AdminUserCreateInputSchema>;
|
|
195
|
+
/**
|
|
196
|
+
* Admin User Update Input Schema.
|
|
197
|
+
* Input for PUT /api/admin/data/{adminId} - uses { admin: {...} } wrapper
|
|
198
|
+
*/
|
|
199
|
+
export declare const AdminUserUpdateInputSchema: z.ZodObject<{
|
|
200
|
+
email: z.ZodOptional<z.ZodString>;
|
|
201
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
202
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
203
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
204
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
205
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
+
notificationsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
+
plainPassword: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
email?: string | undefined;
|
|
211
|
+
firstName?: string | undefined;
|
|
212
|
+
lastName?: string | undefined;
|
|
213
|
+
phone?: string | undefined;
|
|
214
|
+
notificationsEnabled?: boolean | undefined;
|
|
215
|
+
isActive?: boolean | undefined;
|
|
216
|
+
external?: boolean | undefined;
|
|
217
|
+
roles?: (string | number)[] | undefined;
|
|
218
|
+
plainPassword?: string | undefined;
|
|
219
|
+
}, {
|
|
220
|
+
email?: string | undefined;
|
|
221
|
+
firstName?: string | undefined;
|
|
222
|
+
lastName?: string | undefined;
|
|
223
|
+
phone?: string | undefined;
|
|
224
|
+
notificationsEnabled?: boolean | undefined;
|
|
225
|
+
isActive?: boolean | undefined;
|
|
226
|
+
external?: boolean | undefined;
|
|
227
|
+
roles?: (string | number)[] | undefined;
|
|
228
|
+
plainPassword?: string | undefined;
|
|
229
|
+
}>;
|
|
230
|
+
export type AdminUserUpdateInput = z.infer<typeof AdminUserUpdateInputSchema>;
|
|
231
|
+
/**
|
|
232
|
+
* Admin Permission Schema.
|
|
233
|
+
* Represents admin permissions.
|
|
234
|
+
*/
|
|
235
|
+
export declare const AdminPermissionSchema: z.ZodObject<{
|
|
236
|
+
superAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
238
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
roles?: string[] | undefined;
|
|
241
|
+
superAdmin?: boolean | undefined;
|
|
242
|
+
permissions?: string[] | undefined;
|
|
243
|
+
}, {
|
|
244
|
+
roles?: string[] | undefined;
|
|
245
|
+
superAdmin?: boolean | undefined;
|
|
246
|
+
permissions?: string[] | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
export type AdminPermission = z.infer<typeof AdminPermissionSchema>;
|
|
249
|
+
/**
|
|
250
|
+
* Change Password Input Schema.
|
|
251
|
+
* Input for PUT /api/admin/password
|
|
252
|
+
*/
|
|
253
|
+
export declare const ChangePasswordInputSchema: z.ZodObject<{
|
|
254
|
+
currentPassword: z.ZodString;
|
|
255
|
+
plainPassword: z.ZodString;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
plainPassword: string;
|
|
258
|
+
currentPassword: string;
|
|
259
|
+
}, {
|
|
260
|
+
plainPassword: string;
|
|
261
|
+
currentPassword: string;
|
|
262
|
+
}>;
|
|
263
|
+
export type ChangePasswordInput = z.infer<typeof ChangePasswordInputSchema>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Admin Role Schema.
|
|
4
|
+
* Represents a role assigned to an admin user.
|
|
5
|
+
*/
|
|
6
|
+
export const AdminRoleSchema = z.object({
|
|
7
|
+
role: z.string().optional().describe("Role identifier."),
|
|
8
|
+
id: z.union([z.string(), z.number()]).optional().describe("Role ID."),
|
|
9
|
+
name: z.string().optional().describe("Role name."),
|
|
10
|
+
master: z.boolean().optional().describe("Whether this is a master/super role."),
|
|
11
|
+
default: z.boolean().optional().describe("Whether this is a default role."),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Admin Settings Schema.
|
|
15
|
+
* User-specific settings for an admin.
|
|
16
|
+
*/
|
|
17
|
+
export const AdminSettingsSchema = z.object({
|
|
18
|
+
notificationsEnabled: z.union([z.boolean(), z.string()]).optional().describe("Whether notifications are enabled."),
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Admin User Schema.
|
|
22
|
+
* Full admin user profile from GET /api/admin/data/{adminId}
|
|
23
|
+
*/
|
|
24
|
+
export const AdminUserSchema = z.object({
|
|
25
|
+
id: z.string().optional().describe("Admin user ID (UUID)."),
|
|
26
|
+
adminId: z.string().optional().describe("Admin user ID (alternative key)."),
|
|
27
|
+
username: z.string().optional().describe("Admin username."),
|
|
28
|
+
email: z.string().optional().describe("Admin email address."),
|
|
29
|
+
firstName: z.string().optional().describe("Admin first name."),
|
|
30
|
+
lastName: z.string().optional().describe("Admin last name."),
|
|
31
|
+
phone: z.string().optional().describe("Admin phone number."),
|
|
32
|
+
isActive: z.boolean().optional().describe("Whether admin account is active."),
|
|
33
|
+
external: z.boolean().optional().describe("Whether admin is from external system."),
|
|
34
|
+
canChangePassword: z.boolean().optional().describe("Whether admin can change their password."),
|
|
35
|
+
roles: z.array(AdminRoleSchema).optional().describe("Roles assigned to admin."),
|
|
36
|
+
settings: AdminSettingsSchema.optional().describe("Admin-specific settings."),
|
|
37
|
+
createdAt: z.string().optional().describe("Account creation timestamp."),
|
|
38
|
+
dtype: z.string().optional().describe("Discriminator type."),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Admin User List Item Schema.
|
|
42
|
+
* Simplified representation for list responses.
|
|
43
|
+
*/
|
|
44
|
+
export const AdminUserListItemSchema = z.object({
|
|
45
|
+
id: z.string().optional().describe("Admin user ID."),
|
|
46
|
+
username: z.string().optional().describe("Admin username."),
|
|
47
|
+
email: z.string().optional().describe("Admin email address."),
|
|
48
|
+
firstName: z.string().optional().describe("Admin first name."),
|
|
49
|
+
lastName: z.string().optional().describe("Admin last name."),
|
|
50
|
+
isActive: z.boolean().optional().describe("Whether admin account is active."),
|
|
51
|
+
createdAt: z.string().optional().describe("Account creation timestamp."),
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Admin User Create Input Schema.
|
|
55
|
+
* Input for POST /api/admin/data - uses { admin: {...} } wrapper
|
|
56
|
+
*/
|
|
57
|
+
export const AdminUserCreateInputSchema = z.object({
|
|
58
|
+
email: z.string().describe("Admin email address (required)."),
|
|
59
|
+
plainPassword: z.string().describe("Admin password (required)."),
|
|
60
|
+
firstName: z.string().optional().describe("Admin first name."),
|
|
61
|
+
lastName: z.string().optional().describe("Admin last name."),
|
|
62
|
+
phone: z.string().optional().describe("Admin phone number."),
|
|
63
|
+
roles: z.array(z.union([z.string(), z.number()])).optional().describe("Role IDs to assign."),
|
|
64
|
+
isActive: z.boolean().optional().describe("Whether account is active (default: true)."),
|
|
65
|
+
external: z.boolean().optional().describe("Whether admin is external."),
|
|
66
|
+
notificationsEnabled: z.boolean().optional().describe("Whether notifications are enabled."),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Admin User Update Input Schema.
|
|
70
|
+
* Input for PUT /api/admin/data/{adminId} - uses { admin: {...} } wrapper
|
|
71
|
+
*/
|
|
72
|
+
export const AdminUserUpdateInputSchema = z.object({
|
|
73
|
+
email: z.string().optional().describe("Admin email address."),
|
|
74
|
+
firstName: z.string().optional().describe("Admin first name."),
|
|
75
|
+
lastName: z.string().optional().describe("Admin last name."),
|
|
76
|
+
phone: z.string().optional().describe("Admin phone number."),
|
|
77
|
+
roles: z.array(z.union([z.string(), z.number()])).optional().describe("Role IDs to assign."),
|
|
78
|
+
isActive: z.boolean().optional().describe("Whether account is active."),
|
|
79
|
+
external: z.boolean().optional().describe("Whether admin is external."),
|
|
80
|
+
notificationsEnabled: z.boolean().optional().describe("Whether notifications are enabled."),
|
|
81
|
+
plainPassword: z.string().optional().describe("New password (if changing)."),
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Admin Permission Schema.
|
|
85
|
+
* Represents admin permissions.
|
|
86
|
+
*/
|
|
87
|
+
export const AdminPermissionSchema = z.object({
|
|
88
|
+
superAdmin: z.boolean().optional().describe("Whether user is a super admin."),
|
|
89
|
+
roles: z.array(z.string()).optional().describe("List of role names."),
|
|
90
|
+
permissions: z.array(z.string()).optional().describe("List of permission strings."),
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Change Password Input Schema.
|
|
94
|
+
* Input for PUT /api/admin/password
|
|
95
|
+
*/
|
|
96
|
+
export const ChangePasswordInputSchema = z.object({
|
|
97
|
+
currentPassword: z.string().describe("Current password."),
|
|
98
|
+
plainPassword: z.string().describe("New password."),
|
|
99
|
+
});
|