@samebase/convex-hosting 0.0.0-stage → 0.3.1

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 (122) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/INTEGRATION.md +399 -0
  3. package/LICENSE +201 -0
  4. package/NOTICE +7 -0
  5. package/README.md +471 -2
  6. package/dist/cli/args.d.ts +28 -0
  7. package/dist/cli/args.d.ts.map +1 -0
  8. package/dist/cli/args.js +148 -0
  9. package/dist/cli/args.js.map +1 -0
  10. package/dist/cli/argumentChunks.d.ts +3 -0
  11. package/dist/cli/argumentChunks.d.ts.map +1 -0
  12. package/dist/cli/argumentChunks.js +29 -0
  13. package/dist/cli/argumentChunks.js.map +1 -0
  14. package/dist/cli/collectFiles.d.ts +10 -0
  15. package/dist/cli/collectFiles.d.ts.map +1 -0
  16. package/dist/cli/collectFiles.js +53 -0
  17. package/dist/cli/collectFiles.js.map +1 -0
  18. package/dist/cli/commands.d.ts +8 -0
  19. package/dist/cli/commands.d.ts.map +1 -0
  20. package/dist/cli/commands.js +56 -0
  21. package/dist/cli/commands.js.map +1 -0
  22. package/dist/cli/componentName.d.ts +32 -0
  23. package/dist/cli/componentName.d.ts.map +1 -0
  24. package/dist/cli/componentName.js +43 -0
  25. package/dist/cli/componentName.js.map +1 -0
  26. package/dist/cli/deploy.d.ts +16 -0
  27. package/dist/cli/deploy.d.ts.map +1 -0
  28. package/dist/cli/deploy.js +283 -0
  29. package/dist/cli/deploy.js.map +1 -0
  30. package/dist/cli/deployEnvironment.d.ts +10 -0
  31. package/dist/cli/deployEnvironment.d.ts.map +1 -0
  32. package/dist/cli/deployEnvironment.js +12 -0
  33. package/dist/cli/deployEnvironment.js.map +1 -0
  34. package/dist/cli/index.d.ts +12 -0
  35. package/dist/cli/index.d.ts.map +1 -0
  36. package/dist/cli/index.js +60 -0
  37. package/dist/cli/index.js.map +1 -0
  38. package/dist/cli/upload.d.ts +22 -0
  39. package/dist/cli/upload.d.ts.map +1 -0
  40. package/dist/cli/upload.js +630 -0
  41. package/dist/cli/upload.js.map +1 -0
  42. package/dist/client/_generated/_ignore.d.ts +1 -0
  43. package/dist/client/_generated/_ignore.d.ts.map +1 -0
  44. package/dist/client/_generated/_ignore.js +3 -0
  45. package/dist/client/_generated/_ignore.js.map +1 -0
  46. package/dist/client/index.d.ts +119 -0
  47. package/dist/client/index.d.ts.map +1 -0
  48. package/dist/client/index.js +272 -0
  49. package/dist/client/index.js.map +1 -0
  50. package/dist/component/_generated/api.d.ts +38 -0
  51. package/dist/component/_generated/api.d.ts.map +1 -0
  52. package/dist/component/_generated/api.js +31 -0
  53. package/dist/component/_generated/api.js.map +1 -0
  54. package/dist/component/_generated/component.d.ts +43 -0
  55. package/dist/component/_generated/component.d.ts.map +1 -0
  56. package/dist/component/_generated/component.js +11 -0
  57. package/dist/component/_generated/component.js.map +1 -0
  58. package/dist/component/_generated/dataModel.d.ts +46 -0
  59. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  60. package/dist/component/_generated/dataModel.js +11 -0
  61. package/dist/component/_generated/dataModel.js.map +1 -0
  62. package/dist/component/_generated/server.d.ts +121 -0
  63. package/dist/component/_generated/server.d.ts.map +1 -0
  64. package/dist/component/_generated/server.js +78 -0
  65. package/dist/component/_generated/server.js.map +1 -0
  66. package/dist/component/convex.config.d.ts +3 -0
  67. package/dist/component/convex.config.d.ts.map +1 -0
  68. package/dist/component/convex.config.js +3 -0
  69. package/dist/component/convex.config.js.map +1 -0
  70. package/dist/component/http.d.ts +4 -0
  71. package/dist/component/http.d.ts.map +1 -0
  72. package/dist/component/http.js +125 -0
  73. package/dist/component/http.js.map +1 -0
  74. package/dist/component/lib.d.ts +164 -0
  75. package/dist/component/lib.d.ts.map +1 -0
  76. package/dist/component/lib.js +768 -0
  77. package/dist/component/lib.js.map +1 -0
  78. package/dist/component/schema.d.ts +84 -0
  79. package/dist/component/schema.d.ts.map +1 -0
  80. package/dist/component/schema.js +69 -0
  81. package/dist/component/schema.js.map +1 -0
  82. package/dist/component/serving.d.ts +17 -0
  83. package/dist/component/serving.d.ts.map +1 -0
  84. package/dist/component/serving.js +150 -0
  85. package/dist/component/serving.js.map +1 -0
  86. package/dist/react/index.d.ts +59 -0
  87. package/dist/react/index.d.ts.map +1 -0
  88. package/dist/react/index.js +137 -0
  89. package/dist/react/index.js.map +1 -0
  90. package/package.json +78 -3
  91. package/src/cli/args.test.ts +79 -0
  92. package/src/cli/args.ts +153 -0
  93. package/src/cli/argumentChunks.test.ts +27 -0
  94. package/src/cli/argumentChunks.ts +40 -0
  95. package/src/cli/collectFiles.test.ts +26 -0
  96. package/src/cli/collectFiles.ts +59 -0
  97. package/src/cli/commands.ts +68 -0
  98. package/src/cli/componentName.test.ts +41 -0
  99. package/src/cli/componentName.ts +46 -0
  100. package/src/cli/deploy.ts +336 -0
  101. package/src/cli/deployEnvironment.test.ts +27 -0
  102. package/src/cli/deployEnvironment.ts +17 -0
  103. package/src/cli/index.ts +65 -0
  104. package/src/cli/upload.ts +837 -0
  105. package/src/client/_generated/_ignore.ts +1 -0
  106. package/src/client/index.test.ts +510 -0
  107. package/src/client/index.ts +355 -0
  108. package/src/client/setup.test.ts +22 -0
  109. package/src/component/_generated/api.ts +54 -0
  110. package/src/component/_generated/component.ts +55 -0
  111. package/src/component/_generated/dataModel.ts +60 -0
  112. package/src/component/_generated/server.ts +156 -0
  113. package/src/component/convex.config.ts +3 -0
  114. package/src/component/http.test.ts +223 -0
  115. package/src/component/http.ts +144 -0
  116. package/src/component/lib.test.ts +1007 -0
  117. package/src/component/lib.ts +862 -0
  118. package/src/component/schema.ts +75 -0
  119. package/src/component/serving.ts +158 -0
  120. package/src/component/setup.test.ts +11 -0
  121. package/src/react/index.tsx +197 -0
  122. package/src/test.ts +23 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Generated utilities for implementing server-side Convex query and mutation functions.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
