modifywithai 1.9.0 → 2.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/README.md +145 -0
- package/dist/assistant/index.d.ts +3 -0
- package/dist/assistant/index.js +1 -0
- package/dist/assistant-NY2A-1_6.js +2 -0
- package/dist/assistant-nextjs/api.d.ts +42 -0
- package/dist/assistant-nextjs/api.js +1 -0
- package/dist/assistant-remix/api.d.ts +46 -0
- package/dist/assistant-remix/api.js +1 -0
- package/dist/assistant-tanstack-start/api.d.ts +56 -0
- package/dist/assistant-tanstack-start/api.js +1 -0
- package/dist/index-BiZCpmdI.d.ts +1227 -0
- package/dist/index.d.ts +3 -70
- package/dist/index.js +1 -1
- package/dist/types-CzieyGF2.d.ts +344 -0
- package/dist/utils-DQD-DMi0.js +1 -0
- package/package.json +115 -35
- package/dist/nextjs/api.d.ts +0 -67
- package/dist/nextjs/api.js +0 -1
- package/dist/nextjs/shims.d.ts +0 -13
- package/dist/nextjs/shims.js +0 -78
- package/dist/react/index.d.ts +0 -403
- package/dist/react/index.js +0 -1
- package/dist/types-BgiWGYKC.js +0 -1
- package/dist/types-DjksF7DU.d.ts +0 -135
package/dist/nextjs/shims.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/nextjs/shims.d.ts
|
|
2
|
-
declare function generateStaticParams(): Promise<{
|
|
3
|
-
path: string;
|
|
4
|
-
}[]>;
|
|
5
|
-
declare const GET: (_request: Request, {
|
|
6
|
-
params
|
|
7
|
-
}: {
|
|
8
|
-
params: Promise<{
|
|
9
|
-
path: string;
|
|
10
|
-
}>;
|
|
11
|
-
}) => Promise<Response>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { GET, generateStaticParams };
|
package/dist/nextjs/shims.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const e={"react-shim.js":`// Re-export React from the window object (set by the app)
|
|
2
|
-
const React = window.__REACT__;
|
|
3
|
-
export default React;
|
|
4
|
-
export const {
|
|
5
|
-
useState,
|
|
6
|
-
useEffect,
|
|
7
|
-
useLayoutEffect,
|
|
8
|
-
useRef,
|
|
9
|
-
useCallback,
|
|
10
|
-
useMemo,
|
|
11
|
-
useContext,
|
|
12
|
-
useReducer,
|
|
13
|
-
useId,
|
|
14
|
-
useTransition,
|
|
15
|
-
useDeferredValue,
|
|
16
|
-
useImperativeHandle,
|
|
17
|
-
useDebugValue,
|
|
18
|
-
useSyncExternalStore,
|
|
19
|
-
useInsertionEffect,
|
|
20
|
-
createElement,
|
|
21
|
-
createContext,
|
|
22
|
-
createRef,
|
|
23
|
-
forwardRef,
|
|
24
|
-
memo,
|
|
25
|
-
lazy,
|
|
26
|
-
Suspense,
|
|
27
|
-
Fragment,
|
|
28
|
-
Children,
|
|
29
|
-
cloneElement,
|
|
30
|
-
isValidElement,
|
|
31
|
-
Component,
|
|
32
|
-
PureComponent,
|
|
33
|
-
StrictMode,
|
|
34
|
-
startTransition,
|
|
35
|
-
use,
|
|
36
|
-
} = React;
|
|
37
|
-
`,"react-jsx-shim.js":`// Re-export jsx-runtime from the window object (set by the app)
|
|
38
|
-
const jsxRuntime = window.__REACT_JSX_RUNTIME__;
|
|
39
|
-
export const jsx = jsxRuntime?.jsx;
|
|
40
|
-
export const jsxs = jsxRuntime?.jsxs;
|
|
41
|
-
export const Fragment = jsxRuntime?.Fragment;
|
|
42
|
-
`,"react-dom-shim.js":`// Re-export ReactDOM from the window object (set by the app)
|
|
43
|
-
const ReactDOM = window.__REACT_DOM__
|
|
44
|
-
export default ReactDOM
|
|
45
|
-
export const {
|
|
46
|
-
createPortal,
|
|
47
|
-
flushSync,
|
|
48
|
-
findDOMNode,
|
|
49
|
-
hydrate,
|
|
50
|
-
render,
|
|
51
|
-
unmountComponentAtNode,
|
|
52
|
-
unstable_batchedUpdates,
|
|
53
|
-
version,
|
|
54
|
-
} = ReactDOM || {}
|
|
55
|
-
`,"react-dom-client-shim.js":`// Re-export ReactDOM/client from the window object (set by the app)
|
|
56
|
-
const ReactDOMClient = window.__REACT_DOM_CLIENT__;
|
|
57
|
-
export const createRoot = ReactDOMClient?.createRoot;
|
|
58
|
-
export const hydrateRoot = ReactDOMClient?.hydrateRoot;
|
|
59
|
-
export default ReactDOMClient;
|
|
60
|
-
`,"next-link-shim.js":`// Re-export next/link from the window object (set by the app)
|
|
61
|
-
const NextLink = window.__NEXT_LINK__;
|
|
62
|
-
export default NextLink;
|
|
63
|
-
`,"next-image-shim.js":`// Re-export next/image from the window object (set by the app)
|
|
64
|
-
const NextImage = window.__NEXT_IMAGE__;
|
|
65
|
-
export default NextImage;
|
|
66
|
-
`,"next-navigation-shim.js":`// Re-export next/navigation from the window object (set by the app)
|
|
67
|
-
const NextNavigation = window.__NEXT_NAVIGATION__;
|
|
68
|
-
export const useRouter = NextNavigation?.useRouter;
|
|
69
|
-
export const usePathname = NextNavigation?.usePathname;
|
|
70
|
-
export const useSearchParams = NextNavigation?.useSearchParams;
|
|
71
|
-
export const useParams = NextNavigation?.useParams;
|
|
72
|
-
export const useSelectedLayoutSegment = NextNavigation?.useSelectedLayoutSegment;
|
|
73
|
-
export const useSelectedLayoutSegments = NextNavigation?.useSelectedLayoutSegments;
|
|
74
|
-
export const redirect = NextNavigation?.redirect;
|
|
75
|
-
export const notFound = NextNavigation?.notFound;
|
|
76
|
-
export const permanentRedirect = NextNavigation?.permanentRedirect;
|
|
77
|
-
export default NextNavigation;
|
|
78
|
-
`};async function t(){return Object.keys(e).map(e=>({path:e}))}const n=async(t,{params:n})=>{let r=(await n).path;return new Response(e[r],{headers:{"Content-Type":`application/javascript`,"Cache-Control":`public, max-age=31536000, immutable`}})};export{n as GET,t as generateStaticParams};
|
package/dist/react/index.d.ts
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
import { _ as ModifyWithAIOptions, a as DisableResponseSchema, c as EnableResponseSchema, d as ModificationSchema, f as ModificationToggleOptions, h as ModifyResponseSchema, i as DisableResponse, m as ModifyResponse, n as ApiErrorSchema, p as ModificationsListSchema, s as EnableResponse, t as ApiError, u as Modification } from "../types-DjksF7DU.js";
|
|
2
|
-
import * as react0 from "react";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
import * as jsxRuntime from "react/jsx-runtime";
|
|
5
|
-
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
6
|
-
|
|
7
|
-
//#region src/react/components.d.ts
|
|
8
|
-
declare const useComponents: () => jsxRuntime.JSX.Element | null;
|
|
9
|
-
declare const MWAIComponents: () => jsxRuntime.JSX.Element | null;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/react/head.d.ts
|
|
12
|
-
declare const MWAIHead: ({
|
|
13
|
-
basePath
|
|
14
|
-
}?: {
|
|
15
|
-
basePath?: string;
|
|
16
|
-
}) => jsxRuntime.JSX.Element;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/react/hooks.d.ts
|
|
19
|
-
/**
|
|
20
|
-
* React hook for fetching the list of modifications
|
|
21
|
-
* Polls every 10 seconds for updates
|
|
22
|
-
* Automatically reloads the page when enabled modifications change
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* const { data, isLoading, error } = useList()
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare function useList(): _tanstack_react_query0.UseQueryResult<{
|
|
30
|
-
id: string;
|
|
31
|
-
title: string | null;
|
|
32
|
-
description: string | null;
|
|
33
|
-
status: "error" | "pending" | "success";
|
|
34
|
-
createdAt: number;
|
|
35
|
-
updatedAt: number;
|
|
36
|
-
enabled: boolean | null;
|
|
37
|
-
}[], Error>;
|
|
38
|
-
/**
|
|
39
|
-
* React hook for submitting modification requests to ModifyWithAI
|
|
40
|
-
* Returns mutation state and a `modify` function for submitting prompts
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```tsx
|
|
44
|
-
* const { modify, isPending, isError, error } = useModify()
|
|
45
|
-
*
|
|
46
|
-
* const handleSubmit = () => {
|
|
47
|
-
* modify("Change the button color to blue", {
|
|
48
|
-
* onSuccess: () => console.log("Submitted!"),
|
|
49
|
-
* onError: (err) => console.error(err),
|
|
50
|
-
* })
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function useModify(options?: ModifyWithAIOptions): {
|
|
55
|
-
data: undefined;
|
|
56
|
-
variables: undefined;
|
|
57
|
-
error: null;
|
|
58
|
-
isError: false;
|
|
59
|
-
isIdle: true;
|
|
60
|
-
isPending: false;
|
|
61
|
-
isSuccess: false;
|
|
62
|
-
status: "idle";
|
|
63
|
-
reset: () => void;
|
|
64
|
-
context: unknown;
|
|
65
|
-
failureCount: number;
|
|
66
|
-
failureReason: Error | null;
|
|
67
|
-
isPaused: boolean;
|
|
68
|
-
submittedAt: number;
|
|
69
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
70
|
-
modificationId: string;
|
|
71
|
-
}, Error, string, unknown>;
|
|
72
|
-
modify: _tanstack_react_query0.UseMutateFunction<{
|
|
73
|
-
modificationId: string;
|
|
74
|
-
}, Error, string, unknown>;
|
|
75
|
-
} | {
|
|
76
|
-
data: undefined;
|
|
77
|
-
variables: string;
|
|
78
|
-
error: null;
|
|
79
|
-
isError: false;
|
|
80
|
-
isIdle: false;
|
|
81
|
-
isPending: true;
|
|
82
|
-
isSuccess: false;
|
|
83
|
-
status: "pending";
|
|
84
|
-
reset: () => void;
|
|
85
|
-
context: unknown;
|
|
86
|
-
failureCount: number;
|
|
87
|
-
failureReason: Error | null;
|
|
88
|
-
isPaused: boolean;
|
|
89
|
-
submittedAt: number;
|
|
90
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
91
|
-
modificationId: string;
|
|
92
|
-
}, Error, string, unknown>;
|
|
93
|
-
modify: _tanstack_react_query0.UseMutateFunction<{
|
|
94
|
-
modificationId: string;
|
|
95
|
-
}, Error, string, unknown>;
|
|
96
|
-
} | {
|
|
97
|
-
data: undefined;
|
|
98
|
-
error: Error;
|
|
99
|
-
variables: string;
|
|
100
|
-
isError: true;
|
|
101
|
-
isIdle: false;
|
|
102
|
-
isPending: false;
|
|
103
|
-
isSuccess: false;
|
|
104
|
-
status: "error";
|
|
105
|
-
reset: () => void;
|
|
106
|
-
context: unknown;
|
|
107
|
-
failureCount: number;
|
|
108
|
-
failureReason: Error | null;
|
|
109
|
-
isPaused: boolean;
|
|
110
|
-
submittedAt: number;
|
|
111
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
112
|
-
modificationId: string;
|
|
113
|
-
}, Error, string, unknown>;
|
|
114
|
-
modify: _tanstack_react_query0.UseMutateFunction<{
|
|
115
|
-
modificationId: string;
|
|
116
|
-
}, Error, string, unknown>;
|
|
117
|
-
} | {
|
|
118
|
-
data: {
|
|
119
|
-
modificationId: string;
|
|
120
|
-
};
|
|
121
|
-
error: null;
|
|
122
|
-
variables: string;
|
|
123
|
-
isError: false;
|
|
124
|
-
isIdle: false;
|
|
125
|
-
isPending: false;
|
|
126
|
-
isSuccess: true;
|
|
127
|
-
status: "success";
|
|
128
|
-
reset: () => void;
|
|
129
|
-
context: unknown;
|
|
130
|
-
failureCount: number;
|
|
131
|
-
failureReason: Error | null;
|
|
132
|
-
isPaused: boolean;
|
|
133
|
-
submittedAt: number;
|
|
134
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
135
|
-
modificationId: string;
|
|
136
|
-
}, Error, string, unknown>;
|
|
137
|
-
modify: _tanstack_react_query0.UseMutateFunction<{
|
|
138
|
-
modificationId: string;
|
|
139
|
-
}, Error, string, unknown>;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* React hook for enabling a modification
|
|
143
|
-
* Returns mutation state and an `enable` function for enabling modifications
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```tsx
|
|
147
|
-
* const { enable, isPending, isError, error } = useEnable()
|
|
148
|
-
*
|
|
149
|
-
* const handleEnable = () => {
|
|
150
|
-
* enable("modification-id", {
|
|
151
|
-
* onSuccess: () => console.log("Enabled!"),
|
|
152
|
-
* onError: (err) => console.error(err),
|
|
153
|
-
* })
|
|
154
|
-
* }
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
declare function useEnable(options?: ModificationToggleOptions): {
|
|
158
|
-
data: undefined;
|
|
159
|
-
variables: undefined;
|
|
160
|
-
error: null;
|
|
161
|
-
isError: false;
|
|
162
|
-
isIdle: true;
|
|
163
|
-
isPending: false;
|
|
164
|
-
isSuccess: false;
|
|
165
|
-
status: "idle";
|
|
166
|
-
reset: () => void;
|
|
167
|
-
context: unknown;
|
|
168
|
-
failureCount: number;
|
|
169
|
-
failureReason: Error | null;
|
|
170
|
-
isPaused: boolean;
|
|
171
|
-
submittedAt: number;
|
|
172
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
173
|
-
message: string;
|
|
174
|
-
modificationId: string;
|
|
175
|
-
endUserId: string;
|
|
176
|
-
}, Error, string, unknown>;
|
|
177
|
-
enable: _tanstack_react_query0.UseMutateFunction<{
|
|
178
|
-
message: string;
|
|
179
|
-
modificationId: string;
|
|
180
|
-
endUserId: string;
|
|
181
|
-
}, Error, string, unknown>;
|
|
182
|
-
} | {
|
|
183
|
-
data: undefined;
|
|
184
|
-
variables: string;
|
|
185
|
-
error: null;
|
|
186
|
-
isError: false;
|
|
187
|
-
isIdle: false;
|
|
188
|
-
isPending: true;
|
|
189
|
-
isSuccess: false;
|
|
190
|
-
status: "pending";
|
|
191
|
-
reset: () => void;
|
|
192
|
-
context: unknown;
|
|
193
|
-
failureCount: number;
|
|
194
|
-
failureReason: Error | null;
|
|
195
|
-
isPaused: boolean;
|
|
196
|
-
submittedAt: number;
|
|
197
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
198
|
-
message: string;
|
|
199
|
-
modificationId: string;
|
|
200
|
-
endUserId: string;
|
|
201
|
-
}, Error, string, unknown>;
|
|
202
|
-
enable: _tanstack_react_query0.UseMutateFunction<{
|
|
203
|
-
message: string;
|
|
204
|
-
modificationId: string;
|
|
205
|
-
endUserId: string;
|
|
206
|
-
}, Error, string, unknown>;
|
|
207
|
-
} | {
|
|
208
|
-
data: undefined;
|
|
209
|
-
error: Error;
|
|
210
|
-
variables: string;
|
|
211
|
-
isError: true;
|
|
212
|
-
isIdle: false;
|
|
213
|
-
isPending: false;
|
|
214
|
-
isSuccess: false;
|
|
215
|
-
status: "error";
|
|
216
|
-
reset: () => void;
|
|
217
|
-
context: unknown;
|
|
218
|
-
failureCount: number;
|
|
219
|
-
failureReason: Error | null;
|
|
220
|
-
isPaused: boolean;
|
|
221
|
-
submittedAt: number;
|
|
222
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
223
|
-
message: string;
|
|
224
|
-
modificationId: string;
|
|
225
|
-
endUserId: string;
|
|
226
|
-
}, Error, string, unknown>;
|
|
227
|
-
enable: _tanstack_react_query0.UseMutateFunction<{
|
|
228
|
-
message: string;
|
|
229
|
-
modificationId: string;
|
|
230
|
-
endUserId: string;
|
|
231
|
-
}, Error, string, unknown>;
|
|
232
|
-
} | {
|
|
233
|
-
data: {
|
|
234
|
-
message: string;
|
|
235
|
-
modificationId: string;
|
|
236
|
-
endUserId: string;
|
|
237
|
-
};
|
|
238
|
-
error: null;
|
|
239
|
-
variables: string;
|
|
240
|
-
isError: false;
|
|
241
|
-
isIdle: false;
|
|
242
|
-
isPending: false;
|
|
243
|
-
isSuccess: true;
|
|
244
|
-
status: "success";
|
|
245
|
-
reset: () => void;
|
|
246
|
-
context: unknown;
|
|
247
|
-
failureCount: number;
|
|
248
|
-
failureReason: Error | null;
|
|
249
|
-
isPaused: boolean;
|
|
250
|
-
submittedAt: number;
|
|
251
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
252
|
-
message: string;
|
|
253
|
-
modificationId: string;
|
|
254
|
-
endUserId: string;
|
|
255
|
-
}, Error, string, unknown>;
|
|
256
|
-
enable: _tanstack_react_query0.UseMutateFunction<{
|
|
257
|
-
message: string;
|
|
258
|
-
modificationId: string;
|
|
259
|
-
endUserId: string;
|
|
260
|
-
}, Error, string, unknown>;
|
|
261
|
-
};
|
|
262
|
-
/**
|
|
263
|
-
* React hook for disabling a modification
|
|
264
|
-
* Returns mutation state and a `disable` function for disabling modifications
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```tsx
|
|
268
|
-
* const { disable, isPending, isError, error } = useDisable()
|
|
269
|
-
*
|
|
270
|
-
* const handleDisable = () => {
|
|
271
|
-
* disable("modification-id", {
|
|
272
|
-
* onSuccess: () => console.log("Disabled!"),
|
|
273
|
-
* onError: (err) => console.error(err),
|
|
274
|
-
* })
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
*/
|
|
278
|
-
declare function useDisable(options?: ModificationToggleOptions): {
|
|
279
|
-
data: undefined;
|
|
280
|
-
variables: undefined;
|
|
281
|
-
error: null;
|
|
282
|
-
isError: false;
|
|
283
|
-
isIdle: true;
|
|
284
|
-
isPending: false;
|
|
285
|
-
isSuccess: false;
|
|
286
|
-
status: "idle";
|
|
287
|
-
reset: () => void;
|
|
288
|
-
context: unknown;
|
|
289
|
-
failureCount: number;
|
|
290
|
-
failureReason: Error | null;
|
|
291
|
-
isPaused: boolean;
|
|
292
|
-
submittedAt: number;
|
|
293
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
294
|
-
message: string;
|
|
295
|
-
modificationId: string;
|
|
296
|
-
endUserId: string;
|
|
297
|
-
}, Error, string, unknown>;
|
|
298
|
-
disable: _tanstack_react_query0.UseMutateFunction<{
|
|
299
|
-
message: string;
|
|
300
|
-
modificationId: string;
|
|
301
|
-
endUserId: string;
|
|
302
|
-
}, Error, string, unknown>;
|
|
303
|
-
} | {
|
|
304
|
-
data: undefined;
|
|
305
|
-
variables: string;
|
|
306
|
-
error: null;
|
|
307
|
-
isError: false;
|
|
308
|
-
isIdle: false;
|
|
309
|
-
isPending: true;
|
|
310
|
-
isSuccess: false;
|
|
311
|
-
status: "pending";
|
|
312
|
-
reset: () => void;
|
|
313
|
-
context: unknown;
|
|
314
|
-
failureCount: number;
|
|
315
|
-
failureReason: Error | null;
|
|
316
|
-
isPaused: boolean;
|
|
317
|
-
submittedAt: number;
|
|
318
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
319
|
-
message: string;
|
|
320
|
-
modificationId: string;
|
|
321
|
-
endUserId: string;
|
|
322
|
-
}, Error, string, unknown>;
|
|
323
|
-
disable: _tanstack_react_query0.UseMutateFunction<{
|
|
324
|
-
message: string;
|
|
325
|
-
modificationId: string;
|
|
326
|
-
endUserId: string;
|
|
327
|
-
}, Error, string, unknown>;
|
|
328
|
-
} | {
|
|
329
|
-
data: undefined;
|
|
330
|
-
error: Error;
|
|
331
|
-
variables: string;
|
|
332
|
-
isError: true;
|
|
333
|
-
isIdle: false;
|
|
334
|
-
isPending: false;
|
|
335
|
-
isSuccess: false;
|
|
336
|
-
status: "error";
|
|
337
|
-
reset: () => void;
|
|
338
|
-
context: unknown;
|
|
339
|
-
failureCount: number;
|
|
340
|
-
failureReason: Error | null;
|
|
341
|
-
isPaused: boolean;
|
|
342
|
-
submittedAt: number;
|
|
343
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
344
|
-
message: string;
|
|
345
|
-
modificationId: string;
|
|
346
|
-
endUserId: string;
|
|
347
|
-
}, Error, string, unknown>;
|
|
348
|
-
disable: _tanstack_react_query0.UseMutateFunction<{
|
|
349
|
-
message: string;
|
|
350
|
-
modificationId: string;
|
|
351
|
-
endUserId: string;
|
|
352
|
-
}, Error, string, unknown>;
|
|
353
|
-
} | {
|
|
354
|
-
data: {
|
|
355
|
-
message: string;
|
|
356
|
-
modificationId: string;
|
|
357
|
-
endUserId: string;
|
|
358
|
-
};
|
|
359
|
-
error: null;
|
|
360
|
-
variables: string;
|
|
361
|
-
isError: false;
|
|
362
|
-
isIdle: false;
|
|
363
|
-
isPending: false;
|
|
364
|
-
isSuccess: true;
|
|
365
|
-
status: "success";
|
|
366
|
-
reset: () => void;
|
|
367
|
-
context: unknown;
|
|
368
|
-
failureCount: number;
|
|
369
|
-
failureReason: Error | null;
|
|
370
|
-
isPaused: boolean;
|
|
371
|
-
submittedAt: number;
|
|
372
|
-
mutateAsync: _tanstack_react_query0.UseMutateAsyncFunction<{
|
|
373
|
-
message: string;
|
|
374
|
-
modificationId: string;
|
|
375
|
-
endUserId: string;
|
|
376
|
-
}, Error, string, unknown>;
|
|
377
|
-
disable: _tanstack_react_query0.UseMutateFunction<{
|
|
378
|
-
message: string;
|
|
379
|
-
modificationId: string;
|
|
380
|
-
endUserId: string;
|
|
381
|
-
}, Error, string, unknown>;
|
|
382
|
-
};
|
|
383
|
-
//#endregion
|
|
384
|
-
//#region src/react/provider.d.ts
|
|
385
|
-
declare const MWAIContext: react0.Context<string | null>;
|
|
386
|
-
declare const MWAIProvider: ({
|
|
387
|
-
appId,
|
|
388
|
-
children
|
|
389
|
-
}: {
|
|
390
|
-
appId: string;
|
|
391
|
-
children: ReactNode;
|
|
392
|
-
}) => jsxRuntime.JSX.Element;
|
|
393
|
-
//#endregion
|
|
394
|
-
//#region src/react/query-keys.d.ts
|
|
395
|
-
/**
|
|
396
|
-
* Centralized query key factory for type-safe, consistent cache management
|
|
397
|
-
*/
|
|
398
|
-
declare const mwaiQueryKeys: {
|
|
399
|
-
readonly all: readonly ["mwai"];
|
|
400
|
-
readonly modifications: () => readonly ["mwai", "modifications"];
|
|
401
|
-
};
|
|
402
|
-
//#endregion
|
|
403
|
-
export { type ApiError, ApiErrorSchema, type DisableResponse, DisableResponseSchema, type EnableResponse, EnableResponseSchema, MWAIComponents, MWAIContext, MWAIHead, MWAIProvider, type Modification, ModificationSchema, type ModificationToggleOptions, ModificationsListSchema, type ModifyResponse, ModifyResponseSchema, type ModifyWithAIOptions, mwaiQueryKeys, useComponents, useDisable, useEnable, useList, useModify };
|
package/dist/react/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{a as e,i as t,n,o as r,r as i,t as a}from"../types-BgiWGYKC.js";import o from"next/image";import s from"next/link";import*as c from"next/navigation";import*as l from"react";import{createContext as u,useContext as d,useLayoutEffect as f,useRef as p,useState as m}from"react";import*as h from"react/jsx-runtime";import{Fragment as g,jsx as _}from"react/jsx-runtime";import*as v from"react-dom";import*as y from"react-dom/client";import{QueryClient as b,QueryClientProvider as x,useMutation as S,useQuery as C,useQueryClient as w}from"@tanstack/react-query";const T={all:[`mwai`],modifications:()=>[...T.all,`modifications`]};function E(){let t=p(null);return C({queryKey:T.modifications(),queryFn:async()=>{let n=await fetch(`/api/mwai/api/list`);if(!n.ok)throw Error(`Failed to fetch modifications`);let r=await n.json(),i=e.parse(r),a=i.filter(e=>e.enabled&&e.status===`success`).map(e=>e.id),o=t.current;if(o!==null){let e=new Set(o),t=new Set(a);(o.length!==a.length||a.some(t=>!e.has(t))||o.some(e=>!t.has(e)))&&typeof window<`u`&&window.location.reload()}return t.current=a,i},refetchInterval:1e4})}function D(e){let t=w(),{mutate:n,...i}=S({mutationFn:async e=>{let t=e.trim();if(!t)throw Error(`Prompt cannot be empty`);let n=await fetch(`/api/mwai/api/modify`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:t})});if(!n.ok){let e=await n.json().catch(()=>({})),t=a.safeParse(e),r=t.success&&(t.data.message||t.data.error)||`Failed to submit modification`;throw Error(r)}let i=await n.json();return r.parse(i)},onSuccess:()=>{t.invalidateQueries({queryKey:T.modifications()}),e?.onSuccess?.()},onError:t=>{let n=t instanceof Error?t:Error(`Unknown error`);e?.onError?.(n)}});return{modify:n,...i}}function O(e){let t=w(),{mutate:n,...r}=S({mutationFn:async e=>{let t=await fetch(`/api/mwai/api/enable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({modificationId:e})});if(!t.ok){let e=await t.json().catch(()=>({})),n=a.safeParse(e),r=n.success&&(n.data.message||n.data.error)||`Failed to enable modification`;throw Error(r)}let n=await t.json();return i.parse(n)},onSuccess:()=>{t.invalidateQueries({queryKey:T.modifications()}),e?.onSuccess?.()},onError:t=>{let n=t instanceof Error?t:Error(`Unknown error`);e?.onError?.(n)}});return{enable:n,...r}}function k(e){let t=w(),{mutate:r,...i}=S({mutationFn:async e=>{let t=await fetch(`/api/mwai/api/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({modificationId:e})});if(!t.ok){let e=await t.json().catch(()=>({})),n=a.safeParse(e),r=n.success&&(n.data.message||n.data.error)||`Failed to disable modification`;throw Error(r)}let r=await t.json();return n.parse(r)},onSuccess:()=>{t.invalidateQueries({queryKey:T.modifications()}),e?.onSuccess?.()},onError:t=>{let n=t instanceof Error?t:Error(`Unknown error`);e?.onError?.(n)}});return{disable:r,...i}}const A=u(null);function j(){return new b({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}})}const M=({appId:e,children:t})=>{let[n]=m(j);return _(x,{client:n,children:_(A.Provider,{value:e,children:t})})},N=()=>{let e=d(A),[t,n]=m(null),{data:r}=E();return f(()=>{if(!e){console.error(`ModifyWithAI: No appId provided. Wrap your app with <MWAIProvider appId='your-app-id'>`);return}typeof window<`u`&&(window.__REACT__=l,window.__REACT_JSX_RUNTIME__=h,window.__REACT_DOM__=v,window.__REACT_DOM_CLIENT__=y,window.__NEXT_LINK__=s,window.__NEXT_IMAGE__=o,window.__NEXT_NAVIGATION__=c)},[e]),f(()=>{if(!e||!r)return;let t=Function(`url`,`return import(url)`),i=r.filter(e=>e.enabled&&e.status===`success`).map(e=>e.id);n([]),i.forEach(r=>{t(`https://bucket.modifywithai.com/${e}/${r}.js`).then(e=>n(t=>[...t||[],e.default])).catch(e=>console.error(`Failed to load external module:`,e))})},[e,r]),t?_(g,{children:t.map(e=>_(e,{},e.name))}):null},P=()=>N(),F=({basePath:e=`/api/mwai`}={})=>_(`script`,{type:`importmap`,dangerouslySetInnerHTML:{__html:JSON.stringify({imports:{react:`${e}/shims/react-shim.js`,"react/jsx-runtime":`${e}/shims/react-jsx-shim.js`,"react-dom":`${e}/shims/react-dom-shim.js`,"react-dom/client":`${e}/shims/react-dom-client-shim.js`,"next/link":`${e}/shims/next-link-shim.js`,"next/image":`${e}/shims/next-image-shim.js`,"next/navigation":`${e}/shims/next-navigation-shim.js`}})}});export{a as ApiErrorSchema,n as DisableResponseSchema,i as EnableResponseSchema,P as MWAIComponents,A as MWAIContext,F as MWAIHead,M as MWAIProvider,t as ModificationSchema,e as ModificationsListSchema,r as ModifyResponseSchema,T as mwaiQueryKeys,N as useComponents,k as useDisable,O as useEnable,E as useList,D as useModify};
|
package/dist/types-BgiWGYKC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";const t=e.object({id:e.string(),title:e.string().nullable(),description:e.string().nullable(),status:e.enum([`pending`,`success`,`error`]),createdAt:e.number(),updatedAt:e.number(),enabled:e.boolean().nullable()}),n=e.array(t),r=e.object({modificationId:e.string()}),i=e.object({message:e.string(),modificationId:e.string(),endUserId:e.string()}),a=e.object({message:e.string(),modificationId:e.string(),endUserId:e.string()}),o=e.object({message:e.string().optional(),error:e.string().optional()});export{n as a,t as i,a as n,r as o,i as r,o as t};
|
package/dist/types-DjksF7DU.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
//#region src/types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Schema for a modification in the ModifyWithAI system
|
|
7
|
-
*/
|
|
8
|
-
declare const ModificationSchema: z.ZodObject<{
|
|
9
|
-
id: z.ZodString;
|
|
10
|
-
title: z.ZodNullable<z.ZodString>;
|
|
11
|
-
description: z.ZodNullable<z.ZodString>;
|
|
12
|
-
status: z.ZodEnum<{
|
|
13
|
-
error: "error";
|
|
14
|
-
pending: "pending";
|
|
15
|
-
success: "success";
|
|
16
|
-
}>;
|
|
17
|
-
createdAt: z.ZodNumber;
|
|
18
|
-
updatedAt: z.ZodNumber;
|
|
19
|
-
enabled: z.ZodNullable<z.ZodBoolean>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
/**
|
|
22
|
-
* Schema for the list modifications API response
|
|
23
|
-
*/
|
|
24
|
-
declare const ModificationsListSchema: z.ZodArray<z.ZodObject<{
|
|
25
|
-
id: z.ZodString;
|
|
26
|
-
title: z.ZodNullable<z.ZodString>;
|
|
27
|
-
description: z.ZodNullable<z.ZodString>;
|
|
28
|
-
status: z.ZodEnum<{
|
|
29
|
-
error: "error";
|
|
30
|
-
pending: "pending";
|
|
31
|
-
success: "success";
|
|
32
|
-
}>;
|
|
33
|
-
createdAt: z.ZodNumber;
|
|
34
|
-
updatedAt: z.ZodNumber;
|
|
35
|
-
enabled: z.ZodNullable<z.ZodBoolean>;
|
|
36
|
-
}, z.core.$strip>>;
|
|
37
|
-
/**
|
|
38
|
-
* Schema for the modify API response
|
|
39
|
-
*/
|
|
40
|
-
declare const ModifyResponseSchema: z.ZodObject<{
|
|
41
|
-
modificationId: z.ZodString;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
/**
|
|
44
|
-
* Schema for the enable API response
|
|
45
|
-
*/
|
|
46
|
-
declare const EnableResponseSchema: z.ZodObject<{
|
|
47
|
-
message: z.ZodString;
|
|
48
|
-
modificationId: z.ZodString;
|
|
49
|
-
endUserId: z.ZodString;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
/**
|
|
52
|
-
* Schema for the disable API response
|
|
53
|
-
*/
|
|
54
|
-
declare const DisableResponseSchema: z.ZodObject<{
|
|
55
|
-
message: z.ZodString;
|
|
56
|
-
modificationId: z.ZodString;
|
|
57
|
-
endUserId: z.ZodString;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
/**
|
|
60
|
-
* Schema for API error responses
|
|
61
|
-
*/
|
|
62
|
-
declare const ApiErrorSchema: z.ZodObject<{
|
|
63
|
-
message: z.ZodOptional<z.ZodString>;
|
|
64
|
-
error: z.ZodOptional<z.ZodString>;
|
|
65
|
-
}, z.core.$strip>;
|
|
66
|
-
/**
|
|
67
|
-
* Represents a modification in the ModifyWithAI system
|
|
68
|
-
*/
|
|
69
|
-
type Modification = z.infer<typeof ModificationSchema>;
|
|
70
|
-
/**
|
|
71
|
-
* Response from a modification request
|
|
72
|
-
*/
|
|
73
|
-
type ModifyResponse = z.infer<typeof ModifyResponseSchema>;
|
|
74
|
-
/**
|
|
75
|
-
* Response from enabling a modification
|
|
76
|
-
*/
|
|
77
|
-
type EnableResponse = z.infer<typeof EnableResponseSchema>;
|
|
78
|
-
/**
|
|
79
|
-
* Response from disabling a modification
|
|
80
|
-
*/
|
|
81
|
-
type DisableResponse = z.infer<typeof DisableResponseSchema>;
|
|
82
|
-
/**
|
|
83
|
-
* API error response
|
|
84
|
-
*/
|
|
85
|
-
type ApiError = z.infer<typeof ApiErrorSchema>;
|
|
86
|
-
/**
|
|
87
|
-
* Options for modification requests
|
|
88
|
-
*/
|
|
89
|
-
type ModifyWithAIOptions = {
|
|
90
|
-
/** Called when modification submission succeeds */
|
|
91
|
-
onSuccess?: () => void;
|
|
92
|
-
/** Called when modification submission fails */
|
|
93
|
-
onError?: (error: Error) => void;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Arguments for listModifications function
|
|
97
|
-
*/
|
|
98
|
-
type ListModificationsArgs = {
|
|
99
|
-
/** The MWAI instance ID */
|
|
100
|
-
id: string;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Arguments for modifyWithAI function
|
|
104
|
-
*/
|
|
105
|
-
type ModifyWithAIArgs = {
|
|
106
|
-
/** The MWAI instance ID */
|
|
107
|
-
id: string;
|
|
108
|
-
/** The modification prompt */
|
|
109
|
-
prompt: string;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Arguments for enableModification function
|
|
113
|
-
*/
|
|
114
|
-
type EnableModificationArgs = {
|
|
115
|
-
/** The ID of the modification to enable */
|
|
116
|
-
modificationId: string;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Arguments for disableModification function
|
|
120
|
-
*/
|
|
121
|
-
type DisableModificationArgs = {
|
|
122
|
-
/** The ID of the modification to disable */
|
|
123
|
-
modificationId: string;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Options for enable/disable modification requests
|
|
127
|
-
*/
|
|
128
|
-
type ModificationToggleOptions = {
|
|
129
|
-
/** Called when the operation succeeds */
|
|
130
|
-
onSuccess?: () => void;
|
|
131
|
-
/** Called when the operation fails */
|
|
132
|
-
onError?: (error: Error) => void;
|
|
133
|
-
};
|
|
134
|
-
//#endregion
|
|
135
|
-
export { ModifyWithAIOptions as _, DisableResponseSchema as a, EnableResponseSchema as c, ModificationSchema as d, ModificationToggleOptions as f, ModifyWithAIArgs as g, ModifyResponseSchema as h, DisableResponse as i, ListModificationsArgs as l, ModifyResponse as m, ApiErrorSchema as n, EnableModificationArgs as o, ModificationsListSchema as p, DisableModificationArgs as r, EnableResponse as s, ApiError as t, Modification as u };
|