@fatagnus/convex-sync-check 0.2.0 → 0.3.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.
@@ -9,11 +9,45 @@ var BUILTIN_INTERNAL = /* @__PURE__ */ new Set([
9
9
  ]);
10
10
  var SKIP_DIRS = /* @__PURE__ */ new Set(["_generated", "node_modules"]);
11
11
  var SKIP_FILE_PATTERNS = [/\.test\.ts$/, /\.spec\.ts$/];
12
+ var BASE_VISIBILITY = {
13
+ query: "public",
14
+ mutation: "public",
15
+ action: "public",
16
+ internalQuery: "internal",
17
+ internalMutation: "internal",
18
+ internalAction: "internal"
19
+ };
20
+ function detectWrappers(files) {
21
+ const detected = {};
22
+ const customFnPattern = /(?:export\s+)?const\s+(\w+)\s*=\s*custom(?:Query|Mutation|Action)\s*\(\s*(query|mutation|action|internalQuery|internalMutation|internalAction)\b/g;
23
+ for (const file of files) {
24
+ const content = readFileSync(file, "utf-8");
25
+ let match;
26
+ customFnPattern.lastIndex = 0;
27
+ while ((match = customFnPattern.exec(content)) !== null) {
28
+ const wrapperName = match[1];
29
+ const baseFn = match[2];
30
+ if (BUILTIN_PUBLIC.has(wrapperName) || BUILTIN_INTERNAL.has(wrapperName)) {
31
+ continue;
32
+ }
33
+ const visibility = BASE_VISIBILITY[baseFn];
34
+ if (visibility) {
35
+ detected[wrapperName] = visibility;
36
+ }
37
+ }
38
+ }
39
+ return detected;
40
+ }
12
41
  function scanBackend(convexDir, functionWrappers) {
13
42
  const files = collectTsFiles(convexDir);
14
43
  const defs = [];
44
+ const autoDetected = detectWrappers(files);
15
45
  const allPublic = new Set(BUILTIN_PUBLIC);
16
46
  const allInternal = new Set(BUILTIN_INTERNAL);
47
+ for (const [name, visibility] of Object.entries(autoDetected)) {
48
+ if (visibility === "public") allPublic.add(name);
49
+ else allInternal.add(name);
50
+ }
17
51
  if (functionWrappers) {
18
52
  for (const [name, visibility] of Object.entries(functionWrappers)) {
19
53
  if (visibility === "public") allPublic.add(name);
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  checkConvexSync
3
- } from "./chunk-DIBNW6FK.js";
3
+ } from "./chunk-OJYCE5NZ.js";
4
4
 
5
5
  // src/cli.ts
6
6
  import { parseArgs } from "util";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  checkConvexSync
3
- } from "./chunk-DIBNW6FK.js";
3
+ } from "./chunk-OJYCE5NZ.js";
4
4
  export {
5
5
  checkConvexSync
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatagnus/convex-sync-check",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Zero-config CLI to check Convex frontend/backend function sync",
5
5
  "type": "module",
6
6
  "bin": {