@vite-hub/workspace 0.0.3 → 0.1.0
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/LICENSE +201 -0
- package/README.md +236 -58
- package/dist/{ai-nmHdzjCM.d.ts → ai-BW2ZhizI.d.ts} +22 -7
- package/dist/{ai-Ce3PtWFW.js → ai-BZyLwULx.js} +147 -66
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-CaG9b7tf.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
- package/dist/blob-database.d.ts +521 -0
- package/dist/blob-database.js +601 -0
- package/dist/cloudflare.d.ts +5 -6
- package/dist/cloudflare.js +1 -1
- package/dist/config-B7dmzDX3.js +1112 -0
- package/dist/{config-3I1BnsdO.d.ts → config-DLKdaFWN.d.ts} +1 -2
- package/dist/error-diagnostics-A_8Kp-48.js +116 -0
- package/dist/error-diagnostics-DY5GP47p.js +96 -0
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
- package/dist/file-C0_aPWSS.js +26 -0
- package/dist/file-metadata-CxDy-E2H.js +58 -0
- package/dist/{files-QRV55OCx.js → files-C7Px8uaC.js} +21 -10
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
- package/dist/{github-CfA5vpJ5.js → github-CPxHtFB7.js} +36 -34
- package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
- package/dist/glob--XcLlcml.js +22 -0
- package/dist/glob--kNYDbfU.js +30 -0
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
- package/dist/host-CFnrTXTK.js +1086 -0
- package/dist/{hosted-C1-tTTTf.js → hosted-acMA5XyL.js} +216 -43
- package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
- package/dist/hosted-vercel-blob.d.ts +5 -6
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +6 -7
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +76 -64
- package/dist/index.js +162 -457
- package/dist/inspect-BoObD2cJ.js +167 -0
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-BwZ7c9hb.js +596 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-BREFCmtn.js +39 -0
- package/dist/memory-BbwOqDXl.js +248 -0
- package/dist/metadata-target-DZEZQGHA.js +1588 -0
- package/dist/mountx.d.ts +4 -6
- package/dist/mountx.js +10 -8
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +13 -12
- package/dist/nuxt.js +10 -8
- package/dist/operations-BcpWr41m.js +159 -0
- package/dist/operations-CGqY1XeG.js +965 -0
- package/dist/operations-DnOwKsJT.d.ts +136 -0
- package/dist/operations.d.ts +53 -0
- package/dist/operations.js +2 -0
- package/dist/{path-CNI6wKIU.js → path-CNAwN7pw.js} +34 -35
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-DqQ8b4T5.d.ts +10 -0
- package/dist/provider-kXjfli9u.js +1457 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-Bp-8UUfG.js +129 -0
- package/dist/{registry-BIQVCBWI.d.ts → registry-Cg1TJVVZ.d.ts} +3 -4
- package/dist/{request-execution-u9mgUXKX.js → request-execution-Dk9rY-Yh.js} +24 -20
- package/dist/rolldown-runtime-B4iAMlE-.js +35 -0
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +9 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +1 -2
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +10 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +84 -15
- package/dist/runtime.js +561 -108
- package/dist/{search-C4REyHj9.js → search-CrTmXj5h.js} +10 -9
- package/dist/server-BNQ-Nbjj.js +290 -0
- package/dist/server.d.ts +22 -34
- package/dist/server.js +2 -355
- package/dist/shared-DalXdP0i.js +2158 -0
- package/dist/source-metadata.d.ts +7 -1
- package/dist/source-metadata.js +34 -2
- package/dist/{state-TTqa3x3Y.d.ts → state-B8zbLi5t.d.ts} +14 -13
- package/dist/store-CXgmu-uw.js +1729 -0
- package/dist/{sync-DiuDmSGk.js → sync-CN6ec-5M.js} +62 -41
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/token-CO62GglH.js +61 -0
- package/dist/{types-60Yn149G.d.ts → types-DeK9GIxy.d.ts} +348 -49
- package/dist/{use-CsV3oIxH.js → use-BQj7nSz6.js} +200 -45
- package/dist/{use-CUFSnFCS.d.ts → use-DhwhbAVV.d.ts} +34 -12
- package/dist/utils-Blrh4N2n.js +545 -0
- package/dist/vite-BEvgU2GY.js +20909 -0
- package/dist/vite-CcZmMQ7S.d.ts +476 -0
- package/dist/vite.d.ts +2 -50
- package/dist/vite.js +2 -2
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
- package/dist/workspace-6pxkOuxr.js +1286 -0
- package/dist/workspace-BWJQBK1u.d.ts +7 -0
- package/package.json +90 -59
- package/dist/chunk-8H4AJuhK.js +0 -14
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-CDoyls2X.js +0 -30
- package/dist/config-CZLO0m9h.js +0 -7811
- package/dist/file-CHfsZpso.js +0 -23
- package/dist/glob-D0vD_wRY.js +0 -17
- package/dist/host-CAnbugpI.js +0 -370
- package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
- package/dist/lifecycle-BYoa9hVb.js +0 -176
- package/dist/provider-C3_elpEh.js +0 -599
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-CqyDTW9Y.js +0 -74
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/shared-jfogBrd5.js +0 -273
- package/dist/store-Bs1SLh55.js +0 -414
- package/dist/vite-tbfDxtlu.js +0 -2191
- package/dist/workspace-66SKyiec.d.ts +0 -6
- package/dist/workspace-C4k92Ow8.js +0 -1460
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { F as WorkspaceDefinition, T as Workspace } from "./types-DeK9GIxy.js";
|
|
2
|
+
//#region src/core/workspace.d.ts
|
|
3
|
+
declare function createWorkspace(definition: WorkspaceDefinition, options?: {
|
|
4
|
+
reuseStartupSnapshots?: boolean;
|
|
5
|
+
}): Workspace;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createWorkspace as t };
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/workspace",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Agent-oriented filesystem state and Vite integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"ai-agents",
|
|
6
7
|
"cloudflare",
|
|
8
|
+
"filesystem",
|
|
9
|
+
"nuxt",
|
|
10
|
+
"nuxt-module",
|
|
11
|
+
"typescript",
|
|
7
12
|
"vercel",
|
|
8
13
|
"vite",
|
|
9
14
|
"vitehub",
|
|
10
15
|
"workspace"
|
|
11
16
|
],
|
|
12
|
-
"homepage": "https://
|
|
17
|
+
"homepage": "https://vitehub.dev",
|
|
13
18
|
"bugs": "https://github.com/vite-hub/vitehub/issues",
|
|
14
19
|
"license": "Apache-2.0",
|
|
15
20
|
"author": "onmax <maximogarciamtnez@gmail.com>",
|
|
@@ -38,139 +43,165 @@
|
|
|
38
43
|
"exports": {
|
|
39
44
|
".": {
|
|
40
45
|
"types": "./dist/index.d.ts",
|
|
41
|
-
"import": "./dist/index.js"
|
|
46
|
+
"import": "./dist/index.js",
|
|
47
|
+
"default": "./dist/index.js"
|
|
42
48
|
},
|
|
43
49
|
"./ai": {
|
|
44
50
|
"types": "./dist/ai.d.ts",
|
|
45
|
-
"import": "./dist/ai.js"
|
|
51
|
+
"import": "./dist/ai.js",
|
|
52
|
+
"default": "./dist/ai.js"
|
|
53
|
+
},
|
|
54
|
+
"./blob-database": {
|
|
55
|
+
"types": "./dist/blob-database.d.ts",
|
|
56
|
+
"import": "./dist/blob-database.js",
|
|
57
|
+
"default": "./dist/blob-database.js"
|
|
46
58
|
},
|
|
47
59
|
"./cloudflare": {
|
|
48
60
|
"types": "./dist/cloudflare.d.ts",
|
|
49
|
-
"import": "./dist/cloudflare.js"
|
|
50
|
-
|
|
51
|
-
"./collections": {
|
|
52
|
-
"types": "./dist/collections.d.ts",
|
|
53
|
-
"import": "./dist/collections.js"
|
|
61
|
+
"import": "./dist/cloudflare.js",
|
|
62
|
+
"default": "./dist/cloudflare.js"
|
|
54
63
|
},
|
|
55
|
-
"./
|
|
56
|
-
"types": "./dist/
|
|
57
|
-
"import": "./dist/
|
|
64
|
+
"./internal/path": {
|
|
65
|
+
"types": "./dist/internal/path.d.ts",
|
|
66
|
+
"import": "./dist/internal/path.js",
|
|
67
|
+
"default": "./dist/internal/path.js"
|
|
58
68
|
},
|
|
59
69
|
"./loader": {
|
|
60
70
|
"types": "./dist/loader.d.ts",
|
|
61
|
-
"import": "./dist/loader.js"
|
|
71
|
+
"import": "./dist/loader.js",
|
|
72
|
+
"default": "./dist/loader.js"
|
|
62
73
|
},
|
|
63
74
|
"./mountx": {
|
|
64
75
|
"types": "./dist/mountx.d.ts",
|
|
65
|
-
"import": "./dist/mountx.js"
|
|
76
|
+
"import": "./dist/mountx.js",
|
|
77
|
+
"default": "./dist/mountx.js"
|
|
66
78
|
},
|
|
67
79
|
"./nitro": {
|
|
68
80
|
"types": "./dist/nitro.d.ts",
|
|
69
|
-
"import": "./dist/nitro.js"
|
|
81
|
+
"import": "./dist/nitro.js",
|
|
82
|
+
"default": "./dist/nitro.js"
|
|
70
83
|
},
|
|
71
84
|
"./nuxt": {
|
|
72
85
|
"types": "./dist/nuxt.d.ts",
|
|
73
|
-
"import": "./dist/nuxt.js"
|
|
86
|
+
"import": "./dist/nuxt.js",
|
|
87
|
+
"default": "./dist/nuxt.js"
|
|
74
88
|
},
|
|
75
|
-
"./
|
|
76
|
-
"types": "./dist/
|
|
77
|
-
"import": "./dist/
|
|
89
|
+
"./operations": {
|
|
90
|
+
"types": "./dist/operations.d.ts",
|
|
91
|
+
"import": "./dist/operations.js",
|
|
92
|
+
"default": "./dist/operations.js"
|
|
78
93
|
},
|
|
79
94
|
"./runtime": {
|
|
80
95
|
"types": "./dist/runtime.d.ts",
|
|
81
|
-
"import": "./dist/runtime.js"
|
|
96
|
+
"import": "./dist/runtime.js",
|
|
97
|
+
"default": "./dist/runtime.js"
|
|
82
98
|
},
|
|
83
99
|
"./server": {
|
|
84
100
|
"types": "./dist/server.d.ts",
|
|
85
|
-
"import": "./dist/server.js"
|
|
101
|
+
"import": "./dist/server.js",
|
|
102
|
+
"default": "./dist/server.js"
|
|
86
103
|
},
|
|
87
104
|
"./source-metadata": {
|
|
88
105
|
"types": "./dist/source-metadata.d.ts",
|
|
89
|
-
"import": "./dist/source-metadata.js"
|
|
106
|
+
"import": "./dist/source-metadata.js",
|
|
107
|
+
"default": "./dist/source-metadata.js"
|
|
90
108
|
},
|
|
91
109
|
"./test": {
|
|
92
110
|
"types": "./dist/test.d.ts",
|
|
93
|
-
"import": "./dist/test.js"
|
|
111
|
+
"import": "./dist/test.js",
|
|
112
|
+
"default": "./dist/test.js"
|
|
94
113
|
},
|
|
95
114
|
"./vite": {
|
|
96
115
|
"types": "./dist/vite.d.ts",
|
|
97
|
-
"import": "./dist/vite.js"
|
|
116
|
+
"import": "./dist/vite.js",
|
|
117
|
+
"default": "./dist/vite.js"
|
|
98
118
|
},
|
|
99
119
|
"./package.json": "./package.json",
|
|
100
120
|
"./internal/runtime/assets": {
|
|
101
121
|
"types": "./dist/runtime/assets.d.ts",
|
|
102
|
-
"import": "./dist/runtime/assets.js"
|
|
122
|
+
"import": "./dist/runtime/assets.js",
|
|
123
|
+
"default": "./dist/runtime/assets.js"
|
|
103
124
|
},
|
|
104
125
|
"./internal/runtime/hosted": {
|
|
105
126
|
"types": "./dist/hosted.d.ts",
|
|
106
|
-
"import": "./dist/hosted.js"
|
|
127
|
+
"import": "./dist/hosted.js",
|
|
128
|
+
"default": "./dist/hosted.js"
|
|
107
129
|
},
|
|
108
130
|
"./internal/runtime/hosted-vercel-blob": {
|
|
109
131
|
"types": "./dist/hosted-vercel-blob.d.ts",
|
|
110
|
-
"import": "./dist/hosted-vercel-blob.js"
|
|
132
|
+
"import": "./dist/hosted-vercel-blob.js",
|
|
133
|
+
"default": "./dist/hosted-vercel-blob.js"
|
|
111
134
|
},
|
|
112
135
|
"./internal/runtime/state": {
|
|
113
136
|
"types": "./dist/runtime/state.d.ts",
|
|
114
|
-
"import": "./dist/runtime/state.js"
|
|
137
|
+
"import": "./dist/runtime/state.js",
|
|
138
|
+
"default": "./dist/runtime/state.js"
|
|
115
139
|
},
|
|
116
140
|
"./internal/runtime/workspace": {
|
|
117
141
|
"types": "./dist/runtime/workspace.d.ts",
|
|
118
|
-
"import": "./dist/runtime/workspace.js"
|
|
142
|
+
"import": "./dist/runtime/workspace.js",
|
|
143
|
+
"default": "./dist/runtime/workspace.js"
|
|
119
144
|
},
|
|
120
145
|
"./internal/stores/github": {
|
|
121
146
|
"types": "./dist/providers/github/store.d.ts",
|
|
122
|
-
"import": "./dist/providers/github/store.js"
|
|
147
|
+
"import": "./dist/providers/github/store.js",
|
|
148
|
+
"default": "./dist/providers/github/store.js"
|
|
123
149
|
}
|
|
124
150
|
},
|
|
125
151
|
"dependencies": {
|
|
126
|
-
"@
|
|
152
|
+
"@standard-schema/spec": "^1.1.0",
|
|
153
|
+
"@vercel/nft": "^1.11.0",
|
|
154
|
+
"@vite-hub/forge": "0.1.0",
|
|
155
|
+
"@vite-hub/runtime": "0.1.0",
|
|
156
|
+
"@vite-hub/source": "0.1.0",
|
|
127
157
|
"defu": "^6.1.7",
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
158
|
+
"esbuild": "^0.28.2",
|
|
159
|
+
"exsolve": "^1.1.3",
|
|
160
|
+
"h3": "2.0.1-rc.33",
|
|
161
|
+
"isomorphic-git": "^1.42.6",
|
|
131
162
|
"jiti": "^2.7.0",
|
|
163
|
+
"minimatch": "^10.2.6",
|
|
132
164
|
"mountx": "0.0.2",
|
|
133
|
-
"minimatch": "^10.2.5",
|
|
134
165
|
"mrmime": "^2.0.1",
|
|
166
|
+
"nostics": "1.3.0",
|
|
135
167
|
"ofetch": "^1.5.1",
|
|
136
|
-
"
|
|
137
|
-
"@vite-hub/markdown-template": "0.0
|
|
138
|
-
"@vite-hub/
|
|
139
|
-
"@vite-hub/
|
|
168
|
+
"valibot": "^1.5.0",
|
|
169
|
+
"@vite-hub/markdown-template": "0.1.0",
|
|
170
|
+
"@vite-hub/blob": "0.1.0",
|
|
171
|
+
"@vite-hub/database": "0.1.0",
|
|
172
|
+
"@vite-hub/sandbox": "0.1.0"
|
|
140
173
|
},
|
|
141
174
|
"devDependencies": {
|
|
142
|
-
"@types/node": "^24.
|
|
143
|
-
"@vercel/blob": "^2.
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
175
|
+
"@types/node": "^24.19.1",
|
|
176
|
+
"@vercel/blob": "^2.8.0",
|
|
177
|
+
"@vite-hub/env": "0.1.0",
|
|
178
|
+
"@vite-hub/shell": "0.1.0",
|
|
179
|
+
"ai": "7.0.130",
|
|
180
|
+
"ocache": "^0.3.0",
|
|
181
|
+
"publint": "^0.3.25",
|
|
147
182
|
"typescript": "^6.0.3",
|
|
148
|
-
"vite": "^8.
|
|
149
|
-
"vite-plus": "^0.
|
|
150
|
-
"vitest": "^4.1.
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"@
|
|
154
|
-
"@vite-hub/
|
|
183
|
+
"vite": "^8.2.2",
|
|
184
|
+
"vite-plus": "^0.3.3",
|
|
185
|
+
"vitest": "^4.1.11",
|
|
186
|
+
"drizzle-orm": "^0.45.3",
|
|
187
|
+
"miniflare": "4.20260730.0",
|
|
188
|
+
"@libsql/client": "^0.18.0",
|
|
189
|
+
"@vite-hub/internal": "0.0.1"
|
|
155
190
|
},
|
|
156
191
|
"peerDependencies": {
|
|
157
|
-
"@
|
|
192
|
+
"@vite-hub/shell": "0.1.0",
|
|
158
193
|
"ai": "^6.0.0 || ^7.0.0-0",
|
|
159
194
|
"vite": ">=8.0.0",
|
|
160
|
-
"
|
|
161
|
-
"@vite-hub/shell": "0.0.3"
|
|
195
|
+
"drizzle-orm": "^0.45.3"
|
|
162
196
|
},
|
|
163
197
|
"peerDependenciesMeta": {
|
|
164
|
-
"@vercel/blob": {
|
|
165
|
-
"optional": true
|
|
166
|
-
},
|
|
167
198
|
"@vite-hub/shell": {
|
|
168
199
|
"optional": true
|
|
169
200
|
},
|
|
170
201
|
"vite": {
|
|
171
202
|
"optional": true
|
|
172
203
|
},
|
|
173
|
-
"
|
|
204
|
+
"drizzle-orm": {
|
|
174
205
|
"optional": true
|
|
175
206
|
}
|
|
176
207
|
},
|
|
@@ -180,7 +211,7 @@
|
|
|
180
211
|
"scripts": {
|
|
181
212
|
"build": "vp pack",
|
|
182
213
|
"dev": "vp pack --watch",
|
|
183
|
-
"typecheck": "
|
|
214
|
+
"typecheck": "vp run --cache -t @vite-hub/workspace#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
|
|
184
215
|
"test": "vp run -t @vite-hub/workspace#build && vp test"
|
|
185
216
|
}
|
|
186
217
|
}
|
package/dist/chunk-8H4AJuhK.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __exportAll = (all, no_symbols) => {
|
|
5
|
-
let target = {};
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { __exportAll as t };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { WorkspaceCollectionItem, WorkspaceCollectionPage } from "../collections.js";
|
|
2
|
-
import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
-
|
|
4
|
-
//#region src/collections/client.d.ts
|
|
5
|
-
interface WorkspaceCollectionRequestOptions {
|
|
6
|
-
query?: Record<string, unknown>;
|
|
7
|
-
signal: AbortSignal;
|
|
8
|
-
}
|
|
9
|
-
type WorkspaceCollectionRequester = <T>(endpoint: string, options: WorkspaceCollectionRequestOptions) => Promise<T>;
|
|
10
|
-
interface UseWorkspaceCollectionOptions {
|
|
11
|
-
immediate?: boolean;
|
|
12
|
-
limit?: number;
|
|
13
|
-
query?: MaybeRefOrGetter<Record<string, unknown>>;
|
|
14
|
-
request?: WorkspaceCollectionRequester;
|
|
15
|
-
}
|
|
16
|
-
interface UseWorkspaceCollectionReturn<T> {
|
|
17
|
-
error: Ref<unknown>;
|
|
18
|
-
facets: Ref<WorkspaceCollectionPage<T>["facets"]>;
|
|
19
|
-
hasMore: ComputedRef<boolean>;
|
|
20
|
-
items: Ref<T[]>;
|
|
21
|
-
loadMore: () => Promise<WorkspaceCollectionPage<T> | undefined>;
|
|
22
|
-
pending: Ref<boolean>;
|
|
23
|
-
refresh: () => Promise<WorkspaceCollectionPage<T> | undefined>;
|
|
24
|
-
total: Ref<number>;
|
|
25
|
-
}
|
|
26
|
-
interface UseWorkspaceCollectionItemOptions {
|
|
27
|
-
immediate?: boolean;
|
|
28
|
-
request?: WorkspaceCollectionRequester;
|
|
29
|
-
}
|
|
30
|
-
interface UseWorkspaceCollectionItemReturn<T> {
|
|
31
|
-
data: Ref<T | null>;
|
|
32
|
-
error: Ref<unknown>;
|
|
33
|
-
pending: Ref<boolean>;
|
|
34
|
-
refresh: () => Promise<WorkspaceCollectionItem<T> | undefined>;
|
|
35
|
-
}
|
|
36
|
-
declare function useWorkspaceCollection<T = Record<string, unknown>>(endpoint: string, options?: UseWorkspaceCollectionOptions): UseWorkspaceCollectionReturn<T>;
|
|
37
|
-
declare function useWorkspaceCollectionItem<T = Record<string, unknown>>(endpoint: string, value: MaybeRefOrGetter<string | undefined>, options?: UseWorkspaceCollectionItemOptions): UseWorkspaceCollectionItemReturn<T>;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { UseWorkspaceCollectionItemOptions, UseWorkspaceCollectionItemReturn, UseWorkspaceCollectionOptions, UseWorkspaceCollectionReturn, WorkspaceCollectionRequestOptions, WorkspaceCollectionRequester, useWorkspaceCollection, useWorkspaceCollectionItem };
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { $fetch } from "ofetch";
|
|
2
|
-
import { computed, onScopeDispose, ref, toValue, watch } from "vue";
|
|
3
|
-
//#region src/collections/client.ts
|
|
4
|
-
const defaultRequester = async (endpoint, options) => {
|
|
5
|
-
return await $fetch(endpoint, options);
|
|
6
|
-
};
|
|
7
|
-
function isAbortError(error) {
|
|
8
|
-
return Boolean(error && typeof error === "object" && "name" in error && error.name === "AbortError");
|
|
9
|
-
}
|
|
10
|
-
function isStaleCursorError(error) {
|
|
11
|
-
if (!error || typeof error !== "object") return false;
|
|
12
|
-
return ("statusCode" in error ? error.statusCode : "status" in error ? error.status : void 0) === 409;
|
|
13
|
-
}
|
|
14
|
-
function useWorkspaceCollection(endpoint, options = {}) {
|
|
15
|
-
const items = ref([]);
|
|
16
|
-
const facets = ref({});
|
|
17
|
-
const total = ref(0);
|
|
18
|
-
const nextCursor = ref(null);
|
|
19
|
-
const pending = ref(false);
|
|
20
|
-
const error = ref(null);
|
|
21
|
-
const request = options.request || defaultRequester;
|
|
22
|
-
let active;
|
|
23
|
-
let loaded = false;
|
|
24
|
-
async function load(reset) {
|
|
25
|
-
if (!reset && (pending.value || loaded && !nextCursor.value)) return;
|
|
26
|
-
active?.abort();
|
|
27
|
-
const controller = new AbortController();
|
|
28
|
-
active = controller;
|
|
29
|
-
pending.value = true;
|
|
30
|
-
error.value = null;
|
|
31
|
-
try {
|
|
32
|
-
const response = await request(endpoint, {
|
|
33
|
-
query: {
|
|
34
|
-
...options.query ? toValue(options.query) : {},
|
|
35
|
-
cursor: reset ? void 0 : nextCursor.value || void 0,
|
|
36
|
-
limit: options.limit
|
|
37
|
-
},
|
|
38
|
-
signal: controller.signal
|
|
39
|
-
});
|
|
40
|
-
if (active !== controller) return;
|
|
41
|
-
items.value = reset ? response.items : [...items.value, ...response.items];
|
|
42
|
-
facets.value = response.facets;
|
|
43
|
-
total.value = response.total;
|
|
44
|
-
nextCursor.value = response.nextCursor;
|
|
45
|
-
loaded = true;
|
|
46
|
-
return response;
|
|
47
|
-
} catch (cause) {
|
|
48
|
-
if (active !== controller || isAbortError(cause)) return;
|
|
49
|
-
if (!reset && isStaleCursorError(cause)) return await load(true);
|
|
50
|
-
error.value = cause;
|
|
51
|
-
} finally {
|
|
52
|
-
if (active === controller) {
|
|
53
|
-
active = void 0;
|
|
54
|
-
pending.value = false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const stop = watch(() => options.query ? toValue(options.query) : void 0, () => {
|
|
59
|
-
load(true);
|
|
60
|
-
}, {
|
|
61
|
-
deep: true,
|
|
62
|
-
immediate: options.immediate !== false && (options.request !== void 0 || "window" in globalThis)
|
|
63
|
-
});
|
|
64
|
-
onScopeDispose(() => {
|
|
65
|
-
stop();
|
|
66
|
-
active?.abort();
|
|
67
|
-
active = void 0;
|
|
68
|
-
pending.value = false;
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
error,
|
|
72
|
-
facets,
|
|
73
|
-
hasMore: computed(() => Boolean(nextCursor.value)),
|
|
74
|
-
items,
|
|
75
|
-
loadMore: () => load(false),
|
|
76
|
-
pending,
|
|
77
|
-
refresh: () => load(true),
|
|
78
|
-
total
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function useWorkspaceCollectionItem(endpoint, value, options = {}) {
|
|
82
|
-
const data = ref(null);
|
|
83
|
-
const pending = ref(false);
|
|
84
|
-
const error = ref(null);
|
|
85
|
-
const request = options.request || defaultRequester;
|
|
86
|
-
let active;
|
|
87
|
-
async function refresh() {
|
|
88
|
-
const resolvedValue = toValue(value);
|
|
89
|
-
if (resolvedValue === void 0) {
|
|
90
|
-
active?.abort();
|
|
91
|
-
active = void 0;
|
|
92
|
-
data.value = null;
|
|
93
|
-
error.value = null;
|
|
94
|
-
pending.value = false;
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
active?.abort();
|
|
98
|
-
const controller = new AbortController();
|
|
99
|
-
active = controller;
|
|
100
|
-
pending.value = true;
|
|
101
|
-
error.value = null;
|
|
102
|
-
try {
|
|
103
|
-
const response = await request(endpoint, {
|
|
104
|
-
query: { value: resolvedValue },
|
|
105
|
-
signal: controller.signal
|
|
106
|
-
});
|
|
107
|
-
if (active !== controller) return;
|
|
108
|
-
data.value = response.item;
|
|
109
|
-
return response;
|
|
110
|
-
} catch (cause) {
|
|
111
|
-
if (active !== controller || isAbortError(cause)) return;
|
|
112
|
-
error.value = cause;
|
|
113
|
-
} finally {
|
|
114
|
-
if (active === controller) {
|
|
115
|
-
active = void 0;
|
|
116
|
-
pending.value = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const stop = watch(() => toValue(value), () => {
|
|
121
|
-
refresh();
|
|
122
|
-
}, { immediate: options.immediate !== false && (options.request !== void 0 || "window" in globalThis) });
|
|
123
|
-
onScopeDispose(() => {
|
|
124
|
-
stop();
|
|
125
|
-
active?.abort();
|
|
126
|
-
active = void 0;
|
|
127
|
-
pending.value = false;
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
data,
|
|
131
|
-
error,
|
|
132
|
-
pending,
|
|
133
|
-
refresh
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
export { useWorkspaceCollection, useWorkspaceCollectionItem };
|
package/dist/collections.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { rt as WorkspaceName } from "./types-60Yn149G.js";
|
|
2
|
-
import { t as ReadonlyWorkspaceFacade } from "./use-CUFSnFCS.js";
|
|
3
|
-
|
|
4
|
-
//#region src/collections.d.ts
|
|
5
|
-
interface WorkspaceCollectionEmptyFilter {
|
|
6
|
-
empty: true;
|
|
7
|
-
}
|
|
8
|
-
declare const workspaceCollectionEmpty: WorkspaceCollectionEmptyFilter;
|
|
9
|
-
type WorkspaceCollectionFilter = string | string[] | WorkspaceCollectionEmptyFilter;
|
|
10
|
-
interface WorkspaceCollectionSort {
|
|
11
|
-
direction?: "asc" | "desc";
|
|
12
|
-
field: string;
|
|
13
|
-
}
|
|
14
|
-
interface WorkspaceCollectionQuery {
|
|
15
|
-
cursor?: string;
|
|
16
|
-
facets?: string[];
|
|
17
|
-
filters?: Record<string, WorkspaceCollectionFilter | undefined>;
|
|
18
|
-
limit?: number;
|
|
19
|
-
search?: string;
|
|
20
|
-
searchFields?: string[];
|
|
21
|
-
select?: string[];
|
|
22
|
-
sort?: WorkspaceCollectionSort;
|
|
23
|
-
}
|
|
24
|
-
interface WorkspaceCollectionItemQuery {
|
|
25
|
-
key: string;
|
|
26
|
-
select?: string[];
|
|
27
|
-
value: string | number;
|
|
28
|
-
}
|
|
29
|
-
interface WorkspaceCollectionOptions<Name extends WorkspaceName = WorkspaceName> {
|
|
30
|
-
defaultLimit?: number;
|
|
31
|
-
maxLimit?: number;
|
|
32
|
-
path: string;
|
|
33
|
-
workspace: Name | ReadonlyWorkspaceFacade<Name> | Promise<ReadonlyWorkspaceFacade<Name>>;
|
|
34
|
-
}
|
|
35
|
-
interface WorkspaceCollectionPageOptions<Name extends WorkspaceName = WorkspaceName> extends WorkspaceCollectionOptions<Name> {
|
|
36
|
-
query?: WorkspaceCollectionQuery;
|
|
37
|
-
}
|
|
38
|
-
interface WorkspaceCollectionItemOptions<Name extends WorkspaceName = WorkspaceName> extends WorkspaceCollectionOptions<Name> {
|
|
39
|
-
query: WorkspaceCollectionItemQuery;
|
|
40
|
-
}
|
|
41
|
-
interface WorkspaceCollectionFacetValue {
|
|
42
|
-
count: number;
|
|
43
|
-
value: string;
|
|
44
|
-
}
|
|
45
|
-
interface WorkspaceCollectionPage<T = Record<string, unknown>> {
|
|
46
|
-
digest: string;
|
|
47
|
-
facets: Record<string, WorkspaceCollectionFacetValue[]>;
|
|
48
|
-
items: T[];
|
|
49
|
-
nextCursor: string | null;
|
|
50
|
-
total: number;
|
|
51
|
-
}
|
|
52
|
-
interface WorkspaceCollectionItem<T = Record<string, unknown>> {
|
|
53
|
-
digest: string;
|
|
54
|
-
item: T | null;
|
|
55
|
-
}
|
|
56
|
-
declare function queryWorkspaceCollection<T = Record<string, unknown>, Name extends WorkspaceName = WorkspaceName>(options: WorkspaceCollectionPageOptions<Name>): Promise<WorkspaceCollectionPage<T>>;
|
|
57
|
-
declare function getWorkspaceCollectionItem<T = Record<string, unknown>, Name extends WorkspaceName = WorkspaceName>(options: WorkspaceCollectionItemOptions<Name>): Promise<WorkspaceCollectionItem<T>>;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { WorkspaceCollectionEmptyFilter, WorkspaceCollectionFacetValue, WorkspaceCollectionFilter, WorkspaceCollectionItem, WorkspaceCollectionItemOptions, WorkspaceCollectionItemQuery, WorkspaceCollectionOptions, WorkspaceCollectionPage, WorkspaceCollectionPageOptions, WorkspaceCollectionQuery, WorkspaceCollectionSort, getWorkspaceCollectionItem, queryWorkspaceCollection, workspaceCollectionEmpty };
|