@uploadista/server 0.0.10 → 0.0.12
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/ADVANCED_TYPE_SYSTEM.md +495 -0
- package/PLUGIN_TYPING.md +369 -0
- package/TYPE_SAFE_EXAMPLES.md +468 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +639 -17
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +638 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/backward-compatibility.test.ts +285 -0
- package/src/core/__tests__/plugin-validation.test.ts +472 -0
- package/src/core/create-type-safe-server.ts +204 -0
- package/src/core/index.ts +3 -0
- package/src/core/plugin-types.ts +217 -0
- package/src/core/plugin-validation.ts +319 -0
- package/src/core/server.ts +231 -15
- package/src/core/types.ts +19 -6
- package/src/plugins-typing.ts +122 -40
- package/type-tests/plugin-types.test-d.ts +388 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backward compatibility tests for deprecated exports.
|
|
3
|
+
*
|
|
4
|
+
* These tests verify that old import paths and deprecated APIs still work
|
|
5
|
+
* correctly, ensuring no breaking changes for existing code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, it } from "vitest";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Test Deprecated plugins-typing Module
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
describe("Deprecated plugins-typing module", () => {
|
|
15
|
+
it("should still be importable", async () => {
|
|
16
|
+
// Import from deprecated module - should not throw
|
|
17
|
+
const pluginsTyping = await import("../plugins-typing");
|
|
18
|
+
|
|
19
|
+
// Module should exist
|
|
20
|
+
expect(pluginsTyping).toBeDefined();
|
|
21
|
+
// All exports in plugins-typing are type-only, so we can't test runtime values
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should export type-only deprecated types", () => {
|
|
25
|
+
// This test verifies at compile time that deprecated types are still exported
|
|
26
|
+
// Runtime verification is not possible for type-only exports
|
|
27
|
+
// Types to verify (compile-time only):
|
|
28
|
+
// - LayerSuccessUnion
|
|
29
|
+
// - FlowSuccess
|
|
30
|
+
// - FlowRequirementsOf
|
|
31
|
+
// - RequiredPluginsOf
|
|
32
|
+
// - PluginAssertion
|
|
33
|
+
expect(true).toBe(true); // Placeholder - types are tested at compile time
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Test Deprecated createTypeSafeServer
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
describe("Deprecated createTypeSafeServer", () => {
|
|
42
|
+
it("should still be exported from core module", async () => {
|
|
43
|
+
const coreModule = await import("../core");
|
|
44
|
+
|
|
45
|
+
expect(coreModule).toHaveProperty("createTypeSafeServer");
|
|
46
|
+
expect(typeof coreModule.createTypeSafeServer).toBe("function");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should be exported from create-type-safe-server module", async () => {
|
|
50
|
+
const module = await import("../core/create-type-safe-server");
|
|
51
|
+
|
|
52
|
+
expect(module).toHaveProperty("createTypeSafeServer");
|
|
53
|
+
expect(typeof module.createTypeSafeServer).toBe("function");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should export helper functions", async () => {
|
|
57
|
+
const module = await import("../core/create-type-safe-server");
|
|
58
|
+
|
|
59
|
+
expect(module).toHaveProperty("defineFlow");
|
|
60
|
+
expect(module).toHaveProperty("defineSimpleFlow");
|
|
61
|
+
expect(typeof module.defineFlow).toBe("function");
|
|
62
|
+
expect(typeof module.defineSimpleFlow).toBe("function");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Test New Module Exports
|
|
68
|
+
// ============================================================================
|
|
69
|
+
|
|
70
|
+
describe("New module exports", () => {
|
|
71
|
+
it("should export runtime utilities from core module", async () => {
|
|
72
|
+
const coreModule = await import("../core");
|
|
73
|
+
|
|
74
|
+
// Runtime validation (these are actual runtime functions)
|
|
75
|
+
expect(coreModule).toHaveProperty("validatePluginRequirements");
|
|
76
|
+
expect(coreModule).toHaveProperty("formatPluginValidationError");
|
|
77
|
+
expect(coreModule).toHaveProperty("validatePluginRequirementsEffect");
|
|
78
|
+
expect(coreModule).toHaveProperty("validatePluginsOrThrow");
|
|
79
|
+
|
|
80
|
+
// Server creation
|
|
81
|
+
expect(coreModule).toHaveProperty("createUploadistaServer");
|
|
82
|
+
|
|
83
|
+
// Note: ExtractFlowPluginRequirements, InferFlowRequirements, ValidatePlugins,
|
|
84
|
+
// PluginServices, TypeSafeFlowFunction are type-only exports and cannot be
|
|
85
|
+
// tested at runtime. They are tested at compile time.
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should export plugin validation utilities", async () => {
|
|
89
|
+
const validationModule = await import("../core/plugin-validation");
|
|
90
|
+
|
|
91
|
+
expect(validationModule).toHaveProperty("validatePluginRequirements");
|
|
92
|
+
expect(validationModule).toHaveProperty("formatPluginValidationError");
|
|
93
|
+
expect(validationModule).toHaveProperty(
|
|
94
|
+
"validatePluginRequirementsEffect",
|
|
95
|
+
);
|
|
96
|
+
expect(validationModule).toHaveProperty("validatePluginsOrThrow");
|
|
97
|
+
expect(validationModule).toHaveProperty("extractServiceIdentifiers");
|
|
98
|
+
|
|
99
|
+
// Verify they are functions
|
|
100
|
+
expect(typeof validationModule.validatePluginRequirements).toBe("function");
|
|
101
|
+
expect(typeof validationModule.formatPluginValidationError).toBe("function");
|
|
102
|
+
expect(typeof validationModule.validatePluginRequirementsEffect).toBe(
|
|
103
|
+
"function",
|
|
104
|
+
);
|
|
105
|
+
expect(typeof validationModule.validatePluginsOrThrow).toBe("function");
|
|
106
|
+
expect(typeof validationModule.extractServiceIdentifiers).toBe("function");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should export plugin types module", async () => {
|
|
110
|
+
const pluginTypesModule = await import("../core/plugin-types");
|
|
111
|
+
|
|
112
|
+
// Module should exist and be importable
|
|
113
|
+
expect(pluginTypesModule).toBeDefined();
|
|
114
|
+
|
|
115
|
+
// Note: All exports from plugin-types are type-only (TypeScript types)
|
|
116
|
+
// and cannot be tested at runtime. They include:
|
|
117
|
+
// - ExtractFlowPluginRequirements (type)
|
|
118
|
+
// - InferFlowRequirements (type)
|
|
119
|
+
// - ValidatePlugins (type)
|
|
120
|
+
// - PluginServices (type)
|
|
121
|
+
// - TypeSafeFlowFunction (type)
|
|
122
|
+
// These are tested at compile time, not runtime.
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Test Import Path Compatibility
|
|
128
|
+
// ============================================================================
|
|
129
|
+
|
|
130
|
+
describe("Import path compatibility", () => {
|
|
131
|
+
it("should support importing from main core module", async () => {
|
|
132
|
+
const exports = await import("../core");
|
|
133
|
+
|
|
134
|
+
// Old APIs
|
|
135
|
+
expect(exports.createTypeSafeServer).toBeDefined();
|
|
136
|
+
|
|
137
|
+
// New APIs
|
|
138
|
+
expect(exports.createUploadistaServer).toBeDefined();
|
|
139
|
+
expect(exports.validatePluginRequirements).toBeDefined();
|
|
140
|
+
|
|
141
|
+
// Both should be functions
|
|
142
|
+
expect(typeof exports.createTypeSafeServer).toBe("function");
|
|
143
|
+
expect(typeof exports.createUploadistaServer).toBe("function");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("should support importing deprecated module directly", async () => {
|
|
147
|
+
const exports = await import("../plugins-typing");
|
|
148
|
+
|
|
149
|
+
// Module should be importable
|
|
150
|
+
expect(exports).toBeDefined();
|
|
151
|
+
// All exports are type-only
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("should support importing new modules directly", async () => {
|
|
155
|
+
const pluginTypes = await import("../core/plugin-types");
|
|
156
|
+
const pluginValidation = await import("../core/plugin-validation");
|
|
157
|
+
const server = await import("../core/server");
|
|
158
|
+
|
|
159
|
+
// Modules should be importable
|
|
160
|
+
expect(pluginTypes).toBeDefined();
|
|
161
|
+
expect(pluginValidation.validatePluginRequirements).toBeDefined();
|
|
162
|
+
expect(server.createUploadistaServer).toBeDefined();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Test Helper Functions
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
describe("Helper functions compatibility", () => {
|
|
171
|
+
it("should support defineFlow helper", async () => {
|
|
172
|
+
const { defineFlow } = await import("../core/create-type-safe-server");
|
|
173
|
+
const { Effect } = await import("effect");
|
|
174
|
+
|
|
175
|
+
// Should be able to use defineFlow
|
|
176
|
+
const flow = defineFlow(() => Effect.succeed({} as any));
|
|
177
|
+
|
|
178
|
+
expect(typeof flow).toBe("function");
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("should support defineSimpleFlow helper", async () => {
|
|
182
|
+
const { defineSimpleFlow } = await import(
|
|
183
|
+
"../core/create-type-safe-server"
|
|
184
|
+
);
|
|
185
|
+
const { Effect } = await import("effect");
|
|
186
|
+
|
|
187
|
+
// Should be able to use defineSimpleFlow
|
|
188
|
+
const flow = defineSimpleFlow(() => Effect.succeed({} as any));
|
|
189
|
+
|
|
190
|
+
expect(typeof flow).toBe("function");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("should have ExtractFlowPluginRequirements type available", () => {
|
|
194
|
+
// ExtractFlowPluginRequirements is a type-only export from plugin-types
|
|
195
|
+
// It cannot be tested at runtime, only at compile time
|
|
196
|
+
// This test serves as documentation that the type exists
|
|
197
|
+
expect(true).toBe(true);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("should have InferFlowRequirements type available", () => {
|
|
201
|
+
// InferFlowRequirements is a type-only export from plugin-types
|
|
202
|
+
// It cannot be tested at runtime, only at compile time
|
|
203
|
+
// This test serves as documentation that the type exists
|
|
204
|
+
expect(true).toBe(true);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// ============================================================================
|
|
209
|
+
// Test TypeScript Type Availability (Runtime Check)
|
|
210
|
+
// ============================================================================
|
|
211
|
+
|
|
212
|
+
describe("Type availability", () => {
|
|
213
|
+
it("should have TypeSafeServerConfig type available", async () => {
|
|
214
|
+
// This is a compile-time check that the type exists
|
|
215
|
+
// At runtime, we just verify the module exports
|
|
216
|
+
const module = await import("../core/create-type-safe-server");
|
|
217
|
+
|
|
218
|
+
expect(module).toBeDefined();
|
|
219
|
+
// Type would be checked at compile time
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("should have plugin validation types available", async () => {
|
|
223
|
+
const module = await import("../core/plugin-validation");
|
|
224
|
+
|
|
225
|
+
expect(module).toBeDefined();
|
|
226
|
+
// Types like PluginValidationResult would be checked at compile time
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("should have plugin types available", async () => {
|
|
230
|
+
const module = await import("../core/plugin-types");
|
|
231
|
+
|
|
232
|
+
expect(module).toBeDefined();
|
|
233
|
+
// Types like ValidatePlugins, PluginServices would be checked at compile time
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// ============================================================================
|
|
238
|
+
// Test Migration Scenarios
|
|
239
|
+
// ============================================================================
|
|
240
|
+
|
|
241
|
+
describe("Migration scenarios", () => {
|
|
242
|
+
it("should support old createTypeSafeServer imports", async () => {
|
|
243
|
+
// Old code pattern
|
|
244
|
+
const { createTypeSafeServer } = await import(
|
|
245
|
+
"../core/create-type-safe-server"
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
expect(createTypeSafeServer).toBeDefined();
|
|
249
|
+
expect(typeof createTypeSafeServer).toBe("function");
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("should support new createUploadistaServer imports", async () => {
|
|
253
|
+
// New code pattern
|
|
254
|
+
const { createUploadistaServer } = await import("../core/server");
|
|
255
|
+
|
|
256
|
+
expect(createUploadistaServer).toBeDefined();
|
|
257
|
+
expect(typeof createUploadistaServer).toBe("function");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should support old plugin typing imports", async () => {
|
|
261
|
+
// Old code pattern - module should be importable
|
|
262
|
+
const oldModule = await import("../plugins-typing");
|
|
263
|
+
|
|
264
|
+
expect(oldModule).toBeDefined();
|
|
265
|
+
// All exports are type-only (LayerSuccessUnion, FlowRequirementsOf, etc.)
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("should support new plugin typing imports", async () => {
|
|
269
|
+
// New code pattern - module should be importable
|
|
270
|
+
const newModule = await import("../core/plugin-types");
|
|
271
|
+
|
|
272
|
+
expect(newModule).toBeDefined();
|
|
273
|
+
// All exports are type-only (ExtractFlowPluginRequirements, ValidatePlugins, etc.)
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("should support importing both old and new modules", async () => {
|
|
277
|
+
// Both modules should be importable without conflicts
|
|
278
|
+
const oldModule = await import("../plugins-typing");
|
|
279
|
+
const newModule = await import("../core/plugin-types");
|
|
280
|
+
|
|
281
|
+
expect(oldModule).toBeDefined();
|
|
282
|
+
expect(newModule).toBeDefined();
|
|
283
|
+
// Type compatibility is tested at compile time
|
|
284
|
+
});
|
|
285
|
+
});
|