@rexezuge/tooling 1.2.0 → 1.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 (153) hide show
  1. package/README.md +66 -10
  2. package/dist/eslint-boundaries.d.ts +31 -7
  3. package/dist/eslint-boundaries.d.ts.map +1 -1
  4. package/dist/eslint-boundaries.js +1 -138
  5. package/dist/eslint-boundaries.js.map +7 -1
  6. package/dist/eslint-rules.js +1 -273
  7. package/dist/eslint-rules.js.map +7 -1
  8. package/dist/eslint.d.ts +12 -7
  9. package/dist/eslint.d.ts.map +1 -1
  10. package/dist/eslint.js +1 -189
  11. package/dist/eslint.js.map +7 -1
  12. package/dist/functions/pages-proxy.d.ts.map +1 -1
  13. package/dist/functions/pages-proxy.js +1 -131
  14. package/dist/functions/pages-proxy.js.map +7 -1
  15. package/dist/index.d.ts +20 -14
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -28
  18. package/dist/index.js.map +7 -1
  19. package/dist/scripts/backup/d1-target.d.ts +15 -5
  20. package/dist/scripts/backup/d1-target.d.ts.map +1 -1
  21. package/dist/scripts/backup/d1-target.js +1 -31
  22. package/dist/scripts/backup/d1-target.js.map +7 -1
  23. package/dist/scripts/backup/destination-config.d.ts +24 -8
  24. package/dist/scripts/backup/destination-config.d.ts.map +1 -1
  25. package/dist/scripts/backup/destination-config.js +1 -57
  26. package/dist/scripts/backup/destination-config.js.map +7 -1
  27. package/dist/scripts/backup/encrypt-backup.js +2 -97
  28. package/dist/scripts/backup/encrypt-backup.js.map +7 -1
  29. package/dist/scripts/backup/naming.d.ts +3 -1
  30. package/dist/scripts/backup/naming.d.ts.map +1 -1
  31. package/dist/scripts/backup/naming.js +1 -58
  32. package/dist/scripts/backup/naming.js.map +7 -1
  33. package/dist/scripts/check-god-files.d.ts +40 -14
  34. package/dist/scripts/check-god-files.d.ts.map +1 -1
  35. package/dist/scripts/check-god-files.js +2 -271
  36. package/dist/scripts/check-god-files.js.map +7 -1
  37. package/dist/scripts/ensure-spa-shell-stub.js +1 -29
  38. package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
  39. package/dist/scripts/init-secrets.d.ts +0 -16
  40. package/dist/scripts/init-secrets.d.ts.map +1 -1
  41. package/dist/scripts/init-secrets.js +2 -239
  42. package/dist/scripts/init-secrets.js.map +7 -1
  43. package/dist/scripts/lib/cli-args.d.ts.map +1 -1
  44. package/dist/scripts/lib/cli-args.js +1 -116
  45. package/dist/scripts/lib/cli-args.js.map +7 -1
  46. package/dist/scripts/lib/github-actions.js +3 -38
  47. package/dist/scripts/lib/github-actions.js.map +7 -1
  48. package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
  49. package/dist/scripts/lib/wrangler-table.js +2 -99
  50. package/dist/scripts/lib/wrangler-table.js.map +7 -1
  51. package/dist/scripts/migrations-lock.js +1 -44
  52. package/dist/scripts/migrations-lock.js.map +7 -1
  53. package/dist/scripts/prepare-wrangler-config.js +1 -49
  54. package/dist/scripts/prepare-wrangler-config.js.map +7 -1
  55. package/dist/scripts/spa-shell.d.ts +12 -4
  56. package/dist/scripts/spa-shell.d.ts.map +1 -1
  57. package/dist/scripts/spa-shell.js +3 -160
  58. package/dist/scripts/spa-shell.js.map +7 -1
  59. package/dist/scripts/validate-locales.d.ts +13 -5
  60. package/dist/scripts/validate-locales.d.ts.map +1 -1
  61. package/dist/scripts/validate-locales.js +4 -350
  62. package/dist/scripts/validate-locales.js.map +7 -1
  63. package/dist/scripts/verify-migrations.d.ts +27 -9
  64. package/dist/scripts/verify-migrations.d.ts.map +1 -1
  65. package/dist/scripts/verify-migrations.js +2 -312
  66. package/dist/scripts/verify-migrations.js.map +7 -1
  67. package/dist/scripts/verify-spa-shell.js +1 -52
  68. package/dist/scripts/verify-spa-shell.js.map +7 -1
  69. package/dist/scripts/wrangler-config/cli.js +3 -51
  70. package/dist/scripts/wrangler-config/cli.js.map +7 -1
  71. package/dist/scripts/wrangler-config/patches.d.ts +10 -4
  72. package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
  73. package/dist/scripts/wrangler-config/patches.js +4 -141
  74. package/dist/scripts/wrangler-config/patches.js.map +7 -1
  75. package/dist/scripts/wrangler-config/resources.d.ts +19 -7
  76. package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
  77. package/dist/scripts/wrangler-config/resources.js +1 -290
  78. package/dist/scripts/wrangler-config/resources.js.map +7 -1
  79. package/dist/scripts/wrangler-config/types.d.ts +24 -8
  80. package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
  81. package/dist/scripts/wrangler-config/types.js +1 -49
  82. package/dist/scripts/wrangler-config/types.js.map +7 -1
  83. package/dist/test/integration-migrations.d.ts +29 -12
  84. package/dist/test/integration-migrations.d.ts.map +1 -1
  85. package/dist/test/integration-migrations.js +2 -171
  86. package/dist/test/integration-migrations.js.map +7 -1
  87. package/dist/test/mocks/cloudflare-workers.js +1 -90
  88. package/dist/test/mocks/cloudflare-workers.js.map +7 -1
  89. package/dist/vite.d.ts +5 -3
  90. package/dist/vite.d.ts.map +1 -1
  91. package/dist/vite.js +3 -125
  92. package/dist/vite.js.map +7 -1
  93. package/dist/vitest-aliases.d.ts +90 -0
  94. package/dist/vitest-aliases.d.ts.map +1 -0
  95. package/dist/vitest-aliases.js +1 -0
  96. package/dist/vitest-aliases.js.map +7 -0
  97. package/dist/vitest-integration.d.ts +96 -0
  98. package/dist/vitest-integration.d.ts.map +1 -0
  99. package/dist/vitest-integration.js +1 -0
  100. package/dist/vitest-integration.js.map +7 -0
  101. package/dist/vitest-repo.d.ts +154 -0
  102. package/dist/vitest-repo.d.ts.map +1 -0
  103. package/dist/vitest-repo.js +1 -0
  104. package/dist/vitest-repo.js.map +7 -0
  105. package/dist/vitest-web.d.ts +76 -19
  106. package/dist/vitest-web.d.ts.map +1 -1
  107. package/dist/vitest-web.js +1 -72
  108. package/dist/vitest-web.js.map +7 -1
  109. package/dist/vitest.d.ts +70 -19
  110. package/dist/vitest.d.ts.map +1 -1
  111. package/dist/vitest.js +1 -128
  112. package/dist/vitest.js.map +7 -1
  113. package/package.json +9 -3
  114. package/src/eslint-boundaries.ts +112 -11
  115. package/src/eslint.test.ts +40 -9
  116. package/src/eslint.ts +14 -9
  117. package/src/functions/pages-proxy.test.ts +3 -3
  118. package/src/functions/pages-proxy.ts +4 -2
  119. package/src/index.ts +23 -14
  120. package/src/scripts/backup/backup-rules.test.ts +4 -4
  121. package/src/scripts/backup/d1-target.ts +16 -6
  122. package/src/scripts/backup/destination-config.ts +27 -9
  123. package/src/scripts/backup/encrypt-backup.ts +12 -10
  124. package/src/scripts/backup/naming.ts +3 -1
  125. package/src/scripts/check-god-files.test.ts +19 -19
  126. package/src/scripts/check-god-files.ts +62 -33
  127. package/src/scripts/ensure-spa-shell-stub.ts +1 -1
  128. package/src/scripts/init-secrets.ts +20 -10
  129. package/src/scripts/lib/cli-args.ts +6 -3
  130. package/src/scripts/lib/wrangler-table.ts +5 -3
  131. package/src/scripts/migrations-lock.ts +2 -2
  132. package/src/scripts/prepare-wrangler-config.ts +3 -3
  133. package/src/scripts/spa-shell.test.ts +18 -18
  134. package/src/scripts/spa-shell.ts +26 -14
  135. package/src/scripts/validate-locales.test.ts +18 -18
  136. package/src/scripts/validate-locales.ts +43 -25
  137. package/src/scripts/verify-migrations.test.ts +8 -8
  138. package/src/scripts/verify-migrations.ts +47 -24
  139. package/src/scripts/verify-spa-shell.ts +1 -1
  140. package/src/scripts/wrangler-config/patches.ts +13 -5
  141. package/src/scripts/wrangler-config/resources.ts +34 -18
  142. package/src/scripts/wrangler-config/types.ts +24 -8
  143. package/src/test/integration-migrations.test.ts +7 -7
  144. package/src/test/integration-migrations.ts +33 -14
  145. package/src/vite.test.ts +25 -14
  146. package/src/vite.ts +5 -5
  147. package/src/vitest-aliases.test.ts +53 -0
  148. package/src/vitest-aliases.ts +125 -0
  149. package/src/vitest-factories.test.ts +127 -0
  150. package/src/vitest-integration.ts +118 -0
  151. package/src/vitest-repo.ts +269 -0
  152. package/src/vitest-web.ts +110 -28
  153. package/src/vitest.ts +96 -47
