@gradial/aci 0.1.36 → 0.1.38

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.
@@ -244,7 +244,11 @@ function edgeKeySegment(value) {
244
244
  return value.replace(/[^A-Za-z0-9_-]/g, '_');
245
245
  }
246
246
  function isAssetPath(pathname) {
247
- return pathname === ASSET_PREFIX || pathname.startsWith(`${ASSET_PREFIX}/`);
247
+ if (pathname === ASSET_PREFIX || pathname.startsWith(`${ASSET_PREFIX}/`))
248
+ return true;
249
+ if (pathname.startsWith('/gradial/assets/'))
250
+ return true;
251
+ return false;
248
252
  }
249
253
  function isPassthroughRoute(pathname) {
250
254
  return PASSTHROUGH_ROUTES.some((route) => routeMatches(pathname, route));
@@ -56,7 +56,9 @@ function resolveChecks(input) {
56
56
  export function runConformanceChecks(options) {
57
57
  const ctx = {
58
58
  framework: options.framework,
59
- siteId: options.siteId,
59
+ // 'env' mode carries no site identity in the repo; checks never compare
60
+ // against a value, so the context uses the empty string.
61
+ siteId: options.siteId ?? '',
60
62
  rootDir: options.rootDir || process.cwd(),
61
63
  siteIdMode: options.siteIdMode || 'literal',
62
64
  };
@@ -83,7 +85,9 @@ export function conformancePreset(options) {
83
85
  test('ACI conformance', async (t) => {
84
86
  const ctx = {
85
87
  framework: options.framework,
86
- siteId: options.siteId,
88
+ // 'env' mode carries no site identity in the repo; checks never compare
89
+ // against a value, so the context uses the empty string.
90
+ siteId: options.siteId ?? '',
87
91
  rootDir: options.rootDir || process.cwd(),
88
92
  siteIdMode: options.siteIdMode || 'literal',
89
93
  };
@@ -8,35 +8,48 @@
8
8
  export type ConformanceFramework = 'next' | 'astro';
9
9
  /** Individual check names that can be enabled/disabled. */
10
10
  export type ConformanceCheckName = 'config' | 'registry' | 'pageEntry' | 'middleware' | 'noFileContentProvider' | 'noCustomContent' | 'noLegacyAssetRoute' | 'buildSucceeds' | 'contentCompile' | 'sdkVersion';
11
- /** Options for the conformance preset. */
12
- export interface ConformancePresetOptions {
11
+ /** Options common to both siteId modes. */
12
+ export interface ConformancePresetCommonOptions {
13
13
  /** Framework the site uses. */
14
14
  framework: ConformanceFramework;
15
- /** Expected siteId value (verified in config and middleware). */
16
- siteId: string;
17
15
  /** Root directory of the site project. Defaults to process.cwd(). */
18
16
  rootDir?: string;
19
- /**
20
- * How the middleware is expected to obtain its siteId. Defaults to 'literal'.
21
- *
22
- * - 'literal': the middleware passes the canonical siteId as a string
23
- * literal (or `process.env.ACI_SITE_ID || '<canonical>'` / `??` with the
24
- * canonical literal as the default). This is what the template stamps for
25
- * single-tenant repos.
26
- * - 'env': the middleware must read siteId ONLY from the environment —
27
- * exactly `siteId: process.env.ACI_SITE_ID`, with no literal default, no
28
- * `||`/`??` fallback, no other env var names, and no computed
29
- * expressions. Use this for tenant-agnostic repos deployed to multiple
30
- * sites (the platform owns tenant identity and injects ACI_SITE_ID per
31
- * deployment; a missing env produces a clean 500 at runtime).
32
- */
33
- siteIdMode?: 'literal' | 'env';
34
17
  /**
35
18
  * Which checks to run. Defaults to all checks.
36
19
  * Pass an array to run only those checks, or an object to enable/disable individually.
37
20
  */
38
21
  checks?: ConformanceCheckName[] | Partial<Record<ConformanceCheckName, boolean>>;
39
22
  }
23
+ /**
24
+ * Options for the conformance preset.
25
+ *
26
+ * The siteId requirement is keyed off `siteIdMode` (defaults to 'literal'):
27
+ *
28
+ * - 'literal': `siteId` is REQUIRED — it is the tenant's canonical site id,
29
+ * and the middleware must pass it as a string literal (or
30
+ * `process.env.ACI_SITE_ID || '<canonical>'` / `??` with the canonical
31
+ * literal as the default). This is what the template stamps for
32
+ * single-tenant repos.
33
+ * - 'env': `siteId` is FORBIDDEN — tenant-agnostic repos deployed to
34
+ * multiple sites have no site identity in the repo at all. The middleware
35
+ * must read siteId ONLY from the environment — exactly
36
+ * `siteId: process.env.ACI_SITE_ID`, with no literal default, no
37
+ * `||`/`??` fallback, no other env var names, and no computed
38
+ * expressions — and `.aci.yaml` must not pin a siteId. The platform owns
39
+ * tenant identity and injects ACI_SITE_ID per deployment; a missing env
40
+ * produces a clean 500 at runtime.
41
+ */
42
+ export type ConformancePresetOptions = ConformancePresetCommonOptions & ({
43
+ /** See ConformancePresetOptions: 'literal' expects a canonical siteId in the repo. */
44
+ siteIdMode?: 'literal';
45
+ /** Expected canonical siteId value (verified in config and middleware). */
46
+ siteId: string;
47
+ } | {
48
+ /** See ConformancePresetOptions: 'env' means the repo carries no site identity. */
49
+ siteIdMode: 'env';
50
+ /** Forbidden in env mode — the repo must not carry a site identity. */
51
+ siteId?: never;
52
+ });
40
53
  /** Result of a single conformance check. */
41
54
  export interface ConformanceCheckResult {
42
55
  name: ConformanceCheckName;
@@ -55,6 +68,10 @@ export type ConformanceCheckFn = (ctx: ConformanceContext) => ConformanceCheckRe
55
68
  /** Context passed to each check function. */
56
69
  export interface ConformanceContext {
57
70
  framework: ConformanceFramework;
71
+ /**
72
+ * Canonical siteId in 'literal' mode; '' in 'env' mode (no site identity
73
+ * in the repo — env-mode checks never compare against a value).
74
+ */
58
75
  siteId: string;
59
76
  rootDir: string;
60
77
  /** See ConformancePresetOptions.siteIdMode. Defaults to 'literal'. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradial/aci",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -127,12 +127,12 @@
127
127
  "zod": "^4.0.0"
128
128
  },
129
129
  "optionalDependencies": {
130
- "@gradial/aci-cli-darwin-arm64": "0.1.36",
131
- "@gradial/aci-cli-darwin-x64": "0.1.36",
132
- "@gradial/aci-cli-linux-arm64": "0.1.36",
133
- "@gradial/aci-cli-linux-x64": "0.1.36",
134
- "@gradial/aci-cli-win32-arm64": "0.1.36",
135
- "@gradial/aci-cli-win32-x64": "0.1.36"
130
+ "@gradial/aci-cli-darwin-arm64": "0.1.38",
131
+ "@gradial/aci-cli-darwin-x64": "0.1.38",
132
+ "@gradial/aci-cli-linux-arm64": "0.1.38",
133
+ "@gradial/aci-cli-linux-x64": "0.1.38",
134
+ "@gradial/aci-cli-win32-arm64": "0.1.38",
135
+ "@gradial/aci-cli-win32-x64": "0.1.38"
136
136
  },
137
137
  "scripts": {
138
138
  "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",