@autional/shared 0.1.0-rc.62 → 0.1.0-rc.63
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autional/shared",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.63",
|
|
4
4
|
"description": "Autional shared layer — API client, auth, types, hooks, utils",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./branding": "./src/branding/index.ts",
|
|
12
12
|
"./slug-from-url": "./src/auth/slug-from-url.ts",
|
|
13
13
|
"./portal": "./src/portal/registry.ts",
|
|
14
|
+
"./fetch": "./src/api/fetch-client.ts",
|
|
14
15
|
"./generated/api": "./src/generated/api.ts",
|
|
15
16
|
"./generated/types": "./src/generated/types.ts",
|
|
16
17
|
"./generated/queries": "./src/generated/queries.ts",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { FetchApiError, createFetchClient } from '@autional/shared/fetch';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 子路径导出 `@autional/shared/fetch` 的意义:**不把整包 index 拉进站点**。
|
|
6
|
+
*
|
|
7
|
+
* 实测教训(2026-11-11,密钥中心迁移):`import { createFetchClient } from '@autional/shared'`
|
|
8
|
+
* 会连带初始化 130 个模块(axios/react-query/zustand/生成类型…),在 vitest 的
|
|
9
|
+
* `vi.resetModules()` + 动态 import 场景下每个用例多花 5–20s,直接把 5s 超时的用例打红。
|
|
10
|
+
* 只引这个子路径后,模块图只有本文件(零依赖)。
|
|
11
|
+
*/
|
|
12
|
+
describe('@autional/shared/fetch 子路径导出', () => {
|
|
13
|
+
it('可从包名子路径导入 createFetchClient / FetchApiError', () => {
|
|
14
|
+
expect(typeof createFetchClient).toBe('function');
|
|
15
|
+
expect(typeof FetchApiError).toBe('function');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('模块本身不引入运行时依赖(源码级断言)', async () => {
|
|
19
|
+
const fs = await import('node:fs/promises');
|
|
20
|
+
const url = new URL('../fetch-client.ts', import.meta.url);
|
|
21
|
+
const src = await fs.readFile(url, 'utf8');
|
|
22
|
+
const imports = src
|
|
23
|
+
.split(/\r?\n/)
|
|
24
|
+
.filter((line) => /^\s*import\s/.test(line) || /^\s*\} from\s+['"]/.test(line));
|
|
25
|
+
expect(imports).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
});
|