package/dist/eslint.js CHANGED
@@ -1,189 +1 @@
1
- /**
2
- * The converged ESLint flat config for a monorepo in the Rexezuge family.
3
- *
4
- * Provenance: the base is Durable-DAV's `eslint.config.mjs` (380+ lines, the most
5
- * elaborate of the nine repos, with the layered `no-restricted-imports` boundary
6
- * rules). Merged in from the other three stacks that share the same plugin set:
7
- *
8
- * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
9
- * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
10
- * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary
11
- * guard and its `apps/web` layer block.
12
- * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
13
- * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses
14
- * `allowTypeImports` where the source repos do not. It is also the source for
15
- * the anchored skip patterns and the symlink-safe walk that came out of its own
16
- * backlog.
17
- *
18
- * Canonical decisions, and why each one:
19
- *
20
- * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at
21
- * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see
22
- * is a gate that has never run. Formatting drift is therefore a hard failure.
23
- * 2. **The layered boundary rules are parameterized by `scope`.** Every source
24
- * repo wrote the same seven blocks with a different npm scope hardcoded; the
25
- * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
26
- * The table itself lives in {@link ./eslint-boundaries}.
27
- * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
28
- * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
29
- * violations that nothing reported.
30
- * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`
31
- * package. Edge-Sonic is the only source with that block; the others had none,
32
- * which is how their layer table's "may import: the browser" was a convention
33
- * rather than a gate. A backend package imported by the SPA compiles and then
34
- * fails at bundle time, with the error pointing at the bundler.
35
- * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;
36
- * `apps/web` needs browser globals as well, and the vitest config for the SPA
37
- * runs under jsdom, so the lint environment matches the test environment.
38
- * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays
39
- * zero-dependency, and the plugin belongs to the app that has JSX. A consumer
40
- * appends it — the README shows the four lines.
41
- *
42
- * The rule bodies live in {@link ./eslint-rules} and the boundary table in
43
- * {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a
44
- * boundary the canonical table does not name passes `extraLayers` — see
45
- * {@link RepoLintConfigOptions}.
46
- */
47
- import globals from 'globals';
48
- import tseslint from 'typescript-eslint';
49
- import unicorn from 'eslint-plugin-unicorn';
50
- import { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';
51
- import pluginRegexp from 'eslint-plugin-regexp';
52
- import eslintConfigPrettier from 'eslint-config-prettier';
53
- import prettier from 'eslint-plugin-prettier';
54
- import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';
55
- import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';
56
- /**
57
- * Bridge a third-party preset into `tseslint.config()`.
58
- *
59
- * `sonarjs`' `recommended` preset is typed as a union that includes the legacy
60
- * config shape, which `tseslint.config()` does not accept — but ESLint accepts it
61
- * at runtime, which is the only thing that matters here. One checked assertion,
62
- * rather than forking the plugin's own types.
63
- */
64
- function asConfig(config) {
65
- return config;
66
- }
67
- /**
68
- * Bridge a rule block onto `tseslint.config()`'s `rules` field.
69
- *
70
- * The blocks in `eslint-rules.ts` are written as ESLint expects them —
71
- * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a
72
- * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`
73
- * union is narrower than the data shape, and widening every entry to that union
74
- * would buy nothing; one assertion here, with the reason, is the cheaper and
75
- * more honest of the two.
76
- */
77
- function asRules(block) {
78
- return block;
79
- }
80
- /**
81
- * Build the repo's flat config.
82
- *
83
- * Consumed from the repo root as three lines:
84
- *
85
- * ```js
86
- * // eslint.config.mjs
87
- * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';
88
- * export default defineRepoLintConfig({ scope: '@myapp' });
89
- * ```
90
- */
91
- export function defineRepoLintConfig(options) {
92
- const { scope } = options;
93
- const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;
94
- const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));
95
- const extra = options.extraLayers ?? [];
96
- const bans = [...canonical, ...extra];
97
- return tseslint.config({
98
- ignores: [
99
- 'eslint.config.mjs',
100
- 'eslint.config.js',
101
- 'scripts/**',
102
- 'worker-configuration.d.ts',
103
- 'local/**',
104
- 'app/dist/**',
105
- 'apps/web/dist/**',
106
- 'apps/*/dist/**',
107
- 'src/generated/**',
108
- 'apps/api/src/generated/**',
109
- 'coverage/**',
110
- 'coverage-integration/**',
111
- 'coverage-web/**',
112
- 'node_modules/**',
113
- ...(options.extraIgnores ?? []),
114
- ],
115
- },
116
- // Base: globals for all JS/TS source files. Node is the floor because the
117
- // scripts and the workers both run on it; the web block below adds browser
118
- // globals rather than replacing them, so a shared file that touches both
119
- // (there are several in `shared/`) still lints.
120
- {
121
- files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],
122
- languageOptions: {
123
- globals: globals.node,
124
- },
125
- },
126
- // Type-aware TS rules, scoped to TS files only.
127
- {
128
- files: ['**/*.{ts,mts,cts,tsx}'],
129
- extends: tseslint.configs.recommendedTypeChecked,
130
- languageOptions: {
131
- parserOptions: {
132
- projectService: true,
133
- tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),
134
- },
135
- },
136
- },
137
- // --- typescript-eslint overrides (identical in all four source stacks) ---
138
- {
139
- files: ['**/*.{ts,mts,cts,tsx}'],
140
- rules: asRules(TYPESCRIPT_RULES),
141
- },
142
- // --- Unicorn: modern JS/TS quality rules ---
143
- asConfig(unicorn.configs['flat/recommended']), {
144
- rules: asRules(UNICORN_RULES),
145
- },
146
- // --- SonarJS: code smell and bug detection ---
147
- asConfig(sonarjsConfigs.recommended), {
148
- rules: asRules(SONARJS_RULES),
149
- },
150
- // --- Regexp: static analysis for regular expressions ---
151
- asConfig(pluginRegexp.configs['flat/recommended']),
152
- // --- Prettier: formatting drift is a hard error ---
153
- //
154
- // Mail-Meow's decision, adopted repo-wide because the alternative is
155
- // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the
156
- // four source repos, and `--quiet` discards every warning, so a
157
- // `prettier/prettier` *warning* is a silent no-op. 242 files were in that
158
- // state in Edge-Sonic: the gate had never run.
159
- asConfig(eslintConfigPrettier), {
160
- plugins: { prettier },
161
- rules: {
162
- 'prettier/prettier': 'error',
163
- },
164
- },
165
- // --- Import direction guardrails (parameterized by scope) ---
166
- ...restrictedImports(bans), ...restrictedDynamicImports(bans),
167
- // --- Web: browser globals, matching the jsdom test environment ---
168
- //
169
- // The sources linted `apps/web` under `globals.node` only, so `window`,
170
- // `document` and `localStorage` read as undefined globals. The vitest web
171
- // config runs those suites under jsdom; the lint environment should agree
172
- // with the environment the code is executed in, or the rule is reporting
173
- // something untrue about how the file behaves.
174
- {
175
- files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],
176
- languageOptions: {
177
- globals: { ...globals.node, ...globals.browser },
178
- },
179
- },
180
- // --- Test suite ---
181
- //
182
- // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES
183
- // for the override block and the reasoning behind it.
184
- {
185
- files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],
186
- rules: asRules(TEST_RULES),
187
- });
188
- }
189
- //# sourceMappingURL=eslint.js.map
1
+ import t from"globals";import r from"typescript-eslint";import p from"eslint-plugin-unicorn";import{configs as f}from"eslint-plugin-sonarjs";import g from"eslint-plugin-regexp";import l from"eslint-config-prettier";import d from"eslint-plugin-prettier";import{DEFAULT_PROJECT_DIRS as u,layerBans as x,restrictedDynamicImports as j,restrictedImports as R}from"./eslint-boundaries.js";import{SONARJS_RULES as S,TEST_RULES as b,TYPESCRIPT_RULES as C,UNICORN_RULES as E}from"./eslint-rules.js";function y(s){return s}function P(s){return s}function N(s){const{scope:o}=s,i=s.projectDirs??u,n=x(o).filter(a=>i.some(m=>a.dir.startsWith(m))),c=s.extraLayers??[],e=[...n,...c];return r.config({ignores:["eslint.config.mjs","eslint.config.js","scripts/**","worker-configuration.d.ts","local/**","app/dist/**","apps/web/dist/**","apps/*/dist/**","src/generated/**","apps/api/src/generated/**","coverage/**","coverage-integration/**","coverage-web/**","node_modules/**",...s.extraIgnores??[]]},{files:["**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}"],languageOptions:{globals:t.node}},{files:["**/*.{ts,mts,cts,tsx}"],extends:r.configs.recommendedTypeChecked,languageOptions:{parserOptions:{projectService:!0,tsconfigRootDir:s.tsconfigRootDir??process.cwd()}}},{files:["**/*.{ts,mts,cts,tsx}"],rules:C},p.configs["flat/recommended"],{rules:E},f.recommended,{rules:S},g.configs["flat/recommended"],l,{plugins:{prettier:d},rules:{"prettier/prettier":"error"}},...R(e),...j(e),{files:["apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"],languageOptions:{globals:{...t.node,...t.browser}}},{files:["test/**/*.{ts,tsx,mts,cts}","**/*.test.{ts,tsx,mts,cts}","**/*.spec.{ts,tsx,mts,cts}"],rules:b})}export{N as defineRepoLintConfig};
@@ -1 +1,7 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAgD5F;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,MAAmB;IACnC,OAAO,MAAqB,CAAC;AAC/B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,OAAO,CAAC,KAAwC;IACvD,OAAO,KAAmC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAC;IAChE,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3G,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC;IAEtC,OAAO,QAAQ,CAAC,MAAM,CACpB;QACE,OAAO,EAAE;YACP,mBAAmB;YACnB,kBAAkB;YAClB,YAAY;YACZ,2BAA2B;YAC3B,UAAU;YACV,aAAa;YACb,kBAAkB;YAClB,gBAAgB;YAChB,kBAAkB;YAClB,2BAA2B;YAC3B,aAAa;YACb,yBAAyB;YACzB,iBAAiB;YACjB,iBAAiB;YACjB,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;SAChC;KACF;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,yEAAyE;IACzE,gDAAgD;IAChD;QACE,KAAK,EAAE,CAAC,sCAAsC,CAAC;QAC/C,eAAe,EAAE;YACf,OAAO,EAAE,OAAO,CAAC,IAAI;SACtB;KACF;IAED,gDAAgD;IAChD;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB;QAChD,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,cAAc,EAAE,IAAI;gBACpB,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,EAAE;aAC1D;SACF;KACF;IAED,4EAA4E;IAC5E;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC;KACjC;IAED,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAC7C;QACE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC;KAC9B;IAED,gDAAgD;IAChD,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EACpC;QACE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC;KAC9B;IAED,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAElD,qDAAqD;IACrD,EAAE;IACF,qEAAqE;IACrE,2EAA2E;IAC3E,gEAAgE;IAChE,0EAA0E;IAC1E,+CAA+C;IAC/C,QAAQ,CAAC,oBAAoB,CAAC,EAC9B;QACE,OAAO,EAAE,EAAE,QAAQ,EAAE;QACrB,KAAK,EAAE;YACL,mBAAmB,EAAE,OAAO;SAC7B;KACF;IAED,+DAA+D;IAC/D,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAC1B,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAEjC,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,+CAA+C;IAC/C;QACE,KAAK,EAAE,CAAC,+CAA+C,CAAC;QACxD,eAAe,EAAE;YACf,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;SACjD;KACF;IAED,qBAAqB;IACrB,EAAE;IACF,0EAA0E;IAC1E,sDAAsD;IACtD;QACE,KAAK,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC;QACjG,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (380+ lines, the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the other three stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same seven blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries}.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules} and the boundary table in\n * {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';\nimport type { LayerBan } from './eslint-boundaries';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/eslint.ts"],
4
+ "sourcesContent": ["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { LayerBan } from './eslint-boundaries.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"],
5
+ "mappings": "AAoDA,OAAOA,MAAa,UACpB,OAAOC,MAAc,oBACrB,OAAOC,MAAa,wBACpB,OAAS,WAAWC,MAAsB,wBAC1C,OAAOC,MAAkB,uBACzB,OAAOC,MAA0B,yBACjC,OAAOC,MAAc,yBAErB,OAAS,wBAAAC,EAAsB,aAAAC,EAAW,4BAAAC,EAA0B,qBAAAC,MAAyB,yBAE7F,OAAS,iBAAAC,EAAe,cAAAC,EAAY,oBAAAC,EAAkB,iBAAAC,MAAqB,oBAwD3E,SAASC,EAASC,EAAmB,CACnC,OAAOA,CACT,CAYA,SAASC,EAAQC,EAAwC,CACvD,OAAOA,CACT,CAaM,SAAUC,EAAqBC,EAA8B,CACjE,KAAM,CAAE,MAAAC,CAAK,EAAKD,EACZE,EAAcF,EAAQ,aAAeb,EACrCgB,EAAYf,EAAUa,CAAK,EAAE,OAAQG,GAAUF,EAAY,KAAMG,GAAQD,EAAM,IAAI,WAAWC,CAAG,CAAC,CAAC,EACnGC,EAAQN,EAAQ,aAAe,CAAA,EAC/BO,EAAO,CAAC,GAAGJ,EAAW,GAAGG,CAAK,EAEpC,OAAOzB,EAAS,OACd,CACE,QAAS,CACP,oBACA,mBACA,aACA,4BACA,WACA,cACA,mBACA,iBACA,mBACA,4BACA,cACA,0BACA,kBACA,kBACA,GAAImB,EAAQ,cAAgB,CAAA,IAQhC,CACE,MAAO,CAAC,sCAAsC,EAC9C,gBAAiB,CACf,QAASpB,EAAQ,OAKrB,CACE,MAAO,CAAC,uBAAuB,EAC/B,QAASC,EAAS,QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiBmB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeP,GAIRX,EAAQ,QAAQ,kBAAkB,EAC3C,CACE,MAAeY,GAIRX,EAAe,YACxB,CACE,MAAeQ,GAIRP,EAAa,QAAQ,kBAAkB,EASvCC,EACT,CACE,QAAS,CAAE,SAAAC,CAAQ,EACnB,MAAO,CACL,oBAAqB,UAKzB,GAAGI,EAAkBiB,CAAI,EACzB,GAAGlB,EAAyBkB,CAAI,EAShC,CACE,MAAO,CAAC,+CAA+C,EACvD,gBAAiB,CACf,QAAS,CAAE,GAAG3B,EAAQ,KAAM,GAAGA,EAAQ,OAAO,IAQlD,CACE,MAAO,CAAC,6BAA8B,6BAA8B,4BAA4B,EAChG,MAAeY,EAChB,CAEL",
6
+ "names": ["globals", "tseslint", "unicorn", "sonarjsConfigs", "pluginRegexp", "eslintConfigPrettier", "prettier", "DEFAULT_PROJECT_DIRS", "layerBans", "restrictedDynamicImports", "restrictedImports", "SONARJS_RULES", "TEST_RULES", "TYPESCRIPT_RULES", "UNICORN_RULES", "asConfig", "config", "asRules", "block", "defineRepoLintConfig", "options", "scope", "projectDirs", "canonical", "layer", "dir", "extra", "bans"]
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAgCjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa,CAuC/E"}
1
+ {"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAkCjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa,CAuC/E"}
@@ -1,131 +1 @@
1
- /**
2
- * The Cloudflare Pages catch-all proxy.
3
- *
4
- * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,
5
- * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an
6
- * `onRequest` handler that forwards the request to the API worker through a
7
- * service binding, rewriting the three headers the worker routes on.
8
- *
9
- * What each source contributes:
10
- *
11
- * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,
12
- * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the
13
- * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.
14
- * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*
15
- * delete `X-Forwarded-For` before conditionally setting it from
16
- * `CF-Connecting-IP`. Setting it only when the header was present left a
17
- * caller-supplied value intact on any request that reached Pages without
18
- * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.
19
- * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded
20
- * body is a stream. Without it this threw a `TypeError` on every non-GET
21
- * request rather than proxying it.
22
- * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally
23
- * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes
24
- * further and *never* sets `X-Forwarded-For` at all, because its worker keys
25
- * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on
26
- * purpose.
27
- *
28
- * ### The convergence decision on `X-Forwarded-For`
29
- *
30
- * The two families disagree, and the disagreement is about which worker is
31
- * behind the binding. Mail-Meow's behaviour is kept as the default because it is
32
- * the only one that preserves the client IP for the audit trail, which five repos
33
- * read. A repo whose worker refuses the header — Edge-Sonic's — passes
34
- * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*
35
- * available is the source repos' conditional `if (clientIp) set(...)`: that is
36
- * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it
37
- * would be a factory that carries the bug forward.
38
- *
39
- * ### `duplex: 'half'` rides with the body
40
- *
41
- * Required by the Fetch spec whenever a `Request` is constructed with a **stream**
42
- * body. workerd does not throw without it, which is why the line was absent from
43
- * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in
44
- * Edge-Sonic could not drive the handler at all. It is spread only where a body
45
- * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape
46
- * no runtime documents; the cast is `as RequestInit` either way, since `duplex`
47
- * is not in the DOM lib's type.
48
- *
49
- * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a
50
- * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared
51
- * here rather than imported from `@cloudflare/workers-types`, so the kit stays
52
- * zero-dependency and this module typechecks without the generated
53
- * `worker-configuration.d.ts`.
54
- */
55
- /**
56
- * Headers a *client* may have set, stripped before the request crosses the
57
- * binding.
58
- *
59
- * These describe the connection between the client and the proxy. Forwarding
60
- * them would let the origin believe the proxy's view of the client is the
61
- * client's own claim about itself. The three the proxy sets itself are set from
62
- * values it reads off the request, not from the client's headers.
63
- */
64
- const CLIENT_FORWARDING_HEADERS = [
65
- 'connection',
66
- 'keep-alive',
67
- 'proxy-authenticate',
68
- 'proxy-authorization',
69
- 'te',
70
- 'trailer',
71
- 'transfer-encoding',
72
- 'upgrade',
73
- 'X-Forwarded-For',
74
- 'X-Forwarded-Host',
75
- 'X-Forwarded-Proto',
76
- 'X-Forwarded-Uri',
77
- 'Forwarded',
78
- 'True-Client-IP',
79
- 'X-Real-Ip',
80
- ];
81
- /** The header Cloudflare sets with the socket's peer address. */
82
- const CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';
83
- /**
84
- * The `onRequest` handler for `functions/[[path]].ts`.
85
- *
86
- * Usage — the consumer's `functions/[[path]].ts` becomes two lines:
87
- *
88
- * ```ts
89
- * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';
90
- * export const onRequest = createPagesProxy();
91
- * ```
92
- *
93
- * @param options see {@link PagesProxyOptions}. Omitted gives the family's
94
- * majority behaviour.
95
- */
96
- export function createPagesProxy(options = {}) {
97
- const forwardClientIp = options.forwardClientIp ?? true;
98
- return async ({ request, env }) => {
99
- const originalUrl = new URL(request.url);
100
- const headers = new Headers(request.headers);
101
- for (const header of CLIENT_FORWARDING_HEADERS)
102
- headers.delete(header);
103
- // Set from values read off the request rather than from the client: only the
104
- // proxy knows which host it served, and a service binding hands over a
105
- // rewritten URL, so the original path is what has to be carried across.
106
- headers.set('X-Forwarded-Host', originalUrl.host);
107
- headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));
108
- headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);
109
- if (forwardClientIp) {
110
- const clientIp = request.headers.get(CF_CONNECTING_IP_HEADER);
111
- if (clientIp)
112
- headers.set('X-Forwarded-For', clientIp);
113
- }
114
- // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright
115
- // for those methods. The body is forwarded as a *stream*, so a large upload
116
- // does not have to fit in memory on the Pages side.
117
- const hasBody = request.method !== 'GET' && request.method !== 'HEAD';
118
- const proxyRequest = new Request(originalUrl.href, {
119
- method: request.method,
120
- headers,
121
- body: hasBody ? request.body : undefined,
122
- // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and
123
- // removing the cast would mean not forwarding bodies at all, which is a
124
- // worse answer than one assertion.
125
- ...(hasBody && { duplex: 'half' }),
126
- redirect: request.redirect,
127
- });
128
- return env.API_WORKER.fetch(proxyRequest);
129
- };
130
- }
131
- //# sourceMappingURL=pages-proxy.js.map
1
+ const s=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","X-Forwarded-For","X-Forwarded-Host","X-Forwarded-Proto","X-Forwarded-Uri","Forwarded","True-Client-IP","X-Real-Ip"],h="CF-Connecting-IP";function l(n={}){const a=n.forwardClientIp??!0;return async({request:e,env:c})=>{const o=new URL(e.url),r=new Headers(e.headers);for(const t of s)r.delete(t);if(r.set("X-Forwarded-Host",o.host),r.set("X-Forwarded-Proto",o.protocol.replace(":","")),r.set("X-Forwarded-Uri",`${o.pathname}${o.search}`),a){const t=e.headers.get(h);t&&r.set("X-Forwarded-For",t)}const d=e.method!=="GET"&&e.method!=="HEAD",i=new Request(o.href,{method:e.method,headers:r,body:d?e.body:void 0,...d&&{duplex:"half"},redirect:e.redirect});return c.API_WORKER.fetch(i)}}export{l as createPagesProxy};
@@ -1 +1,7 @@
1
- {"version":3,"file":"pages-proxy.js","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAqCH;;;;;;;;GAQG;AACH,MAAM,yBAAyB,GAAsB;IACnD,YAAY;IACZ,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;IACT,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,WAAW;IACX,gBAAgB;IAChB,WAAW;CACZ,CAAC;AAEF,iEAAiE;AACjE,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAgBnD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA6B,EAAE;IAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;IAExD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAwB,EAAqB,EAAE;QACzE,MAAM,WAAW,GAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAE9C,MAAM,OAAO,GAAY,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtD,KAAK,MAAM,MAAM,IAAI,yBAAyB;YAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEvE,6EAA6E;QAC7E,uEAAuE;QACvE,wEAAwE;QACxE,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/E,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,QAAQ,GAAkB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAC7E,IAAI,QAAQ;gBAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;QAED,4EAA4E;QAC5E,4EAA4E;QAC5E,oDAAoD;QACpD,MAAM,OAAO,GAAY,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC;QAE/E,MAAM,YAAY,GAAY,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE;YAC1D,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACxC,2EAA2E;YAC3E,wEAAwE;YACxE,mCAAmC;YACnC,GAAG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SACZ,CAAC,CAAC;QAElB,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The Cloudflare Pages catch-all proxy.\n *\n * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,\n * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an\n * `onRequest` handler that forwards the request to the API worker through a\n * service binding, rewriting the three headers the worker routes on.\n *\n * What each source contributes:\n *\n * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,\n * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the\n * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.\n * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*\n * delete `X-Forwarded-For` before conditionally setting it from\n * `CF-Connecting-IP`. Setting it only when the header was present left a\n * caller-supplied value intact on any request that reached Pages without\n * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.\n * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded\n * body is a stream. Without it this threw a `TypeError` on every non-GET\n * request rather than proxying it.\n * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally\n * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes\n * further and *never* sets `X-Forwarded-For` at all, because its worker keys\n * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on\n * purpose.\n *\n * ### The convergence decision on `X-Forwarded-For`\n *\n * The two families disagree, and the disagreement is about which worker is\n * behind the binding. Mail-Meow's behaviour is kept as the default because it is\n * the only one that preserves the client IP for the audit trail, which five repos\n * read. A repo whose worker refuses the header — Edge-Sonic's — passes\n * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*\n * available is the source repos' conditional `if (clientIp) set(...)`: that is\n * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it\n * would be a factory that carries the bug forward.\n *\n * ### `duplex: 'half'` rides with the body\n *\n * Required by the Fetch spec whenever a `Request` is constructed with a **stream**\n * body. workerd does not throw without it, which is why the line was absent from\n * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in\n * Edge-Sonic could not drive the handler at all. It is spread only where a body\n * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape\n * no runtime documents; the cast is `as RequestInit` either way, since `duplex`\n * is not in the DOM lib's type.\n *\n * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a\n * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared\n * here rather than imported from `@cloudflare/workers-types`, so the kit stays\n * zero-dependency and this module typechecks without the generated\n * `worker-configuration.d.ts`.\n */\n\n/**\n * The subset of Cloudflare's `Fetcher` this proxy uses.\n *\n * Structural, not imported: the shim only ever calls `fetch`, and requiring\n * `@cloudflare/workers-types` for one method would couple the kit to a generated\n * types file that only exists inside a Wrangler project.\n */\nexport interface Fetcher {\n fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * The environment a Pages Function is invoked with.\n */\nexport interface PagesProxyEnv {\n readonly API_WORKER: Fetcher;\n}\n\n/**\n * The context Cloudflare passes to `onRequest`.\n *\n * Only the fields this proxy reads are declared. `params` and `waitUntil` are\n * omitted because the catch-all does not use them — a shim that named them would\n * be claiming a contract it does not exercise.\n */\nexport interface PagesFunctionContext {\n readonly request: Request;\n readonly env: PagesProxyEnv;\n}\n\n/**\n * A Pages Function handler.\n */\nexport type PagesFunction = (context: PagesFunctionContext) => Promise<Response>;\n\n/**\n * Headers a *client* may have set, stripped before the request crosses the\n * binding.\n *\n * These describe the connection between the client and the proxy. Forwarding\n * them would let the origin believe the proxy's view of the client is the\n * client's own claim about itself. The three the proxy sets itself are set from\n * values it reads off the request, not from the client's headers.\n */\nconst CLIENT_FORWARDING_HEADERS: readonly string[] = [\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'X-Forwarded-For',\n 'X-Forwarded-Host',\n 'X-Forwarded-Proto',\n 'X-Forwarded-Uri',\n 'Forwarded',\n 'True-Client-IP',\n 'X-Real-Ip',\n];\n\n/** The header Cloudflare sets with the socket's peer address. */\nconst CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';\n\n/**\n * What `createPagesProxy` accepts.\n */\nexport interface PagesProxyOptions {\n /**\n * Set `X-Forwarded-For` from `CF-Connecting-IP`.\n *\n * Default `true` — Mail-Meow's behaviour, which five repos rely on for their\n * audit trail. Pass `false` for a worker that refuses the header outright\n * (Edge-Sonic's does), and the header is deleted and nothing set.\n */\n readonly forwardClientIp?: boolean;\n}\n\n/**\n * The `onRequest` handler for `functions/[[path]].ts`.\n *\n * Usage — the consumer's `functions/[[path]].ts` becomes two lines:\n *\n * ```ts\n * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';\n * export const onRequest = createPagesProxy();\n * ```\n *\n * @param options see {@link PagesProxyOptions}. Omitted gives the family's\n * majority behaviour.\n */\nexport function createPagesProxy(options: PagesProxyOptions = {}): PagesFunction {\n const forwardClientIp = options.forwardClientIp ?? true;\n\n return async ({ request, env }: PagesFunctionContext): Promise<Response> => {\n const originalUrl: URL = new URL(request.url);\n\n const headers: Headers = new Headers(request.headers);\n for (const header of CLIENT_FORWARDING_HEADERS) headers.delete(header);\n\n // Set from values read off the request rather than from the client: only the\n // proxy knows which host it served, and a service binding hands over a\n // rewritten URL, so the original path is what has to be carried across.\n headers.set('X-Forwarded-Host', originalUrl.host);\n headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));\n headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);\n\n if (forwardClientIp) {\n const clientIp: string | null = request.headers.get(CF_CONNECTING_IP_HEADER);\n if (clientIp) headers.set('X-Forwarded-For', clientIp);\n }\n\n // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright\n // for those methods. The body is forwarded as a *stream*, so a large upload\n // does not have to fit in memory on the Pages side.\n const hasBody: boolean = request.method !== 'GET' && request.method !== 'HEAD';\n\n const proxyRequest: Request = new Request(originalUrl.href, {\n method: request.method,\n headers,\n body: hasBody ? request.body : undefined,\n // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and\n // removing the cast would mean not forwarding bodies at all, which is a\n // worse answer than one assertion.\n ...(hasBody && { duplex: 'half' }),\n redirect: request.redirect,\n } as RequestInit);\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/functions/pages-proxy.ts"],
4
+ "sourcesContent": ["/**\n * The Cloudflare Pages catch-all proxy.\n *\n * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,\n * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an\n * `onRequest` handler that forwards the request to the API worker through a\n * service binding, rewriting the three headers the worker routes on.\n *\n * What each source contributes:\n *\n * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,\n * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the\n * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.\n * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*\n * delete `X-Forwarded-For` before conditionally setting it from\n * `CF-Connecting-IP`. Setting it only when the header was present left a\n * caller-supplied value intact on any request that reached Pages without\n * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.\n * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded\n * body is a stream. Without it this threw a `TypeError` on every non-GET\n * request rather than proxying it.\n * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally\n * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes\n * further and *never* sets `X-Forwarded-For` at all, because its worker keys\n * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on\n * purpose.\n *\n * ### The convergence decision on `X-Forwarded-For`\n *\n * The two families disagree, and the disagreement is about which worker is\n * behind the binding. Mail-Meow's behaviour is kept as the default because it is\n * the only one that preserves the client IP for the audit trail, which five repos\n * read. A repo whose worker refuses the header — Edge-Sonic's — passes\n * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*\n * available is the source repos' conditional `if (clientIp) set(...)`: that is\n * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it\n * would be a factory that carries the bug forward.\n *\n * ### `duplex: 'half'` rides with the body\n *\n * Required by the Fetch spec whenever a `Request` is constructed with a **stream**\n * body. workerd does not throw without it, which is why the line was absent from\n * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in\n * Edge-Sonic could not drive the handler at all. It is spread only where a body\n * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape\n * no runtime documents; the cast is `as RequestInit` either way, since `duplex`\n * is not in the DOM lib's type.\n *\n * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a\n * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared\n * here rather than imported from `@cloudflare/workers-types`, so the kit stays\n * zero-dependency and this module typechecks without the generated\n * `worker-configuration.d.ts`.\n */\n\n/**\n * The subset of Cloudflare's `Fetcher` this proxy uses.\n *\n * Structural, not imported: the shim only ever calls `fetch`, and requiring\n * `@cloudflare/workers-types` for one method would couple the kit to a generated\n * types file that only exists inside a Wrangler project.\n */\nexport interface Fetcher {\n fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * The environment a Pages Function is invoked with.\n */\nexport interface PagesProxyEnv {\n readonly API_WORKER: Fetcher;\n}\n\n/**\n * The context Cloudflare passes to `onRequest`.\n *\n * Only the fields this proxy reads are declared. `params` and `waitUntil` are\n * omitted because the catch-all does not use them — a shim that named them would\n * be claiming a contract it does not exercise.\n */\nexport interface PagesFunctionContext {\n readonly request: Request;\n readonly env: PagesProxyEnv;\n}\n\n/**\n * A Pages Function handler.\n */\nexport type PagesFunction = (context: PagesFunctionContext) => Promise<Response>;\n\n/**\n * Headers a *client* may have set, stripped before the request crosses the\n * binding.\n *\n * These describe the connection between the client and the proxy. Forwarding\n * them would let the origin believe the proxy's view of the client is the\n * client's own claim about itself. The three the proxy sets itself are set from\n * values it reads off the request, not from the client's headers.\n */\nconst CLIENT_FORWARDING_HEADERS: readonly string[] = [\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'X-Forwarded-For',\n 'X-Forwarded-Host',\n 'X-Forwarded-Proto',\n 'X-Forwarded-Uri',\n 'Forwarded',\n 'True-Client-IP',\n 'X-Real-Ip',\n];\n\n/**\nThe header Cloudflare sets with the socket's peer address.\n*/\nconst CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';\n\n/**\n * What `createPagesProxy` accepts.\n */\nexport interface PagesProxyOptions {\n /**\n * Set `X-Forwarded-For` from `CF-Connecting-IP`.\n *\n * Default `true` — Mail-Meow's behaviour, which five repos rely on for their\n * audit trail. Pass `false` for a worker that refuses the header outright\n * (Edge-Sonic's does), and the header is deleted and nothing set.\n */\n readonly forwardClientIp?: boolean;\n}\n\n/**\n * The `onRequest` handler for `functions/[[path]].ts`.\n *\n * Usage — the consumer's `functions/[[path]].ts` becomes two lines:\n *\n * ```ts\n * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';\n * export const onRequest = createPagesProxy();\n * ```\n *\n * @param options see {@link PagesProxyOptions}. Omitted gives the family's\n * majority behaviour.\n */\nexport function createPagesProxy(options: PagesProxyOptions = {}): PagesFunction {\n const forwardClientIp = options.forwardClientIp ?? true;\n\n return async ({ request, env }: PagesFunctionContext): Promise<Response> => {\n const originalUrl: URL = new URL(request.url);\n\n const headers: Headers = new Headers(request.headers);\n for (const header of CLIENT_FORWARDING_HEADERS) headers.delete(header);\n\n // Set from values read off the request rather than from the client: only the\n // proxy knows which host it served, and a service binding hands over a\n // rewritten URL, so the original path is what has to be carried across.\n headers.set('X-Forwarded-Host', originalUrl.host);\n headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));\n headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);\n\n if (forwardClientIp) {\n const clientIp: string | null = request.headers.get(CF_CONNECTING_IP_HEADER);\n if (clientIp) headers.set('X-Forwarded-For', clientIp);\n }\n\n // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright\n // for those methods. The body is forwarded as a *stream*, so a large upload\n // does not have to fit in memory on the Pages side.\n const hasBody: boolean = request.method !== 'GET' && request.method !== 'HEAD';\n\n const proxyRequest: Request = new Request(originalUrl.href, {\n method: request.method,\n headers,\n body: hasBody ? request.body : undefined,\n // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and\n // removing the cast would mean not forwarding bodies at all, which is a\n // worse answer than one assertion.\n ...(hasBody && { duplex: 'half' }),\n redirect: request.redirect,\n });\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"],
5
+ "mappings": "AAmGA,MAAMA,EAA+C,CACnD,aACA,aACA,qBACA,sBACA,KACA,UACA,oBACA,UACA,kBACA,mBACA,oBACA,kBACA,YACA,iBACA,aAMIC,EAA0B,mBA6B1B,SAAUC,EAAiBC,EAA6B,CAAA,EAAE,CAC9D,MAAMC,EAAkBD,EAAQ,iBAAmB,GAEnD,MAAO,OAAO,CAAE,QAAAE,EAAS,IAAAC,CAAG,IAA+C,CACzE,MAAMC,EAAmB,IAAI,IAAIF,EAAQ,GAAG,EAEtCG,EAAmB,IAAI,QAAQH,EAAQ,OAAO,EACpD,UAAWI,KAAUT,EAA2BQ,EAAQ,OAAOC,CAAM,EASrE,GAJAD,EAAQ,IAAI,mBAAoBD,EAAY,IAAI,EAChDC,EAAQ,IAAI,oBAAqBD,EAAY,SAAS,QAAQ,IAAK,EAAE,CAAC,EACtEC,EAAQ,IAAI,kBAAmB,GAAGD,EAAY,QAAQ,GAAGA,EAAY,MAAM,EAAE,EAEzEH,EAAiB,CACnB,MAAMM,EAA0BL,EAAQ,QAAQ,IAAIJ,CAAuB,EACvES,GAAUF,EAAQ,IAAI,kBAAmBE,CAAQ,CACvD,CAKA,MAAMC,EAAmBN,EAAQ,SAAW,OAASA,EAAQ,SAAW,OAElEO,EAAwB,IAAI,QAAQL,EAAY,KAAM,CAC1D,OAAQF,EAAQ,OAChB,QAAAG,EACA,KAAMG,EAAUN,EAAQ,KAAO,OAI/B,GAAIM,GAAW,CAAE,OAAQ,MAAM,EAC/B,SAAUN,EAAQ,SACnB,EAED,OAAOC,EAAI,WAAW,MAAMM,CAAY,CAC1C,CACF",
6
+ "names": ["CLIENT_FORWARDING_HEADERS", "CF_CONNECTING_IP_HEADER", "createPagesProxy", "options", "forwardClientIp", "request", "env", "originalUrl", "headers", "header", "clientIp", "hasBody", "proxyRequest"]
7
+ }
package/dist/index.d.ts CHANGED
@@ -14,18 +14,24 @@
14
14
  * and is only ever resolved in the consumer's repo, where the kit is installed
