@financial-times/cp-content-pipeline-schema 3.5.1 → 3.6.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.
- package/CHANGELOG.md +16 -0
- package/lib/datasources/capi.test.js +1 -1
- package/lib/datasources/capi.test.js.map +1 -1
- package/lib/datasources/instrumented.js +1 -2
- package/lib/datasources/instrumented.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js.map +1 -1
- package/lib/model/Image.js +11 -32
- package/lib/model/Image.js.map +1 -1
- package/lib/model/Image.test.js +24 -54
- package/lib/model/Image.test.js.map +1 -1
- package/package.json +1 -1
- package/src/datasources/capi.test.ts +1 -1
- package/src/datasources/instrumented.ts +4 -8
- package/src/index.ts +2 -1
- package/src/model/Image.test.ts +37 -60
- package/src/model/Image.ts +12 -36
- package/tsconfig.tsbuildinfo +1 -1
package/src/model/Image.ts
CHANGED
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
validLiteralUnionValue,
|
|
12
12
|
} from '../resolvers/literal-union'
|
|
13
13
|
import { ImageFormat, ImageType } from '../resolvers/scalars'
|
|
14
|
-
import
|
|
15
|
-
import { BaseError, OperationalError } from '@dotcom-reliability-kit/errors'
|
|
14
|
+
import { BaseError } from '@dotcom-reliability-kit/errors'
|
|
16
15
|
import type { ImageSource } from '../generated'
|
|
17
16
|
|
|
18
17
|
export type ImageSourceArgs = {
|
|
@@ -126,7 +125,7 @@ export class CAPIImage implements Image {
|
|
|
126
125
|
args.maxDpr || Infinity,
|
|
127
126
|
Math.floor(dimensions.width / maxAllowedWidth)
|
|
128
127
|
)
|
|
129
|
-
:
|
|
128
|
+
: 2
|
|
130
129
|
|
|
131
130
|
const resolutions = [...Array(maxDpr + 1).keys()].slice(1)
|
|
132
131
|
|
|
@@ -158,40 +157,17 @@ export class CAPIImage implements Image {
|
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
|
|
161
|
-
// HACK:KB:20241029 graphics don't
|
|
162
|
-
//
|
|
163
|
-
// performance. skip calling Image Service for
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
return null
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
const imageMetadata = await this.#dataSources.origami.getImageMetadata(
|
|
177
|
-
this.capiImage.binaryUrl
|
|
178
|
-
)
|
|
179
|
-
return imageMetadata
|
|
180
|
-
} catch (error) {
|
|
181
|
-
if (isError(error)) {
|
|
182
|
-
this.context.logger.warn({
|
|
183
|
-
event: 'RECOVERABLE_ERROR',
|
|
184
|
-
error: new OperationalError({
|
|
185
|
-
code: 'IMAGE_DIMENSIONS_ERROR',
|
|
186
|
-
message: `Failed to get dimensions for ${this.capiImage.binaryUrl}`,
|
|
187
|
-
url: this.capiImage.binaryUrl,
|
|
188
|
-
cause: error,
|
|
189
|
-
}),
|
|
190
|
-
})
|
|
191
|
-
}
|
|
160
|
+
// HACK:KB:20241029 graphics and images in layouts don't have pixelWidth/
|
|
161
|
+
// pixelHeight because of reasons. we want to avoid calling Image Service
|
|
162
|
+
// to improve performance. skip calling Image Service for the time being
|
|
163
|
+
this.context.logger.warn({
|
|
164
|
+
event: 'SKIPPING_IMAGE_DIMENSIONS',
|
|
165
|
+
message: 'Not calling Image Service to get graphics dimensions',
|
|
166
|
+
url: this.capiImage.binaryUrl,
|
|
167
|
+
type: this.type(),
|
|
168
|
+
})
|
|
192
169
|
|
|
193
|
-
|
|
194
|
-
}
|
|
170
|
+
return null
|
|
195
171
|
}
|
|
196
172
|
|
|
197
173
|
credit() {
|