convex 1.47.0 → 1.48.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.
Files changed (190) hide show
  1. package/CHANGELOG.md +28 -4
  2. package/README.md +1 -1
  3. package/dist/browser.bundle.js +1 -1
  4. package/dist/browser.bundle.js.map +1 -1
  5. package/dist/cjs/cli/aiFiles.js +26 -4
  6. package/dist/cjs/cli/aiFiles.js.map +2 -2
  7. package/dist/cjs/cli/env.js +6 -3
  8. package/dist/cjs/cli/env.js.map +2 -2
  9. package/dist/cjs/cli/envDefault.js +5 -2
  10. package/dist/cjs/cli/envDefault.js.map +2 -2
  11. package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js +2 -1
  12. package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js.map +2 -2
  13. package/dist/cjs/cli/lib/aiFiles/index.js +13 -2
  14. package/dist/cjs/cli/lib/aiFiles/index.js.map +2 -2
  15. package/dist/cjs/cli/lib/aiFiles/skills.js +6 -5
  16. package/dist/cjs/cli/lib/aiFiles/skills.js.map +2 -2
  17. package/dist/cjs/cli/lib/aiFiles/state.js +1 -1
  18. package/dist/cjs/cli/lib/aiFiles/state.js.map +1 -1
  19. package/dist/cjs/cli/lib/components.js +12 -2
  20. package/dist/cjs/cli/lib/components.js.map +2 -2
  21. package/dist/cjs/cli/lib/deployApi/startPush.js +42 -1
  22. package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
  23. package/dist/cjs/cli/lib/env.js +9 -1
  24. package/dist/cjs/cli/lib/env.js.map +2 -2
  25. package/dist/cjs/cli/lib/localDeployment/dashboard.js +11 -1
  26. package/dist/cjs/cli/lib/localDeployment/dashboard.js.map +2 -2
  27. package/dist/cjs/cli/lib/localDeployment/download.js +16 -1
  28. package/dist/cjs/cli/lib/localDeployment/download.js.map +2 -2
  29. package/dist/cjs/cli/lib/localDeployment/utils.js +4 -0
  30. package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
  31. package/dist/cjs/cli/lib/utils/aiAgent.js +32 -0
  32. package/dist/cjs/cli/lib/utils/aiAgent.js.map +7 -0
  33. package/dist/cjs/index.js +1 -1
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/cjs/server/authentication.js.map +1 -1
  36. package/dist/cjs/server/components/index.js.map +2 -2
  37. package/dist/cjs/server/impl/authentication_impl.js +15 -1
  38. package/dist/cjs/server/impl/authentication_impl.js.map +2 -2
  39. package/dist/cjs/server/impl/registration_impl.js +1 -1
  40. package/dist/cjs/server/impl/registration_impl.js.map +2 -2
  41. package/dist/cjs/server/index.js.map +2 -2
  42. package/dist/cjs/server/meta.js.map +1 -1
  43. package/dist/cjs/server/registration.js.map +1 -1
  44. package/dist/cjs/server/schema.js +0 -2
  45. package/dist/cjs/server/schema.js.map +2 -2
  46. package/dist/cjs/server/storage.js.map +1 -1
  47. package/dist/cjs-types/cli/aiFiles.d.ts.map +1 -1
  48. package/dist/cjs-types/cli/env.d.ts.map +1 -1
  49. package/dist/cjs-types/cli/envDefault.d.ts.map +1 -1
  50. package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts +3 -1
  51. package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -1
  52. package/dist/cjs-types/cli/lib/aiFiles/index.d.ts +11 -1
  53. package/dist/cjs-types/cli/lib/aiFiles/index.d.ts.map +1 -1
  54. package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts +4 -1
  55. package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts.map +1 -1
  56. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  57. package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +13 -0
  58. package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
  59. package/dist/cjs-types/cli/lib/env.d.ts +1 -0
  60. package/dist/cjs-types/cli/lib/env.d.ts.map +1 -1
  61. package/dist/cjs-types/cli/lib/localDeployment/dashboard.d.ts +6 -0
  62. package/dist/cjs-types/cli/lib/localDeployment/dashboard.d.ts.map +1 -1
  63. package/dist/cjs-types/cli/lib/localDeployment/download.d.ts.map +1 -1
  64. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
  65. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  66. package/dist/cjs-types/cli/lib/utils/aiAgent.d.ts +8 -0
  67. package/dist/cjs-types/cli/lib/utils/aiAgent.d.ts.map +1 -0
  68. package/dist/cjs-types/index.d.ts +1 -1
  69. package/dist/cjs-types/server/authentication.d.ts +65 -0
  70. package/dist/cjs-types/server/authentication.d.ts.map +1 -1
  71. package/dist/cjs-types/server/components/index.d.ts +6 -0
  72. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  73. package/dist/cjs-types/server/impl/authentication_impl.d.ts +2 -1
  74. package/dist/cjs-types/server/impl/authentication_impl.d.ts.map +1 -1
  75. package/dist/cjs-types/server/index.d.ts +2 -2
  76. package/dist/cjs-types/server/index.d.ts.map +1 -1
  77. package/dist/cjs-types/server/meta.d.ts +8 -0
  78. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  79. package/dist/cjs-types/server/registration.d.ts +5 -3
  80. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  81. package/dist/cjs-types/server/schema.d.ts +0 -2
  82. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  83. package/dist/cjs-types/server/storage.d.ts +28 -25
  84. package/dist/cjs-types/server/storage.d.ts.map +1 -1
  85. package/dist/cli.bundle.cjs +284 -25
  86. package/dist/cli.bundle.cjs.map +4 -4
  87. package/dist/esm/cli/aiFiles.js +26 -4
  88. package/dist/esm/cli/aiFiles.js.map +2 -2
  89. package/dist/esm/cli/env.js +6 -3
  90. package/dist/esm/cli/env.js.map +2 -2
  91. package/dist/esm/cli/envDefault.js +5 -2
  92. package/dist/esm/cli/envDefault.js.map +2 -2
  93. package/dist/esm/cli/lib/aiFiles/guidelinesmd.js +2 -1
  94. package/dist/esm/cli/lib/aiFiles/guidelinesmd.js.map +2 -2
  95. package/dist/esm/cli/lib/aiFiles/index.js +13 -2
  96. package/dist/esm/cli/lib/aiFiles/index.js.map +2 -2
  97. package/dist/esm/cli/lib/aiFiles/skills.js +6 -5
  98. package/dist/esm/cli/lib/aiFiles/skills.js.map +2 -2
  99. package/dist/esm/cli/lib/aiFiles/state.js +1 -1
  100. package/dist/esm/cli/lib/aiFiles/state.js.map +1 -1
  101. package/dist/esm/cli/lib/components.js +15 -2
  102. package/dist/esm/cli/lib/components.js.map +2 -2
  103. package/dist/esm/cli/lib/deployApi/startPush.js +39 -0
  104. package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
  105. package/dist/esm/cli/lib/env.js +9 -1
  106. package/dist/esm/cli/lib/env.js.map +2 -2
  107. package/dist/esm/cli/lib/localDeployment/dashboard.js +9 -0
  108. package/dist/esm/cli/lib/localDeployment/dashboard.js.map +2 -2
  109. package/dist/esm/cli/lib/localDeployment/download.js +16 -1
  110. package/dist/esm/cli/lib/localDeployment/download.js.map +2 -2
  111. package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
  112. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  113. package/dist/esm/cli/lib/utils/aiAgent.js +10 -0
  114. package/dist/esm/cli/lib/utils/aiAgent.js.map +7 -0
  115. package/dist/esm/index.js +1 -1
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/server/components/index.js.map +2 -2
  118. package/dist/esm/server/impl/authentication_impl.js +13 -0
  119. package/dist/esm/server/impl/authentication_impl.js.map +2 -2
  120. package/dist/esm/server/impl/registration_impl.js +2 -2
  121. package/dist/esm/server/impl/registration_impl.js.map +2 -2
  122. package/dist/esm/server/index.js.map +2 -2
  123. package/dist/esm/server/schema.js +0 -2
  124. package/dist/esm/server/schema.js.map +2 -2
  125. package/dist/esm-types/cli/aiFiles.d.ts.map +1 -1
  126. package/dist/esm-types/cli/env.d.ts.map +1 -1
  127. package/dist/esm-types/cli/envDefault.d.ts.map +1 -1
  128. package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts +3 -1
  129. package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -1
  130. package/dist/esm-types/cli/lib/aiFiles/index.d.ts +11 -1
  131. package/dist/esm-types/cli/lib/aiFiles/index.d.ts.map +1 -1
  132. package/dist/esm-types/cli/lib/aiFiles/skills.d.ts +4 -1
  133. package/dist/esm-types/cli/lib/aiFiles/skills.d.ts.map +1 -1
  134. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  135. package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +13 -0
  136. package/dist/esm-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
  137. package/dist/esm-types/cli/lib/env.d.ts +1 -0
  138. package/dist/esm-types/cli/lib/env.d.ts.map +1 -1
  139. package/dist/esm-types/cli/lib/localDeployment/dashboard.d.ts +6 -0
  140. package/dist/esm-types/cli/lib/localDeployment/dashboard.d.ts.map +1 -1
  141. package/dist/esm-types/cli/lib/localDeployment/download.d.ts.map +1 -1
  142. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
  143. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  144. package/dist/esm-types/cli/lib/utils/aiAgent.d.ts +8 -0
  145. package/dist/esm-types/cli/lib/utils/aiAgent.d.ts.map +1 -0
  146. package/dist/esm-types/index.d.ts +1 -1
  147. package/dist/esm-types/server/authentication.d.ts +65 -0
  148. package/dist/esm-types/server/authentication.d.ts.map +1 -1
  149. package/dist/esm-types/server/components/index.d.ts +6 -0
  150. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  151. package/dist/esm-types/server/impl/authentication_impl.d.ts +2 -1
  152. package/dist/esm-types/server/impl/authentication_impl.d.ts.map +1 -1
  153. package/dist/esm-types/server/index.d.ts +2 -2
  154. package/dist/esm-types/server/index.d.ts.map +1 -1
  155. package/dist/esm-types/server/meta.d.ts +8 -0
  156. package/dist/esm-types/server/meta.d.ts.map +1 -1
  157. package/dist/esm-types/server/registration.d.ts +5 -3
  158. package/dist/esm-types/server/registration.d.ts.map +1 -1
  159. package/dist/esm-types/server/schema.d.ts +0 -2
  160. package/dist/esm-types/server/schema.d.ts.map +1 -1
  161. package/dist/esm-types/server/storage.d.ts +28 -25
  162. package/dist/esm-types/server/storage.d.ts.map +1 -1
  163. package/dist/react.bundle.js +1 -1
  164. package/dist/react.bundle.js.map +1 -1
  165. package/package.json +3 -2
  166. package/schemas/convex.schema.json +1 -2
  167. package/src/cli/aiFiles.ts +30 -4
  168. package/src/cli/env.ts +4 -1
  169. package/src/cli/envDefault.ts +4 -1
  170. package/src/cli/lib/aiFiles/guidelinesmd.ts +7 -2
  171. package/src/cli/lib/aiFiles/index.ts +23 -3
  172. package/src/cli/lib/aiFiles/skills.ts +11 -7
  173. package/src/cli/lib/aiFiles/state.ts +1 -1
  174. package/src/cli/lib/components.ts +18 -3
  175. package/src/cli/lib/deployApi/startPush.ts +64 -0
  176. package/src/cli/lib/env.ts +13 -2
  177. package/src/cli/lib/localDeployment/dashboard.ts +19 -0
  178. package/src/cli/lib/localDeployment/download.ts +17 -1
  179. package/src/cli/lib/localDeployment/utils.ts +4 -0
  180. package/src/cli/lib/utils/aiAgent.ts +15 -0
  181. package/src/index.ts +1 -1
  182. package/src/server/authentication.ts +79 -0
  183. package/src/server/components/index.ts +11 -0
  184. package/src/server/impl/authentication_impl.ts +15 -1
  185. package/src/server/impl/registration_impl.ts +2 -2
  186. package/src/server/index.ts +6 -0
  187. package/src/server/meta.ts +0 -8
  188. package/src/server/registration.ts +5 -2
  189. package/src/server/schema.ts +0 -2
  190. package/src/server/storage.ts +29 -42
