@bb-labs/convex-cache 0.0.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.
Files changed (86) hide show
  1. package/README.md +342 -0
  2. package/dist/cli/fns/dev.d.ts +11 -0
  3. package/dist/cli/fns/dev.js +59 -0
  4. package/dist/cli/fns/fns/convex-runner.d.ts +26 -0
  5. package/dist/cli/fns/fns/convex-runner.js +71 -0
  6. package/dist/cli/fns/fns/generate-z-schema/fns/build-schema-map.d.ts +8 -0
  7. package/dist/cli/fns/fns/generate-z-schema/fns/build-schema-map.js +39 -0
  8. package/dist/cli/fns/fns/generate-z-schema/fns/load-convex.d.ts +7 -0
  9. package/dist/cli/fns/fns/generate-z-schema/fns/load-convex.js +49 -0
  10. package/dist/cli/fns/fns/generate-z-schema/generate.d.ts +7 -0
  11. package/dist/cli/fns/fns/generate-z-schema/generate.js +16 -0
  12. package/dist/cli/fns/fns/generate-z-schema/utils/build-schema-file.d.ts +13 -0
  13. package/dist/cli/fns/fns/generate-z-schema/utils/build-schema-file.js +42 -0
  14. package/dist/cli/fns/fns/generate-z-schema/utils/extract-schema.d.ts +3 -0
  15. package/dist/cli/fns/fns/generate-z-schema/utils/extract-schema.js +84 -0
  16. package/dist/cli/fns/fns/generate-z-schema/utils/find-fn-ref.d.ts +5 -0
  17. package/dist/cli/fns/fns/generate-z-schema/utils/find-fn-ref.js +27 -0
  18. package/dist/cli/index.d.ts +2 -0
  19. package/dist/cli/index.js +25 -0
  20. package/dist/cli/lib/convex-config.d.ts +21 -0
  21. package/dist/cli/lib/convex-config.js +37 -0
  22. package/dist/cli/lib/dir-watcher.d.ts +49 -0
  23. package/dist/cli/lib/dir-watcher.js +97 -0
  24. package/dist/cli/lib/package-cmds.d.ts +10 -0
  25. package/dist/cli/lib/package-cmds.js +17 -0
  26. package/dist/cli/lib/resolve-bun.d.ts +4 -0
  27. package/dist/cli/lib/resolve-bun.js +24 -0
  28. package/dist/cli/lib/shell-runner.d.ts +61 -0
  29. package/dist/cli/lib/shell-runner.js +133 -0
  30. package/dist/convex-cache/adapters/next/fns/build-preloader.d.ts +5 -0
  31. package/dist/convex-cache/adapters/next/fns/build-preloader.js +6 -0
  32. package/dist/convex-cache/adapters/next/fns/preload-query.d.ts +12 -0
  33. package/dist/convex-cache/adapters/next/fns/preload-query.js +27 -0
  34. package/dist/convex-cache/adapters/next/hooks/hooks.d.ts +8 -0
  35. package/dist/convex-cache/adapters/next/hooks/hooks.js +9 -0
  36. package/dist/convex-cache/adapters/next/index.d.ts +1 -0
  37. package/dist/convex-cache/adapters/next/index.js +1 -0
  38. package/dist/convex-cache/adapters/next/lib/revalidate-query-cache.d.ts +13 -0
  39. package/dist/convex-cache/adapters/next/lib/revalidate-query-cache.js +21 -0
  40. package/dist/convex-cache/adapters/next/server-fns/preload-query.d.ts +16 -0
  41. package/dist/convex-cache/adapters/next/server-fns/preload-query.js +32 -0
  42. package/dist/convex-cache/adapters/next/server-fns/revalidate-cache.d.ts +3 -0
  43. package/dist/convex-cache/adapters/next/server-fns/revalidate-cache.js +6 -0
  44. package/dist/convex-cache/adapters/next/server.d.ts +2 -0
  45. package/dist/convex-cache/adapters/next/server.js +2 -0
  46. package/dist/convex-cache/adapters/next/types/preloaded.d.ts +8 -0
  47. package/dist/convex-cache/adapters/next/types/preloaded.js +1 -0
  48. package/dist/convex-cache/adapters/next/utils/cache-profile.d.ts +1 -0
  49. package/dist/convex-cache/adapters/next/utils/cache-profile.js +1 -0
  50. package/dist/convex-cache/adapters/react/hooks/hooks.d.ts +8 -0
  51. package/dist/convex-cache/adapters/react/hooks/hooks.js +12 -0
  52. package/dist/convex-cache/adapters/react/index.d.ts +2 -0
  53. package/dist/convex-cache/adapters/react/index.js +2 -0
  54. package/dist/convex-cache/adapters/react/provider/provider.d.ts +13 -0
  55. package/dist/convex-cache/adapters/react/provider/provider.js +16 -0
  56. package/dist/convex-cache/core/client-cache/helpers/hooks/use-client-cache.d.ts +10 -0
  57. package/dist/convex-cache/core/client-cache/helpers/hooks/use-client-cache.js +16 -0
  58. package/dist/convex-cache/core/client-cache/helpers/hooks/use-query-key.d.ts +7 -0
  59. package/dist/convex-cache/core/client-cache/helpers/hooks/use-query-key.js +5 -0
  60. package/dist/convex-cache/core/client-cache/queries/paginated-query.d.ts +13 -0
  61. package/dist/convex-cache/core/client-cache/queries/paginated-query.js +37 -0
  62. package/dist/convex-cache/core/client-cache/queries/query.d.ts +10 -0
  63. package/dist/convex-cache/core/client-cache/queries/query.js +23 -0
  64. package/dist/convex-cache/core/helpers/utils/convert-paginated-schema.d.ts +13 -0
  65. package/dist/convex-cache/core/helpers/utils/convert-paginated-schema.js +45 -0
  66. package/dist/convex-cache/core/helpers/utils/fetch-schema-from-map.d.ts +21 -0
  67. package/dist/convex-cache/core/helpers/utils/fetch-schema-from-map.js +16 -0
  68. package/dist/convex-cache/core/helpers/utils/query-key.d.ts +10 -0
  69. package/dist/convex-cache/core/helpers/utils/query-key.js +16 -0
  70. package/dist/convex-cache/core/server-cache/queries/paginated-query.d.ts +15 -0
  71. package/dist/convex-cache/core/server-cache/queries/paginated-query.js +16 -0
  72. package/dist/convex-cache/core/server-cache/queries/query.d.ts +12 -0
  73. package/dist/convex-cache/core/server-cache/queries/query.js +16 -0
  74. package/dist/convex-cache/core/types/index.d.ts +2 -0
  75. package/dist/convex-cache/core/types/index.js +2 -0
  76. package/dist/convex-cache/core/types/types/paginated-query.d.ts +8 -0
  77. package/dist/convex-cache/core/types/types/paginated-query.js +2 -0
  78. package/dist/convex-cache/core/types/types/query.d.ts +5 -0
  79. package/dist/convex-cache/core/types/types/query.js +1 -0
  80. package/dist/convex-cache/index.d.ts +1 -0
  81. package/dist/convex-cache/index.js +1 -0
  82. package/dist/convex-cache/types/schema-map.d.ts +4 -0
  83. package/dist/convex-cache/types/schema-map.js +1 -0
  84. package/dist/validation/index.d.ts +10 -0
  85. package/dist/validation/index.js +83 -0
  86. package/package.json +58 -0
