use-convex 0.0.2 → 1.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/README.md +115 -35
- package/dist/module.d.mts +5 -3
- package/dist/module.mjs +35 -1
- package/dist/runtime/composables/useAuth.d.ts +5 -5
- package/dist/runtime/composables/useAuth.js +11 -24
- package/dist/runtime/composables/useAuthToken.d.ts +1 -1
- package/dist/runtime/composables/useAuthToken.js +2 -10
- package/dist/runtime/composables/useConvex.js +1 -1
- package/dist/runtime/composables/useConvexAction.js +6 -18
- package/dist/runtime/composables/useConvexAuth.js +4 -13
- package/dist/runtime/composables/useConvexFileUpload.d.ts +43 -0
- package/dist/runtime/composables/useConvexFileUpload.js +102 -0
- package/dist/runtime/composables/useConvexGate.js +3 -9
- package/dist/runtime/composables/useConvexMutation.js +7 -17
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +1 -1
- package/dist/runtime/composables/useConvexPaginatedQuery.js +7 -29
- package/dist/runtime/composables/useConvexQueries.d.ts +12 -7
- package/dist/runtime/composables/useConvexQueries.js +1 -3
- package/dist/runtime/composables/useConvexQuery.js +6 -12
- package/dist/runtime/composables/useConvexR2Upload.d.ts +40 -0
- package/dist/runtime/composables/useConvexR2Upload.js +86 -0
- package/dist/runtime/plugin.client.js +3 -7
- package/dist/runtime/plugin.devtools.client.d.ts +15 -2
- package/dist/runtime/plugin.devtools.client.js +18 -4
- package/dist/runtime/plugin.server.js +3 -7
- package/dist/runtime/server/api/convex/auth/session.js +7 -12
- package/dist/runtime/server/auth.js +1 -9
- package/dist/runtime/server/authCookies.js +8 -30
- package/dist/runtime/server/convexConfig.d.ts +12 -0
- package/dist/runtime/server/convexConfig.js +9 -0
- package/dist/runtime/server/fetch.d.ts +2 -4
- package/dist/runtime/server/fetch.js +3 -13
- package/dist/runtime/server/routes/__convex_devtools.get.d.ts +6 -2
- package/dist/runtime/server/routes/__convex_devtools.get.js +184 -16
- package/dist/runtime/server/sameOrigin.js +1 -5
- package/dist/runtime/utils/authCookie.d.ts +0 -2
- package/dist/runtime/utils/authCookie.js +0 -1
- package/dist/runtime/utils/authState.js +1 -6
- package/dist/runtime/utils/authStorage.js +1 -1
- package/dist/runtime/utils/context.js +3 -2
- package/dist/runtime/utils/convexDashboard.d.ts +44 -0
- package/dist/runtime/utils/convexDashboard.js +77 -0
- package/dist/runtime/utils/errors.d.ts +14 -0
- package/dist/runtime/utils/errors.js +25 -0
- package/dist/runtime/utils/oauthRedirect.js +3 -2
- package/dist/runtime/utils/paginatedOptimistic.js +4 -22
- package/dist/runtime/utils/payloadCache.d.ts +6 -0
- package/dist/runtime/utils/payloadCache.js +7 -0
- package/dist/runtime/utils/pendingError.d.ts +9 -0
- package/dist/runtime/utils/pendingError.js +23 -0
- package/dist/types.d.mts +7 -3
- package/package.json +36 -20
|
@@ -13,9 +13,7 @@ export function optimisticallyUpdateValueInPaginatedQuery(localStore, query, arg
|
|
|
13
13
|
if (typeof value === "object" && value !== null && Array.isArray(value.page)) {
|
|
14
14
|
localStore.setQuery(query, queryResult.args, {
|
|
15
15
|
...value,
|
|
16
|
-
page: value.page.map(
|
|
17
|
-
updateValue
|
|
18
|
-
)
|
|
16
|
+
page: value.page.map(updateValue)
|
|
19
17
|
});
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -55,9 +53,7 @@ export function insertAtBottomIfLoaded(options) {
|
|
|
55
53
|
(key) => compareValues(argsToMatch[key], q.args[key]) === 0
|
|
56
54
|
);
|
|
57
55
|
});
|
|
58
|
-
const lastPage = matching.find(
|
|
59
|
-
(q) => q.value !== void 0 && q.value.isDone
|
|
60
|
-
);
|
|
56
|
+
const lastPage = matching.find((q) => q.value !== void 0 && q.value.isDone);
|
|
61
57
|
if (lastPage === void 0 || lastPage.value === void 0) {
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
@@ -67,14 +63,7 @@ export function insertAtBottomIfLoaded(options) {
|
|
|
67
63
|
});
|
|
68
64
|
}
|
|
69
65
|
export function insertAtPosition(options) {
|
|
70
|
-
const {
|
|
71
|
-
paginatedQuery,
|
|
72
|
-
sortOrder,
|
|
73
|
-
sortKeyFromItem,
|
|
74
|
-
localQueryStore,
|
|
75
|
-
item,
|
|
76
|
-
argsToMatch
|
|
77
|
-
} = options;
|
|
66
|
+
const { paginatedQuery, sortOrder, sortKeyFromItem, localQueryStore, item, argsToMatch } = options;
|
|
78
67
|
const queries = localQueryStore.getAllQueries(paginatedQuery);
|
|
79
68
|
const queryGroups = {};
|
|
80
69
|
for (const query of queries) {
|
|
@@ -107,14 +96,7 @@ export function insertAtPosition(options) {
|
|
|
107
96
|
}
|
|
108
97
|
}
|
|
109
98
|
function insertAtPositionInPages(options) {
|
|
110
|
-
const {
|
|
111
|
-
pageQueries,
|
|
112
|
-
sortOrder,
|
|
113
|
-
sortKeyFromItem,
|
|
114
|
-
localQueryStore,
|
|
115
|
-
item,
|
|
116
|
-
paginatedQuery
|
|
117
|
-
} = options;
|
|
99
|
+
const { pageQueries, sortOrder, sortKeyFromItem, localQueryStore, item, paginatedQuery } = options;
|
|
118
100
|
const insertedKey = sortKeyFromItem(item);
|
|
119
101
|
const loadedPages = pageQueries.filter(
|
|
120
102
|
(q) => q.value !== void 0 && q.value.page.length > 0
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* When HttpOnly auth leaves the client without a JWT for HttpClient, keep the
|
|
4
|
+
* hydrated Nuxt payload and let the live subscription own updates.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readHydratedPayloadCache<T>(key: MaybeRefOrGetter<string>): T | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pending/error state for browser-only Convex client operations
|
|
3
|
+
* (`useConvexMutation`, `useConvexAction`).
|
|
4
|
+
*/
|
|
5
|
+
export declare function createPendingErrorState(): {
|
|
6
|
+
error: import("vue").Ref<Error | null, Error | null>;
|
|
7
|
+
pending: import("vue").ComputedRef<boolean>;
|
|
8
|
+
withPending: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
export function createPendingErrorState() {
|
|
3
|
+
const error = ref(null);
|
|
4
|
+
const pendingCount = ref(0);
|
|
5
|
+
async function withPending(fn) {
|
|
6
|
+
pendingCount.value++;
|
|
7
|
+
error.value = null;
|
|
8
|
+
try {
|
|
9
|
+
return await fn();
|
|
10
|
+
} catch (cause) {
|
|
11
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
12
|
+
error.value = err;
|
|
13
|
+
throw err;
|
|
14
|
+
} finally {
|
|
15
|
+
pendingCount.value--;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
error,
|
|
20
|
+
pending: computed(() => pendingCount.value > 0),
|
|
21
|
+
withPending
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -10,11 +10,15 @@ export { type ConvexQueryArgs, type UseConvexQueryOptions, type UseConvexQueryRe
|
|
|
10
10
|
|
|
11
11
|
export { type AuthTokenFetcher, type UseConvexAuthReturn, type UseConvexAuthSetupOptions } from '../dist/runtime/composables/useConvexAuth.js'
|
|
12
12
|
|
|
13
|
-
export { type UseConvexMutationOptions } from '../dist/runtime/composables/useConvexMutation.js'
|
|
13
|
+
export { type OptimisticUpdate, type UseConvexMutationOptions } from '../dist/runtime/composables/useConvexMutation.js'
|
|
14
14
|
|
|
15
|
-
export { type
|
|
15
|
+
export { type ConvexFileUploadExtraArgs, type ConvexFileUploadMeta, type UseConvexFileUploadOptions } from '../dist/runtime/composables/useConvexFileUpload.js'
|
|
16
16
|
|
|
17
|
-
export { type
|
|
17
|
+
export { type ConvexR2UploadApi, type ConvexR2UploadProgress } from '../dist/runtime/composables/useConvexR2Upload.js'
|
|
18
|
+
|
|
19
|
+
export { type PaginatedQueryArgs, type PaginatedQueryItem, type PaginatedQueryReference, type PaginationStatus, type UseConvexPaginatedQueryOptions, type UseConvexPaginatedQueryReturn } from '../dist/runtime/composables/useConvexPaginatedQuery.js'
|
|
20
|
+
|
|
21
|
+
export { type ConvexQueriesRequest, type ConvexQueriesResult, type ConvexQueryRequestEntry } from '../dist/runtime/composables/useConvexQueries.js'
|
|
18
22
|
|
|
19
23
|
export { type ConvexFetchOptions } from '../dist/runtime/server/fetch.js'
|
|
20
24
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-convex",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "First-class Convex integration for Nuxt",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"license": "MIT",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
9
8
|
"url": "https://github.com/jrmybtlr/convex-nuxt.git"
|
|
10
9
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/module.d.mts",
|
|
@@ -18,26 +18,26 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./runtime/*": "./dist/runtime/*"
|
|
20
20
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "nuxt-module-build build",
|
|
26
26
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
27
|
-
"dev": "nuxi dev playground --dotenv
|
|
27
|
+
"dev": "nuxi dev playground --dotenv playground/.env.local",
|
|
28
28
|
"dev:backend": "cd playground && convex dev",
|
|
29
29
|
"build:playground": "nuxi build playground",
|
|
30
|
+
"lint": "vp lint",
|
|
31
|
+
"fmt": "vp fmt",
|
|
32
|
+
"fmt:check": "vp fmt --check",
|
|
33
|
+
"check": "vp check",
|
|
30
34
|
"typecheck": "vue-tsc --noEmit",
|
|
31
|
-
"
|
|
32
|
-
"test
|
|
33
|
-
"test:
|
|
35
|
+
"typecheck:playground": "nuxi typecheck playground",
|
|
36
|
+
"test": "vp test",
|
|
37
|
+
"test:watch": "vp test --watch",
|
|
38
|
+
"test:e2e": "E2E_CONVEX=1 vp test playground/e2e test/e2e",
|
|
34
39
|
"release": "semantic-release"
|
|
35
40
|
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"convex": "^1.21.0",
|
|
38
|
-
"nuxt": "^4.0.0",
|
|
39
|
-
"vue": "^3.5.0"
|
|
40
|
-
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@nuxt/kit": "^4.0.0",
|
|
43
43
|
"defu": "^6.1.4",
|
|
@@ -51,16 +51,32 @@
|
|
|
51
51
|
"@nuxt/test-utils": "^3.23.0",
|
|
52
52
|
"@types/node": "^26.5.0",
|
|
53
53
|
"convex": "^1.45.0",
|
|
54
|
-
"convex-helpers": "^0.1.124",
|
|
55
54
|
"convex-test": "^0.0.56",
|
|
56
55
|
"happy-dom": "^20.14.0",
|
|
57
56
|
"nitropack": "^2.13.0",
|
|
58
57
|
"nuxt": "^4.5.2",
|
|
59
58
|
"semantic-release": "^25.0.9",
|
|
60
59
|
"typescript": "^5.9.0",
|
|
61
|
-
"
|
|
60
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
61
|
+
"vite-plus": "0.3.1",
|
|
62
62
|
"vue": "^3.5.0",
|
|
63
63
|
"vue-tsc": "^3.0.0"
|
|
64
64
|
},
|
|
65
|
-
"
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"convex": "^1.21.0",
|
|
67
|
+
"nuxt": "^4.0.0",
|
|
68
|
+
"vue": "^3.5.0"
|
|
69
|
+
},
|
|
70
|
+
"packageManager": "pnpm@10.0.0",
|
|
71
|
+
"pnpm": {
|
|
72
|
+
"overrides": {
|
|
73
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
74
|
+
"vitest": "4.1.11"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencyRules": {
|
|
77
|
+
"allowedVersions": {
|
|
78
|
+
"vitest": "4"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
66
82
|
}
|