@objectstack/plugin-msw 1.0.1 โ†’ 1.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @objectstack/plugin-msw
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a0a6c85: Infrastructure and development tooling improvements
8
+
9
+ - Add changeset configuration for automated version management
10
+ - Add comprehensive GitHub Actions workflows (CI, CodeQL, linting, releases)
11
+ - Add development configuration files (.cursorrules, .github/prompts)
12
+ - Add documentation files (ARCHITECTURE.md, CONTRIBUTING.md, workflows docs)
13
+ - Update test script configuration in package.json
14
+ - Add @objectstack/cli to devDependencies for better development experience
15
+
16
+ - 109fc5b: Unified patch release to align all package versions.
17
+ - Updated dependencies [a0a6c85]
18
+ - Updated dependencies [109fc5b]
19
+ - @objectstack/spec@1.0.2
20
+ - @objectstack/core@1.0.2
21
+ - @objectstack/types@1.0.2
22
+ - @objectstack/objectql@1.0.2
23
+ - @objectstack/runtime@1.0.2
24
+
3
25
  ## 1.0.1
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -21,12 +21,17 @@ See [objectstack.config.ts](./objectstack.config.ts) for the complete capability
21
21
 
22
22
  ## Features
23
23
 
24
- - ๐ŸŽฏ **Automatic API Mocking**: Automatically generates MSW handlers for all ObjectStack API endpoints
25
- - ๐Ÿ”„ **Runtime Integration**: Seamlessly integrates with ObjectStack Runtime Protocol
26
- - ๐Ÿงช **Testing Ready**: Perfect for unit tests, integration tests, and development
27
- - ๐ŸŒ **Browser & Node Support**: Works in both browser and Node.js environments
28
- - ๐ŸŽจ **Custom Handlers**: Easily add custom MSW handlers alongside standard ones
29
- - ๐Ÿ“ **TypeScript First**: Fully typed with TypeScript
24
+ - ๐ŸŽฏ **Unified Dispatcher**: Uses `@objectstack/runtime`'s `HttpDispatcher` to ensure mocks behave exactly like the real server.
25
+ - ๐Ÿ”„ **Full Protocol Support**: Mocks **all** Runtime endpoints:
26
+ - Auth (`/auth`)
27
+ - Metadata (`/metadata`)
28
+ - Data (`/data` - with filtering, batching, relations)
29
+ - Storage (`/storage`)
30
+ - Analytics (`/analytics`)
31
+ - Automation (`/automation`)
32
+ - ๐ŸŒ **Universal Support**: Works in Browser (Service Worker) and Node.js (Interceptor).
33
+ - ๐ŸŽจ **Custom Handlers**: Easily inject custom MSW handlers that take precedence.
34
+ - ๐Ÿ“ **TypeScript First**: Fully typed configuration.
30
35
 
31
36
  ## Installation
32
37
 
@@ -44,12 +49,21 @@ import { ObjectKernel } from '@objectstack/runtime';
44
49
 
45
50
  const kernel = new ObjectKernel();
46
51
 
52
+ // The MSW Plugin will initialize the HttpDispatcher and intercept requests
47
53
  kernel.use(new MSWPlugin({
48
54
  enableBrowser: true,
49
55
  baseUrl: '/api/v1',
50
56
  logRequests: true
51
57
  }));
52
58
 
59
+ await kernel.start();
60
+ ```
61
+
62
+ ### Architecture
63
+
64
+ The plugin uses the `HttpDispatcher` from the Runtime to process requests intercepted by MSW. This means your mock server runs the **actual** ObjectStack business logic (permissions, validation, flow execution) in-memory, providing a high-fidelity simulation of the backend.
65
+ }));
66
+
53
67
  await kernel.bootstrap();
54
68
  ```
55
69
 
@@ -18,221 +18,9 @@ export interface MSWPluginOptions {
18
18
  */
19
19
  logRequests?: boolean;
20
20
  }
