@samebase/convex-hosting 0.3.2 → 0.4.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 (193) hide show
  1. package/CHANGELOG.md +10 -134
  2. package/README.md +136 -398
  3. package/dist/cli/convex.d.ts +63 -0
  4. package/dist/cli/convex.js +108 -0
  5. package/dist/cli/convex.js.map +1 -0
  6. package/dist/cli/files.d.ts +18 -0
  7. package/dist/cli/files.js +106 -0
  8. package/dist/cli/files.js.map +1 -0
  9. package/dist/cli/index.d.ts +1 -11
  10. package/dist/cli/index.js +3 -58
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/main.d.ts +5 -0
  13. package/dist/cli/main.js +346 -0
  14. package/dist/cli/main.js.map +1 -0
  15. package/dist/client/index.d.ts +8 -115
  16. package/dist/client/index.js +65 -242
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/types.d.ts +5 -0
  19. package/dist/client/version-module.d.ts +6 -0
  20. package/dist/component/_generated/api.d.ts +0 -5
  21. package/dist/component/_generated/api.js.map +1 -1
  22. package/dist/component/_generated/component.d.ts +20 -18
  23. package/dist/component/_generated/dataModel.d.ts +0 -1
  24. package/dist/component/_generated/server.d.ts +12 -1
  25. package/dist/component/_generated/server.js +2 -0
  26. package/dist/component/_generated/server.js.map +1 -1
  27. package/dist/component/convex.config.d.ts +0 -1
  28. package/dist/component/lib.d.ts +175 -156
  29. package/dist/component/lib.js +396 -710
  30. package/dist/component/lib.js.map +1 -1
  31. package/dist/component/schema.d.ts +76 -72
  32. package/dist/component/schema.js +35 -59
  33. package/dist/component/schema.js.map +1 -1
  34. package/dist/workers-shared/asset-worker/src/analytics.d.ts +39 -0
  35. package/dist/workers-shared/asset-worker/src/analytics.js +86 -0
  36. package/dist/workers-shared/asset-worker/src/analytics.js.map +1 -0
  37. package/dist/workers-shared/asset-worker/src/compatibility-flags.d.ts +19 -0
  38. package/dist/workers-shared/asset-worker/src/compatibility-flags.js +29 -0
  39. package/dist/workers-shared/asset-worker/src/compatibility-flags.js.map +1 -0
  40. package/dist/workers-shared/asset-worker/src/configuration.d.ts +3 -0
  41. package/dist/workers-shared/asset-worker/src/configuration.js +30 -0
  42. package/dist/workers-shared/asset-worker/src/configuration.js.map +1 -0
  43. package/dist/workers-shared/asset-worker/src/constants.d.ts +1 -0
  44. package/dist/workers-shared/asset-worker/src/constants.js +3 -0
  45. package/dist/workers-shared/asset-worker/src/constants.js.map +1 -0
  46. package/dist/workers-shared/asset-worker/src/handler.d.ts +28 -0
  47. package/dist/workers-shared/asset-worker/src/handler.js +717 -0
  48. package/dist/workers-shared/asset-worker/src/handler.js.map +1 -0
  49. package/dist/workers-shared/asset-worker/src/types.d.ts +13 -0
  50. package/dist/workers-shared/asset-worker/src/types.js +2 -0
  51. package/dist/workers-shared/asset-worker/src/types.js.map +1 -0
  52. package/dist/workers-shared/asset-worker/src/utils/base-path.d.ts +29 -0
  53. package/dist/workers-shared/asset-worker/src/utils/base-path.js +56 -0
  54. package/dist/workers-shared/asset-worker/src/utils/base-path.js.map +1 -0
  55. package/dist/workers-shared/asset-worker/src/utils/headers.d.ts +11 -0
  56. package/dist/workers-shared/asset-worker/src/utils/headers.js +77 -0
  57. package/dist/workers-shared/asset-worker/src/utils/headers.js.map +1 -0
  58. package/dist/workers-shared/asset-worker/src/utils/rules-engine.d.ts +23 -0
  59. package/dist/workers-shared/asset-worker/src/utils/rules-engine.js +133 -0
  60. package/dist/workers-shared/asset-worker/src/utils/rules-engine.js.map +1 -0
  61. package/dist/workers-shared/asset-worker/src/worker.d.ts +14 -0
  62. package/dist/workers-shared/asset-worker/src/worker.js +12 -0
  63. package/dist/workers-shared/asset-worker/src/worker.js.map +1 -0
  64. package/dist/workers-shared/utils/base-path.d.ts +32 -0
  65. package/dist/workers-shared/utils/base-path.js +94 -0
  66. package/dist/workers-shared/utils/base-path.js.map +1 -0
  67. package/dist/workers-shared/utils/configuration/constants.d.ts +15 -0
  68. package/dist/workers-shared/utils/configuration/constants.js +16 -0
  69. package/dist/workers-shared/utils/configuration/constants.js.map +1 -0
  70. package/dist/workers-shared/utils/configuration/constructConfiguration.d.ts +12 -0
  71. package/dist/workers-shared/utils/configuration/constructConfiguration.js +103 -0
  72. package/dist/workers-shared/utils/configuration/constructConfiguration.js.map +1 -0
  73. package/dist/workers-shared/utils/configuration/parseHeaders.d.ts +5 -0
  74. package/dist/workers-shared/utils/configuration/parseHeaders.js +181 -0
  75. package/dist/workers-shared/utils/configuration/parseHeaders.js.map +1 -0
  76. package/dist/workers-shared/utils/configuration/parseRedirects.d.ts +8 -0
  77. package/dist/workers-shared/utils/configuration/parseRedirects.js +129 -0
  78. package/dist/workers-shared/utils/configuration/parseRedirects.js.map +1 -0
  79. package/dist/workers-shared/utils/configuration/parseStaticRouting.d.ts +2 -0
  80. package/dist/workers-shared/utils/configuration/parseStaticRouting.js +94 -0
  81. package/dist/workers-shared/utils/configuration/parseStaticRouting.js.map +1 -0
  82. package/dist/workers-shared/utils/configuration/types.d.ts +38 -0
  83. package/dist/workers-shared/utils/configuration/types.js +2 -0
  84. package/dist/workers-shared/utils/configuration/types.js.map +1 -0
  85. package/dist/workers-shared/utils/configuration/validateURL.d.ts +3 -0
  86. package/dist/workers-shared/utils/configuration/validateURL.js +56 -0
  87. package/dist/workers-shared/utils/configuration/validateURL.js.map +1 -0
  88. package/dist/workers-shared/utils/constants.d.ts +28 -0
  89. package/dist/workers-shared/utils/constants.js +34 -0
  90. package/dist/workers-shared/utils/constants.js.map +1 -0
  91. package/dist/workers-shared/utils/helpers.d.ts +22 -0
  92. package/dist/workers-shared/utils/helpers.js +73 -0
  93. package/dist/workers-shared/utils/helpers.js.map +1 -0
  94. package/dist/workers-shared/utils/responses.d.ts +43 -0
  95. package/dist/workers-shared/utils/responses.js +125 -0
  96. package/dist/workers-shared/utils/responses.js.map +1 -0
  97. package/dist/workers-shared/utils/tracing.d.ts +3 -0
  98. package/dist/workers-shared/utils/tracing.js +29 -0
  99. package/dist/workers-shared/utils/tracing.js.map +1 -0
  100. package/dist/workers-shared/utils/types.d.ts +131 -0
  101. package/dist/workers-shared/utils/types.js +72 -0
  102. package/dist/workers-shared/utils/types.js.map +1 -0
  103. package/package.json +16 -32
  104. package/INTEGRATION.md +0 -399
  105. package/dist/cli/args.d.ts +0 -28
  106. package/dist/cli/args.d.ts.map +0 -1
  107. package/dist/cli/args.js +0 -148
  108. package/dist/cli/args.js.map +0 -1
  109. package/dist/cli/argumentChunks.d.ts +0 -3
  110. package/dist/cli/argumentChunks.d.ts.map +0 -1
  111. package/dist/cli/argumentChunks.js +0 -29
  112. package/dist/cli/argumentChunks.js.map +0 -1
  113. package/dist/cli/collectFiles.d.ts +0 -10
  114. package/dist/cli/collectFiles.d.ts.map +0 -1
  115. package/dist/cli/collectFiles.js +0 -53
  116. package/dist/cli/collectFiles.js.map +0 -1
  117. package/dist/cli/commands.d.ts +0 -8
  118. package/dist/cli/commands.d.ts.map +0 -1
  119. package/dist/cli/commands.js +0 -56
  120. package/dist/cli/commands.js.map +0 -1
  121. package/dist/cli/componentName.d.ts +0 -32
  122. package/dist/cli/componentName.d.ts.map +0 -1
  123. package/dist/cli/componentName.js +0 -43
  124. package/dist/cli/componentName.js.map +0 -1
  125. package/dist/cli/deploy.d.ts +0 -16
  126. package/dist/cli/deploy.d.ts.map +0 -1
  127. package/dist/cli/deploy.js +0 -283
  128. package/dist/cli/deploy.js.map +0 -1
  129. package/dist/cli/deployEnvironment.d.ts +0 -10
  130. package/dist/cli/deployEnvironment.d.ts.map +0 -1
  131. package/dist/cli/deployEnvironment.js +0 -12
  132. package/dist/cli/deployEnvironment.js.map +0 -1
  133. package/dist/cli/index.d.ts.map +0 -1
  134. package/dist/cli/upload.d.ts +0 -22
  135. package/dist/cli/upload.d.ts.map +0 -1
  136. package/dist/cli/upload.js +0 -630
  137. package/dist/cli/upload.js.map +0 -1
  138. package/dist/client/_generated/_ignore.d.ts +0 -1
  139. package/dist/client/_generated/_ignore.d.ts.map +0 -1
  140. package/dist/client/_generated/_ignore.js +0 -3
  141. package/dist/client/_generated/_ignore.js.map +0 -1
  142. package/dist/client/index.d.ts.map +0 -1
  143. package/dist/component/_generated/api.d.ts.map +0 -1
  144. package/dist/component/_generated/component.d.ts.map +0 -1
  145. package/dist/component/_generated/dataModel.d.ts.map +0 -1
  146. package/dist/component/_generated/server.d.ts.map +0 -1
  147. package/dist/component/convex.config.d.ts.map +0 -1
  148. package/dist/component/http.d.ts +0 -4
  149. package/dist/component/http.d.ts.map +0 -1
  150. package/dist/component/http.js +0 -113
  151. package/dist/component/http.js.map +0 -1
  152. package/dist/component/lib.d.ts.map +0 -1
  153. package/dist/component/schema.d.ts.map +0 -1
  154. package/dist/component/serving.d.ts +0 -23
  155. package/dist/component/serving.d.ts.map +0 -1
  156. package/dist/component/serving.js +0 -161
  157. package/dist/component/serving.js.map +0 -1
  158. package/dist/react/index.d.ts +0 -59
  159. package/dist/react/index.d.ts.map +0 -1
  160. package/dist/react/index.js +0 -137
  161. package/dist/react/index.js.map +0 -1
  162. package/src/cli/args.test.ts +0 -79
  163. package/src/cli/args.ts +0 -153
  164. package/src/cli/argumentChunks.test.ts +0 -27
  165. package/src/cli/argumentChunks.ts +0 -40
  166. package/src/cli/collectFiles.test.ts +0 -26
  167. package/src/cli/collectFiles.ts +0 -59
  168. package/src/cli/commands.ts +0 -68
  169. package/src/cli/componentName.test.ts +0 -41
  170. package/src/cli/componentName.ts +0 -46
  171. package/src/cli/deploy.ts +0 -336
  172. package/src/cli/deployEnvironment.test.ts +0 -27
  173. package/src/cli/deployEnvironment.ts +0 -17
  174. package/src/cli/index.ts +0 -65
  175. package/src/cli/upload.ts +0 -837
  176. package/src/client/_generated/_ignore.ts +0 -1
  177. package/src/client/index.test.ts +0 -549
  178. package/src/client/index.ts +0 -344
  179. package/src/client/setup.test.ts +0 -22
  180. package/src/component/_generated/api.ts +0 -54
  181. package/src/component/_generated/component.ts +0 -55
  182. package/src/component/_generated/dataModel.ts +0 -60
  183. package/src/component/_generated/server.ts +0 -156
  184. package/src/component/convex.config.ts +0 -3
  185. package/src/component/http.test.ts +0 -254
  186. package/src/component/http.ts +0 -133
  187. package/src/component/lib.test.ts +0 -1007
  188. package/src/component/lib.ts +0 -862
  189. package/src/component/schema.ts +0 -75
  190. package/src/component/serving.ts +0 -170
  191. package/src/component/setup.test.ts +0 -11
  192. package/src/react/index.tsx +0 -197
  193. package/src/test.ts +0 -23
