@offworld/sdk 0.2.2 → 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.
@@ -0,0 +1,174 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { ConfigSchema } from "@offworld/types";
4
+ import { xdgConfig, xdgData, xdgState } from "xdg-basedir";
5
+ import { homedir } from "node:os";
6
+
7
+ //#region src/paths.ts
8
+ /**
9
+ * XDG-based directory paths for offworld CLI
10
+ * Uses xdg-basedir package for cross-platform compatibility (Linux/macOS)
11
+ */
12
+ const APP_NAME = "offworld";
13
+ /**
14
+ * Main namespace for all XDG-compliant paths
15
+ */
16
+ const Paths = {
17
+ get config() {
18
+ return join(xdgConfig ?? join(homedir(), ".config"), APP_NAME);
19
+ },
20
+ get data() {
21
+ return join(xdgData ?? join(homedir(), ".local", "share"), APP_NAME);
22
+ },
23
+ get state() {
24
+ return join(xdgState ?? join(homedir(), ".local", "state"), APP_NAME);
25
+ },
26
+ get configFile() {
27
+ return join(this.config, "offworld.json");
28
+ },
29
+ get authFile() {
30
+ return join(this.data, "auth.json");
31
+ },
32
+ get metaDir() {
33
+ return join(this.data, "meta");
34
+ },
35
+ get defaultRepoRoot() {
36
+ return join(homedir(), "ow");
37
+ },
38
+ get offworldSkillDir() {
39
+ return join(this.data, "skill", "offworld");
40
+ },
41
+ get offworldReferencesDir() {
42
+ return join(this.offworldSkillDir, "references");
43
+ },
44
+ get offworldAssetsDir() {
45
+ return join(this.offworldSkillDir, "assets");
46
+ },
47
+ get offworldGlobalMapPath() {
48
+ return join(this.offworldAssetsDir, "map.json");
49
+ }
50
+ };
51
+ /**
52
+ * Expands ~ to user's home directory (for backward compatibility)
53
+ */
54
+ function expandTilde(path) {
55
+ if (path.startsWith("~/")) return join(homedir(), path.slice(2));
56
+ return path;
57
+ }
58
+
59
+ //#endregion
60
+ //#region src/config.ts
61
+ /**
62
+ * Config utilities for path management and configuration loading
63
+ */
64
+ /**
65
+ * Returns the repository root directory.
66
+ * Uses configured repoRoot or defaults to ~/ow
67
+ */
68
+ function getMetaRoot() {
69
+ return Paths.data;
70
+ }
71
+ function getRepoRoot(config) {
72
+ return expandTilde(config?.repoRoot ?? Paths.defaultRepoRoot);
73
+ }
74
+ /**
75
+ * Returns the path for a specific repository.
76
+ * Format: {repoRoot}/{provider}/{owner}/{repo}
77
+ *
78
+ * @param fullName - The repo identifier in "owner/repo" format
79
+ * @param provider - Git provider (defaults to "github")
80
+ * @param config - Optional config for custom repoRoot
81
+ */
82
+ function getRepoPath(fullName, provider = "github", config) {
83
+ const root = getRepoRoot(config);
84
+ const [owner, repo] = fullName.split("/");
85
+ if (!owner || !repo) throw new Error(`Invalid fullName format: ${fullName}. Expected "owner/repo"`);
86
+ return join(root, provider, owner, repo);
87
+ }
88
+ /**
89
+ * Convert owner/repo format to meta directory name.
90
+ * Collapses owner==repo (e.g., better-auth/better-auth -> better-auth)
91
+ */
92
+ function toMetaDirName(repoName) {
93
+ if (repoName.includes("/")) {
94
+ const parts = repoName.split("/");
95
+ const owner = parts[0];
96
+ const repo = parts[1];
97
+ if (!owner || !repo) return repoName;
98
+ if (owner === repo) return repo;
99
+ return `${owner}-${repo}`;
100
+ }
101
+ return repoName;
102
+ }
103
+ /**
104
+ * Convert owner/repo format to reference filename.
105
+ * Collapses redundant owner/repo pairs by checking if repo name is contained in owner:
106
+ * - honojs/hono -> hono.md (hono is in honojs)
107
+ * - get-convex/convex-backend -> convex-backend.md (convex is in get-convex)
108
+ * - tanstack/query -> tanstack-query.md (query is not in tanstack)
109
+ */
110
+ function toReferenceFileName(repoName) {
111
+ if (repoName.includes("/")) {
112
+ const parts = repoName.split("/");
113
+ const owner = parts[0];
114
+ const repo = parts[1];
115
+ if (!owner || !repo) return `${repoName.toLowerCase()}.md`;
116
+ const ownerLower = owner.toLowerCase();
117
+ const repoLower = repo.toLowerCase();
118
+ if (repoLower.split("-").find((part) => part.length >= 3 && ownerLower.includes(part)) || ownerLower === repoLower) return `${repoLower}.md`;
119
+ return `${ownerLower}-${repoLower}.md`;
120
+ }
121
+ return `${repoName.toLowerCase()}.md`;
122
+ }
123
+ function toReferenceName(repoName) {
124
+ return toReferenceFileName(repoName).replace(/\.md$/, "");
125
+ }
126
+ function getReferencePath(fullName) {
127
+ return join(Paths.offworldReferencesDir, toReferenceFileName(fullName));
128
+ }
129
+ function getMetaPath(fullName) {
130
+ return join(Paths.data, "meta", toMetaDirName(fullName));
131
+ }
132
+ /**
133
+ * Returns the path to the configuration file
134
+ * Uses XDG Base Directory specification
135
+ */
136
+ function getConfigPath() {
137
+ return Paths.configFile;
138
+ }
139
+ /**
140
+ * Loads configuration from ~/.config/offworld/offworld.json
141
+ * Returns defaults if file doesn't exist
142
+ */
143
+ function loadConfig() {
144
+ const configPath = getConfigPath();
145
+ if (!existsSync(configPath)) return ConfigSchema.parse({});
146
+ try {
147
+ const content = readFileSync(configPath, "utf-8");
148
+ const data = JSON.parse(content);
149
+ return ConfigSchema.parse(data);
150
+ } catch {
151
+ return ConfigSchema.parse({});
152
+ }
153
+ }
154
+ /**
155
+ * Saves configuration to ~/.config/offworld/offworld.json
156
+ * Creates directory if it doesn't exist
157
+ * Merges with existing config
158
+ */
159
+ function saveConfig(updates) {
160
+ const configPath = getConfigPath();
161
+ const configDir = dirname(configPath);
162
+ if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true });
163
+ const merged = {
164
+ ...loadConfig(),
165
+ ...updates
166
+ };
167
+ const validated = ConfigSchema.parse(merged);
168
+ writeFileSync(configPath, JSON.stringify(validated, null, 2), "utf-8");
169
+ return validated;
170
+ }
171
+
172
+ //#endregion
173
+ export { getRepoPath as a, saveConfig as c, toReferenceName as d, Paths as f, getReferencePath as i, toMetaDirName as l, getMetaPath as n, getRepoRoot as o, expandTilde as p, getMetaRoot as r, loadConfig as s, getConfigPath as t, toReferenceFileName as u };
174
+ //# sourceMappingURL=config-DW8J4gl5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-DW8J4gl5.mjs","names":[],"sources":["../src/paths.ts","../src/config.ts"],"sourcesContent":["/**\n * XDG-based directory paths for offworld CLI\n * Uses xdg-basedir package for cross-platform compatibility (Linux/macOS)\n */\n\nimport { xdgConfig, xdgData, xdgState } from \"xdg-basedir\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst APP_NAME = \"offworld\";\n\n/**\n * Main namespace for all XDG-compliant paths\n */\nexport const Paths = {\n\t/**\n\t * XDG_CONFIG_HOME/offworld\n\t * Fallback: ~/.config/offworld\n\t */\n\tget config(): string {\n\t\treturn join(xdgConfig ?? join(homedir(), \".config\"), APP_NAME);\n\t},\n\n\t/**\n\t * XDG_DATA_HOME/offworld\n\t * Fallback: ~/.local/share/offworld\n\t */\n\tget data(): string {\n\t\treturn join(xdgData ?? join(homedir(), \".local\", \"share\"), APP_NAME);\n\t},\n\n\t/**\n\t * XDG_STATE_HOME/offworld\n\t * Fallback: ~/.local/state/offworld\n\t */\n\tget state(): string {\n\t\treturn join(xdgState ?? join(homedir(), \".local\", \"state\"), APP_NAME);\n\t},\n\n\t/**\n\t * Configuration file path: ~/.config/offworld/offworld.json\n\t */\n\tget configFile(): string {\n\t\treturn join(this.config, \"offworld.json\");\n\t},\n\n\t/**\n\t * Auth file path: ~/.local/share/offworld/auth.json\n\t */\n\tget authFile(): string {\n\t\treturn join(this.data, \"auth.json\");\n\t},\n\n\t/**\n\t * Meta directory: ~/.local/share/offworld/meta\n\t */\n\tget metaDir(): string {\n\t\treturn join(this.data, \"meta\");\n\t},\n\n\t/**\n\t * Default repo root: ~/ow\n\t */\n\tget defaultRepoRoot(): string {\n\t\treturn join(homedir(), \"ow\");\n\t},\n\n\t/**\n\t * Offworld single-skill directory: ~/.local/share/offworld/skill/offworld\n\t */\n\tget offworldSkillDir(): string {\n\t\treturn join(this.data, \"skill\", \"offworld\");\n\t},\n\n\t/**\n\t * Offworld references directory: ~/.local/share/offworld/skill/offworld/references\n\t */\n\tget offworldReferencesDir(): string {\n\t\treturn join(this.offworldSkillDir, \"references\");\n\t},\n\n\t/**\n\t * Offworld assets directory: ~/.local/share/offworld/skill/offworld/assets\n\t */\n\tget offworldAssetsDir(): string {\n\t\treturn join(this.offworldSkillDir, \"assets\");\n\t},\n\n\t/**\n\t * Global map path: ~/.local/share/offworld/skill/offworld/assets/map.json\n\t */\n\tget offworldGlobalMapPath(): string {\n\t\treturn join(this.offworldAssetsDir, \"map.json\");\n\t},\n};\n\n/**\n * Expands ~ to user's home directory (for backward compatibility)\n */\nexport function expandTilde(path: string): string {\n\tif (path.startsWith(\"~/\")) {\n\t\treturn join(homedir(), path.slice(2));\n\t}\n\treturn path;\n}\n","/**\n * Config utilities for path management and configuration loading\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { ConfigSchema } from \"@offworld/types\";\nimport type { Config } from \"@offworld/types\";\nimport { Paths, expandTilde } from \"./paths\";\n\n/**\n * Returns the repository root directory.\n * Uses configured repoRoot or defaults to ~/ow\n */\nexport function getMetaRoot(): string {\n\treturn Paths.data;\n}\n\nexport function getRepoRoot(config?: Config): string {\n\tconst root = config?.repoRoot ?? Paths.defaultRepoRoot;\n\treturn expandTilde(root);\n}\n\n/**\n * Returns the path for a specific repository.\n * Format: {repoRoot}/{provider}/{owner}/{repo}\n *\n * @param fullName - The repo identifier in \"owner/repo\" format\n * @param provider - Git provider (defaults to \"github\")\n * @param config - Optional config for custom repoRoot\n */\nexport function getRepoPath(\n\tfullName: string,\n\tprovider: \"github\" | \"gitlab\" | \"bitbucket\" = \"github\",\n\tconfig?: Config,\n): string {\n\tconst root = getRepoRoot(config);\n\tconst [owner, repo] = fullName.split(\"/\");\n\tif (!owner || !repo) {\n\t\tthrow new Error(`Invalid fullName format: ${fullName}. Expected \"owner/repo\"`);\n\t}\n\treturn join(root, provider, owner, repo);\n}\n\n/**\n * Convert owner/repo format to meta directory name.\n * Collapses owner==repo (e.g., better-auth/better-auth -> better-auth)\n */\nexport function toMetaDirName(repoName: string): string {\n\tif (repoName.includes(\"/\")) {\n\t\tconst parts = repoName.split(\"/\");\n\t\tconst owner = parts[0];\n\t\tconst repo = parts[1];\n\t\tif (!owner || !repo) {\n\t\t\treturn repoName;\n\t\t}\n\t\tif (owner === repo) {\n\t\t\treturn repo;\n\t\t}\n\t\treturn `${owner}-${repo}`;\n\t}\n\treturn repoName;\n}\n\n/**\n * Convert owner/repo format to reference filename.\n * Collapses redundant owner/repo pairs by checking if repo name is contained in owner:\n * - honojs/hono -> hono.md (hono is in honojs)\n * - get-convex/convex-backend -> convex-backend.md (convex is in get-convex)\n * - tanstack/query -> tanstack-query.md (query is not in tanstack)\n */\nexport function toReferenceFileName(repoName: string): string {\n\tif (repoName.includes(\"/\")) {\n\t\tconst parts = repoName.split(\"/\");\n\t\tconst owner = parts[0];\n\t\tconst repo = parts[1];\n\t\tif (!owner || !repo) {\n\t\t\treturn `${repoName.toLowerCase()}.md`;\n\t\t}\n\t\tconst ownerLower = owner.toLowerCase();\n\t\tconst repoLower = repo.toLowerCase();\n\n\t\tconst repoParts = repoLower.split(\"-\");\n\t\tconst significantPart = repoParts.find((part) => part.length >= 3 && ownerLower.includes(part));\n\n\t\tif (significantPart || ownerLower === repoLower) {\n\t\t\treturn `${repoLower}.md`;\n\t\t}\n\n\t\treturn `${ownerLower}-${repoLower}.md`;\n\t}\n\treturn `${repoName.toLowerCase()}.md`;\n}\n\nexport function toReferenceName(repoName: string): string {\n\treturn toReferenceFileName(repoName).replace(/\\.md$/, \"\");\n}\n\nexport function getReferencePath(fullName: string): string {\n\treturn join(Paths.offworldReferencesDir, toReferenceFileName(fullName));\n}\n\nexport function getMetaPath(fullName: string): string {\n\treturn join(Paths.data, \"meta\", toMetaDirName(fullName));\n}\n\n/**\n * Returns the path to the configuration file\n * Uses XDG Base Directory specification\n */\nexport function getConfigPath(): string {\n\treturn Paths.configFile;\n}\n\n/**\n * Loads configuration from ~/.config/offworld/offworld.json\n * Returns defaults if file doesn't exist\n */\nexport function loadConfig(): Config {\n\tconst configPath = getConfigPath();\n\n\tif (!existsSync(configPath)) {\n\t\treturn ConfigSchema.parse({});\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(configPath, \"utf-8\");\n\t\tconst data = JSON.parse(content);\n\t\treturn ConfigSchema.parse(data);\n\t} catch {\n\t\treturn ConfigSchema.parse({});\n\t}\n}\n\n/**\n * Saves configuration to ~/.config/offworld/offworld.json\n * Creates directory if it doesn't exist\n * Merges with existing config\n */\nexport function saveConfig(updates: Partial<Config>): Config {\n\tconst configPath = getConfigPath();\n\tconst configDir = dirname(configPath);\n\n\tif (!existsSync(configDir)) {\n\t\tmkdirSync(configDir, { recursive: true });\n\t}\n\n\tconst existing = loadConfig();\n\tconst merged = { ...existing, ...updates };\n\n\tconst validated = ConfigSchema.parse(merged);\n\n\twriteFileSync(configPath, JSON.stringify(validated, null, 2), \"utf-8\");\n\n\treturn validated;\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,WAAW;;;;AAKjB,MAAa,QAAQ;CAKpB,IAAI,SAAiB;AACpB,SAAO,KAAK,aAAa,KAAK,SAAS,EAAE,UAAU,EAAE,SAAS;;CAO/D,IAAI,OAAe;AAClB,SAAO,KAAK,WAAW,KAAK,SAAS,EAAE,UAAU,QAAQ,EAAE,SAAS;;CAOrE,IAAI,QAAgB;AACnB,SAAO,KAAK,YAAY,KAAK,SAAS,EAAE,UAAU,QAAQ,EAAE,SAAS;;CAMtE,IAAI,aAAqB;AACxB,SAAO,KAAK,KAAK,QAAQ,gBAAgB;;CAM1C,IAAI,WAAmB;AACtB,SAAO,KAAK,KAAK,MAAM,YAAY;;CAMpC,IAAI,UAAkB;AACrB,SAAO,KAAK,KAAK,MAAM,OAAO;;CAM/B,IAAI,kBAA0B;AAC7B,SAAO,KAAK,SAAS,EAAE,KAAK;;CAM7B,IAAI,mBAA2B;AA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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 auth from "../auth.js";
13
+ import type * as github from "../github.js";
14
+ import type * as http from "../http.js";
15
+ import type * as lib_githubAuth from "../lib/githubAuth.js";
16
+ import type * as references from "../references.js";
17
+ import type * as repository from "../repository.js";
18
+ import type * as validation_github from "../validation/github.js";
19
+ import type * as validation_push from "../validation/push.js";
20
+ import type * as validation_referenceContent from "../validation/referenceContent.js";
21
+
22
+ import type {
23
+ ApiFromModules,
24
+ FilterApi,
25
+ FunctionReference,
26
+ } from "convex/server";
27
+
28
+ declare const fullApi: ApiFromModules<{
29
+ admin: typeof admin;
30
+ auth: typeof auth;
31
+ github: typeof github;
32
+ http: typeof http;
33
+ "lib/githubAuth": typeof lib_githubAuth;
34
+ references: typeof references;
35
+ repository: typeof repository;
36
+ "validation/github": typeof validation_github;
37
+ "validation/push": typeof validation_push;
38
+ "validation/referenceContent": typeof validation_referenceContent;
39
+ }>;
40
+
41
+ /**
42
+ * A utility for referencing Convex functions in your app's public API.
43
+ *
44
+ * Usage:
45
+ * ```js
46
+ * const myFunctionReference = api.myModule.myFunction;
47
+ * ```
48
+ */
49
+ export declare const api: FilterApi<
50
+ typeof fullApi,
51
+ FunctionReference<any, "public">
52
+ >;
53
+
54
+ /**
55
+ * A utility for referencing Convex functions in your app's internal API.
56
+ *
57
+ * Usage:
58
+ * ```js
59
+ * const myFunctionReference = internal.myModule.myFunction;
60
+ * ```
61
+ */
62
+ export declare const internal: FilterApi<
63
+ typeof fullApi,
64
+ FunctionReference<any, "internal">
65
+ >;
66
+
67
+ 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;