15
15
  * alongside `@rexezuge/d1`.
16
16
  */
17
- export { defineRepoLintConfig } from './eslint';
18
- export type { RepoLintConfigOptions } from './eslint';
19
- export { defineUnitVitestConfig } from './vitest';
20
- export type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest';
21
- export { defineWebVitestConfig } from './vitest-web';
22
- export type { WebVitestConfigOptions } from './vitest-web';
23
- export { defineWebViteConfig, spaShellEmbedPlugin } from './vite';
24
- export type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite';
25
- export { createPagesProxy } from './functions/pages-proxy';
26
- export type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy';
27
- export { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers';
28
- export type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers';
29
- export { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations';
30
- export type { D1DatabaseLike, D1PreparedStatementLike, MigrationFile, MigrationHelper, MigrationHelperOptions, MigrationRange, } from './test/integration-migrations';
17
+ export { defineRepoLintConfig } from './eslint.ts';
18
+ export type { RepoLintConfigOptions } from './eslint.ts';
19
+ export { defineUnitVitestConfig } from './vitest.ts';
20
+ export type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest.ts';
21
+ export { defineWebVitestConfig } from './vitest-web.ts';
22
+ export type { WebVitestConfigOptions } from './vitest-web.ts';
23
+ export { defineRepoVitestConfig } from './vitest-repo.ts';
24
+ export type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';
25
+ export { defineIntegrationVitestConfig } from './vitest-integration.ts';
26
+ export type { IntegrationVitestConfigOptions } from './vitest-integration.ts';
27
+ export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
28
+ export type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';
29
+ export { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';
30
+ export type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';
31
+ export { createPagesProxy } from './functions/pages-proxy.ts';
32
+ export type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy.ts';
33
+ export { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers.ts';
34
+ export type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers.ts';
35
+ export { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations.ts';
36
+ export type { D1DatabaseLike, D1PreparedStatementLike, MigrationFile, MigrationHelper, MigrationHelperOptions, MigrationRange, } from './test/integration-migrations.ts';
31
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO9H,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACpG,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9H,YAAY,EAAE,WAAW,IAAI,cAAc,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOjI,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAClG,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvG,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -1,28 +1 @@
1
- /**
2
- * `@rexezuge/tooling` — the tooling layer of the kit.
3
- *
4
- * The config factories and the test helpers are re-exported here, so a consumer has
5
- * one import for everything its `*.config.mts` files and its mocks need. The
6
- * scripts under `scripts/` are **not** re-exported: they resolve paths relative to
7
- * the repository they run in, so they are run from disk with `tsx`, not imported.
8
- * See `README.md` for the copy-in recipe and the per-script usage.
9
- *
10
- * The zero-dependency rule: nothing here imports another `@rexezuge/*` package. The
11
- * one exception in the tree is `scripts/backup/encrypt-backup.ts`, which uses
12
- * `@rexezuge/d1`'s AES-GCM so the backup and the workers share one definition of
13
- * "what an encryption key looks like"; that dependency is declared on the package
14
- * and is only ever resolved in the consumer's repo, where the kit is installed
15
- * alongside `@rexezuge/d1`.
16
- */
17
- export { defineRepoLintConfig } from './eslint';
18
- export { defineUnitVitestConfig } from './vitest';
19
- export { defineWebVitestConfig } from './vitest-web';
20
- export { defineWebViteConfig, spaShellEmbedPlugin } from './vite';
21
- export { createPagesProxy } from './functions/pages-proxy';
22
- // --- Test helpers ---------------------------------------------------------
23
- //
24
- // Aliased in a Vitest config, not imported by application code, so the mocks stay
25
- // where the suites can reach them.
26
- export { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers';
27
- export { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations';
28
- //# sourceMappingURL=index.js.map
1
+ import{defineRepoLintConfig as r}from"./eslint.js";import{defineUnitVitestConfig as i}from"./vitest.js";import{defineWebVitestConfig as n}from"./vitest-web.js";import{defineRepoVitestConfig as a}from"./vitest-repo.js";import{defineIntegrationVitestConfig as m}from"./vitest-integration.js";import{DEFAULT_CLOUDFLARE_MOCKS as x,DEFAULT_WORKSPACE_PACKAGES as l,KIT_NO_EXTERNAL as C,workspaceAliases as E}from"./vitest-aliases.js";import{defineWebViteConfig as A,spaShellEmbedPlugin as L}from"./vite.js";import{createPagesProxy as _}from"./functions/pages-proxy.js";import{DurableObject as c,RpcTarget as O,WorkflowEntrypoint as P}from"./test/mocks/cloudflare-workers.js";import{createMigrationHelper as T,readMigrationFiles as V,splitSql as D}from"./test/integration-migrations.js";export{x as DEFAULT_CLOUDFLARE_MOCKS,l as DEFAULT_WORKSPACE_PACKAGES,c as DurableObject,C as KIT_NO_EXTERNAL,O as RpcTarget,P as WorkflowEntrypoint,T as createMigrationHelper,_ as createPagesProxy,m as defineIntegrationVitestConfig,r as defineRepoLintConfig,a as defineRepoVitestConfig,i as defineUnitVitestConfig,A as defineWebViteConfig,n as defineWebVitestConfig,V as readMigrationFiles,L as spaShellEmbedPlugin,D as splitSql,E as workspaceAliases};
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,6EAA6E;AAC7E,EAAE;AACF,kFAAkF;AAClF,mCAAmC;AAEnC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["/**\n * `@rexezuge/tooling` — the tooling layer of the kit.\n *\n * The config factories and the test helpers are re-exported here, so a consumer has\n * one import for everything its `*.config.mts` files and its mocks need. The\n * scripts under `scripts/` are **not** re-exported: they resolve paths relative to\n * the repository they run in, so they are run from disk with `tsx`, not imported.\n * See `README.md` for the copy-in recipe and the per-script usage.\n *\n * The zero-dependency rule: nothing here imports another `@rexezuge/*` package. The\n * one exception in the tree is `scripts/backup/encrypt-backup.ts`, which uses\n * `@rexezuge/d1`'s AES-GCM so the backup and the workers share one definition of\n * \"what an encryption key looks like\"; that dependency is declared on the package\n * and is only ever resolved in the consumer's repo, where the kit is installed\n * alongside `@rexezuge/d1`.\n */\n\nexport { defineRepoLintConfig } from './eslint';\nexport type { RepoLintConfigOptions } from './eslint';\n\nexport { defineUnitVitestConfig } from './vitest';\nexport type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest';\n\nexport { defineWebVitestConfig } from './vitest-web';\nexport type { WebVitestConfigOptions } from './vitest-web';\n\nexport { defineWebViteConfig, spaShellEmbedPlugin } from './vite';\nexport type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite';\n\nexport { createPagesProxy } from './functions/pages-proxy';\nexport type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy';\n\n// --- Test helpers ---------------------------------------------------------\n//\n// Aliased in a Vitest config, not imported by application code, so the mocks stay\n// where the suites can reach them.\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers';\nexport type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers';\n\nexport { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations';\nexport type {\n D1DatabaseLike,\n D1PreparedStatementLike,\n MigrationFile,\n MigrationHelper,\n MigrationHelperOptions,\n MigrationRange,\n} from './test/integration-migrations';\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * `@rexezuge/tooling` — the tooling layer of the kit.\n *\n * The config factories and the test helpers are re-exported here, so a consumer has\n * one import for everything its `*.config.mts` files and its mocks need. The\n * scripts under `scripts/` are **not** re-exported: they resolve paths relative to\n * the repository they run in, so they are run from disk with `tsx`, not imported.\n * See `README.md` for the copy-in recipe and the per-script usage.\n *\n * The zero-dependency rule: nothing here imports another `@rexezuge/*` package. The\n * one exception in the tree is `scripts/backup/encrypt-backup.ts`, which uses\n * `@rexezuge/d1`'s AES-GCM so the backup and the workers share one definition of\n * \"what an encryption key looks like\"; that dependency is declared on the package\n * and is only ever resolved in the consumer's repo, where the kit is installed\n * alongside `@rexezuge/d1`.\n */\n\nexport { defineRepoLintConfig } from './eslint.ts';\nexport type { RepoLintConfigOptions } from './eslint.ts';\n\nexport { defineUnitVitestConfig } from './vitest.ts';\nexport type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest.ts';\n\nexport { defineWebVitestConfig } from './vitest-web.ts';\nexport type { WebVitestConfigOptions } from './vitest-web.ts';\n\nexport { defineRepoVitestConfig } from './vitest-repo.ts';\nexport type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';\n\nexport { defineIntegrationVitestConfig } from './vitest-integration.ts';\nexport type { IntegrationVitestConfigOptions } from './vitest-integration.ts';\n\nexport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nexport type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';\n\nexport { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';\nexport type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';\n\nexport { createPagesProxy } from './functions/pages-proxy.ts';\nexport type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy.ts';\n\n// --- Test helpers ---------------------------------------------------------\n//\n// Aliased in a Vitest config, not imported by application code, so the mocks stay\n// where the suites can reach them.\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers.ts';\nexport type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers.ts';\n\nexport { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations.ts';\nexport type {\n D1DatabaseLike,\n D1PreparedStatementLike,\n MigrationFile,\n MigrationHelper,\n MigrationHelperOptions,\n MigrationRange,\n} from './test/integration-migrations.ts';\n"],
5
+ "mappings": "AAiBA,OAAS,wBAAAA,MAA4B,cAGrC,OAAS,0BAAAC,MAA8B,cAGvC,OAAS,yBAAAC,MAA6B,kBAGtC,OAAS,0BAAAC,MAA8B,mBAGvC,OAAS,iCAAAC,MAAqC,0BAG9C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAGxG,OAAS,uBAAAC,EAAqB,uBAAAC,MAA2B,YAGzD,OAAS,oBAAAC,MAAwB,6BAQjC,OAAS,iBAAAC,EAAe,aAAAC,EAAW,sBAAAC,MAA0B,qCAG7D,OAAS,yBAAAC,EAAuB,sBAAAC,EAAoB,YAAAC,MAAgB",
6
+ "names": ["defineRepoLintConfig", "defineUnitVitestConfig", "defineWebVitestConfig", "defineRepoVitestConfig", "defineIntegrationVitestConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "defineWebViteConfig", "spaShellEmbedPlugin", "createPagesProxy", "DurableObject", "RpcTarget", "WorkflowEntrypoint", "createMigrationHelper", "readMigrationFiles", "splitSql"]
7
+ }
@@ -5,19 +5,29 @@
5
5
  * empty-database guard is asserted without running Actions or touching a real
6
6
  * account.
7
7
  */
8
- /** A D1 binding as a parsed wrangler config carries one. */
8
+ /**
9
+ A D1 binding as a parsed wrangler config carries one.
10
+ */
9
11
  export interface D1DatabaseBinding {
10
12
  binding?: string;
11
13
  database_id?: string;
12
14
  database_name?: string;
13
15
  }
14
- /** The resolved export target. */
16
+ /**
17
+ The resolved export target.
18
+ */
15
19
  export interface D1Target {
16
- /** The binding name, used for log output and as the export fallback. */
20
+ /**
21
+ The binding name, used for log output and as the export fallback.
22
+ */
17
23
  binding: string;
18
- /** The database id, verified against Cloudflare by the caller. */
24
+ /**
25
+ The database id, verified against Cloudflare by the caller.
26
+ */
19
27
  databaseId: string;
20
- /** What `wrangler d1 export` should be pointed at. */
28
+ /**
29
+ What `wrangler d1 export` should be pointed at.
30
+ */
21
31
  target: string;
22
32
  }
23
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"d1-target.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/d1-target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,kCAAkC;AAClC,MAAM,WAAW,QAAQ;IACvB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAAG,QAAQ,CAiBxF"}
1
+ {"version":3,"file":"d1-target.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/d1-target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;EAEE;AACF,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;EAEE;AACF,MAAM,WAAW,QAAQ;IACvB;;MAEE;IACF,OAAO,EAAE,MAAM,CAAC;IAChB;;MAEE;IACF,UAAU,EAAE,MAAM,CAAC;IACnB;;MAEE;IACF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAAG,QAAQ,CAiBxF"}