Skip to content

Commit e50797a

Browse files
authored
Adapt new computed content and add tag for translation (#3070)
1 parent 5b1e01c commit e50797a

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
},
263263
"overrides": {
264264
"@codemirror/state": "6.4.1",
265-
"@gitbook/api": "0.105.0",
265+
"@gitbook/api": "0.106.0",
266266
"react": "18.3.1",
267267
"react-dom": "18.3.1",
268268
},
@@ -623,7 +623,7 @@
623623

624624
"@fortawesome/fontawesome-svg-core": ["@fortawesome/[email protected]", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
625625

626-
"@gitbook/api": ["@gitbook/api@0.105.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-asM2NzFf+8jG/7FtdxYRE5XiOqPMPZX5hy6egKal/ZcXkjtwWqVEY99Ys+evjg3BJXdb7E1lJoN2QA6PBTKZBQ=="],
626+
"@gitbook/api": ["@gitbook/api@0.106.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-2qA/w18JwHe2fwR2A45q1pEdCZArxqUloegfNibu0xngDhea+iKTXSBrN94wD6Lwkh7cqBp9MvtxC+YMz3hx1g=="],
627627

628628
"@gitbook/cache-do": ["@gitbook/cache-do@workspace:packages/cache-do"],
629629

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@codemirror/state": "6.4.1",
1313
"react": "18.3.1",
1414
"react-dom": "18.3.1",
15-
"@gitbook/api": "0.105.0"
15+
"@gitbook/api": "0.106.0"
1616
},
1717
"private": true,
1818
"scripts": {

packages/cache-tags/src/index.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function getCacheTag(
6060
| {
6161
tag: 'computed-document';
6262
space: string;
63-
integration: string;
63+
sourceType: string;
6464
}
6565
/**
6666
* All data related to the URL of a content
@@ -84,6 +84,14 @@ export function getCacheTag(
8484
organization: string;
8585
openAPISpec: string;
8686
}
87+
/**
88+
* All data related to a translation
89+
*/
90+
| {
91+
tag: 'translation';
92+
organization: string;
93+
translationSettings: string;
94+
}
8795
): string {
8896
switch (spec.tag) {
8997
case 'user':
@@ -99,13 +107,15 @@ export function getCacheTag(
99107
case 'document':
100108
return `space:${spec.space}:document:${spec.document}`;
101109
case 'computed-document':
102-
return `space:${spec.space}:computed-document:${spec.integration}`;
110+
return `space:${spec.space}:computed-document:${spec.sourceType}`;
103111
case 'site':
104112
return `site:${spec.site}`;
105113
case 'integration':
106114
return `integration:${spec.integration}`;
107115
case 'openapi':
108116
return `organization:${spec.organization}:openapi:${spec.openAPISpec}`;
117+
case 'translation':
118+
return `organization:${spec.organization}:translation:${spec.translationSettings}`;
109119
default:
110120
assertNever(spec);
111121
}
@@ -157,6 +167,15 @@ export function getComputedContentSourceCacheTags(
157167
})
158168
);
159169
break;
170+
case 'translation-language':
171+
tags.push(
172+
getCacheTag({
173+
tag: 'translation',
174+
organization: inContext.organizationId,
175+
translationSettings: dependency.ref.translationSettings,
176+
})
177+
);
178+
break;
160179
default:
161180
// Do not throw for unknown dependency types
162181
// as it might mean we are lacking behind the API version
@@ -169,18 +188,22 @@ export function getComputedContentSourceCacheTags(
169188
getCacheTag({
170189
tag: 'computed-document',
171190
space: inContext.spaceId,
172-
integration: source.integration,
191+
sourceType: source.type,
173192
})
174193
);
175194
}
176195

177196
// We invalidate the computed content when a new version of the integration is deployed.
178-
tags.push(
179-
getCacheTag({
180-
tag: 'integration',
181-
integration: source.integration,
182-
})
183-
);
197+
198+
if (source.type.startsWith('integration:')) {
199+
const integration = source.type.split(':')[1];
200+
tags.push(
201+
getCacheTag({
202+
tag: 'integration',
203+
integration,
204+
})
205+
);
206+
}
184207

185208
return tags;
186209
}

0 commit comments

Comments
 (0)