Skip to content

Commit 1fa7e6c

Browse files
committed
refactor(callapi-plugins): reorganize logger plugin structure and exports
- Move logger plugin files to new plugins/logger directory - Update package.json exports configuration - Update tsdown.config.ts entry points
1 parent 57f7f08 commit 1fa7e6c

File tree

8 files changed

+26
-15
lines changed

8 files changed

+26
-15
lines changed

apps/dev/src/client.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@ import * as z from "zod";
1212

1313
const newOptionSchema1 = z.object({
1414
onUpload: z.function({
15-
input: [z.object({ loaded: z.number(), total: z.number() })],
16-
}),
17-
});
18-
19-
const newOptionSchema2 = z.object({
20-
onUploadSuccess: z.function({
2115
input: [
2216
z.object({
23-
load: z.number(),
24-
tots: z.number(),
17+
loaded: z.number(),
18+
total: z.number(),
2519
}),
2620
],
2721
}),
2822
});
2923

30-
type Plugin2Options = z.infer<typeof newOptionSchema2>;
31-
3224
const pluginOne = definePlugin({
3325
defineExtraOptions: () => newOptionSchema1,
3426

@@ -41,6 +33,19 @@ const pluginOne = definePlugin({
4133
name: "plugin",
4234
});
4335

36+
const newOptionSchema2 = z.object({
37+
onUploadSuccess: z.function({
38+
input: [
39+
z.object({
40+
load: z.number(),
41+
tots: z.number(),
42+
}),
43+
],
44+
}),
45+
});
46+
47+
type Plugin2Options = z.infer<typeof newOptionSchema2>;
48+
4449
const pluginTwo = definePlugin({
4550
defineExtraOptions: () => newOptionSchema2,
4651

@@ -49,7 +54,7 @@ const pluginTwo = definePlugin({
4954
onResponseError: (_ctx) => console.info("OnSuccess - PLUGIN2"),
5055
onSuccess: (_ctx: SuccessContext<{ Data: { foo: string } }>) => console.info("OnSuccess - PLUGIN2"),
5156
} satisfies PluginHooks<{
52-
ErrorData: { foo: string };
57+
ErrorData: { trash: string };
5358
InferredExtraOptions: Plugin2Options;
5459
}>,
5560

@@ -58,7 +63,10 @@ const pluginTwo = definePlugin({
5863
name: "plugin",
5964

6065
setup: ({ options, request }: PluginSetupContext<{ InferredExtraOptions: Plugin2Options }>) => {
61-
options.onUploadSuccess?.({ load: 0, tots: 0 });
66+
options.onUploadSuccess?.({
67+
load: 0,
68+
tots: 0,
69+
});
6270

6371
return {
6472
request: {

packages/callapi-plugins/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"url": "git+https://github.com/zayne-labs/callapi.git"
1212
},
1313
"sideEffects": false,
14-
"exports": "./dist/index.js",
14+
"exports": {
15+
".": "./dist/index.js",
16+
"./*": "./dist/plugins/*/index.js"
17+
},
1518
"files": [
1619
"dist"
1720
],
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./logger";
1+
export * from "./plugins/logger";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/callapi-plugins/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const isDevMode = process.env.NODE_ENV === "development";
55
const commonOptions = {
66
clean: true, // clean up dist folder,
77
dts: { newContext: true },
8-
entry: ["src/index.ts"],
8+
entry: ["src/index.ts", "src/plugins/*/index.ts"],
99
ignoreWatch: [".turbo"],
1010
platform: "browser",
1111
sourcemap: !isDevMode,

0 commit comments

Comments
 (0)