@@ -0,0 +1 @@
1
+ export * from "./types/schema-map";
@@ -0,0 +1 @@
1
+ export * from "./types/schema-map";
@@ -0,0 +1,4 @@
1
+ import type { ValidatorJSON } from "convex/values";
2
+ export type T_SchemaMap = Record<string, {
3
+ returns: ValidatorJSON;
4
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type GenericValidator } from "convex/values";
2
+ import type { ValidatorJSON } from "convex/values";
3
+ /**
4
+ * Serialize a Convex validator to its canonical JSON representation.
5
+ */
6
+ export declare function validatorToJSON(validator: GenericValidator): ValidatorJSON;
7
+ /**
8
+ * Rebuild a Convex validator from its ValidatorJSON representation.
9
+ */
10
+ export declare function validatorFromJSON(json: ValidatorJSON): GenericValidator;
@@ -0,0 +1,83 @@
1
+ // convexValidatorCodec.ts
2
+ import { jsonToConvex, v } from "convex/values";
3
+ /**
4
+ * Serialize a Convex validator to its canonical JSON representation.
5
+ */
6
+ export function validatorToJSON(validator) {
7
+ return validator.json;
8
+ }
9
+ /**
10
+ * Rebuild a Convex validator from its ValidatorJSON representation.
11
+ */
12
+ export function validatorFromJSON(json) {
13
+ switch (json.type) {
14
+ case "null":
15
+ return v.null();
16
+ case "number":
17
+ return v.number();
18
+ case "bigint":
19
+ return v.int64(); // or v.bigint(), depending on your style
20
+ case "boolean":
21
+ return v.boolean();
22
+ case "string":
23
+ return v.string();
24
+ case "bytes":
25
+ return v.bytes();
26
+ case "any":
27
+ return v.any();
28
+ case "literal":
29
+ // json.value is a JSONValue; Convex used convexToJson to serialize it.
30
+ // If you have jsonToConvex, use it here; otherwise assume value is already fine.
31
+ return v.literal(jsonToConvex(json.value));
32
+ case "id":
33
+ return v.id(json.tableName);
34
+ case "array": {
35
+ const elementValidator = validatorFromJSON(json.value);
36
+ return v.array(elementValidator);
37
+ }
38
+ case "union": {
39
+ const members = json.value.map((j) => validatorFromJSON(j));
40
+ // v.union expects required validators
41
+ return v.union(...members);
42
+ }
43
+ case "object": {
44
+ const fields = {};
45
+ for (const [name, field] of Object.entries(json.value)) {
46
+ const base = validatorFromJSON(field.fieldType);
47
+ const maybeOptional = field.optional ? v.optional(base) : base;
48
+ fields[name] = maybeOptional;
49
+ }
50
+ return v.object(fields);
51
+ }
52
+ case "record": {
53
+ const keyValidator = recordKeyFromJSON(json.keys);
54
+ const valueValidator = recordValueFromJSON(json.values);
55
+ return v.record(keyValidator, valueValidator);
56
+ }
57
+ default: {
58
+ const _exhaustive = json;
59
+ throw new Error(`Unknown validator JSON type: ${_exhaustive.type}`);
60
+ }
61
+ }
62
+ }
63
+ function recordKeyFromJSON(json) {
64
+ switch (json.type) {
65
+ case "string":
66
+ return v.string();
67
+ case "id":
68
+ return v.id(json.tableName);
69
+ case "union": {
70
+ const members = json.value.map((j) => recordKeyFromJSON(j));
71
+ return v.union(...members);
72
+ }
73
+ default: {
74
+ const _exhaustive = json;
75
+ throw new Error(`Unknown record key validator JSON type: ${_exhaustive.type}`);
76
+ }
77
+ }
78
+ }
79
+ function recordValueFromJSON(json) {
80
+ // json.optional is always false by type, but we’ll respect it anyway.
81
+ const base = validatorFromJSON(json.fieldType);
82
+ return json.optional ? v.optional(base) : base;
83
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@bb-labs/convex-cache",
3
+ "version": "0.0.1",
4
+ "description": "A library for caching Convex queries on the client and server",
5
+ "homepage": "https://github.com/beepbop-labs/convex-cache",
6
+ "keywords": [
7
+ "convex-cache",
8
+ "convex",
9
+ "react",
10
+ "nextjs"
11
+ ],
12
+ "author": "Beepbop",
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/beepbop-labs/convex-cache.git"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "type": "module",
23
+ "exports": {
24
+ ".": "./dist/convex-cache/index.js",
25
+ "./core/*": "./dist/convex-cache/core/*.js",
26
+ "./react": "./dist/convex-cache/adapters/react/index.js",
27
+ "./next": "./dist/convex-cache/adapters/next/index.js",
28
+ "./next/server": "./dist/convex-cache/adapters/next/server.js",
29
+ "./validation": "./dist/validation/index.js"
30
+ },
31
+ "bin": {
32
+ "convex-cache": "dist/cli/index.js"
33
+ },
34
+ "scripts": {
35
+ "build": "rm -rf dist && tsc -p tsconfig.json",
36
+ "archive": "rm -rf archive && mkdir -p archive && bun run build && npm pack --pack-destination ./archive/"
37
+ },
38
+ "dependencies": {
39
+ "@bb-labs/deep-equal": "^0.0.1",
40
+ "@bb-labs/deep-sort": "^0.0.1",
41
+ "@bb-labs/local-db": "^0.0.1",
42
+ "commander": "^14.0.2",
43
+ "convex": "^1.29.3",
44
+ "convex-helpers": "^0.1.106",
45
+ "fast-glob": "^3.3.3",
46
+ "superjson": "^2.2.6",
47
+ "zod": "^4.1.13"
48
+ },
49
+ "peerDependencies": {
50
+ "next": "^16.0.4",
51
+ "react": "^19"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^24.10.1",
55
+ "@types/react": "^19.2.7",
56
+ "typescript": "^5.9.3"
57
+ }
58
+ }