10
+ import type { DataModel } from "./dataModel.js";
11
+ /**
12
+ * Define a query in this Convex app's public API.
13
+ *
14
+ * This function will be allowed to read your Convex database and will be accessible from the client.
15
+ *
16
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
17
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
18
+ */
19
+ export declare const query: QueryBuilder<DataModel, "public">;
20
+ /**
21
+ * Define a query that is only accessible from other Convex functions (but not from the client).
22
+ *
23
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
24
+ *
25
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
26
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
27
+ */
28
+ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
29
+ /**
30
+ * Define a mutation in this Convex app's public API.
31
+ *
32
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
33
+ *
34
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
35
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
36
+ */
37
+ export declare const mutation: MutationBuilder<DataModel, "public">;
38
+ /**
39
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
40
+ *
41
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
42
+ *
43
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
44
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
45
+ */
46
+ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
47
+ /**
48
+ * Define an action in this Convex app's public API.
49
+ *
50
+ * An action is a function which can execute any JavaScript code, including non-deterministic
51
+ * code and code with side-effects, like calling third-party services.
52
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
53
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
54
+ *
55
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
56
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
57
+ */
58
+ export declare const action: ActionBuilder<DataModel, "public">;
59
+ /**
60
+ * Define an action that is only accessible from other Convex functions (but not from the client).
61
+ *
62
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
63
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
64
+ */
65
+ export declare const internalAction: ActionBuilder<DataModel, "internal">;
66
+ /**
67
+ * Define an HTTP action.
68
+ *
69
+ * The wrapped function will be used to respond to HTTP requests received
70
+ * by a Convex deployment if the requests matches the path and method where
71
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
72
+ *
73
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
74
+ * and a Fetch API `Request` object as its second.
75
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
76
+ */
77
+ export declare const httpAction: HttpActionBuilder;
78
+ /**
79
+ * A set of services for use within Convex query functions.
80
+ *
81
+ * The query context is passed as the first argument to any Convex query
82
+ * function run on the server.
83
+ *
84
+ * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
85
+ */
86
+ export type QueryCtx = GenericQueryCtx<DataModel>;
87
+ /**
88
+ * A set of services for use within Convex mutation functions.
89
+ *
90
+ * The mutation context is passed as the first argument to any Convex mutation
91
+ * function run on the server.
92
+ *
93
+ * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
94
+ */
95
+ export type MutationCtx = GenericMutationCtx<DataModel>;
96
+ /**
97
+ * A set of services for use within Convex action functions.
98
+ *
99
+ * The action context is passed as the first argument to any Convex action
100
+ * function run on the server.
101
+ */
102
+ export type ActionCtx = GenericActionCtx<DataModel>;
103
+ /**
104
+ * An interface to read from the database within Convex query functions.
105
+ *
106
+ * The two entry points are {@link DatabaseReader.get}, which fetches a single
107
+ * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
108
+ * building a query.
109
+ */
110
+ export type DatabaseReader = GenericDatabaseReader<DataModel>;
111
+ /**
112
+ * An interface to read from and write to the database within Convex mutation
113
+ * functions.
114
+ *
115
+ * Convex guarantees that all writes within a single mutation are
116
+ * executed atomically, so you never have to worry about partial writes leaving
117
+ * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
118
+ * for the guarantees Convex provides your functions.
119
+ */
120
+ export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
121
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAgB,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAmB,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,SAAS,EAAE,UAAU,CAC3C,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAiB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CACzC,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAqC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,78 @@
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
+ import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
11
+ /**
12
+ * Define a query in this Convex app's public API.
13
+ *
14
+ * This function will be allowed to read your Convex database and will be accessible from the client.
15
+ *
16
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
17
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
18
+ */
19
+ export const query = queryGeneric;
20
+ /**
21
+ * Define a query that is only accessible from other Convex functions (but not from the client).
22
+ *
23
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
24
+ *
25
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
26
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
27
+ */
28
+ export const internalQuery = internalQueryGeneric;
29
+ /**
30
+ * Define a mutation in this Convex app's public API.
31
+ *
32
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
33
+ *
34
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
35
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
36
+ */
37
+ export const mutation = mutationGeneric;
38
+ /**
39
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
40
+ *
41
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
42
+ *
43
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
44
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
45
+ */
46
+ export const internalMutation = internalMutationGeneric;
47
+ /**
48
+ * Define an action in this Convex app's public API.
49
+ *
50
+ * An action is a function which can execute any JavaScript code, including non-deterministic
51
+ * code and code with side-effects, like calling third-party services.
52
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
53
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
54
+ *
55
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
56
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
57
+ */
58
+ export const action = actionGeneric;
59
+ /**
60
+ * Define an action that is only accessible from other Convex functions (but not from the client).
61
+ *
62
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
63
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
64
+ */
65
+ export const internalAction = internalActionGeneric;
66
+ /**
67
+ * Define an HTTP action.
68
+ *
69
+ * The wrapped function will be used to respond to HTTP requests received
70
+ * by a Convex deployment if the requests matches the path and method where
71
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
72
+ *
73
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
74
+ * and a Fetch API `Request` object as its second.
75
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
76
+ */
77
+ export const httpAction = httpActionGeneric;
78
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("convex/server").ComponentDefinition<any, {}>;
2
+ export default _default;
3
+ //# sourceMappingURL=convex.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":";AAEA,wBAA0C"}
@@ -0,0 +1,3 @@
1
+ import { defineComponent } from "convex/server";
2
+ export default defineComponent("hosting");
3
+ //# sourceMappingURL=convex.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAe,eAAe,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function getMountPrefix(): string;
2
+ declare const http: import("convex/server").HttpRouter;
3
+ export default http;
4
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"AAeA,wBAAgB,cAAc,IAAI,MAAM,CAUvC;AA8GD,QAAA,MAAM,IAAI,oCAAe,CAAC;AAQ1B,eAAe,IAAI,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { httpRouter } from "convex/server";
2
+ import { httpAction } from "./_generated/server.js";
3
+ import { internal } from "./_generated/api.js";
4
+ import { cacheControlFor, decodeRequestPath, etagMatches, getMimeType, getSetupHtml, isHtmlContentType, } from "./serving.js";
5
+ // CONVEX_SITE_URL reflects the component's mount point (including any httpPrefix).
6
+ // We use it to strip the prefix from incoming request paths so lookups in
7
+ // the asset table remain relative to the component (e.g. `/index.html`).
8
+ export function getMountPrefix() {
9
+ const siteUrl = process.env.CONVEX_SITE_URL;
10
+ if (!siteUrl)
11
+ return "";
12
+ try {
13
+ const pathname = decodeRequestPath(new URL(siteUrl).pathname);
14
+ if (pathname === null)
15
+ return "";
16
+ return pathname === "/" ? "" : pathname.replace(/\/$/, "");
17
+ }
18
+ catch {
19
+ return "";
20
+ }
21
+ }
22
+ const serveStaticFile = httpAction(async (ctx, request) => {
23
+ const url = new URL(request.url);
24
+ const decodedPath = decodeRequestPath(url.pathname);
25
+ if (decodedPath === null) {
26
+ return new Response("Bad Request", {
27
+ status: 400,
28
+ headers: { "Content-Type": "text/plain" },
29
+ });
30
+ }
31
+ let path = decodedPath;
32
+ const mountPrefix = getMountPrefix();
33
+ if (mountPrefix && path.startsWith(mountPrefix)) {
34
+ path = path.slice(mountPrefix.length) || "/";
35
+ }
36
+ if (path === "" || path === "/") {
37
+ path = "/index.html";
38
+ }
39
+ // One query resolves the asset: an exact match, or, when SPA fallback is
40
+ // enabled for the current deployment, the index.html asset for an
41
+ // extension-less miss. The fallback lookup happens inside the query so the
42
+ // HTTP action never makes a second round-trip.
43
+ const asset = await ctx.runQuery(internal.lib.resolveAsset, { path });
44
+ if (!asset) {
45
+ if (path === "/index.html") {
46
+ return new Response(getSetupHtml(), {
47
+ status: 503,
48
+ headers: {
49
+ "Content-Type": "text/html; charset=utf-8",
50
+ "Cache-Control": "no-store",
51
+ "Retry-After": "5",
52
+ },
53
+ });
54
+ }
55
+ return new Response("Not Found", {
56
+ status: 404,
57
+ headers: { "Content-Type": "text/plain" },
58
+ });
59
+ }
60
+ const contentType = asset.contentType || getMimeType(path);
61
+ // CDN redirect: blobs are served by the platform at /fs/blobs/{id}, which
62
+ // lives at the deployment root (not under the component's prefix).
63
+ if (asset.blobId && !isHtmlContentType(contentType)) {
64
+ const redirectUrl = `${url.origin}/fs/blobs/${asset.blobId}`;
65
+ return new Response(null, {
66
+ status: 302,
67
+ headers: {
68
+ Location: redirectUrl,
69
+ "Cache-Control": cacheControlFor(path),
70
+ },
71
+ });
72
+ }
73
+ if (!asset.storageId) {
74
+ return new Response("Asset not available", {
75
+ status: 500,
76
+ headers: { "Content-Type": "text/plain" },
77
+ });
78
+ }
79
+ const etag = `"${asset.storageId}"`;
80
+ const ifNoneMatch = request.headers.get("If-None-Match");
81
+ const cacheControl = cacheControlFor(path);
82
+ if (etagMatches(ifNoneMatch, etag)) {
83
+ return new Response(null, {
84
+ status: 304,
85
+ headers: { ETag: etag, "Cache-Control": cacheControl },
86
+ });
87
+ }
88
+ const blob = await ctx.storage.get(asset.storageId);
89
+ if (!blob) {
90
+ // A same-name v1 to v2 migration can temporarily inherit an index row that
91
+ // points at app-owned storage. Treat that interval like an empty component
92
+ // rather than returning a misleading permanent storage error.
93
+ if (asset.path === "/index.html") {
94
+ return new Response(getSetupHtml(), {
95
+ status: 503,
96
+ headers: {
97
+ "Content-Type": "text/html; charset=utf-8",
98
+ "Cache-Control": "no-store",
99
+ "Retry-After": "5",
100
+ },
101
+ });
102
+ }
103
+ return new Response("Storage error", {
104
+ status: 500,
105
+ headers: { "Content-Type": "text/plain" },
106
+ });
107
+ }
108
+ return new Response(blob, {
109
+ status: 200,
110
+ headers: {
111
+ "Content-Type": contentType,
112
+ "Cache-Control": cacheControl,
113
+ ETag: etag,
114
+ "X-Content-Type-Options": "nosniff",
115
+ },
116
+ });
117
+ });
118
+ const http = httpRouter();
119
+ http.route({
120
+ pathPrefix: "/",
121
+ method: "GET",
122
+ handler: serveStaticFile,
123
+ });
124
+ export default http;
125
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,mFAAmF;AACnF,0EAA0E;AAC1E,yEAAyE;AACzE,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QACjC,OAAO,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EA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AAC,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,2EAA2E;QAC3E,2EAA2E;QAC3E,8DAA8D;QAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACjC,OAAO,IAAI,QAAQ,CAAC,YAAY,EAAE,EAAE;gBAClC,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE;oBACP,cAAc,EAAE,0BAA0B;oBAC1C,eAAe,EAAE,UAAU;oBAC3B,aAAa,EAAE,GAAG;iBACnB;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,eAAe,EAAE;YACnC,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,WAAW;YAC3B,eAAe,EAAE,YAAY;YAC7B,IAAI,EAAE,IAAI;YACV,wBAAwB,EAAE,SAAS;SACpC;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;AAE1B,IAAI,CAAC,KAAK,CAAC;IACT,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,eAAe;CACzB,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -0,0 +1,164 @@
1
+ export declare const getCurrentDeployment: import("convex/server").RegisteredQuery<"public", {}, Promise<{
2
+ pendingBlobCleanupCount: number | undefined;
3
+ _id: import("convex/values").GenericId<"deploymentInfo">;
4
+ _creationTime: number;
5
+ spaFallback?: boolean | undefined;
6
+ currentDeploymentId: string;
7
+ deployedAt: number;
8
+ } | null>>;
9
+ export declare const resolveAssetForHttp: import("convex/server").RegisteredQuery<"public", {
10
+ spaFallback?: boolean | undefined;
11
+ path: string;
12
+ }, Promise<{
13
+ etag?: string | undefined;
14
+ contentType: string;
15
+ blobId?: string | undefined;
16
+ appStorageId?: import("convex/values").GenericId<"_storage"> | undefined;
17
+ storageUrl?: string | undefined;
18
+ } | null>>;
19
+ export declare const getUrls: import("convex/server").RegisteredQuery<"internal", {}, Promise<{
20
+ siteUrl: string;
21
+ cloudUrl: string;
22
+ }>>;
23
+ export declare const getByPath: import("convex/server").RegisteredQuery<"internal", {
24
+ path: string;
25
+ }, Promise<{
26
+ _id: import("convex/values").GenericId<"staticAssets">;
27
+ _creationTime: number;
28
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
29
+ blobId?: string | undefined;
30
+ path: string;
31
+ deploymentId: string;
32
+ contentType: string;
33
+ } | null>>;
34
+ export declare const resolveAsset: import("convex/server").RegisteredQuery<"internal", {
35
+ path: string;
36
+ }, Promise<{
37
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
38
+ blobId?: string | undefined;
39
+ path: string;
40
+ deploymentId: string;
41
+ _id: import("convex/values").GenericId<"staticAssets">;
42
+ _creationTime: number;
43
+ contentType: string;
44
+ } | {
45
+ path: string;
46
+ deploymentId: string;
47
+ storageId: string & {
48
+ __tableName: "_storage";
49
+ };
50
+ blobId?: string | undefined;
51
+ _creationTime: number;
52
+ contentType: string;
53
+ _id: import("convex/values").GenericId<"retiredAssets">;
54
+ expiresAt: number;
55
+ } | null>>;
56
+ export declare const listAssets: import("convex/server").RegisteredQuery<"internal", {
57
+ limit?: number | undefined;
58
+ }, Promise<{
59
+ _id: import("convex/values").GenericId<"staticAssets">;
60
+ _creationTime: number;
61
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
62
+ blobId?: string | undefined;
63
+ path: string;
64
+ deploymentId: string;
65
+ contentType: string;
66
+ }[]>>;
67
+ export declare const generateUploadUrl: import("convex/server").RegisteredMutation<"internal", {}, Promise<string>>;
68
+ export declare const generateUploadUrls: import("convex/server").RegisteredMutation<"internal", {
69
+ count: number;
70
+ }, Promise<string[]>>;
71
+ export declare const listPendingBlobCleanup: import("convex/server").RegisteredQuery<"internal", {
72
+ limit?: number | undefined;
73
+ }, Promise<string[]>>;
74
+ export declare const acknowledgeBlobCleanup: import("convex/server").RegisteredMutation<"internal", {
75
+ blobIds: string[];
76
+ }, Promise<{
77
+ acknowledged: number;
78
+ }>>;
79
+ export declare const queueBlobCleanup: import("convex/server").RegisteredMutation<"internal", {
80
+ blobIds: string[];
81
+ }, Promise<{
82
+ queued: number;
83
+ }>>;
84
+ export declare const cleanupPendingStorage: import("convex/server").RegisteredMutation<"internal", {
85
+ limit?: number | undefined;
86
+ }, Promise<{
87
+ processed: number;
88
+ deleted: number;
89
+ needsAnotherPass: boolean;
90
+ }>>;
91
+ export declare const deleteUploadedFiles: import("convex/server").RegisteredMutation<"internal", {
92
+ storageIds: import("convex/values").GenericId<"_storage">[];
93
+ }, Promise<{
94
+ deleted: number;
95
+ alreadyMissing: number;
96
+ stillReferenced: number;
97
+ }>>;
98
+ export declare const stageAssets: import("convex/server").RegisteredMutation<"internal", {
99
+ assets: {
100
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
101
+ blobId?: string | undefined;
102
+ path: string;
103
+ deploymentId: string;
104
+ contentType: string;
105
+ }[];
106
+ }, Promise<{
107
+ staged: number;
108
+ }>>;
109
+ export declare const discardStagedDeployment: import("convex/server").RegisteredMutation<"internal", {
110
+ deploymentId: string;
111
+ }, Promise<{
112
+ discarded: number;
113
+ }>>;
114
+ export declare const cleanupAbandonedStaging: import("convex/server").RegisteredMutation<"internal", {
115
+ limit?: number | undefined;
116
+ before?: number | undefined;
117
+ }, Promise<{
118
+ discarded: number;
119
+ deletedFiles: number;
120
+ queuedBlobIds: number;
121
+ }>>;
122
+ export declare const cleanupUnreferencedStorage: import("convex/server").RegisteredMutation<"internal", {
123
+ limit?: number | undefined;
124
+ order?: "asc" | "desc" | undefined;
125
+ before?: number | undefined;
126
+ }, Promise<{
127
+ scanned: number;
128
+ deleted: number;
129
+ needsAnotherPass: boolean;
130
+ }>>;
131
+ export declare const recordAsset: import("convex/server").RegisteredMutation<"internal", {
132
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
133
+ blobId?: string | undefined;
134
+ path: string;
135
+ deploymentId: string;
136
+ contentType: string;
137
+ }, Promise<string | null>>;
138
+ export declare const recordAssets: import("convex/server").RegisteredMutation<"internal", {
139
+ assets: {
140
+ storageId?: import("convex/values").GenericId<"_storage"> | undefined;
141
+ blobId?: string | undefined;
142
+ path: string;
143
+ deploymentId: string;
144
+ contentType: string;
145
+ }[];
146
+ }, Promise<{
147
+ blobIds: string[];
148
+ }>>;
149
+ export declare const publishDeployment: import("convex/server").RegisteredMutation<"internal", {
150
+ spaFallback?: boolean | undefined;
151
+ currentDeploymentId: string;
152
+ expectedAssetCount: number;
153
+ }, Promise<{
154
+ deleted: number;
155
+ pendingBlobCleanup: number;
156
+ }>>;
157
+ export declare const commitDeployment: import("convex/server").RegisteredMutation<"internal", {
158
+ spaFallback?: boolean | undefined;
159
+ currentDeploymentId: string;
160
+ }, Promise<{
161
+ deleted: number;
162
+ blobIds: string[];
163
+ }>>;
164
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAoIA,eAAO,MAAM,oBAAoB;;;;;;;UAY/B,CAAC;AAKH,eAAO,MAAM,mBAAmB;;;;;;;;;UAkC9B,CAAC;AAQH,eAAO,MAAM,OAAO;;;GAUlB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;UASpB,CAAC;AAMH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;UAMvB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;KASrB,CAAC;AAEH,eAAO,MAAM,iBAAiB,6EAM5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;qBAa7B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;qBAQjC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;GAqBjC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;GAkB3B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;GA2ChC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;GAkC9B,CAAC;AA4DH,eAAO,MAAM,WAAW;;;;;;;;;;GA0BtB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;GAalC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;GA6ClC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;GAiErC,CAAC;AA0BH,eAAO,MAAM,WAAW;;;;;;0BAwBtB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;GA+BvB,CAAC;AAOH,eAAO,MAAM,iBAAiB;;;;;;;GAgI5B,CAAC;AAMH,eAAO,MAAM,gBAAgB;;;;;;GA8B3B,CAAC"}