@@ -0,0 +1,56 @@
1
+ export const extractPathname = (path = "/", includeSearch, includeHash) => {
2
+ if (!path.startsWith("/")) {
3
+ path = `/${path}`;
4
+ }
5
+ const url = new URL(`//${path}`, "relative://");
6
+ return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
7
+ };
8
+ const URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
9
+ const HOST_WITH_PORT_REGEX = /.*:\d+$/;
10
+ const PATH_REGEX = /^\//;
11
+ export const validateUrl = (token, onlyRelative = false, disallowPorts = false, includeSearch = false, includeHash = false) => {
12
+ const host = URL_REGEX.exec(token);
13
+ if (host && host.groups && host.groups.host) {
14
+ if (onlyRelative) {
15
+ return [
16
+ undefined,
17
+ `Only relative URLs are allowed. Skipping absolute URL ${token}.`,
18
+ ];
19
+ }
20
+ if (disallowPorts && host.groups.host.match(HOST_WITH_PORT_REGEX)) {
21
+ return [
22
+ undefined,
23
+ `Specifying ports is not supported. Skipping absolute URL ${token}.`,
24
+ ];
25
+ }
26
+ return [
27
+ `https://${host.groups.host}${extractPathname(host.groups.path, includeSearch, includeHash)}`,
28
+ undefined,
29
+ ];
30
+ }
31
+ else {
32
+ if (!token.startsWith("/") && onlyRelative) {
33
+ token = `/${token}`;
34
+ }
35
+ const path = PATH_REGEX.exec(token);
36
+ if (path) {
37
+ try {
38
+ return [extractPathname(token, includeSearch, includeHash), undefined];
39
+ }
40
+ catch {
41
+ return [undefined, `Error parsing URL segment ${token}. Skipping.`];
42
+ }
43
+ }
44
+ }
45
+ return [
46
+ undefined,
47
+ onlyRelative
48
+ ? "URLs should begin with a forward-slash."
49
+ : 'URLs should either be relative (e.g. begin with a forward-slash), or use HTTPS (e.g. begin with "https://").',
50
+ ];
51
+ };
52
+ export function urlHasHost(token) {
53
+ const host = URL_REGEX.exec(token);
54
+ return Boolean(host && host.groups && host.groups.host);
55
+ }
56
+ //# sourceMappingURL=validateURL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateURL.js","sourceRoot":"","sources":["../../../../src/workers-shared/utils/configuration/validateURL.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,IAAI,GAAG,GAAG,EACV,aAAsB,EACtB,WAAoB,EACX,EAAE;IACX,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACnB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,aAAa,CAAC,CAAC;IAChD,OAAO,GAAG,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GACvD,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAC1B,EAAE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,0CAA0C,CAAC;AAC7D,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,MAAM,CAAC,MAAM,WAAW,GAAG,CAC1B,KAAa,EACb,YAAY,GAAG,KAAK,EACpB,aAAa,GAAG,KAAK,EACrB,aAAa,GAAG,KAAK,EACrB,WAAW,GAAG,KAAK,EACyB,EAAE;IAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,IAAI,I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I,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /** Reserved header at the start of the whole manifest, NOT in each entry (currently unused)
2
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ]
3
+ */
4
+ export declare const HEADER_SIZE = 20;
5
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
6
+ export declare const PATH_HASH_SIZE = 16;
7
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
8
+ export declare const CONTENT_HASH_SIZE = 16;
9
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
10
+ export declare const TAIL_SIZE = 8;
11
+ /** offset of PATH_HASH from start of each entry
12
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
13
+ export declare const PATH_HASH_OFFSET = 0;
14
+ /** offset of CONTENT_HASH from start of each entry
15
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
16
+ export declare const CONTENT_HASH_OFFSET = 16;
17
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
18
+ export declare const ENTRY_SIZE: number;
19
+ /**
20
+ * Maximum number of assets that can be deployed with a Worker; this is a global
21
+ * ceiling, and may vary by the user's subscription.
22
+ */
23
+ export declare const MAX_ASSET_COUNT = 100000;
24
+ /** Maximum size per asset that can be deployed with a Worker */
25
+ export declare const MAX_ASSET_SIZE: number;
26
+ export declare const CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
27
+ export declare const REDIRECTS_FILENAME = "_redirects";
28
+ export declare const HEADERS_FILENAME = "_headers";
@@ -0,0 +1,34 @@
1
+ // -- Constants for manifest encoding/decoding --
2
+ // (header and tails are not currently being used for anything afaik)
3
+ // NB these all refer to bytes
4
+ /** Reserved header at the start of the whole manifest, NOT in each entry (currently unused)
5
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ]
6
+ */
7
+ export const HEADER_SIZE = 20;
8
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
9
+ export const PATH_HASH_SIZE = 16;
10
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
11
+ export const CONTENT_HASH_SIZE = 16;
12
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
13
+ export const TAIL_SIZE = 8;
14
+ /** offset of PATH_HASH from start of each entry
15
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
16
+ export const PATH_HASH_OFFSET = 0;
17
+ /** offset of CONTENT_HASH from start of each entry
18
+ * manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
19
+ export const CONTENT_HASH_OFFSET = PATH_HASH_SIZE;
20
+ /** manifest = [HEADER, [ entry = PATH_HASH, CONTENT_HASH, TAIL], [entry], ... , [entry] ] */
21
+ export const ENTRY_SIZE = PATH_HASH_SIZE + CONTENT_HASH_SIZE + TAIL_SIZE;
22
+ // -- Manifest creation constants --
23
+ // used in wrangler dev and deploy
24
+ /**
25
+ * Maximum number of assets that can be deployed with a Worker; this is a global
26
+ * ceiling, and may vary by the user's subscription.
27
+ */
28
+ export const MAX_ASSET_COUNT = 100_000;
29
+ /** Maximum size per asset that can be deployed with a Worker */
30
+ export const MAX_ASSET_SIZE = 25 * 1024 * 1024;
31
+ export const CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
32
+ export const REDIRECTS_FILENAME = "_redirects";
33
+ export const HEADERS_FILENAME = "_headers";
34
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/workers-shared/utils/constants.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,qEAAqE;AACrE,8BAA8B;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,6FAA6F;AAC7F,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B;6FAC6F;AAC7F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC;6FAC6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAEzE,oCAAoC;AACpC,kCAAkC;AAClC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { PathOrFileDescriptor } from "node:fs";
2
+ /** normalises sep for windows and prefix with `/` */
3
+ export declare const normalizeFilePath: (relativeFilepath: string) => string;
4
+ export declare const getContentType: (absFilePath: string) => string | null;
5
+ /**
6
+ * Generate a function that can match relative filepaths against a list of gitignore formatted patterns.
7
+ */
8
+ export declare function createPatternMatcher(patterns: string[], exclude: boolean): (filePath: string) => boolean;
9
+ export declare function thrownIsDoesNotExistError(thrown: unknown): thrown is Error & {
10
+ code: "ENOENT";
11
+ };
12
+ export declare function maybeGetFile(filePath: PathOrFileDescriptor): string | undefined;
13
+ /**
14
+ * Create a function for filtering out ignored assets.
15
+ *
16
+ * The generated function takes an asset path, relative to the asset directory,
17
+ * and returns true if the asset should not be ignored.
18
+ */
19
+ export declare function createAssetsIgnoreFunction(dir: string): Promise<{
20
+ assetsIgnoreFunction: (filePath: string) => boolean;
21
+ assetsIgnoreFilePresent: boolean;
22
+ }>;
@@ -0,0 +1,73 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { isAbsolute, resolve, sep } from "node:path";
3
+ import ignore from "ignore";
4
+ import mime from "mime";
5
+ import { CF_ASSETS_IGNORE_FILENAME, HEADERS_FILENAME, REDIRECTS_FILENAME, } from "./constants.js";
6
+ /** normalises sep for windows and prefix with `/` */
7
+ export const normalizeFilePath = (relativeFilepath) => {
8
+ if (isAbsolute(relativeFilepath)) {
9
+ throw new Error(`Expected relative path`);
10
+ }
11
+ return "/" + relativeFilepath.split(sep).join("/");
12
+ };
13
+ export const getContentType = (absFilePath) => {
14
+ let contentType = mime.getType(absFilePath);
15
+ if (contentType &&
16
+ contentType.startsWith("text/") &&
17
+ !contentType.includes("charset")) {
18
+ contentType = `${contentType}; charset=utf-8`;
19
+ }
20
+ return contentType;
21
+ };
22
+ /**
23
+ * Generate a function that can match relative filepaths against a list of gitignore formatted patterns.
24
+ */
25
+ export function createPatternMatcher(patterns, exclude) {
26
+ if (patterns.length === 0) {
27
+ return (_filePath) => !exclude;
28
+ }
29
+ else {
30
+ const ignorer = ignore().add(patterns);
31
+ return (filePath) => ignorer.test(filePath).ignored;
32
+ }
33
+ }
34
+ export function thrownIsDoesNotExistError(thrown) {
35
+ return (thrown instanceof Error && "code" in thrown && thrown.code === "ENOENT");
36
+ }
37
+ export function maybeGetFile(filePath) {
38
+ try {
39
+ return readFileSync(filePath, "utf8");
40
+ }
41
+ catch (e) {
42
+ if (!thrownIsDoesNotExistError(e)) {
43
+ throw e;
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Create a function for filtering out ignored assets.
49
+ *
50
+ * The generated function takes an asset path, relative to the asset directory,
51
+ * and returns true if the asset should not be ignored.
52
+ */
53
+ export async function createAssetsIgnoreFunction(dir) {
54
+ const cfAssetIgnorePath = resolve(dir, CF_ASSETS_IGNORE_FILENAME);
55
+ const ignorePatterns = [
56
+ // Ignore the `.assetsignore` file and other metafiles by default.
57
+ // The ignore lib expects unix-style paths for its patterns
58
+ `/${CF_ASSETS_IGNORE_FILENAME}`,
59
+ `/${REDIRECTS_FILENAME}`,
60
+ `/${HEADERS_FILENAME}`,
61
+ ];
62
+ let assetsIgnoreFilePresent = false;
63
+ const assetsIgnore = maybeGetFile(cfAssetIgnorePath);
64
+ if (assetsIgnore !== undefined) {
65
+ assetsIgnoreFilePresent = true;
66
+ ignorePatterns.push(...assetsIgnore.split("\n"));
67
+ }
68
+ return {
69
+ assetsIgnoreFunction: createPatternMatcher(ignorePatterns, true),
70
+ assetsIgnoreFilePresent,
71
+ };
72
+ }
73
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/workers-shared/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACN,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,qDAAqD;AACrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,gBAAwB,EAAE,EAAE;IAC7D,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE,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AAE,CAAC;QACrB,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,GAAW;IAC3D,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;IAElE,MAAM,cAAc,GAAG;QACtB,kEAAkE;QAClE,2DAA2D;QAC3D,IAAI,yBAAyB,EAAE;QAC/B,IAAI,kBAAkB,EAAE;QACxB,IAAI,gBAAgB,EAAE;KACtB,CAAC;IAEF,IAAI,uBAAuB,GAAG,KAAK,CAAC;IACpC,MAAM,YAAY,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACrD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,uBAAuB,GAAG,IAAI,CAAC;QAC/B,cAAc,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO;QACN,oBAAoB,EAAE,oBAAoB,CAAC,cAAc,EAAE,IAAI,CAAC;QAChE,uBAAuB;KACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ export declare class OkResponse extends Response {
2
+ static readonly status = 200;
3
+ constructor(body: BodyInit | null, init?: ResponseInit);
4
+ }
5
+ export declare class NotFoundResponse extends Response {
6
+ static readonly status = 404;
7
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
8
+ }
9
+ export declare class NoIntentResponse extends NotFoundResponse {
10
+ constructor();
11
+ }
12
+ export declare class MethodNotAllowedResponse extends Response {
13
+ static readonly status = 405;
14
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
15
+ }
16
+ export declare class InternalServerErrorResponse extends Response {
17
+ static readonly status = 500;
18
+ constructor(_: Error, init?: ResponseInit);
19
+ }
20
+ export declare class NotModifiedResponse extends Response {
21
+ static readonly status = 304;
22
+ constructor(...[_body, init]: ConstructorParameters<typeof Response>);
23
+ }
24
+ export declare class MovedPermanentlyResponse extends Response {
25
+ static readonly status = 301;
26
+ constructor(location: string, init?: ResponseInit);
27
+ }
28
+ export declare class FoundResponse extends Response {
29
+ static readonly status = 302;
30
+ constructor(location: string, init?: ResponseInit);
31
+ }
32
+ export declare class SeeOtherResponse extends Response {
33
+ static readonly status = 303;
34
+ constructor(location: string, init?: ResponseInit);
35
+ }
36
+ export declare class TemporaryRedirectResponse extends Response {
37
+ static readonly status = 307;
38
+ constructor(location: string, init?: ResponseInit);
39
+ }
40
+ export declare class PermanentRedirectResponse extends Response {
41
+ static readonly status = 308;
42
+ constructor(location: string, init?: ResponseInit);
43
+ }
@@ -0,0 +1,125 @@
1
+ export class OkResponse extends Response {
2
+ static status = 200;
3
+ constructor(body, init) {
4
+ super(body, {
5
+ ...init,
6
+ status: OkResponse.status,
7
+ });
8
+ }
9
+ }
10
+ export class NotFoundResponse extends Response {
11
+ static status = 404;
12
+ constructor(...[body, init]) {
13
+ super(body, {
14
+ ...init,
15
+ status: NotFoundResponse.status,
16
+ statusText: "Not Found",
17
+ });
18
+ }
19
+ }
20
+ // A magical response type which is used to signal that a user worker should be invoked if one is present.
21
+ export class NoIntentResponse extends NotFoundResponse {
22
+ constructor() {
23
+ super();
24
+ }
25
+ }
26
+ export class MethodNotAllowedResponse extends Response {
27
+ static status = 405;
28
+ constructor(...[body, init]) {
29
+ super(body, {
30
+ ...init,
31
+ status: MethodNotAllowedResponse.status,
32
+ statusText: "Method Not Allowed",
33
+ });
34
+ }
35
+ }
36
+ export class InternalServerErrorResponse extends Response {
37
+ static status = 500;
38
+ constructor(_, init) {
39
+ super(null, {
40
+ ...init,
41
+ status: InternalServerErrorResponse.status,
42
+ });
43
+ }
44
+ }
45
+ export class NotModifiedResponse extends Response {
46
+ static status = 304;
47
+ constructor(...[_body, init]) {
48
+ super(null, {
49
+ ...init,
50
+ status: NotModifiedResponse.status,
51
+ statusText: "Not Modified",
52
+ });
53
+ }
54
+ }
55
+ export class MovedPermanentlyResponse extends Response {
56
+ static status = 301;
57
+ constructor(location, init) {
58
+ super(null, {
59
+ ...init,
60
+ status: MovedPermanentlyResponse.status,
61
+ statusText: "Moved Permanently",
62
+ headers: {
63
+ ...init?.headers,
64
+ Location: location,
65
+ },
66
+ });
67
+ }
68
+ }
69
+ export class FoundResponse extends Response {
70
+ static status = 302;
71
+ constructor(location, init) {
72
+ super(null, {
73
+ ...init,
74
+ status: FoundResponse.status,
75
+ statusText: "Found",
76
+ headers: {
77
+ ...init?.headers,
78
+ Location: location,
79
+ },
80
+ });
81
+ }
82
+ }
83
+ export class SeeOtherResponse extends Response {
84
+ static status = 303;
85
+ constructor(location, init) {
86
+ super(null, {
87
+ ...init,
88
+ status: SeeOtherResponse.status,
89
+ statusText: "See Other",
90
+ headers: {
91
+ ...init?.headers,
92
+ Location: location,
93
+ },
94
+ });
95
+ }
96
+ }
97
+ export class TemporaryRedirectResponse extends Response {
98
+ static status = 307;
99
+ constructor(location, init) {
100
+ super(null, {
101
+ ...init,
102
+ status: TemporaryRedirectResponse.status,
103
+ statusText: "Temporary Redirect",
104
+ headers: {
105
+ ...init?.headers,
106
+ Location: location,
107
+ },
108
+ });
109
+ }
110
+ }
111
+ export class PermanentRedirectResponse extends Response {
112
+ static status = 308;
113
+ constructor(location, init) {
114
+ super(null, {
115
+ ...init,
116
+ status: PermanentRedirectResponse.status,
117
+ statusText: "Permanent Redirect",
118
+ headers: {
119
+ ...init?.headers,
120
+ Location: location,
121
+ },
122
+ });
123
+ }
124
+ }
125
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../src/workers-shared/utils/responses.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,QAAQ;IACvC,MAAM,CAAU,MAAM,GAAG,GAAG,CAAC;IAE7B,YAAY,IAAqB,EAAE,IAAmB;Q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E,yBAAyB,CAAC,MAAM;YACxC,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE;gBACR,GAAG,IAAI,EAAE,OAAO;gBAChB,QAAQ,EAAE,QAAQ;aAClB;SACD,CAAC,CAAC;IACJ,CAAC;;AAGF,MAAM,OAAO,yBAA0B,SAAQ,QAAQ;IACtD,MAAM,CAAU,MAAM,GAAG,GAAG,CAAC;IAE7B,YAAY,QAAgB,EAAE,IAAmB;QAChD,KAAK,CAAC,IAAI,EAAE;YACX,GAAG,IAAI;YACP,MAAM,EAAE,yBAAyB,CAAC,MAAM;YACxC,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE;gBACR,GAAG,IAAI,EAAE,OAAO;gBAChB,QAAQ,EAAE,QAAQ;aAClB;SACD,CAAC,CAAC;IACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { JaegerTracing, Span } from "./types.js";
2
+ export declare function mockJaegerBindingSpan(): Span;
3
+ export declare function mockJaegerBinding(): JaegerTracing;
@@ -0,0 +1,29 @@
1
+ export function mockJaegerBindingSpan() {
2
+ return {
3
+ addLogs: () => { },
4
+ setTags: () => { },
5
+ end: () => { },
6
+ isRecording: true,
7
+ };
8
+ }
9
+ export function mockJaegerBinding() {
10
+ return {
11
+ enterSpan: (_, span, ...args) => {
12
+ return span(mockJaegerBindingSpan(), ...args);
13
+ },
14
+ getSpanContext: () => ({
15
+ traceId: "test-trace",
16
+ spanId: "test-span",
17
+ parentSpanId: "test-parent-span",
18
+ traceFlags: 0,
19
+ }),
20
+ runWithSpanContext: (_, callback, ...args) => {
21
+ return callback(...args);
22
+ },
23
+ traceId: "test-trace",
24
+ spanId: "test-span",
25
+ parentSpanId: "test-parent-span",
26
+ cfTraceIdHeader: "test-trace:test-span:0",
27
+ };
28
+ }
29
+ //# sourceMappingURL=tracing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/workers-shared/utils/tracing.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB;IACpC,OAAO;QACN,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;QACjB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;QACjB,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;QACb,WAAW,EAAE,IAAI;KACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB;IAChC,OAAO;QACN,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE;YAC/B,OAAO,IAAI,CAAC,qBAAqB,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;QACD,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;YACtB,OAAO,EAAE,YAAY;YACrB,MAAM,EAAE,WAAW;YACnB,YAAY,EAAE,kBAAkB;YAChC,UAAU,EAAE,CAAC;SACb,CAAC;QACF,kBAAkB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE;YAC5C,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;QACnB,YAAY,EAAE,kBAAkB;QAChC,eAAe,EAAE,wBAAwB;KACzC,CAAC;AACH,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { z } from "zod";
2
+ declare const StaticRoutingSchema: z.ZodObject<{
3
+ user_worker: z.ZodArray<z.ZodString>;
4
+ asset_worker: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
+ }, z.core.$strip>;
6
+ export type StaticRouting = z.infer<typeof StaticRoutingSchema>;
7
+ export declare const RouterConfigSchema: z.ZodObject<{
8
+ account_id: z.ZodOptional<z.ZodNumber>;
9
+ script_id: z.ZodOptional<z.ZodNumber>;
10
+ debug: z.ZodOptional<z.ZodBoolean>;
11
+ invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>;
12
+ static_routing: z.ZodOptional<z.ZodObject<{
13
+ user_worker: z.ZodArray<z.ZodString>;
14
+ asset_worker: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>>;
16
+ has_user_worker: z.ZodOptional<z.ZodBoolean>;
17
+ }, z.core.$strip>;
18
+ export declare const EyeballRouterConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
19
+ limitedAssetsOnly: z.ZodOptional<z.ZodBoolean>;
20
+ }, z.core.$strip>, z.ZodNull]>;
21
+ declare const MetadataStaticRedirects: z.ZodRecord<z.ZodString, z.ZodObject<{
22
+ status: z.ZodNumber;
23
+ to: z.ZodString;
24
+ lineNumber: z.ZodNumber;
25
+ }, z.core.$strip>>;
26
+ export type MetadataStaticRedirects = z.infer<typeof MetadataStaticRedirects>;
27
+ declare const MetadataRedirects: z.ZodRecord<z.ZodString, z.ZodObject<{
28
+ status: z.ZodNumber;
29
+ to: z.ZodString;
30
+ }, z.core.$strip>>;
31
+ export type MetadataRedirects = z.infer<typeof MetadataRedirects>;
32
+ declare const MetadataHeaders: z.ZodRecord<z.ZodString, z.ZodObject<{
33
+ set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
34
+ unset: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
+ }, z.core.$strip>>;
36
+ export type MetadataHeaders = z.infer<typeof MetadataHeaders>;
37
+ export declare const RedirectsSchema: z.ZodOptional<z.ZodObject<{
38
+ version: z.ZodLiteral<1>;
39
+ staticRules: z.ZodRecord<z.ZodString, z.ZodObject<{
40
+ status: z.ZodNumber;
41
+ to: z.ZodString;
42
+ lineNumber: z.ZodNumber;
43
+ }, z.core.$strip>>;
44
+ rules: z.ZodRecord<z.ZodString, z.ZodObject<{
45
+ status: z.ZodNumber;
46
+ to: z.ZodString;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>>;
49
+ export declare const HeadersSchema: z.ZodOptional<z.ZodObject<{
50
+ version: z.ZodLiteral<2>;
51
+ rules: z.ZodRecord<z.ZodString, z.ZodObject<{
52
+ set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
53
+ unset: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>>;
56
+ export declare const AssetConfigSchema: z.ZodObject<{
57
+ account_id: z.ZodOptional<z.ZodNumber>;
58
+ script_id: z.ZodOptional<z.ZodNumber>;
59
+ debug: z.ZodOptional<z.ZodBoolean>;
60
+ compatibility_date: z.ZodOptional<z.ZodString>;
61
+ compatibility_flags: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
+ html_handling: z.ZodOptional<z.ZodEnum<{
63
+ "auto-trailing-slash": "auto-trailing-slash";
64
+ "force-trailing-slash": "force-trailing-slash";
65
+ "drop-trailing-slash": "drop-trailing-slash";
66
+ none: "none";
67
+ }>>;
68
+ not_found_handling: z.ZodOptional<z.ZodEnum<{
69
+ none: "none";
70
+ "single-page-application": "single-page-application";
71
+ "404-page": "404-page";
72
+ }>>;
73
+ base_path: z.ZodOptional<z.ZodString>;
74
+ redirects: z.ZodOptional<z.ZodObject<{
75
+ version: z.ZodLiteral<1>;
76
+ staticRules: z.ZodRecord<z.ZodString, z.ZodObject<{
77
+ status: z.ZodNumber;
78
+ to: z.ZodString;
79
+ lineNumber: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ rules: z.ZodRecord<z.ZodString, z.ZodObject<{
82
+ status: z.ZodNumber;
83
+ to: z.ZodString;
84
+ }, z.core.$strip>>;
85
+ }, z.core.$strip>>;
86
+ headers: z.ZodOptional<z.ZodObject<{
87
+ version: z.ZodLiteral<2>;
88
+ rules: z.ZodRecord<z.ZodString, z.ZodObject<{
89
+ set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
90
+ unset: z.ZodOptional<z.ZodArray<z.ZodString>>;
91
+ }, z.core.$strip>>;
92
+ }, z.core.$strip>>;
93
+ has_static_routing: z.ZodOptional<z.ZodBoolean>;
94
+ }, z.core.$strip>;
95
+ export type EyeballRouterConfig = z.infer<typeof EyeballRouterConfigSchema>;
96
+ export type RouterConfig = z.infer<typeof RouterConfigSchema>;
97
+ export type AssetConfig = z.infer<typeof AssetConfigSchema>;
98
+ export interface UnsafePerformanceTimer {
99
+ readonly timeOrigin: number;
100
+ now: () => number;
101
+ }
102
+ export interface JaegerTracing {
103
+ enterSpan<T extends unknown[], R = void>(name: string, span: (s: Span, ...args: T) => R, ...args: T): R;
104
+ getSpanContext(): SpanContext | null;
105
+ runWithSpanContext<T extends unknown[]>(spanContext: SpanContext | null, callback: (...args: T) => unknown, ...args: T): unknown;
106
+ readonly traceId: string | null;
107
+ readonly spanId: string | null;
108
+ readonly parentSpanId: string | null;
109
+ readonly cfTraceIdHeader: string | null;
110
+ }
111
+ export interface Span {
112
+ addLogs(logs: JaegerRecord): void;
113
+ setTags(tags: JaegerRecord): void;
114
+ end(): void;
115
+ isRecording: boolean;
116
+ }
117
+ export interface SpanContext {
118
+ traceId: string;
119
+ spanId: string;
120
+ parentSpanId: string;
121
+ traceFlags: number;
122
+ }
123
+ export type JaegerValue = string | number | boolean;
124
+ export type JaegerRecord = Record<string, JaegerValue>;
125
+ export interface ColoMetadata {
126
+ metalId: number;
127
+ coloId: number;
128
+ coloRegion: string;
129
+ coloTier: number;
130
+ }
131
+ export {};
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ const InternalConfigSchema = z.object({
3
+ account_id: z.number().optional(),
4
+ script_id: z.number().optional(),
5
+ debug: z.boolean().optional(),
6
+ });
7
+ const StaticRoutingSchema = z.object({
8
+ user_worker: z.array(z.string()),
9
+ asset_worker: z.array(z.string()).optional(),
10
+ });
11
+ export const RouterConfigSchema = z.object({
12
+ invoke_user_worker_ahead_of_assets: z.boolean().optional(),
13
+ static_routing: StaticRoutingSchema.optional(),
14
+ has_user_worker: z.boolean().optional(),
15
+ ...InternalConfigSchema.shape,
16
+ });
17
+ export const EyeballRouterConfigSchema = z.union([
18
+ z.object({
19
+ limitedAssetsOnly: z.boolean().optional(),
20
+ }),
21
+ z.null(),
22
+ ]);
23
+ const MetadataStaticRedirectEntry = z.object({
24
+ status: z.number(),
25
+ to: z.string(),
26
+ lineNumber: z.number(),
27
+ });
28
+ const MetadataRedirectEntry = z.object({
29
+ status: z.number(),
30
+ to: z.string(),
31
+ });
32
+ const MetadataStaticRedirects = z.record(z.string(), MetadataStaticRedirectEntry);
33
+ const MetadataRedirects = z.record(z.string(), MetadataRedirectEntry);
34
+ const MetadataHeaderEntry = z.object({
35
+ set: z.record(z.string(), z.string()).optional(),
36
+ unset: z.array(z.string()).optional(),
37
+ });
38
+ const MetadataHeaders = z.record(z.string(), MetadataHeaderEntry);
39
+ export const RedirectsSchema = z
40
+ .object({
41
+ version: z.literal(1),
42
+ staticRules: MetadataStaticRedirects,
43
+ rules: MetadataRedirects,
44
+ })
45
+ .optional();
46
+ export const HeadersSchema = z
47
+ .object({
48
+ version: z.literal(2),
49
+ rules: MetadataHeaders,
50
+ })
51
+ .optional();
52
+ export const AssetConfigSchema = z.object({
53
+ compatibility_date: z.string().optional(),
54
+ compatibility_flags: z.array(z.string()).optional(),
55
+ html_handling: z
56
+ .enum([
57
+ "auto-trailing-slash",
58
+ "force-trailing-slash",
59
+ "drop-trailing-slash",
60
+ "none",
61
+ ])
62
+ .optional(),
63
+ not_found_handling: z
64
+ .enum(["single-page-application", "404-page", "none"])
65
+ .optional(),
66
+ base_path: z.string().optional(),
67
+ redirects: RedirectsSchema,
68
+ headers: HeadersSchema,
69
+ has_static_routing: z.boolean().optional(),
70
+ ...InternalConfigSchema.shape,
71
+ });
72
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/workers-shared/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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