@listmonk-ops/operations 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @listmonk-ops/operations
2
+
3
+ Shared, runtime-neutral operation contracts and executors used by the
4
+ listmonk-ops CLI and MCP adapters.
5
+
6
+ The initial registry covers subscriber-list CRUD. Each operation owns its
7
+ runtime input/output schemas, generated JSON Schemas, safety hints, MCP name,
8
+ and named executor. Surface packages remain responsible for authentication and
9
+ presentation.
@@ -0,0 +1,3 @@
1
+ export * from "./lists";
2
+ export * from "./operation";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{z as e}from"zod";import{z as w}from"zod";var d=class extends Error{constructor(i){super(i),this.name="OperationInputError"}},l=class extends Error{constructor(i){super(i),this.name="OperationOutputError"}};function b(t,i){let n=w.toJSONSchema(t,{io:i});if(n.type!=="object")throw new TypeError("Operation schemas must have an object root");return n}function I(t,i){if(!t||typeof t!="object"||!(i in t))return!1;let n=Reflect.get(t,i);return n==null?!1:typeof n=="string"?n.trim().length>0:Array.isArray(n)?n.length>0:!0}function v(t,i){let n=t.issues[0];if(!n)return"Invalid operation input";let s=n.path[0],r=n.path.map(String).join(".")||"input";return(typeof s=="string"||typeof s=="number")&&!I(i,s)?`Missing required parameter: ${String(s)}`:`Invalid parameter ${r}: ${n.message}`}function o(t){return{id:t.id,title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,inputJsonSchema:b(t.inputSchema,"input"),outputJsonSchema:b(t.outputSchema,"output"),safety:t.safety,mcp:t.mcp,async invoke(i,n){let s=t.inputSchema.safeParse(n??{});if(!s.success)throw new d(v(s.error,n??{}));let r=await t.execute(i,s.data),a=t.outputSchema.safeParse(r);if(!a.success)throw new l(`${t.id} produced invalid output: ${a.error.message}`);return a.data}}}var u=e.looseObject({id:e.number().optional(),created_at:e.string().optional(),updated_at:e.string().optional(),uuid:e.string().optional(),name:e.string().optional(),type:e.string().optional(),optin:e.string().optional(),tags:e.array(e.string()).optional(),subscriber_count:e.number().optional(),description:e.string().optional()}),_=e.object({results:e.array(u),total:e.number(),per_page:e.number(),page:e.number()}),j=e.object({page:e.coerce.number().int().positive().default(1).describe("Page number for pagination"),per_page:e.coerce.number().int().positive().max(1e3).default(20).describe("Number of items per page")}),f=e.number().int().positive(),g=e.codec(e.union([f,e.string().regex(/^[1-9][0-9]*$/)]),f,{decode:t=>Number(t),encode:t=>t}).describe("Subscriber list ID"),h=e.object({id:g}),z=e.object({name:e.string().trim().min(1).describe("List name"),type:e.enum(["public","private"]).default("private").describe("List visibility"),optin:e.enum(["single","double"]).default("single").describe("Opt-in type"),description:e.string().default("").describe("List description"),tags:e.array(e.string()).default([]).describe("List tags")}),k=e.object({id:g,name:e.string().trim().min(1).optional().describe("List name"),type:e.enum(["public","private"]).optional().describe("List visibility"),optin:e.enum(["single","double"]).optional().describe("Opt-in type"),description:e.string().optional().describe("List description"),tags:e.array(e.string()).optional().describe("List tags")}),H=e.object({id:e.number().int().positive(),deleted:e.boolean()});function S(t){return t instanceof Error?t.message:t&&typeof t=="object"&&"message"in t?String(t.message):String(t)}function p(t,i){if("error"in t&&t.error!==void 0)throw new Error(`${i}: ${S(t.error)}`);if(t.data===void 0)throw new Error(`${i}: received empty data`);return t.data}async function C({client:t},i){let n=await t.list.list({query:{page:i.page,per_page:i.per_page}}),s=p(n,"Failed to fetch lists");return{results:s.results??[],total:s.total??0,per_page:s.per_page??i.per_page,page:s.page??i.page}}async function P({client:t},i){let n=await t.list.getById({path:{list_id:i.id}});return p(n,"Failed to fetch list")}async function M(t,i){let s=await t.list.list({query:{page:1,per_page:100,query:i}}),r=p(s,"Failed to resolve created list"),a=r.results?.find(c=>c.name===i);if(a)return a;let x=Math.max(1,Math.ceil((r.total??0)/100));for(let c=2;c<=x;c+=1){let L=await t.list.list({query:{page:c,per_page:100,query:i}}),m=p(L,"Failed to resolve created list").results?.find(O=>O.name===i);if(m)return m}}async function T({client:t},i){let n=await t.list.create({body:{name:i.name,type:i.type,optin:i.optin,description:i.description,tags:i.tags}});if("error"in n&&n.error!==void 0)throw new Error(`Failed to create list: ${S(n.error)}`);if(n.data!==void 0)return n.data;let s=await M(t,i.name);if(!s)throw new Error("List was created but the created record could not be resolved");return s}async function D({client:t},i){let{id:n,...s}=i,r=await t.list.update({path:{list_id:n},body:s});return p(r,"Failed to update list")}async function E({client:t},i){let n=await t.list.delete({path:{list_id:i.id}});return{id:i.id,deleted:p(n,"Failed to delete list")}}var y={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},J=o({id:"lists.list",title:"List subscriber lists",description:"Get subscriber lists from Listmonk",inputSchema:j,outputSchema:_,safety:y,mcp:{name:"listmonk_get_lists"},execute:C}),$=o({id:"lists.get",title:"Get subscriber list",description:"Get a specific subscriber list by ID",inputSchema:h,outputSchema:u,safety:y,mcp:{name:"listmonk_get_list"},execute:P}),q=o({id:"lists.create",title:"Create subscriber list",description:"Create a new subscriber list",inputSchema:z,outputSchema:u,safety:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},mcp:{name:"listmonk_create_list"},execute:T}),F=o({id:"lists.update",title:"Update subscriber list",description:"Update an existing subscriber list",inputSchema:k,outputSchema:u,safety:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!0},mcp:{name:"listmonk_update_list",legacySuccessText:"List updated successfully"},execute:D}),R=o({id:"lists.delete",title:"Delete subscriber list",description:"Delete a subscriber list",inputSchema:h,outputSchema:H,safety:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!0},mcp:{name:"listmonk_delete_list",legacySuccessText:"List deleted successfully"},execute:E}),Z=[J,$,q,F,R],N=new Map(Z.map(t=>[t.mcp.name,t]));function K(t){return N.get(t)}export{d as OperationInputError,l as OperationOutputError,q as createListOperation,T as createSubscriberList,o as defineOperation,R as deleteListOperation,E as deleteSubscriberList,$ as getListOperation,K as getListOperationByMcpName,J as getListsOperation,P as getSubscriberList,Z as listOperations,C as listSubscriberLists,F as updateListOperation,D as updateSubscriberList};
@@ -0,0 +1,232 @@
1
+ import type { List, ListmonkClient } from "@listmonk-ops/openapi";
2
+ import { z } from "zod";
3
+ export interface ListOperationContext {
4
+ client: Pick<ListmonkClient, "list">;
5
+ }
6
+ export interface ListPage {
7
+ results: List[];
8
+ total: number;
9
+ per_page: number;
10
+ page: number;
11
+ }
12
+ declare const listInputSchema: z.ZodObject<{
13
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
14
+ per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
15
+ }, z.core.$strip>;
16
+ declare const listIdInputSchema: z.ZodObject<{
17
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
18
+ }, z.core.$strip>;
19
+ declare const createListInputSchema: z.ZodObject<{
20
+ name: z.ZodString;
21
+ type: z.ZodDefault<z.ZodEnum<{
22
+ private: "private";
23
+ public: "public";
24
+ }>>;
25
+ optin: z.ZodDefault<z.ZodEnum<{
26
+ double: "double";
27
+ single: "single";
28
+ }>>;
29
+ description: z.ZodDefault<z.ZodString>;
30
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
31
+ }, z.core.$strip>;
32
+ declare const updateListInputSchema: z.ZodObject<{
33
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
34
+ name: z.ZodOptional<z.ZodString>;
35
+ type: z.ZodOptional<z.ZodEnum<{
36
+ private: "private";
37
+ public: "public";
38
+ }>>;
39
+ optin: z.ZodOptional<z.ZodEnum<{
40
+ double: "double";
41
+ single: "single";
42
+ }>>;
43
+ description: z.ZodOptional<z.ZodString>;
44
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ }, z.core.$strip>;
46
+ declare const deleteListOutputSchema: z.ZodObject<{
47
+ id: z.ZodNumber;
48
+ deleted: z.ZodBoolean;
49
+ }, z.core.$strip>;
50
+ export declare function listSubscriberLists({ client }: ListOperationContext, input: z.output<typeof listInputSchema>): Promise<ListPage>;
51
+ export declare function getSubscriberList({ client }: ListOperationContext, input: z.output<typeof listIdInputSchema>): Promise<List>;
52
+ export declare function createSubscriberList({ client }: ListOperationContext, input: z.output<typeof createListInputSchema>): Promise<List>;
53
+ export declare function updateSubscriberList({ client }: ListOperationContext, input: z.output<typeof updateListInputSchema>): Promise<List>;
54
+ export declare function deleteSubscriberList({ client }: ListOperationContext, input: z.output<typeof listIdInputSchema>): Promise<z.output<typeof deleteListOutputSchema>>;
55
+ export declare const getListsOperation: import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
56
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
57
+ per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ results: z.ZodArray<z.ZodObject<{
60
+ id: z.ZodOptional<z.ZodNumber>;
61
+ created_at: z.ZodOptional<z.ZodString>;
62
+ updated_at: z.ZodOptional<z.ZodString>;
63
+ uuid: z.ZodOptional<z.ZodString>;
64
+ name: z.ZodOptional<z.ZodString>;
65
+ type: z.ZodOptional<z.ZodString>;
66
+ optin: z.ZodOptional<z.ZodString>;
67
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
69
+ description: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$loose>>;
71
+ total: z.ZodNumber;
72
+ per_page: z.ZodNumber;
73
+ page: z.ZodNumber;
74
+ }, z.core.$strip>>;
75
+ export declare const getListOperation: import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
76
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ id: z.ZodOptional<z.ZodNumber>;
79
+ created_at: z.ZodOptional<z.ZodString>;
80
+ updated_at: z.ZodOptional<z.ZodString>;
81
+ uuid: z.ZodOptional<z.ZodString>;
82
+ name: z.ZodOptional<z.ZodString>;
83
+ type: z.ZodOptional<z.ZodString>;
84
+ optin: z.ZodOptional<z.ZodString>;
85
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
87
+ description: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$loose>>;
89
+ export declare const createListOperation: import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
90
+ name: z.ZodString;
91
+ type: z.ZodDefault<z.ZodEnum<{
92
+ private: "private";
93
+ public: "public";
94
+ }>>;
95
+ optin: z.ZodDefault<z.ZodEnum<{
96
+ double: "double";
97
+ single: "single";
98
+ }>>;
99
+ description: z.ZodDefault<z.ZodString>;
100
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ id: z.ZodOptional<z.ZodNumber>;
103
+ created_at: z.ZodOptional<z.ZodString>;
104
+ updated_at: z.ZodOptional<z.ZodString>;
105
+ uuid: z.ZodOptional<z.ZodString>;
106
+ name: z.ZodOptional<z.ZodString>;
107
+ type: z.ZodOptional<z.ZodString>;
108
+ optin: z.ZodOptional<z.ZodString>;
109
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
110
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
111
+ description: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$loose>>;
113
+ export declare const updateListOperation: import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
114
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
115
+ name: z.ZodOptional<z.ZodString>;
116
+ type: z.ZodOptional<z.ZodEnum<{
117
+ private: "private";
118
+ public: "public";
119
+ }>>;
120
+ optin: z.ZodOptional<z.ZodEnum<{
121
+ double: "double";
122
+ single: "single";
123
+ }>>;
124
+ description: z.ZodOptional<z.ZodString>;
125
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ id: z.ZodOptional<z.ZodNumber>;
128
+ created_at: z.ZodOptional<z.ZodString>;
129
+ updated_at: z.ZodOptional<z.ZodString>;
130
+ uuid: z.ZodOptional<z.ZodString>;
131
+ name: z.ZodOptional<z.ZodString>;
132
+ type: z.ZodOptional<z.ZodString>;
133
+ optin: z.ZodOptional<z.ZodString>;
134
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
135
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
136
+ description: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$loose>>;
138
+ export declare const deleteListOperation: import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
139
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ id: z.ZodNumber;
142
+ deleted: z.ZodBoolean;
143
+ }, z.core.$strip>>;
144
+ export declare const listOperations: readonly [import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
145
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
146
+ per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ results: z.ZodArray<z.ZodObject<{
149
+ id: z.ZodOptional<z.ZodNumber>;
150
+ created_at: z.ZodOptional<z.ZodString>;
151
+ updated_at: z.ZodOptional<z.ZodString>;
152
+ uuid: z.ZodOptional<z.ZodString>;
153
+ name: z.ZodOptional<z.ZodString>;
154
+ type: z.ZodOptional<z.ZodString>;
155
+ optin: z.ZodOptional<z.ZodString>;
156
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
158
+ description: z.ZodOptional<z.ZodString>;
159
+ }, z.core.$loose>>;
160
+ total: z.ZodNumber;
161
+ per_page: z.ZodNumber;
162
+ page: z.ZodNumber;
163
+ }, z.core.$strip>>, import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
164
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ id: z.ZodOptional<z.ZodNumber>;
167
+ created_at: z.ZodOptional<z.ZodString>;
168
+ updated_at: z.ZodOptional<z.ZodString>;
169
+ uuid: z.ZodOptional<z.ZodString>;
170
+ name: z.ZodOptional<z.ZodString>;
171
+ type: z.ZodOptional<z.ZodString>;
172
+ optin: z.ZodOptional<z.ZodString>;
173
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
174
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
175
+ description: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$loose>>, import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
177
+ name: z.ZodString;
178
+ type: z.ZodDefault<z.ZodEnum<{
179
+ private: "private";
180
+ public: "public";
181
+ }>>;
182
+ optin: z.ZodDefault<z.ZodEnum<{
183
+ double: "double";
184
+ single: "single";
185
+ }>>;
186
+ description: z.ZodDefault<z.ZodString>;
187
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
188
+ }, z.core.$strip>, z.ZodObject<{
189
+ id: z.ZodOptional<z.ZodNumber>;
190
+ created_at: z.ZodOptional<z.ZodString>;
191
+ updated_at: z.ZodOptional<z.ZodString>;
192
+ uuid: z.ZodOptional<z.ZodString>;
193
+ name: z.ZodOptional<z.ZodString>;
194
+ type: z.ZodOptional<z.ZodString>;
195
+ optin: z.ZodOptional<z.ZodString>;
196
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
197
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
198
+ description: z.ZodOptional<z.ZodString>;
199
+ }, z.core.$loose>>, import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
200
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
201
+ name: z.ZodOptional<z.ZodString>;
202
+ type: z.ZodOptional<z.ZodEnum<{
203
+ private: "private";
204
+ public: "public";
205
+ }>>;
206
+ optin: z.ZodOptional<z.ZodEnum<{
207
+ double: "double";
208
+ single: "single";
209
+ }>>;
210
+ description: z.ZodOptional<z.ZodString>;
211
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ id: z.ZodOptional<z.ZodNumber>;
214
+ created_at: z.ZodOptional<z.ZodString>;
215
+ updated_at: z.ZodOptional<z.ZodString>;
216
+ uuid: z.ZodOptional<z.ZodString>;
217
+ name: z.ZodOptional<z.ZodString>;
218
+ type: z.ZodOptional<z.ZodString>;
219
+ optin: z.ZodOptional<z.ZodString>;
220
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
221
+ subscriber_count: z.ZodOptional<z.ZodNumber>;
222
+ description: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$loose>>, import("./operation").OperationDefinition<ListOperationContext, z.ZodObject<{
224
+ id: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodNumber>;
225
+ }, z.core.$strip>, z.ZodObject<{
226
+ id: z.ZodNumber;
227
+ deleted: z.ZodBoolean;
228
+ }, z.core.$strip>>];
229
+ export type ListOperation = (typeof listOperations)[number];
230
+ export declare function getListOperationByMcpName(name: string): ListOperation | undefined;
231
+ export {};
232
+ //# sourceMappingURL=lists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../src/lists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAu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AAE,oBAAoB,EAChC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,GACvC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAQlD;AASD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;kBAS5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;kBAS3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;kBAc9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;kBAiB9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;kBAiB9B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAMjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAM5D,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,GACV,aAAa,GAAG,SAAS,CAE3B"}
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ export type ObjectJsonSchema = {
3
+ $schema?: string;
4
+ type: "object";
5
+ properties?: Record<string, object>;
6
+ required?: string[];
7
+ [key: string]: unknown;
8
+ };
9
+ export interface OperationSafety {
10
+ readOnlyHint: boolean;
11
+ destructiveHint: boolean;
12
+ idempotentHint: boolean;
13
+ openWorldHint: boolean;
14
+ }
15
+ export interface OperationMcpMetadata {
16
+ name: string;
17
+ legacySuccessText?: string;
18
+ }
19
+ export interface OperationDefinition<Context, InputSchema extends z.ZodType, OutputSchema extends z.ZodType> {
20
+ id: string;
21
+ title: string;
22
+ description: string;
23
+ inputSchema: InputSchema;
24
+ outputSchema: OutputSchema;
25
+ inputJsonSchema: ObjectJsonSchema;
26
+ outputJsonSchema: ObjectJsonSchema;
27
+ safety: OperationSafety;
28
+ mcp: OperationMcpMetadata;
29
+ invoke(context: Context, input: unknown): Promise<z.output<OutputSchema>>;
30
+ }
31
+ export declare class OperationInputError extends Error {
32
+ constructor(message: string);
33
+ }
34
+ export declare class OperationOutputError extends Error {
35
+ constructor(message: string);
36
+ }
37
+ export declare function defineOperation<Context, const InputSchema extends z.ZodType, const OutputSchema extends z.ZodType>(config: {
38
+ id: string;
39
+ title: string;
40
+ description: string;
41
+ inputSchema: InputSchema;
42
+ outputSchema: OutputSchema;
43
+ safety: OperationSafety;
44
+ mcp: OperationMcpMetadata;
45
+ execute(context: Context, input: z.output<InputSchema>): Promise<z.output<OutputSchema>>;
46
+ }): OperationDefinition<Context, InputSchema, OutputSchema>;
47
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../src/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB,CACnC,OAAO,EACP,WAAW,SAAS,CAAC,CAAC,OAA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1
+ {
2
+ "name": "@listmonk-ops/operations",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Shared typed operations for listmonk-ops CLI and MCP adapters",
6
+ "sideEffects": false,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/imjlk/listmonk-ops"
10
+ },
11
+ "main": "./dist/index.js",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "clean": "rm -rf dist",
27
+ "build": "bun run clean && ttsc --emitDeclarationOnly && esbuild src/index.ts --bundle --platform=neutral --format=esm --outfile=dist/index.js --minify --external:@listmonk-ops/openapi --external:zod",
28
+ "typecheck": "ttsc --noEmit",
29
+ "format": "ttsc format",
30
+ "lint": "ttsc --noEmit",
31
+ "lint:fix": "ttsc fix",
32
+ "test": "bun test",
33
+ "prepublishOnly": "bun run build && bun run test"
34
+ },
35
+ "dependencies": {
36
+ "@listmonk-ops/openapi": "^0.1.5",
37
+ "zod": "4.3.6"
38
+ },
39
+ "devDependencies": {
40
+ "@types/bun": "1.3.10",
41
+ "esbuild": "0.27.4",
42
+ "typescript": "7.0.2"
43
+ }
44
+ }