@abdssamie/convex-checkpoints 0.1.2 → 0.1.7

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 (2) hide show
  1. package/README.md +4 -29
  2. package/package.json +30 -21
package/README.md CHANGED
@@ -29,34 +29,7 @@ export default app;
29
29
 
30
30
  ## Usage
31
31
 
32
- Define your checkpoint registry in app code and expose wrapper functions from
33
- your own app modules. That keeps auth, permission checks, and business rules
34
- close to the rest of your application code.
35
-
36
- Expose checkpoint submissions as Convex mutations by default. Mutations are the
37
- right fit when recording a checkpoint, updating Convex data, reading Convex
38
- data, or scheduling follow-up work from a handler.
39
-
40
- Use an action only when the submit path needs external, non-transactional work,
41
- such as calling a third-party API, sending an email directly, using Node APIs,
42
- or doing longer-running processing. For most integrations, keep the checkpoint
43
- submission in a mutation and schedule an internal action from the checkpoint
44
- handler:
45
-
46
- ```ts
47
- checkpoints.on("user.signup", async (ctx, payload) => {
48
- await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, {
49
- userId: payload.userId,
50
- });
51
- });
52
- ```
53
-
54
- Actions are not database transactions, so design retries and idempotency
55
- explicitly when external systems are involved.
56
-
57
- The registry gives you typed checkpoint names and payloads while writing
58
- handlers and submit calls. Your exported Convex functions are still the runtime
59
- boundary where you validate input and enforce permissions.
32
+ There are two steps: define your checkpoint registry with handlers, then expose submit mutations for your app to call.
60
33
 
61
34
  ```ts
62
35
  // convex/checkpoints.ts
@@ -66,10 +39,11 @@ import { v } from "convex/values";
66
39
  import { ConvexCheckpoints } from "@abdssamie/convex-checkpoints";
67
40
 
68
41
  export const checkpoints = new ConvexCheckpoints<{
69
- "user.signup": { userId: string };
42
+ "user.signup": { userId: string; email: string };
70
43
  "post.created": { userId: string; postId: string; title: string };
71
44
  }>(components.convexCheckpoints);
72
45
 
46
+ // Handlers run when a checkpoint is first recorded (deduplicated by idempotencyKey)
73
47
  checkpoints.on("user.signup", async (ctx, payload) => {
74
48
  await ctx.scheduler.runAfter(30 * 60 * 1000, internal.emails.welcome, {
75
49
  userId: payload.userId,
@@ -89,6 +63,7 @@ checkpoints.on("post.created", async (ctx, payload) => {
89
63
  }
90
64
  });
91
65
 
66
+ // Submit mutations — called from your app code
92
67
  export const submitPostCreated = mutation({
93
68
  args: {
94
69
  userId: v.string(),
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@abdssamie/convex-checkpoints",
3
3
  "description": "A Convex component for event-driven user checkpoints.",
4
- "repository": "github:abdssamie/convex-checkpoints",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://gitlab.com/Abdssamie/convex-checkpoints.git"
7
+ },
5
8
  "homepage": "https://github.com/abdssamie/convex-checkpoints#readme",
6
9
  "bugs": {
7
10
  "url": "https://github.com/abdssamie/convex-checkpoints/issues"
8
11
  },
9
- "version": "0.1.2",
12
+ "version": "0.1.7",
10
13
  "license": "Apache-2.0",
11
14
  "keywords": [
12
15
  "convex",
@@ -15,6 +18,25 @@
15
18
  "checkpoints"
16
19
  ],
17
20
  "type": "module",
21
+ "scripts": {
22
+ "dev": "convex dev --start 'npm run dev:build'",
23
+ "dev:frontend": "cd example && vite",
24
+ "dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'npm run build:codegen' --initial",
25
+ "predev": "convex init && npm run build:codegen",
26
+ "build": "tsc --project ./tsconfig.build.json",
27
+ "build:codegen": "npx convex codegen --component-dir ./src/component && npm run build",
28
+ "build:clean": "rm -rf dist *.tsbuildinfo && npm run build:codegen",
29
+ "typecheck": "tsc --noEmit && tsc -p example && tsc -p example/convex",
30
+ "lint": "eslint .",
31
+ "test": "vitest run --typecheck",
32
+ "test:watch": "vitest --typecheck --clearScreen false",
33
+ "test:debug": "vitest --inspect-brk --no-file-parallelism",
34
+ "test:coverage": "vitest run --coverage --coverage.reporter=text",
35
+ "preversion": "npm ci && npm run build:clean && npm run test && npm run lint && npm run typecheck",
36
+ "alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
37
+ "release": "npm version patch && npm publish && git push --follow-tags",
38
+ "version": "(npm whoami || npm login) && vim -c 'normal o' -c 'normal o## '$npm_package_version CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md"
39
+ },
18
40
  "files": [
19
41
  "dist",
20
42
  "src"
@@ -72,23 +94,10 @@
72
94
  },
73
95
  "types": "./dist/client/index.d.ts",
74
96
  "module": "./dist/client/index.js",
75
- "scripts": {
76
- "dev": "convex dev --start 'npm run dev:build'",
77
- "dev:frontend": "cd example && vite",
78
- "dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'npm run build:codegen' --initial",
79
- "predev": "convex init && npm run build:codegen",
80
- "build": "tsc --project ./tsconfig.build.json",
81
- "build:codegen": "npx convex codegen --component-dir ./src/component && npm run build",
82
- "build:clean": "rm -rf dist *.tsbuildinfo && npm run build:codegen",
83
- "typecheck": "tsc --noEmit && tsc -p example && tsc -p example/convex",
84
- "lint": "eslint .",
85
- "test": "vitest run --typecheck",
86
- "test:watch": "vitest --typecheck --clearScreen false",
87
- "test:debug": "vitest --inspect-brk --no-file-parallelism",
88
- "test:coverage": "vitest run --coverage --coverage.reporter=text",
89
- "preversion": "npm ci && npm run build:clean && npm run test && npm run lint && npm run typecheck",
90
- "alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
91
- "release": "npm version patch && npm publish && git push --follow-tags",
92
- "version": "(npm whoami || npm login) && vim -c 'normal o' -c 'normal o## '$npm_package_version CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md"
97
+ "pnpm": {
98
+ "onlyBuiltDependencies": [
99
+ "esbuild",
100
+ "@tailwindcss/oxide"
101
+ ]
93
102
  }
94
- }
103
+ }