@devlider001/washlab-backend 1.0.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 +150 -0
- package/convex/README.md +90 -0
- package/convex/_generated/api.d.ts +73 -0
- package/convex/_generated/api.js +23 -0
- package/convex/_generated/dataModel.d.ts +60 -0
- package/convex/_generated/server.d.ts +143 -0
- package/convex/_generated/server.js +93 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Washlab Backend
|
|
2
|
+
|
|
3
|
+
Convex backend package for Washlab. This package provides type-safe access to all Convex functions, mutations, queries, and data models.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @lider-technology-ltd/washlab-backend
|
|
9
|
+
# or
|
|
10
|
+
npm install @lider-technology-ltd/washlab-backend
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @lider-technology-ltd/washlab-backend
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
This package requires `convex` to be installed in your client application:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add convex
|
|
21
|
+
# or
|
|
22
|
+
npm install convex
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### React/Next.js (Recommended)
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
31
|
+
import { api } from "@lider-technology-ltd/washlab-backend";
|
|
32
|
+
|
|
33
|
+
// Initialize the Convex client with your deployment URL
|
|
34
|
+
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<ConvexProvider client={convex}>
|
|
39
|
+
{/* Your app components */}
|
|
40
|
+
<MyComponent />
|
|
41
|
+
</ConvexProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// In your components
|
|
46
|
+
import { useQuery, useMutation } from "convex/react";
|
|
47
|
+
import { api } from "@lider-technology-ltd/washlab-backend";
|
|
48
|
+
|
|
49
|
+
function MyComponent() {
|
|
50
|
+
// Use queries
|
|
51
|
+
const users = useQuery(api.users.list, {});
|
|
52
|
+
|
|
53
|
+
// Use mutations
|
|
54
|
+
const createUser = useMutation(api.users.create);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div>
|
|
58
|
+
{/* Your UI */}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### HTTP Client (Node.js/Server-side)
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { ConvexHttpClient } from "convex/browser";
|
|
68
|
+
import { api } from "@lider-technology-ltd/washlab-backend";
|
|
69
|
+
|
|
70
|
+
const convex = new ConvexHttpClient(process.env.CONVEX_URL!);
|
|
71
|
+
|
|
72
|
+
// Use queries
|
|
73
|
+
const users = await convex.query(api.users.list, {});
|
|
74
|
+
|
|
75
|
+
// Use mutations
|
|
76
|
+
const userId = await convex.mutation(api.users.create, {
|
|
77
|
+
email: "user@example.com",
|
|
78
|
+
password: "securepassword"
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Direct API Type Import
|
|
83
|
+
|
|
84
|
+
You can also import types directly:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import type { api } from "@lider-technology-ltd/washlab-backend";
|
|
88
|
+
import type { Doc, Id } from "@lider-technology-ltd/washlab-backend";
|
|
89
|
+
|
|
90
|
+
// Use the types for type-safe function references
|
|
91
|
+
type User = Doc<"users">;
|
|
92
|
+
type UserId = Id<"users">;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Alternative Import Paths
|
|
96
|
+
|
|
97
|
+
You can also import from specific paths:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Import API types only
|
|
101
|
+
import type { api } from "@lider-technology-ltd/washlab-backend/api";
|
|
102
|
+
|
|
103
|
+
// Import data model types only
|
|
104
|
+
import type { DataModel, Doc, Id } from "@lider-technology-ltd/washlab-backend/dataModel";
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Environment Variables
|
|
108
|
+
|
|
109
|
+
Make sure to set your Convex deployment URL:
|
|
110
|
+
|
|
111
|
+
```env
|
|
112
|
+
# For browser/client applications
|
|
113
|
+
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
|
|
114
|
+
|
|
115
|
+
# For server-side applications
|
|
116
|
+
CONVEX_URL=https://your-deployment.convex.cloud
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
You can get your deployment URL from the [Convex Dashboard](https://dashboard.convex.dev).
|
|
120
|
+
|
|
121
|
+
## Type Safety
|
|
122
|
+
|
|
123
|
+
All function references, arguments, and return types are fully typed. TypeScript will provide autocomplete and type checking for:
|
|
124
|
+
|
|
125
|
+
- Function names (queries, mutations, actions)
|
|
126
|
+
- Function arguments
|
|
127
|
+
- Return types
|
|
128
|
+
- Document types from your schema
|
|
129
|
+
- ID types for each table
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
To build this package:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
yarn build
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
To publish to npm:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm publish
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Note: While this package uses yarn for development, you still use `npm publish` to publish to the npm registry.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
ISC
|
|
150
|
+
|
package/convex/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Welcome to your Convex functions directory!
|
|
2
|
+
|
|
3
|
+
Write your Convex functions here.
|
|
4
|
+
See https://docs.convex.dev/functions for more.
|
|
5
|
+
|
|
6
|
+
A query function that takes two arguments looks like:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// convex/myFunctions.ts
|
|
10
|
+
import { query } from "./_generated/server";
|
|
11
|
+
import { v } from "convex/values";
|
|
12
|
+
|
|
13
|
+
export const myQueryFunction = query({
|
|
14
|
+
// Validators for arguments.
|
|
15
|
+
args: {
|
|
16
|
+
first: v.number(),
|
|
17
|
+
second: v.string(),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// Function implementation.
|
|
21
|
+
handler: async (ctx, args) => {
|
|
22
|
+
// Read the database as many times as you need here.
|
|
23
|
+
// See https://docs.convex.dev/database/reading-data.
|
|
24
|
+
const documents = await ctx.db.query("tablename").collect();
|
|
25
|
+
|
|
26
|
+
// Arguments passed from the client are properties of the args object.
|
|
27
|
+
console.log(args.first, args.second);
|
|
28
|
+
|
|
29
|
+
// Write arbitrary JavaScript here: filter, aggregate, build derived data,
|
|
30
|
+
// remove non-public properties, or create new objects.
|
|
31
|
+
return documents;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Using this query function in a React component looks like:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const data = useQuery(api.myFunctions.myQueryFunction, {
|
|
40
|
+
first: 10,
|
|
41
|
+
second: "hello",
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A mutation function looks like:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// convex/myFunctions.ts
|
|
49
|
+
import { mutation } from "./_generated/server";
|
|
50
|
+
import { v } from "convex/values";
|
|
51
|
+
|
|
52
|
+
export const myMutationFunction = mutation({
|
|
53
|
+
// Validators for arguments.
|
|
54
|
+
args: {
|
|
55
|
+
first: v.string(),
|
|
56
|
+
second: v.string(),
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// Function implementation.
|
|
60
|
+
handler: async (ctx, args) => {
|
|
61
|
+
// Insert or modify documents in the database here.
|
|
62
|
+
// Mutations can also read from the database like queries.
|
|
63
|
+
// See https://docs.convex.dev/database/writing-data.
|
|
64
|
+
const message = { body: args.first, author: args.second };
|
|
65
|
+
const id = await ctx.db.insert("messages", message);
|
|
66
|
+
|
|
67
|
+
// Optionally, return a value from your mutation.
|
|
68
|
+
return await ctx.db.get("messages", id);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Using this mutation function in a React component looks like:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const mutation = useMutation(api.myFunctions.myMutationFunction);
|
|
77
|
+
function handleButtonPress() {
|
|
78
|
+
// fire and forget, the most common way to use mutations
|
|
79
|
+
mutation({ first: "Hello!", second: "me" });
|
|
80
|
+
// OR
|
|
81
|
+
// use the result once the mutation has completed
|
|
82
|
+
mutation({ first: "Hello!", second: "me" }).then((result) =>
|
|
83
|
+
console.log(result),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Use the Convex CLI to push your functions to a deployment. See everything
|
|
89
|
+
the Convex CLI can do by running `npx convex -h` in your project root
|
|
90
|
+
directory. To learn more, launch the docs with `npx convex docs`.
|
|
@@ -0,0 +1,73 @@
|
|
|
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 admin from "../admin.js";
|
|
12
|
+
import type * as attendants from "../attendants.js";
|
|
13
|
+
import type * as audit from "../audit.js";
|
|
14
|
+
import type * as clerk from "../clerk.js";
|
|
15
|
+
import type * as customers from "../customers.js";
|
|
16
|
+
import type * as http from "../http.js";
|
|
17
|
+
import type * as lib_audit from "../lib/audit.js";
|
|
18
|
+
import type * as lib_auth from "../lib/auth.js";
|
|
19
|
+
import type * as lib_utils from "../lib/utils.js";
|
|
20
|
+
import type * as loyalty from "../loyalty.js";
|
|
21
|
+
import type * as orders from "../orders.js";
|
|
22
|
+
import type * as payments from "../payments.js";
|
|
23
|
+
import type * as resources from "../resources.js";
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
ApiFromModules,
|
|
27
|
+
FilterApi,
|
|
28
|
+
FunctionReference,
|
|
29
|
+
} from "convex/server";
|
|
30
|
+
|
|
31
|
+
declare const fullApi: ApiFromModules<{
|
|
32
|
+
admin: typeof admin;
|
|
33
|
+
attendants: typeof attendants;
|
|
34
|
+
audit: typeof audit;
|
|
35
|
+
clerk: typeof clerk;
|
|
36
|
+
customers: typeof customers;
|
|
37
|
+
http: typeof http;
|
|
38
|
+
"lib/audit": typeof lib_audit;
|
|
39
|
+
"lib/auth": typeof lib_auth;
|
|
40
|
+
"lib/utils": typeof lib_utils;
|
|
41
|
+
loyalty: typeof loyalty;
|
|
42
|
+
orders: typeof orders;
|
|
43
|
+
payments: typeof payments;
|
|
44
|
+
resources: typeof resources;
|
|
45
|
+
}>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
49
|
+
*
|
|
50
|
+
* Usage:
|
|
51
|
+
* ```js
|
|
52
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const api: FilterApi<
|
|
56
|
+
typeof fullApi,
|
|
57
|
+
FunctionReference<any, "public">
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* ```js
|
|
65
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const internal: FilterApi<
|
|
69
|
+
typeof fullApi,
|
|
70
|
+
FunctionReference<any, "internal">
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
export declare const components: {};
|
|
@@ -0,0 +1,23 @@
|
|
|
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();
|
|
@@ -0,0 +1,60 @@
|
|
|
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(tableName, 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>;
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
HttpActionBuilder,
|
|
14
|
+
MutationBuilder,
|
|
15
|
+
QueryBuilder,
|
|
16
|
+
GenericActionCtx,
|
|
17
|
+
GenericMutationCtx,
|
|
18
|
+
GenericQueryCtx,
|
|
19
|
+
GenericDatabaseReader,
|
|
20
|
+
GenericDatabaseWriter,
|
|
21
|
+
} from "convex/server";
|
|
22
|
+
import type { DataModel } from "./dataModel.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Define a query in this Convex app's public API.
|
|
26
|
+
*
|
|
27
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
28
|
+
*
|
|
29
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
30
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
31
|
+
*/
|
|
32
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
36
|
+
*
|
|
37
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
38
|
+
*
|
|
39
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
40
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
41
|
+
*/
|
|
42
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Define a mutation in this Convex app's public API.
|
|
46
|
+
*
|
|
47
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
48
|
+
*
|
|
49
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
50
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
51
|
+
*/
|
|
52
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
56
|
+
*
|
|
57
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
58
|
+
*
|
|
59
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
60
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
61
|
+
*/
|
|
62
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Define an action in this Convex app's public API.
|
|
66
|
+
*
|
|
67
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
68
|
+
* code and code with side-effects, like calling third-party services.
|
|
69
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
70
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
71
|
+
*
|
|
72
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
73
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
74
|
+
*/
|
|
75
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
79
|
+
*
|
|
80
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
81
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
82
|
+
*/
|
|
83
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Define an HTTP action.
|
|
87
|
+
*
|
|
88
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
89
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
90
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
91
|
+
*
|
|
92
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
93
|
+
* and a Fetch API `Request` object as its second.
|
|
94
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
95
|
+
*/
|
|
96
|
+
export declare const httpAction: HttpActionBuilder;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A set of services for use within Convex query functions.
|
|
100
|
+
*
|
|
101
|
+
* The query context is passed as the first argument to any Convex query
|
|
102
|
+
* function run on the server.
|
|
103
|
+
*
|
|
104
|
+
* This differs from the {@link MutationCtx} because all of the services are
|
|
105
|
+
* read-only.
|
|
106
|
+
*/
|
|
107
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A set of services for use within Convex mutation functions.
|
|
111
|
+
*
|
|
112
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
113
|
+
* function run on the server.
|
|
114
|
+
*/
|
|
115
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A set of services for use within Convex action functions.
|
|
119
|
+
*
|
|
120
|
+
* The action context is passed as the first argument to any Convex action
|
|
121
|
+
* function run on the server.
|
|
122
|
+
*/
|
|
123
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* An interface to read from the database within Convex query functions.
|
|
127
|
+
*
|
|
128
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
129
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
130
|
+
* building a query.
|
|
131
|
+
*/
|
|
132
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* An interface to read from and write to the database within Convex mutation
|
|
136
|
+
* functions.
|
|
137
|
+
*
|
|
138
|
+
* Convex guarantees that all writes within a single mutation are
|
|
139
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
140
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
141
|
+
* for the guarantees Convex provides your functions.
|
|
142
|
+
*/
|
|
143
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
} from "convex/server";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Define a query in this Convex app's public API.
|
|
23
|
+
*
|
|
24
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
25
|
+
*
|
|
26
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
+
*/
|
|
29
|
+
export const query = queryGeneric;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
33
|
+
*
|
|
34
|
+
* This function will be allowed to read from your Convex database. It will not 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 const internalQuery = internalQueryGeneric;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Define a mutation in this Convex app's public API.
|
|
43
|
+
*
|
|
44
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
45
|
+
*
|
|
46
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
47
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
48
|
+
*/
|
|
49
|
+
export const mutation = mutationGeneric;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
53
|
+
*
|
|
54
|
+
* This function will be allowed to modify your Convex database. It will not 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 const internalMutation = internalMutationGeneric;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Define an action in this Convex app's public API.
|
|
63
|
+
*
|
|
64
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
65
|
+
* code and code with side-effects, like calling third-party services.
|
|
66
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
67
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
68
|
+
*
|
|
69
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
70
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
71
|
+
*/
|
|
72
|
+
export const action = actionGeneric;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
76
|
+
*
|
|
77
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
78
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
79
|
+
*/
|
|
80
|
+
export const internalAction = internalActionGeneric;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Define an HTTP action.
|
|
84
|
+
*
|
|
85
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
86
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
87
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
88
|
+
*
|
|
89
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
90
|
+
* and a Fetch API `Request` object as its second.
|
|
91
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
92
|
+
*/
|
|
93
|
+
export const httpAction = httpActionGeneric;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Washlab Backend - Client Package
|
|
3
|
+
*
|
|
4
|
+
* This package provides type-safe access to the Washlab Convex backend API.
|
|
5
|
+
* See README.md for usage examples.
|
|
6
|
+
*/
|
|
7
|
+
export { api, internal, components } from "../convex/_generated/api.js";
|
|
8
|
+
export type { DataModel, Doc, Id, TableNames } from "../convex/_generated/dataModel.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGxE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Washlab Backend - Client Package
|
|
3
|
+
*
|
|
4
|
+
* This package provides type-safe access to the Washlab Convex backend API.
|
|
5
|
+
* See README.md for usage examples.
|
|
6
|
+
*/
|
|
7
|
+
// Re-export API runtime and types for client-side usage
|
|
8
|
+
export { api, internal, components } from "../convex/_generated/api.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wDAAwD;AACxD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devlider001/washlab-backend",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Washlab backend - Convex API package for Lider Technology Ltd",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./api": {
|
|
13
|
+
"types": "./convex/_generated/api.d.ts",
|
|
14
|
+
"import": "./convex/_generated/api.js"
|
|
15
|
+
},
|
|
16
|
+
"./dataModel": {
|
|
17
|
+
"types": "./convex/_generated/dataModel.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"convex/_generated",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/lider-technology-ltd/washlab-backend.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/lider-technology-ltd/washlab-backend/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/lider-technology-ltd/washlab-backend#readme",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --project tsconfig.build.json || exit 0",
|
|
36
|
+
"build:strict": "tsc --project tsconfig.build.json",
|
|
37
|
+
"prepublishOnly": "npm run build",
|
|
38
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"convex",
|
|
42
|
+
"backend",
|
|
43
|
+
"washlab",
|
|
44
|
+
"lider-technology-ltd"
|
|
45
|
+
],
|
|
46
|
+
"author": "Banahene Owusu Gideon",
|
|
47
|
+
"license": "ISC",
|
|
48
|
+
"type": "module",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"convex": "^1.31.2"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^20.19.27",
|
|
54
|
+
"typescript": "^5.9.3"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"convex": "^1.31.2"
|
|
58
|
+
}
|
|
59
|
+
}
|