@devwithbobby/loops 0.1.0 → 0.1.2
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 +343 -375
- package/dist/client/index.d.ts +186 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +396 -0
- package/dist/client/types.d.ts +24 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +0 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +25 -0
- package/dist/component/lib.d.ts +103 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/component/lib.js +1000 -0
- package/dist/component/schema.d.ts +3 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +16 -0
- package/dist/component/tables/contacts.d.ts +2 -0
- package/dist/component/tables/contacts.d.ts.map +1 -0
- package/dist/component/tables/contacts.js +14 -0
- package/dist/component/tables/emailOperations.d.ts +2 -0
- package/dist/component/tables/emailOperations.d.ts.map +1 -0
- package/dist/component/tables/emailOperations.js +20 -0
- package/dist/component/validators.d.ts +18 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +34 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/package.json +11 -5
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -14
- package/.config/commitlint.config.ts +0 -11
- package/.config/lefthook.yml +0 -11
- package/.github/workflows/release.yml +0 -52
- package/.github/workflows/test-and-lint.yml +0 -39
- package/biome.json +0 -45
- package/bun.lock +0 -1166
- package/bunfig.toml +0 -7
- package/convex.json +0 -3
- package/example/CLAUDE.md +0 -106
- package/example/README.md +0 -21
- package/example/bun-env.d.ts +0 -17
- package/example/convex/_generated/api.d.ts +0 -53
- package/example/convex/_generated/api.js +0 -23
- package/example/convex/_generated/dataModel.d.ts +0 -60
- package/example/convex/_generated/server.d.ts +0 -149
- package/example/convex/_generated/server.js +0 -90
- package/example/convex/convex.config.ts +0 -7
- package/example/convex/example.ts +0 -76
- package/example/convex/schema.ts +0 -3
- package/example/convex/tsconfig.json +0 -34
- package/example/src/App.tsx +0 -185
- package/example/src/frontend.tsx +0 -39
- package/example/src/index.css +0 -15
- package/example/src/index.html +0 -12
- package/example/src/index.tsx +0 -19
- package/example/tsconfig.json +0 -28
- package/prds/CHANGELOG.md +0 -38
- package/prds/CLAUDE.md +0 -408
- package/prds/CONTRIBUTING.md +0 -274
- package/prds/ENV_SETUP.md +0 -222
- package/prds/MONITORING.md +0 -301
- package/prds/RATE_LIMITING.md +0 -412
- package/prds/SECURITY.md +0 -246
- package/renovate.json +0 -32
- package/test/client/_generated/_ignore.ts +0 -1
- package/test/client/index.test.ts +0 -65
- package/test/client/setup.test.ts +0 -54
- package/test/component/lib.test.ts +0 -225
- package/test/component/setup.test.ts +0 -21
- package/tsconfig.build.json +0 -20
- package/tsconfig.json +0 -22
package/bunfig.toml
DELETED
package/convex.json
DELETED
package/example/CLAUDE.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Default to using Bun instead of Node.js.
|
|
3
|
-
|
|
4
|
-
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
|
|
5
|
-
- Use `bun test` instead of `jest` or `vitest`
|
|
6
|
-
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
|
|
7
|
-
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
|
|
8
|
-
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
|
|
9
|
-
- Bun automatically loads .env, so don't use dotenv.
|
|
10
|
-
|
|
11
|
-
## APIs
|
|
12
|
-
|
|
13
|
-
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
|
|
14
|
-
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
|
|
15
|
-
- `Bun.redis` for Redis. Don't use `ioredis`.
|
|
16
|
-
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
|
|
17
|
-
- `WebSocket` is built-in. Don't use `ws`.
|
|
18
|
-
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
|
|
19
|
-
- Bun.$`ls` instead of execa.
|
|
20
|
-
|
|
21
|
-
## Testing
|
|
22
|
-
|
|
23
|
-
Use `bun test` to run tests.
|
|
24
|
-
|
|
25
|
-
```ts#index.test.ts
|
|
26
|
-
import { test, expect } from "bun:test";
|
|
27
|
-
|
|
28
|
-
test("hello world", () => {
|
|
29
|
-
expect(1).toBe(1);
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Frontend
|
|
34
|
-
|
|
35
|
-
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
|
|
36
|
-
|
|
37
|
-
Server:
|
|
38
|
-
|
|
39
|
-
```ts#index.ts
|
|
40
|
-
import index from "./index.html"
|
|
41
|
-
|
|
42
|
-
Bun.serve({
|
|
43
|
-
routes: {
|
|
44
|
-
"/": index,
|
|
45
|
-
"/api/users/:id": {
|
|
46
|
-
GET: (req) => {
|
|
47
|
-
return new Response(JSON.stringify({ id: req.params.id }));
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
// optional websocket support
|
|
52
|
-
websocket: {
|
|
53
|
-
open: (ws) => {
|
|
54
|
-
ws.send("Hello, world!");
|
|
55
|
-
},
|
|
56
|
-
message: (ws, message) => {
|
|
57
|
-
ws.send(message);
|
|
58
|
-
},
|
|
59
|
-
close: (ws) => {
|
|
60
|
-
// handle close
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
development: {
|
|
64
|
-
hmr: true,
|
|
65
|
-
console: true,
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
|
|
71
|
-
|
|
72
|
-
```html#index.html
|
|
73
|
-
<html>
|
|
74
|
-
<body>
|
|
75
|
-
<h1>Hello, world!</h1>
|
|
76
|
-
<script type="module" src="./frontend.tsx"></script>
|
|
77
|
-
</body>
|
|
78
|
-
</html>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
With the following `frontend.tsx`:
|
|
82
|
-
|
|
83
|
-
```tsx#frontend.tsx
|
|
84
|
-
import React from "react";
|
|
85
|
-
|
|
86
|
-
// import .css files directly and it works
|
|
87
|
-
import './index.css';
|
|
88
|
-
|
|
89
|
-
import { createRoot } from "react-dom/client";
|
|
90
|
-
|
|
91
|
-
const root = createRoot(document.body);
|
|
92
|
-
|
|
93
|
-
export default function Frontend() {
|
|
94
|
-
return <h1>Hello, world!</h1>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
root.render(<Frontend />);
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Then, run index.ts
|
|
101
|
-
|
|
102
|
-
```sh
|
|
103
|
-
bun --hot ./index.ts
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
|
package/example/README.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# bun-react-tailwind-template
|
|
2
|
-
|
|
3
|
-
To install dependencies:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
bun install
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
To start a development server:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bun dev
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
To run for production:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
bun start
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
This project was created using `bun init` in bun v1.3.0. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
package/example/bun-env.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Generated by `bun init`
|
|
2
|
-
|
|
3
|
-
declare module "*.svg" {
|
|
4
|
-
/**
|
|
5
|
-
* A path to the SVG file
|
|
6
|
-
*/
|
|
7
|
-
const path: `${string}.svg`;
|
|
8
|
-
export = path;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module "*.module.css" {
|
|
12
|
-
/**
|
|
13
|
-
* A record of class names to their corresponding CSS module classes
|
|
14
|
-
*/
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export = classes;
|
|
17
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated `api` utility.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type * as example from "../example.js";
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
ApiFromModules,
|
|
15
|
-
FilterApi,
|
|
16
|
-
FunctionReference,
|
|
17
|
-
} from "convex/server";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A utility for referencing Convex functions in your app's API.
|
|
21
|
-
*
|
|
22
|
-
* Usage:
|
|
23
|
-
* ```js
|
|
24
|
-
* const myFunctionReference = api.myModule.myFunction;
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare const fullApi: ApiFromModules<{
|
|
28
|
-
example: typeof example;
|
|
29
|
-
}>;
|
|
30
|
-
declare const fullApiWithMounts: typeof fullApi;
|
|
31
|
-
|
|
32
|
-
export declare const api: FilterApi<
|
|
33
|
-
typeof fullApiWithMounts,
|
|
34
|
-
FunctionReference<any, "public">
|
|
35
|
-
>;
|
|
36
|
-
export declare const internal: FilterApi<
|
|
37
|
-
typeof fullApiWithMounts,
|
|
38
|
-
FunctionReference<any, "internal">
|
|
39
|
-
>;
|
|
40
|
-
|
|
41
|
-
export declare const components: {
|
|
42
|
-
shardedCounter: {
|
|
43
|
-
lib: {
|
|
44
|
-
add: FunctionReference<
|
|
45
|
-
"mutation",
|
|
46
|
-
"internal",
|
|
47
|
-
{ count: number; name: string; shards?: number },
|
|
48
|
-
null
|
|
49
|
-
>;
|
|
50
|
-
count: FunctionReference<"query", "internal", { name: string }, number>;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated `api` utility.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { anyApi, componentsGeneric } from "convex/server";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A utility for referencing Convex functions in your app's API.
|
|
15
|
-
*
|
|
16
|
-
* Usage:
|
|
17
|
-
* ```js
|
|
18
|
-
* const myFunctionReference = api.myModule.myFunction;
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export const api = anyApi;
|
|
22
|
-
export const internal = anyApi;
|
|
23
|
-
export const components = componentsGeneric();
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated data model types.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
DataModelFromSchemaDefinition,
|
|
13
|
-
DocumentByName,
|
|
14
|
-
TableNamesInDataModel,
|
|
15
|
-
SystemTableNames,
|
|
16
|
-
} from "convex/server";
|
|
17
|
-
import type { GenericId } from "convex/values";
|
|
18
|
-
import schema from "../schema.js";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The names of all of your Convex tables.
|
|
22
|
-
*/
|
|
23
|
-
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The type of a document stored in Convex.
|
|
27
|
-
*
|
|
28
|
-
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
29
|
-
*/
|
|
30
|
-
export type Doc<TableName extends TableNames> = DocumentByName<
|
|
31
|
-
DataModel,
|
|
32
|
-
TableName
|
|
33
|
-
>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* An identifier for a document in Convex.
|
|
37
|
-
*
|
|
38
|
-
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
39
|
-
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
40
|
-
*
|
|
41
|
-
* Documents can be loaded using `db.get(id)` in query and mutation functions.
|
|
42
|
-
*
|
|
43
|
-
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
44
|
-
* strings when type checking.
|
|
45
|
-
*
|
|
46
|
-
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
47
|
-
*/
|
|
48
|
-
export type Id<TableName extends TableNames | SystemTableNames> =
|
|
49
|
-
GenericId<TableName>;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* A type describing your Convex data model.
|
|
53
|
-
*
|
|
54
|
-
* This type includes information about what tables you have, the type of
|
|
55
|
-
* documents stored in those tables, and the indexes defined on them.
|
|
56
|
-
*
|
|
57
|
-
* This type is used to parameterize methods like `queryGeneric` and
|
|
58
|
-
* `mutationGeneric` to make them type-safe.
|
|
59
|
-
*/
|
|
60
|
-
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
ActionBuilder,
|
|
13
|
-
AnyComponents,
|
|
14
|
-
HttpActionBuilder,
|
|
15
|
-
MutationBuilder,
|
|
16
|
-
QueryBuilder,
|
|
17
|
-
GenericActionCtx,
|
|
18
|
-
GenericMutationCtx,
|
|
19
|
-
GenericQueryCtx,
|
|
20
|
-
GenericDatabaseReader,
|
|
21
|
-
GenericDatabaseWriter,
|
|
22
|
-
FunctionReference,
|
|
23
|
-
} from "convex/server";
|
|
24
|
-
import type { DataModel } from "./dataModel.js";
|
|
25
|
-
|
|
26
|
-
type GenericCtx =
|
|
27
|
-
| GenericActionCtx<DataModel>
|
|
28
|
-
| GenericMutationCtx<DataModel>
|
|
29
|
-
| GenericQueryCtx<DataModel>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Define a query in this Convex app's public API.
|
|
33
|
-
*
|
|
34
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
35
|
-
*
|
|
36
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
37
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
38
|
-
*/
|
|
39
|
-
export declare const query: QueryBuilder<DataModel, "public">;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
43
|
-
*
|
|
44
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
45
|
-
*
|
|
46
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
47
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
48
|
-
*/
|
|
49
|
-
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Define a mutation in this Convex app's public API.
|
|
53
|
-
*
|
|
54
|
-
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
55
|
-
*
|
|
56
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
57
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
58
|
-
*/
|
|
59
|
-
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
63
|
-
*
|
|
64
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
65
|
-
*
|
|
66
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
67
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
68
|
-
*/
|
|
69
|
-
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Define an action in this Convex app's public API.
|
|
73
|
-
*
|
|
74
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
75
|
-
* code and code with side-effects, like calling third-party services.
|
|
76
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
77
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
78
|
-
*
|
|
79
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
80
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
81
|
-
*/
|
|
82
|
-
export declare const action: ActionBuilder<DataModel, "public">;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
86
|
-
*
|
|
87
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
88
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
89
|
-
*/
|
|
90
|
-
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Define an HTTP action.
|
|
94
|
-
*
|
|
95
|
-
* This function will be used to respond to HTTP requests received by a Convex
|
|
96
|
-
* deployment if the requests matches the path and method where this action
|
|
97
|
-
* is routed. Be sure to route your action in `convex/http.js`.
|
|
98
|
-
*
|
|
99
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
100
|
-
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
101
|
-
*/
|
|
102
|
-
export declare const httpAction: HttpActionBuilder;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* A set of services for use within Convex query functions.
|
|
106
|
-
*
|
|
107
|
-
* The query context is passed as the first argument to any Convex query
|
|
108
|
-
* function run on the server.
|
|
109
|
-
*
|
|
110
|
-
* This differs from the {@link MutationCtx} because all of the services are
|
|
111
|
-
* read-only.
|
|
112
|
-
*/
|
|
113
|
-
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* A set of services for use within Convex mutation functions.
|
|
117
|
-
*
|
|
118
|
-
* The mutation context is passed as the first argument to any Convex mutation
|
|
119
|
-
* function run on the server.
|
|
120
|
-
*/
|
|
121
|
-
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* A set of services for use within Convex action functions.
|
|
125
|
-
*
|
|
126
|
-
* The action context is passed as the first argument to any Convex action
|
|
127
|
-
* function run on the server.
|
|
128
|
-
*/
|
|
129
|
-
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* An interface to read from the database within Convex query functions.
|
|
133
|
-
*
|
|
134
|
-
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
135
|
-
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
136
|
-
* building a query.
|
|
137
|
-
*/
|
|
138
|
-
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* An interface to read from and write to the database within Convex mutation
|
|
142
|
-
* functions.
|
|
143
|
-
*
|
|
144
|
-
* Convex guarantees that all writes within a single mutation are
|
|
145
|
-
* executed atomically, so you never have to worry about partial writes leaving
|
|
146
|
-
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
147
|
-
* for the guarantees Convex provides your functions.
|
|
148
|
-
*/
|
|
149
|
-
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
-
*
|
|
5
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
-
*
|
|
7
|
-
* To regenerate, run `npx convex dev`.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
actionGeneric,
|
|
13
|
-
httpActionGeneric,
|
|
14
|
-
queryGeneric,
|
|
15
|
-
mutationGeneric,
|
|
16
|
-
internalActionGeneric,
|
|
17
|
-
internalMutationGeneric,
|
|
18
|
-
internalQueryGeneric,
|
|
19
|
-
componentsGeneric,
|
|
20
|
-
} from "convex/server";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Define a query in this Convex app's public API.
|
|
24
|
-
*
|
|
25
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
26
|
-
*
|
|
27
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
28
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
29
|
-
*/
|
|
30
|
-
export const query = queryGeneric;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
34
|
-
*
|
|
35
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
36
|
-
*
|
|
37
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
38
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
39
|
-
*/
|
|
40
|
-
export const internalQuery = internalQueryGeneric;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Define a mutation in this Convex app's public API.
|
|
44
|
-
*
|
|
45
|
-
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
46
|
-
*
|
|
47
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
48
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
49
|
-
*/
|
|
50
|
-
export const mutation = mutationGeneric;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
54
|
-
*
|
|
55
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
56
|
-
*
|
|
57
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
58
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
59
|
-
*/
|
|
60
|
-
export const internalMutation = internalMutationGeneric;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Define an action in this Convex app's public API.
|
|
64
|
-
*
|
|
65
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
66
|
-
* code and code with side-effects, like calling third-party services.
|
|
67
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
68
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
69
|
-
*
|
|
70
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
71
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
72
|
-
*/
|
|
73
|
-
export const action = actionGeneric;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
77
|
-
*
|
|
78
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
79
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
80
|
-
*/
|
|
81
|
-
export const internalAction = internalActionGeneric;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Define a Convex HTTP action.
|
|
85
|
-
*
|
|
86
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
|
|
87
|
-
* as its second.
|
|
88
|
-
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
|
|
89
|
-
*/
|
|
90
|
-
export const httpAction = httpActionGeneric;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Loops } from "devwithbobby/loops";
|
|
2
|
-
import { components } from "./_generated/api";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Initialize the Loops client with the mounted component.
|
|
6
|
-
* This provides a type-safe interface to the Loops component.
|
|
7
|
-
*
|
|
8
|
-
* ⚠️ SECURITY: The API key MUST be set in your Convex environment variables.
|
|
9
|
-
*
|
|
10
|
-
* Set it via:
|
|
11
|
-
* - Convex Dashboard: Settings → Environment Variables → Add LOOPS_API_KEY
|
|
12
|
-
* - CLI: npx convex env set LOOPS_API_KEY "your-api-key"
|
|
13
|
-
*
|
|
14
|
-
* See ENV_SETUP.md for detailed setup instructions.
|
|
15
|
-
*
|
|
16
|
-
* ⚠️ NEVER pass the API key directly via options in production code.
|
|
17
|
-
* Only use options.apiKey for local testing.
|
|
18
|
-
*/
|
|
19
|
-
const loops = new Loops(components.loops);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* ⚠️ SECURITY WARNING ⚠️
|
|
23
|
-
*
|
|
24
|
-
* This example exports functions directly for demonstration purposes.
|
|
25
|
-
* In production, you MUST:
|
|
26
|
-
*
|
|
27
|
-
* 1. Add authentication checks:
|
|
28
|
-
* ```ts
|
|
29
|
-
* const identity = await ctx.auth.getUserIdentity();
|
|
30
|
-
* if (!identity) throw new Error("Unauthorized");
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* 2. Add authorization/permission checks based on user roles
|
|
34
|
-
*
|
|
35
|
-
* 3. Add rate limiting to prevent abuse
|
|
36
|
-
*
|
|
37
|
-
* 4. Sanitize error messages before returning to clients
|
|
38
|
-
*
|
|
39
|
-
* 5. Audit sensitive operations (delete, unsubscribe, send emails)
|
|
40
|
-
*
|
|
41
|
-
* See SECURITY.md for detailed security guidelines.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Export the API functions for use in the React app.
|
|
46
|
-
* ⚠️ These are exported without auth checks for example purposes only.
|
|
47
|
-
*
|
|
48
|
-
* In production, wrap each function with authentication and authorization:
|
|
49
|
-
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* export const addContact = action({
|
|
52
|
-
* args: { email: v.string(), ... },
|
|
53
|
-
* handler: async (ctx, args) => {
|
|
54
|
-
* const identity = await ctx.auth.getUserIdentity();
|
|
55
|
-
* if (!identity) throw new Error("Unauthorized");
|
|
56
|
-
*
|
|
57
|
-
* // Add permission checks here
|
|
58
|
-
* return await loops.addContact(ctx, args);
|
|
59
|
-
* },
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export const {
|
|
64
|
-
addContact,
|
|
65
|
-
updateContact,
|
|
66
|
-
findContact,
|
|
67
|
-
batchCreateContacts,
|
|
68
|
-
unsubscribeContact,
|
|
69
|
-
resubscribeContact,
|
|
70
|
-
countContacts,
|
|
71
|
-
sendTransactional,
|
|
72
|
-
sendEvent,
|
|
73
|
-
sendCampaign,
|
|
74
|
-
triggerLoop,
|
|
75
|
-
deleteContact,
|
|
76
|
-
} = loops.api();
|
package/example/convex/schema.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
/* This TypeScript project config describes the environment that
|
|
3
|
-
* Convex functions run in and is used to typecheck them.
|
|
4
|
-
* You can modify it, but some settings required to use Convex.
|
|
5
|
-
*/
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
/* These settings are not required by Convex and can be modified. */
|
|
8
|
-
"allowJs": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"verbatimModuleSyntax": true,
|
|
12
|
-
|
|
13
|
-
/* These compiler options are required by Convex */
|
|
14
|
-
"target": "ESNext",
|
|
15
|
-
"lib": ["ES2021", "dom", "ESNext.Array"],
|
|
16
|
-
"forceConsistentCasingInFileNames": true,
|
|
17
|
-
"allowSyntheticDefaultImports": true,
|
|
18
|
-
"module": "ESNext",
|
|
19
|
-
"moduleResolution": "Bundler",
|
|
20
|
-
"isolatedModules": true,
|
|
21
|
-
"noEmit": true,
|
|
22
|
-
|
|
23
|
-
/* This should only be used in this example. Real apps should not attempt
|
|
24
|
-
* to compile TypeScript because differences between tsconfig.json files can
|
|
25
|
-
* cause the code to be compiled differently.
|
|
26
|
-
*/
|
|
27
|
-
// Un-comment this to get instant types between your component and example.
|
|
28
|
-
// However, if you're willing to wait for a build before the types update,
|
|
29
|
-
// it's better to leave this commented out to catch build errors faster.
|
|
30
|
-
"customConditions": ["@convex-dev/component-source"]
|
|
31
|
-
},
|
|
32
|
-
"include": ["./**/*"],
|
|
33
|
-
"exclude": ["./_generated"]
|
|
34
|
-
}
|