@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.
Files changed (129) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +236 -58
  3. package/dist/{ai-nmHdzjCM.d.ts → ai-BW2ZhizI.d.ts} +22 -7
  4. package/dist/{ai-Ce3PtWFW.js → ai-BZyLwULx.js} +147 -66
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.js +1 -1
  7. package/dist/{asset-registry-CaG9b7tf.js → asset-registry-DfBV5kmw.js} +3 -2
  8. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
  9. package/dist/blob-database.d.ts +521 -0
  10. package/dist/blob-database.js +601 -0
  11. package/dist/cloudflare.d.ts +5 -6
  12. package/dist/cloudflare.js +1 -1
  13. package/dist/config-B7dmzDX3.js +1112 -0
  14. package/dist/{config-3I1BnsdO.d.ts → config-DLKdaFWN.d.ts} +1 -2
  15. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  16. package/dist/error-diagnostics-DY5GP47p.js +96 -0
  17. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
  18. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
  19. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
  20. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
  21. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
  22. package/dist/file-C0_aPWSS.js +26 -0
  23. package/dist/file-metadata-CxDy-E2H.js +58 -0
  24. package/dist/{files-QRV55OCx.js → files-C7Px8uaC.js} +21 -10
  25. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
  26. package/dist/{github-CfA5vpJ5.js → github-CPxHtFB7.js} +36 -34
  27. package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
  28. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
  29. package/dist/glob--XcLlcml.js +22 -0
  30. package/dist/glob--kNYDbfU.js +30 -0
  31. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
  32. package/dist/host-CFnrTXTK.js +1086 -0
  33. package/dist/{hosted-C1-tTTTf.js → hosted-acMA5XyL.js} +216 -43
  34. package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
  35. package/dist/hosted-vercel-blob.d.ts +5 -6
  36. package/dist/hosted-vercel-blob.js +1 -1
  37. package/dist/hosted.d.ts +6 -7
  38. package/dist/hosted.js +1 -1
  39. package/dist/index.d.ts +76 -64
  40. package/dist/index.js +162 -457
  41. package/dist/inspect-BoObD2cJ.js +167 -0
  42. package/dist/internal/path.d.ts +2 -0
  43. package/dist/internal/path.js +2 -0
  44. package/dist/lifecycle-BwZ7c9hb.js +596 -0
  45. package/dist/loader.d.ts +5 -6
  46. package/dist/loader.js +3 -2
  47. package/dist/mcp-resources-BREFCmtn.js +39 -0
  48. package/dist/memory-BbwOqDXl.js +248 -0
  49. package/dist/metadata-target-DZEZQGHA.js +1588 -0
  50. package/dist/mountx.d.ts +4 -6
  51. package/dist/mountx.js +10 -8
  52. package/dist/nitro.d.ts +1 -1
  53. package/dist/nitro.js +1 -1
  54. package/dist/nuxt.d.ts +13 -12
  55. package/dist/nuxt.js +10 -8
  56. package/dist/operations-BcpWr41m.js +159 -0
  57. package/dist/operations-CGqY1XeG.js +965 -0
  58. package/dist/operations-DnOwKsJT.d.ts +136 -0
  59. package/dist/operations.d.ts +53 -0
  60. package/dist/operations.js +2 -0
  61. package/dist/{path-CNI6wKIU.js → path-CNAwN7pw.js} +34 -35
  62. package/dist/path-DrSIenjj.js +59 -0
  63. package/dist/path-zHxQUbqa.d.ts +9 -0
  64. package/dist/plugins-DqQ8b4T5.d.ts +10 -0
  65. package/dist/provider-kXjfli9u.js +1457 -0
  66. package/dist/providers/github/store.d.ts +3 -5
  67. package/dist/providers/github/store.js +1 -1
  68. package/dist/registry-Bp-8UUfG.js +129 -0
  69. package/dist/{registry-BIQVCBWI.d.ts → registry-Cg1TJVVZ.d.ts} +3 -4
  70. package/dist/{request-execution-u9mgUXKX.js → request-execution-Dk9rY-Yh.js} +24 -20
  71. package/dist/rolldown-runtime-B4iAMlE-.js +35 -0
  72. package/dist/runtime/assets.d.ts +3 -5
  73. package/dist/runtime/assets.js +9 -6
  74. package/dist/runtime/empty-assets-registry.d.ts +1 -2
  75. package/dist/runtime/empty-registry.d.ts +1 -2
  76. package/dist/runtime/state.d.ts +4 -4
  77. package/dist/runtime/state.js +10 -7
  78. package/dist/runtime/workspace.d.ts +1 -1
  79. package/dist/runtime/workspace.js +1 -1
  80. package/dist/runtime.d.ts +84 -15
  81. package/dist/runtime.js +561 -108
  82. package/dist/{search-C4REyHj9.js → search-CrTmXj5h.js} +10 -9
  83. package/dist/server-BNQ-Nbjj.js +290 -0
  84. package/dist/server.d.ts +22 -34
  85. package/dist/server.js +2 -355
  86. package/dist/shared-DalXdP0i.js +2158 -0
  87. package/dist/source-metadata.d.ts +7 -1
  88. package/dist/source-metadata.js +34 -2
  89. package/dist/{state-TTqa3x3Y.d.ts → state-B8zbLi5t.d.ts} +14 -13
  90. package/dist/store-CXgmu-uw.js +1729 -0
  91. package/dist/{sync-DiuDmSGk.js → sync-CN6ec-5M.js} +62 -41
  92. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
  93. package/dist/test.d.ts +1 -1
  94. package/dist/test.js +1 -1
  95. package/dist/token-CO62GglH.js +61 -0
  96. package/dist/{types-60Yn149G.d.ts → types-DeK9GIxy.d.ts} +348 -49
  97. package/dist/{use-CsV3oIxH.js → use-BQj7nSz6.js} +200 -45
  98. package/dist/{use-CUFSnFCS.d.ts → use-DhwhbAVV.d.ts} +34 -12
  99. package/dist/utils-Blrh4N2n.js +545 -0
  100. package/dist/vite-BEvgU2GY.js +20909 -0
  101. package/dist/vite-CcZmMQ7S.d.ts +476 -0
  102. package/dist/vite.d.ts +2 -50
  103. package/dist/vite.js +2 -2
  104. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
  105. package/dist/workspace-6pxkOuxr.js +1286 -0
  106. package/dist/workspace-BWJQBK1u.d.ts +7 -0
  107. package/package.json +90 -59
  108. package/dist/chunk-8H4AJuhK.js +0 -14
  109. package/dist/collections/client.d.ts +0 -39
  110. package/dist/collections/client.js +0 -137
  111. package/dist/collections.d.ts +0 -59
  112. package/dist/collections.js +0 -159
  113. package/dist/config-CDoyls2X.js +0 -30
  114. package/dist/config-CZLO0m9h.js +0 -7811
  115. package/dist/file-CHfsZpso.js +0 -23
  116. package/dist/glob-D0vD_wRY.js +0 -17
  117. package/dist/host-CAnbugpI.js +0 -370
  118. package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
  119. package/dist/lifecycle-BYoa9hVb.js +0 -176
  120. package/dist/provider-C3_elpEh.js +0 -599
  121. package/dist/publish.d.ts +0 -35
  122. package/dist/publish.js +0 -112
  123. package/dist/registry-CqyDTW9Y.js +0 -74
  124. package/dist/runtime-options-BsPSv5O7.js +0 -13
  125. package/dist/shared-jfogBrd5.js +0 -273
  126. package/dist/store-Bs1SLh55.js +0 -414
  127. package/dist/vite-tbfDxtlu.js +0 -2191
  128. package/dist/workspace-66SKyiec.d.ts +0 -6
  129. 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",
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://github.com/vite-hub/vitehub#readme",
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
- "./collections/client": {
56
- "types": "./dist/collections/client.d.ts",
57
- "import": "./dist/collections/client.js"
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
- "./publish": {
76
- "types": "./dist/publish.d.ts",
77
- "import": "./dist/publish.js"
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
- "@vercel/nft": "^1.10.2",
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
- "exsolve": "^1.1.0",
129
- "h3": "2.0.1-rc.25",
130
- "isomorphic-git": "^1.38.7",
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
- "@vite-hub/box": "0.0.3",
137
- "@vite-hub/markdown-template": "0.0.3",
138
- "@vite-hub/source": "0.0.3",
139
- "@vite-hub/runtime": "0.0.3"
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.13.3",
143
- "@vercel/blob": "^2.6.1",
144
- "ai": "7.0.19",
145
- "ocache": "^0.1.5",
146
- "publint": "^0.3.21",
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.0.8",
149
- "vite-plus": "^0.1.24",
150
- "vitest": "^4.1.4",
151
- "vue": "^3.5.0",
152
- "@vite-hub/env": "0.0.3",
153
- "@vite-hub/internal": "0.0.1",
154
- "@vite-hub/shell": "0.0.3"
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
- "@vercel/blob": "^2.6.1",
192
+ "@vite-hub/shell": "0.1.0",
158
193
  "ai": "^6.0.0 || ^7.0.0-0",
159
194
  "vite": ">=8.0.0",
160
- "vue": "^3.5.0",
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
- "vue": {
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": "tsc --noEmit -p ./tsconfig.json",
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
  }
@@ -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 };
@@ -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 };