21
- /**
22
- * ObjectStack Server Mock - Provides mock database functionality
23
- */
24
- export declare class ObjectStackServer {
25
- private static protocol;
26
- private static logger;
27
- static init(protocol: ObjectStackProtocol, logger?: any): void;
28
- static findData(object: string, params?: any): Promise<{
29
- status: number;
30
- data: {
31
- object: string;
32
- records: Record<string, any>[];
33
- total?: number | undefined;
34
- hasMore?: boolean | undefined;
35
- };
36
- }>;
37
- static getData(object: string, id: string): Promise<{
38
- status: number;
39
- data: {
40
- object: string;
41
- record: Record<string, any>;
42
- id: string;
43
- };
44
- } | {
45
- status: number;
46
- data: {
47
- error: string;
48
- };
49
- }>;
50
- static createData(object: string, data: any): Promise<{
51
- status: number;
52
- data: {
53
- object: string;
54
- record: Record<string, any>;
55
- id: string;
56
- };
57
- } | {
58
- status: number;
59
- data: {
60
- error: string;
61
- };
62
- }>;
63
- static updateData(object: string, id: string, data: any): Promise<{
64
- status: number;
65
- data: {
66
- object: string;
67
- record: Record<string, any>;
68
- id: string;
69
- };
70
- } | {
71
- status: number;
72
- data: {
73
- error: string;
74
- };
75
- }>;
76
- static deleteData(object: string, id: string): Promise<{
77
- status: number;
78
- data: {
79
- object: string;
80
- id: string;
81
- success: boolean;
82
- };
83
- } | {
84
- status: number;
85
- data: {
86
- error: string;
87
- };
88
- }>;
89
- static analyticsQuery(request: any): Promise<{
90
- status: number;
91
- data: {
92
- data: {
93
- fields: {
94
- type: string;
95
- name: string;
96
- }[];
97
- rows: Record<string, any>[];
98
- sql?: string | undefined;
99
- };
100
- success: boolean;
101
- error?: {
102
- message: string;
103
- code: string;
104
- category?: string | undefined;
105
- requestId?: string | undefined;
106
- details?: any;
107
- } | undefined;
108
- meta?: {
109
- timestamp: string;
110
- duration?: number | undefined;
111
- requestId?: string | undefined;
112
- traceId?: string | undefined;
113
- } | undefined;
114
- };
115
- } | {
116
- status: number;
117
- data: {
118
- error: string;
119
- };
120
- }>;
121
- static getAnalyticsMeta(request: any): Promise<{
122
- status: number;
123
- data: {
124
- data: {
125
- cubes: {
126
- dimensions: Record<string, {
127
- type: "string" | "number" | "boolean" | "time" | "geo";
128
- label: string;
129
- name: string;
130
- sql: string;
131
- description?: string | undefined;
132
- granularities?: ("second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year")[] | undefined;
133
- }>;
134
- name: string;
135
- sql: string;
136
- measures: Record<string, {
137
- type: "string" | "number" | "boolean" | "count" | "sum" | "avg" | "min" | "max" | "count_distinct";
138
- label: string;
139
- name: string;
140
- sql: string;
141
- description?: string | undefined;
142
- format?: string | undefined;
143
- filters?: {
144
- sql: string;
145
- }[] | undefined;
146
- }>;
147
- public: boolean;
148
- joins?: Record<string, {
149
- name: string;
150
- sql: string;
151
- relationship: "one_to_one" | "one_to_many" | "many_to_one";
152
- }> | undefined;
153
- description?: string | undefined;
154
- title?: string | undefined;
155
- refreshKey?: {
156
- every?: string | undefined;
157
- sql?: string | undefined;
158
- } | undefined;
159
- }[];
160
- };
161
- success: boolean;
162
- error?: {
163
- message: string;
164
- code: string;
165
- category?: string | undefined;
166
- requestId?: string | undefined;
167
- details?: any;
168
- } | undefined;
169
- meta?: {
170
- timestamp: string;
171
- duration?: number | undefined;
172
- requestId?: string | undefined;
173
- traceId?: string | undefined;
174
- } | undefined;
175
- };
176
- } | {
177
- status: number;
178
- data: {
179
- error: string;
180
- };
181
- }>;
182
- static triggerAutomation(request: any): Promise<{
183
- status: number;
184
- data: {
185
- success: boolean;
186
- result?: any;
187
- jobId?: string | undefined;
188
- };
189
- } | {
190
- status: number;
191
- data: {
192
- error: string;
193
- };
194
- }>;
195
- static getUser(id: string): Promise<{
196
- status: number;
197
- data: {
198
- object: string;
199
- record: Record<string, any>;
200
- id: string;
201
- };
202
- } | {
203
- status: number;
204
- data: {
205
- error: string;
206
- };
207
- }>;
208
- static createUser(data: any): Promise<{
209
- status: number;
210
- data: {
211
- object: string;
212
- record: Record<string, any>;
213
- id: string;
214
- };
215
- } | {
216
- status: number;
217
- data: {
218
- error: string;
219
- };
220
- }>;
221
- static saveMetaItem(type: string, name: string, item: any): Promise<{
222
- status: number;
223
- data: {
224
- success: boolean;
225
- message?: string | undefined;
226
- };
227
- } | {
228
- status: number;
229
- data: {
230
- error: string;
231
- };
232
- }>;
233
- }
234
21
  /**
235
22
  * MSW Plugin for ObjectStack
23
+
236
24
  *
237
25
  * This plugin enables Mock Service Worker integration for testing and development.
238
26
  * It automatically mocks API endpoints using the ObjectStack runtime protocol.
@@ -256,6 +44,7 @@ export declare class MSWPlugin implements Plugin {
256
44
  private worker;
257
45
  private handlers;
258
46
  private protocol?;
47
+ private dispatcher?;
259
48
  constructor(options?: MSWPluginOptions);
260
49
  /**
261
50
  * Init phase
@@ -290,3 +79,52 @@ export declare class MSWPlugin implements Plugin {
290
79
  */
291
80
  getHandlers(): any[];
292
81
  }
82
+ /**
83
+ * Static helper for interacting with ObjectStack protocol in MSW handlers
84
+ */
85
+ export declare class ObjectStackServer {
86
+ private static protocol;
87
+ static init(protocol: ObjectStackProtocol): void;
88
+ private static getProtocol;
89
+ static findData(objectName: string, query?: any): Promise<{
90
+ data: {
91
+ object: string;
92
+ records: Record<string, any>[];
93
+ total?: number | undefined;
94
+ hasMore?: boolean | undefined;
95
+ };
96
+ status: number;
97
+ }>;
98
+ static getData(objectName: string, id: string): Promise<{
99
+ data: {
100
+ object: string;
101
+ record: Record<string, any>;
102
+ id: string;
103
+ };
104
+ status: number;
105
+ }>;
106
+ static createData(objectName: string, data: any): Promise<{
107
+ data: {
108
+ object: string;
109
+ record: Record<string, any>;
110
+ id: string;
111
+ };
112
+ status: number;
113
+ }>;
114
+ static updateData(objectName: string, id: string, data: any): Promise<{
115
+ data: {
116
+ object: string;
117
+ record: Record<string, any>;
118
+ id: string;
119
+ };
120
+ status: number;
121
+ }>;
122
+ static deleteData(objectName: string, id: string): Promise<{
123
+ data: {
124
+ object: string;
125
+ id: string;
126
+ success: boolean;
127
+ };
128
+ status: number;
129
+ }>;
130
+ }