@objectstack/plugin-msw 0.8.2 → 0.9.1
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 +11 -0
- package/dist/msw-plugin.js +1 -1
- package/package.json +9 -7
- package/src/msw-plugin.test.ts +41 -0
- package/src/msw-plugin.ts +1 -1
- package/tsconfig.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @objectstack/plugin-msw
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Patch release for maintenance and stability improvements. All packages updated with unified versioning.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @objectstack/spec@0.9.1
|
|
10
|
+
- @objectstack/types@0.9.1
|
|
11
|
+
- @objectstack/objectql@0.9.1
|
|
12
|
+
- @objectstack/runtime@0.9.1
|
|
13
|
+
|
|
3
14
|
## 0.8.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/msw-plugin.js
CHANGED
|
@@ -144,7 +144,7 @@ ObjectStackServer.logger = null;
|
|
|
144
144
|
export class MSWPlugin {
|
|
145
145
|
constructor(options = {}) {
|
|
146
146
|
this.name = 'com.objectstack.plugin.msw';
|
|
147
|
-
this.version = '
|
|
147
|
+
this.version = '0.9.0';
|
|
148
148
|
this.handlers = [];
|
|
149
149
|
this.options = {
|
|
150
150
|
enableBrowser: true,
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/plugin-msw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "MSW (Mock Service Worker) Plugin for ObjectStack Runtime",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"msw": "^2.0.0",
|
|
9
|
-
"@objectstack/spec": "0.
|
|
10
|
-
"@objectstack/types": "0.
|
|
11
|
-
"@objectstack/objectql": "0.
|
|
9
|
+
"@objectstack/spec": "0.9.1",
|
|
10
|
+
"@objectstack/types": "0.9.1",
|
|
11
|
+
"@objectstack/objectql": "0.9.1"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/node": "^25.1.0",
|
|
15
15
|
"typescript": "^5.0.0",
|
|
16
|
-
"
|
|
16
|
+
"vitest": "^4.0.18",
|
|
17
|
+
"@objectstack/runtime": "0.9.1"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
|
-
"@objectstack/runtime": "^0.
|
|
20
|
+
"@objectstack/runtime": "^0.9.1"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
|
-
"build": "tsc"
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"test": "vitest run"
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { MSWPlugin, ObjectStackServer } from './msw-plugin';
|
|
3
|
+
|
|
4
|
+
describe('MSWPlugin', () => {
|
|
5
|
+
it('should initialize correctly', () => {
|
|
6
|
+
const plugin = new MSWPlugin({ enableBrowser: false });
|
|
7
|
+
expect(plugin.name).toBe('com.objectstack.plugin.msw');
|
|
8
|
+
expect(plugin.version).toBe('0.9.0');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should handle protocol dynamic loading gracefully', async () => {
|
|
12
|
+
// Mock context
|
|
13
|
+
const context: any = {
|
|
14
|
+
logger: { info: vi.fn(), debug: vi.fn(), warn: vi.fn() },
|
|
15
|
+
getService: vi.fn().mockReturnValue(null), // No protocol service initially
|
|
16
|
+
registerService: vi.fn()
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const plugin = new MSWPlugin();
|
|
20
|
+
await plugin.init(context);
|
|
21
|
+
// It should try to load ObjectStackProtocolImplementation dynamically
|
|
22
|
+
// Since we are in test environment, the dynamic import might fail or succeed depending on build
|
|
23
|
+
// But we expect it not to crash
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('ObjectStackServer', () => {
|
|
28
|
+
it('should throw if used before init', async () => {
|
|
29
|
+
await expect(ObjectStackServer.findData('test')).rejects.toThrow('ObjectStackServer not initialized');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should delegate to protocol after init', async () => {
|
|
33
|
+
const protocolMock: any = {
|
|
34
|
+
findData: vi.fn().mockResolvedValue({ records: [] })
|
|
35
|
+
};
|
|
36
|
+
ObjectStackServer.init(protocolMock);
|
|
37
|
+
|
|
38
|
+
await ObjectStackServer.findData('test');
|
|
39
|
+
expect(protocolMock.findData).toHaveBeenCalled();
|
|
40
|
+
});
|
|
41
|
+
});
|
package/src/msw-plugin.ts
CHANGED