@@ -1,4 +1,5 @@
1
- import { Auth } from "../authentication.js";
1
+ import { Auth, MutationAuth } from "../authentication.js";
2
+ import { version } from "../../index.js";
2
3
  import { performAsyncSyscall } from "./syscall.js";
3
4
 
4
5
  export function setupAuth(requestId: string): Auth {
@@ -10,3 +11,16 @@ export function setupAuth(requestId: string): Auth {
10
11
  },
11
12
  };
12
13
  }
14
+
15
+ export function setupMutationAuth(requestId: string): MutationAuth {
16
+ return {
17
+ ...setupAuth(requestId),
18
+ signJwt: async (options) => {
19
+ return await performAsyncSyscall("1.0/signJwt", {
20
+ requestId,
21
+ version,
22
+ ...options,
23
+ });
24
+ },
25
+ };
26
+ }
@@ -24,7 +24,7 @@ import {
24
24
  } from "../registration.js";
25
25
  import { setupActionCalls } from "./actions_impl.js";
26
26
  import { setupActionVectorSearch } from "./vector_search_impl.js";
27
- import { setupAuth } from "./authentication_impl.js";
27
+ import { setupAuth, setupMutationAuth } from "./authentication_impl.js";
28
28
  import { setupReader, setupWriter } from "./database_impl.js";
29
29
  import { QueryImpl, QueryInitializerImpl } from "./query_impl.js";
30
30
  import {
@@ -55,7 +55,7 @@ async function invokeMutation<
55
55
  const args = jsonToConvex(JSON.parse(argsStr));
56
56
  const mutationCtx = {
57
57
  db: setupWriter(),
58
- auth: setupAuth(requestId),
58
+ auth: setupMutationAuth(requestId),
59
59
  storage: setupStorageWriter(requestId),
60
60
  scheduler: setupMutationScheduler(),
61
61
  meta: setupMutationMeta(visibility),
@@ -55,7 +55,12 @@ export type {
55
55
  Auth,
56
56
  AuthConfig,
57
57
  AuthProvider,
58
+ MutationAuth,
58
59
  UserIdentity,
60
+ ReservedJwtClaim,
61
+ ReservedJwtClaimPrefix,
62
+ SignJwtClaims,
63
+ SignJwtOptions,
59
64
  UserIdentityAttributes,
60
65
  } from "./authentication.js";
61
66
  export * from "./database.js";
@@ -209,6 +214,7 @@ export type {
209
214
  ComponentDefinition,
210
215
  AnyComponents,
211
216
  FunctionHandle,
217
+ FunctionHandle_future,
212
218
  } from "./components/index.js";
213
219
 
214
220
  /**
@@ -26,13 +26,9 @@ export type TransactionMetrics = {
26
26
  documentsWritten: TransactionMetric;
27
27
  functionsScheduled: TransactionMetric;
28
28
  scheduledFunctionArgsBytes: TransactionMetric;
29
- /** @internal */
30
29
  filesWritten: TransactionMetric;
31
- /** @internal */
32
30
  fileWriteBytes: TransactionMetric;
33
- /** @internal */
34
31
  filesRead: TransactionMetric;
35
- /** @internal */
36
32
  fileReadBytes: TransactionMetric;
37
33
  };
38
34
 
@@ -51,13 +47,9 @@ export interface TransactionLimits {
51
47
  documentsWritten?: number;
52
48
  functionsScheduled?: number;
53
49
  scheduledFunctionArgsBytes?: number;
54
- /** @internal */
55
50
  filesWritten?: number;
56
- /** @internal */
57
51
  fileWriteBytes?: number;
58
- /** @internal */
59
52
  filesRead?: number;
60
- /** @internal */
61
53
  fileReadBytes?: number;
62
54
  }
63
55
 
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Auth,
3
+ MutationAuth,
3
4
  GenericDatabaseReader,
4
5
  GenericDatabaseReaderWithTable,
5
6
  GenericDatabaseWriter,
@@ -87,12 +88,14 @@ export interface GenericMutationCtx<DataModel extends GenericDataModel> {
87
88
  db: GenericDatabaseWriter<DataModel>;
88
89
 
89
90
  /**
90
- * Information about the currently authenticated user.
91
+ * Auth functionality for mutations.
91
92
  *
92
93
  * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,
93
94
  * or `null` if the user is not authenticated.
95
+ *
96
+ * `ctx.auth.signJwt` is available for creating deployment issued JWTs.
94
97
  */
95
- auth: Auth;
98
+ auth: MutationAuth;
96
99
 
97
100
  /**
98
101
  * A utility for reading and writing files in storage.
@@ -226,8 +226,6 @@ export class TableDefinition<
226
226
  *
227
227
  * Returns indexes defined on this table.
228
228
  * Intended for the advanced use cases of dynamically deciding which index to use for a query.
229
- * If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.
230
- * https://github.com/get-convex/convex-js/issues/49
231
229
  */
232
230
  " indexes"(): { indexDescriptor: string; fields: string[] }[] {
233
231
  return this.indexes;
@@ -133,9 +133,9 @@ export interface StorageReader {
133
133
  }
134
134
 
135
135
  /**
136
- * An interface to write files to storage within Convex mutation functions.
136
+ * An interface to read and write files to storage within Convex mutation functions.
137
137
  *
138
- * Available as `ctx.storage` in mutations.
138
+ * Available as `ctx.storage` in mutations, actions, and HTTP actions.
139
139
  *
140
140
  * @see https://docs.convex.dev/file-storage
141
141
  * @public
@@ -195,46 +195,12 @@ export interface StorageWriter extends StorageReader {
195
195
  storageId: T extends { __tableName: any } ? never : T,
196
196
  ): Promise<void>;
197
197
 
198
- /**
199
- * @internal
200
- */
201
- // TODO: move `store` from StorageActionWriter to StorageWriter when mutation
202
- // file storage access is ready for release
203
- store(
204
- blob: Blob,
205
- options?: { sha256?: string },
206
- ): Promise<GenericId<"_storage">>;
207
-
208
- /**
209
- * @internal
210
- */
211
- // TODO: move `get` from StorageActionWriter to StorageWriter when mutation
212
- // file storage access is ready for release
213
- get(storageId: GenericId<"_storage">): Promise<Blob | null>;
214
- }
215
-
216
- /**
217
- * An interface to read and write files to storage within Convex actions and HTTP actions.
218
- *
219
- * In actions, `ctx.storage` has additional methods not available in mutations:
220
- * `get()` to download a file as a Blob, and `store()` to upload a Blob directly.
221
- *
222
- * @example
223
- * ```typescript
224
- * // In an action, download and re-upload a file:
225
- * const blob = await ctx.storage.get(storageId);
226
- * if (blob) {
227
- * const newStorageId = await ctx.storage.store(blob);
228
- * }
229
- * ```
230
- *
231
- * @public
232
- */
233
- export interface StorageActionWriter extends StorageWriter {
234
198
  /**
235
199
  * Download a file from storage as a Blob.
236
200
  *
237
- * Only available in actions and HTTP actions (not in mutations or queries).
201
+ * In mutations, files read count toward the transaction's `filesRead` and
202
+ * `fileReadBytes` limits. Use
203
+ * `ctx.meta.getTransactionMetrics()` to check the remaining headroom.
238
204
  *
239
205
  * @param storageId - The `Id<"_storage">` of the file.
240
206
  * @returns A Blob containing the file contents, or `null` if the file doesn't exist.
@@ -249,16 +215,21 @@ export interface StorageActionWriter extends StorageWriter {
249
215
  get<T extends StorageId>(
250
216
  storageId: T extends { __tableName: any } ? never : T,
251
217
  ): Promise<Blob | null>;
218
+
252
219
  /**
253
220
  * Upload a Blob directly to storage.
254
221
  *
255
- * Only available in actions and HTTP actions. For client-side uploads from
256
- * mutations, use `generateUploadUrl()` instead.
222
+ * To upload files from a client, use {@link StorageWriter.generateUploadUrl}
223
+ * instead.
224
+ *
225
+ * In mutations, files stored count toward the transaction's `filesWritten`
226
+ * and `fileWriteBytes` limits. Use
227
+ * `ctx.meta.getTransactionMetrics()` to check the remaining headroom.
257
228
  *
258
229
  * @example
259
230
  * ```typescript
260
231
  * const storageId = await ctx.storage.store(blob);
261
- * // Save storageId to the database via ctx.runMutation
232
+ * // If in an action, save storageId to the database via ctx.runMutation
262
233
  * ```
263
234
  *
264
235
  * @param blob - The Blob to store.
@@ -270,3 +241,19 @@ export interface StorageActionWriter extends StorageWriter {
270
241
  options?: { sha256?: string },
271
242
  ): Promise<GenericId<"_storage">>;
272
243
  }
244
+
245
+ /**
246
+ * An interface to read and write files to storage within Convex actions and HTTP actions.
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * // In an action, download and re-upload a file:
251
+ * const blob = await ctx.storage.get(storageId);
252
+ * if (blob) {
253
+ * const newStorageId = await ctx.storage.store(blob);
254
+ * }
255
+ * ```
256
+ *
257
+ * @public
258
+ */
259
+ export interface StorageActionWriter extends StorageWriter {}