@kontent-ai/delivery-sdk 16.4.2 → 16.4.4

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 (83) hide show
  1. package/.npmignore +15 -15
  2. package/LICENSE.md +9 -9
  3. package/dist/bundles/kontent-delivery.umd.js +5770 -4807
  4. package/dist/bundles/kontent-delivery.umd.js.map +1 -1
  5. package/dist/bundles/kontent-delivery.umd.min.js +1 -1
  6. package/dist/bundles/kontent-delivery.umd.min.js.map +1 -1
  7. package/dist/bundles/report.json +1 -1
  8. package/dist/bundles/report.min.json +1 -1
  9. package/dist/bundles/stats.json +10038 -7042
  10. package/dist/bundles/stats.min.json +14400 -10652
  11. package/dist/cjs/sdk-info.generated.js +1 -1
  12. package/dist/es6/sdk-info.generated.js +1 -1
  13. package/dist/esnext/sdk-info.generated.js +1 -1
  14. package/lib/client/delivery-client.factory.ts +9 -9
  15. package/lib/client/delivery-client.ts +163 -163
  16. package/lib/client/idelivery-client.interface.ts +110 -110
  17. package/lib/client/index.ts +3 -3
  18. package/lib/config/delivery-configs.ts +98 -98
  19. package/lib/config/index.ts +1 -1
  20. package/lib/contracts/contracts.ts +265 -265
  21. package/lib/contracts/index.ts +1 -1
  22. package/lib/elements/element-models.ts +89 -89
  23. package/lib/elements/element-resolver.ts +3 -3
  24. package/lib/elements/element-type.ts +16 -16
  25. package/lib/elements/elements.ts +70 -70
  26. package/lib/elements/index.ts +4 -4
  27. package/lib/images/image-url-transformation-builder.factory.ts +5 -5
  28. package/lib/images/image-url-transformation-builder.ts +181 -181
  29. package/lib/images/image.models.ts +4 -4
  30. package/lib/images/index.ts +3 -3
  31. package/lib/index.ts +12 -12
  32. package/lib/mappers/element.mapper.ts +504 -504
  33. package/lib/mappers/generic-element.mapper.ts +20 -20
  34. package/lib/mappers/index.ts +8 -8
  35. package/lib/mappers/item.mapper.ts +181 -181
  36. package/lib/mappers/language.mapper.ts +24 -24
  37. package/lib/mappers/sync.mapper.ts +32 -32
  38. package/lib/mappers/taxonomy.mapper.ts +77 -77
  39. package/lib/mappers/type.mapper.ts +76 -76
  40. package/lib/mappers/used-in.mapper.ts +20 -20
  41. package/lib/models/common/base-responses.ts +13 -13
  42. package/lib/models/common/common-models.ts +118 -118
  43. package/lib/models/common/filters.ts +280 -280
  44. package/lib/models/common/headers.ts +5 -5
  45. package/lib/models/common/index.ts +7 -7
  46. package/lib/models/common/pagination.class.ts +7 -7
  47. package/lib/models/common/parameters.ts +189 -189
  48. package/lib/models/common/sort-order.ts +1 -1
  49. package/lib/models/content-type-models.ts +42 -42
  50. package/lib/models/element-models.ts +51 -51
  51. package/lib/models/index.ts +9 -9
  52. package/lib/models/item-models.ts +192 -192
  53. package/lib/models/language-models.ts +17 -17
  54. package/lib/models/responses.ts +137 -137
  55. package/lib/models/sync-models.ts +18 -18
  56. package/lib/models/taxonomy-models.ts +25 -25
  57. package/lib/query/common/base-item-listing-query.class.ts +274 -274
  58. package/lib/query/common/base-listing-query.class.ts +95 -95
  59. package/lib/query/common/base-query.class.ts +148 -148
  60. package/lib/query/element/element-query.class.ts +45 -45
  61. package/lib/query/index.ts +13 -13
  62. package/lib/query/item/multiple-items-query.class.ts +183 -183
  63. package/lib/query/item/single-item-query.class.ts +106 -106
  64. package/lib/query/items-feed/items-feed-query.class.ts +191 -191
  65. package/lib/query/language/languages-query.class.ts +91 -91
  66. package/lib/query/sync/initialize-sync-query.class.ts +83 -83
  67. package/lib/query/sync/sync-changes-query.class.ts +56 -56
  68. package/lib/query/taxonomy/taxonomies-query.class.ts +82 -82
  69. package/lib/query/taxonomy/taxonomy-query.class.ts +50 -50
  70. package/lib/query/type/multiple-type-query.class.ts +95 -95
  71. package/lib/query/type/single-type-query.class.ts +45 -45
  72. package/lib/query/used-in/used-in-query.class.ts +126 -126
  73. package/lib/sdk-info.generated.ts +1 -1
  74. package/lib/services/base-delivery-query.service.ts +375 -375
  75. package/lib/services/delivery-query.service.ts +336 -336
  76. package/lib/services/index.ts +2 -2
  77. package/lib/services/mapping.service.ts +223 -223
  78. package/lib/utilities/codename.helper.ts +10 -10
  79. package/lib/utilities/delivery-url.helper.ts +11 -11
  80. package/lib/utilities/enum.helper.ts +38 -38
  81. package/lib/utilities/index.ts +3 -3
  82. package/package.json +96 -96
  83. package/readme.md +531 -531
@@ -1,181 +1,181 @@
1
- import { IQueryParameter } from '@kontent-ai/core-sdk';
2
-
3
- import { Parameters } from '../models';
4
- import { ImageCompression, ImageFitMode, ImageFormat } from './image.models';
5
-
6
- export class ImageUrlTransformationBuilder {
7
- private queryParams: IQueryParameter[] = [];
8
- private readonly automaticFormatValue: string = 'format';
9
-
10
- constructor(
11
- /** Image url */
12
- public imageUrl: string
13
- ) { }
14
-
15
- /**
16
- * Used to add custom parameters to existing query string
17
- * @param param Parameter (may or may not include value)
18
- */
19
- withCustomParam(param: string): this {
20
- this.queryParams.push(
21
- new Parameters.CustomParameter(param)
22
- );
23
- return this;
24
- }
25
-
26
- /**
27
- * The dpr transformation is used to serve correctly sized images for devices that expose a device pixel ratio.
28
- * @param dpr A required DPR value.
29
- */
30
- withDpr(dpr: number): this {
31
- this.queryParams.push(
32
- new Parameters.QueryParameter('dpr', dpr.toString())
33
- );
34
-
35
- return this;
36
- }
37
-
38
- /**
39
- * Applies the crop transformation that removes pixels from an image outside the specified rectangle.
40
- * @param x Rectangle offset on the X-axis.
41
- * @param y Rectangle offset on the Y-axis.
42
- * @param width Rectangle width.
43
- * @param height Rectangle height.
44
- */
45
- withRectangleCrop(x: number, y: number, width: number, height: number): this {
46
- this.queryParams.push(
47
- new Parameters.QueryParameter('rect', [x, y, width, height].join(','))
48
- );
49
- return this;
50
- }
51
-
52
- /**
53
- * Applies the crop transformation centered on the specified point.
54
- * @param x Focal point X coordinate.
55
- * @param y Focal point Y coordinate.
56
- * @param z Zoom of the transformation.
57
- */
58
- withFocalPointCrop(x: number, y: number, z: number): this {
59
- this.withFitMode('crop');
60
-
61
- this.queryParams.push(new Parameters.QueryParameter('crop', 'focalpoint'));
62
- this.queryParams.push(new Parameters.QueryParameter('fp-x', x.toString()));
63
- this.queryParams.push(new Parameters.QueryParameter('fp-y', y.toString()));
64
- this.queryParams.push(new Parameters.QueryParameter('fp-z', z.toString()));
65
-
66
- return this;
67
- }
68
-
69
- /**
70
- * Enables WebP image support.
71
- * @param compression Specifies the lossy or lossless compression.
72
- */
73
- withAutomaticFormat(backupFormat?: ImageFormat): this {
74
- this.queryParams.push(
75
- new Parameters.QueryParameter('auto', this.automaticFormatValue)
76
- );
77
-
78
- if (backupFormat) {
79
- this.withFormat(backupFormat);
80
- }
81
-
82
- return this;
83
- }
84
-
85
- /**
86
- * The fit transformation controls how the output image is fit to its target dimensions after resizing.
87
- * @param fitMode Specifies the mode for the transformation.
88
- */
89
- withFitMode(fitMode: ImageFitMode): this {
90
- this.queryParams.push(new Parameters.QueryParameter('fit', fitMode));
91
- return this;
92
- }
93
-
94
- /**
95
- * Specifies the compression mode for the WebP image transformations.
96
- * @param compression Specifies the lossy or lossless compression.
97
- */
98
- withCompression(compression: ImageCompression): this {
99
- this.queryParams.push(
100
- new Parameters.QueryParameter(
101
- 'lossless',
102
- compression === 'lossless' ? 'true' : 'false'
103
- )
104
- );
105
- return this;
106
- }
107
-
108
- /**
109
- * Applies the quality parameter that enables control over the compression level for lossy file-formatted images.
110
- * @param quality The required quality of the image.
111
- */
112
- withQuality(quality: number): this {
113
- this.queryParams.push(
114
- new Parameters.QueryParameter('q', quality.toString())
115
- );
116
- return this;
117
- }
118
-
119
- /**
120
- * The format transformation enables the source image to be converted (a.k.a., "transcoded") from
121
- * one encoded format to another. This is very useful when the source image has been saved in a sub-optimal
122
- * file format that hinders performance.
123
- * @param format Target image file type.
124
- */
125
- withFormat(format: ImageFormat): this {
126
- this.queryParams.push(
127
- new Parameters.QueryParameter('fm', format)
128
- );
129
- return this;
130
- }
131
-
132
- /**
133
- * The height transformation enables dynamic height resizing based on pixels and percent values.
134
- * @param height A required image height.
135
- */
136
- withHeight(height: number): this {
137
- this.queryParams.push(
138
- new Parameters.QueryParameter('h', height.toString())
139
- );
140
- return this;
141
- }
142
-
143
- /**
144
- * The width transformation enables dynamic width resizing based on pixels and percent values.
145
- * @param width A required image width.
146
- */
147
- withWidth(width: number): this {
148
- this.queryParams.push(new Parameters.QueryParameter('w', width.toString()));
149
- return this;
150
- }
151
-
152
- /**
153
- * Gets params applied to image
154
- */
155
- getParams(): IQueryParameter[] {
156
- return this.queryParams;
157
- }
158
-
159
- /**
160
- * Gets query string part of the image URL
161
- */
162
- getQueryString(): string {
163
- let query: string = '';
164
- this.queryParams.forEach(filter => {
165
- if (query.indexOf('?') > -1) {
166
- query = query + '&' + filter.getParam();
167
- } else {
168
- query = query + '?' + filter.getParam();
169
- }
170
- });
171
-
172
- return query;
173
- }
174
-
175
- /**
176
- * Gets full transformed url to image with parameters
177
- */
178
- getUrl(): string {
179
- return this.imageUrl + this.getQueryString();
180
- }
181
- }
1
+ import { IQueryParameter } from '@kontent-ai/core-sdk';
2
+
3
+ import { Parameters } from '../models';
4
+ import { ImageCompression, ImageFitMode, ImageFormat } from './image.models';
5
+
6
+ export class ImageUrlTransformationBuilder {
7
+ private queryParams: IQueryParameter[] = [];
8
+ private readonly automaticFormatValue: string = 'format';
9
+
10
+ constructor(
11
+ /** Image url */
12
+ public imageUrl: string
13
+ ) { }
14
+
15
+ /**
16
+ * Used to add custom parameters to existing query string
17
+ * @param param Parameter (may or may not include value)
18
+ */
19
+ withCustomParam(param: string): this {
20
+ this.queryParams.push(
21
+ new Parameters.CustomParameter(param)
22
+ );
23
+ return this;
24
+ }
25
+
26
+ /**
27
+ * The dpr transformation is used to serve correctly sized images for devices that expose a device pixel ratio.
28
+ * @param dpr A required DPR value.
29
+ */
30
+ withDpr(dpr: number): this {
31
+ this.queryParams.push(
32
+ new Parameters.QueryParameter('dpr', dpr.toString())
33
+ );
34
+
35
+ return this;
36
+ }
37
+
38
+ /**
39
+ * Applies the crop transformation that removes pixels from an image outside the specified rectangle.
40
+ * @param x Rectangle offset on the X-axis.
41
+ * @param y Rectangle offset on the Y-axis.
42
+ * @param width Rectangle width.
43
+ * @param height Rectangle height.
44
+ */
45
+ withRectangleCrop(x: number, y: number, width: number, height: number): this {
46
+ this.queryParams.push(
47
+ new Parameters.QueryParameter('rect', [x, y, width, height].join(','))
48
+ );
49
+ return this;
50
+ }
51
+
52
+ /**
53
+ * Applies the crop transformation centered on the specified point.
54
+ * @param x Focal point X coordinate.
55
+ * @param y Focal point Y coordinate.
56
+ * @param z Zoom of the transformation.
57
+ */
58
+ withFocalPointCrop(x: number, y: number, z: number): this {
59
+ this.withFitMode('crop');
60
+
61
+ this.queryParams.push(new Parameters.QueryParameter('crop', 'focalpoint'));
62
+ this.queryParams.push(new Parameters.QueryParameter('fp-x', x.toString()));
63
+ this.queryParams.push(new Parameters.QueryParameter('fp-y', y.toString()));
64
+ this.queryParams.push(new Parameters.QueryParameter('fp-z', z.toString()));
65
+
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Enables WebP image support.
71
+ * @param compression Specifies the lossy or lossless compression.
72
+ */
73
+ withAutomaticFormat(backupFormat?: ImageFormat): this {
74
+ this.queryParams.push(
75
+ new Parameters.QueryParameter('auto', this.automaticFormatValue)
76
+ );
77
+
78
+ if (backupFormat) {
79
+ this.withFormat(backupFormat);
80
+ }
81
+
82
+ return this;
83
+ }
84
+
85
+ /**
86
+ * The fit transformation controls how the output image is fit to its target dimensions after resizing.
87
+ * @param fitMode Specifies the mode for the transformation.
88
+ */
89
+ withFitMode(fitMode: ImageFitMode): this {
90
+ this.queryParams.push(new Parameters.QueryParameter('fit', fitMode));
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * Specifies the compression mode for the WebP image transformations.
96
+ * @param compression Specifies the lossy or lossless compression.
97
+ */
98
+ withCompression(compression: ImageCompression): this {
99
+ this.queryParams.push(
100
+ new Parameters.QueryParameter(
101
+ 'lossless',
102
+ compression === 'lossless' ? 'true' : 'false'
103
+ )
104
+ );
105
+ return this;
106
+ }
107
+
108
+ /**
109
+ * Applies the quality parameter that enables control over the compression level for lossy file-formatted images.
110
+ * @param quality The required quality of the image.
111
+ */
112
+ withQuality(quality: number): this {
113
+ this.queryParams.push(
114
+ new Parameters.QueryParameter('q', quality.toString())
115
+ );
116
+ return this;
117
+ }
118
+
119
+ /**
120
+ * The format transformation enables the source image to be converted (a.k.a., "transcoded") from
121
+ * one encoded format to another. This is very useful when the source image has been saved in a sub-optimal
122
+ * file format that hinders performance.
123
+ * @param format Target image file type.
124
+ */
125
+ withFormat(format: ImageFormat): this {
126
+ this.queryParams.push(
127
+ new Parameters.QueryParameter('fm', format)
128
+ );
129
+ return this;
130
+ }
131
+
132
+ /**
133
+ * The height transformation enables dynamic height resizing based on pixels and percent values.
134
+ * @param height A required image height.
135
+ */
136
+ withHeight(height: number): this {
137
+ this.queryParams.push(
138
+ new Parameters.QueryParameter('h', height.toString())
139
+ );
140
+ return this;
141
+ }
142
+
143
+ /**
144
+ * The width transformation enables dynamic width resizing based on pixels and percent values.
145
+ * @param width A required image width.
146
+ */
147
+ withWidth(width: number): this {
148
+ this.queryParams.push(new Parameters.QueryParameter('w', width.toString()));
149
+ return this;
150
+ }
151
+
152
+ /**
153
+ * Gets params applied to image
154
+ */
155
+ getParams(): IQueryParameter[] {
156
+ return this.queryParams;
157
+ }
158
+
159
+ /**
160
+ * Gets query string part of the image URL
161
+ */
162
+ getQueryString(): string {
163
+ let query: string = '';
164
+ this.queryParams.forEach(filter => {
165
+ if (query.indexOf('?') > -1) {
166
+ query = query + '&' + filter.getParam();
167
+ } else {
168
+ query = query + '?' + filter.getParam();
169
+ }
170
+ });
171
+
172
+ return query;
173
+ }
174
+
175
+ /**
176
+ * Gets full transformed url to image with parameters
177
+ */
178
+ getUrl(): string {
179
+ return this.imageUrl + this.getQueryString();
180
+ }
181
+ }
@@ -1,4 +1,4 @@
1
- export type ImageFitMode = 'clip' | 'scale' | 'crop';
2
- export type ImageFormat = 'gif' | 'png' |'png8' | 'jpg' | 'pjpg' |'webp'| 'mp4';
3
- export type ImageCompression = 'lossless' | 'lossy';
4
-
1
+ export type ImageFitMode = 'clip' | 'scale' | 'crop';
2
+ export type ImageFormat = 'gif' | 'png' |'png8' | 'jpg' | 'pjpg' |'webp'| 'mp4';
3
+ export type ImageCompression = 'lossless' | 'lossy';
4
+
@@ -1,3 +1,3 @@
1
- export * from './image-url-transformation-builder';
2
- export * from './image.models';
3
- export * from './image-url-transformation-builder.factory';
1
+ export * from './image-url-transformation-builder';
2
+ export * from './image.models';
3
+ export * from './image-url-transformation-builder.factory';
package/lib/index.ts CHANGED
@@ -1,12 +1,12 @@
1
- // Public API
2
- export * from './client';
3
- export * from './config';
4
- export * from './contracts';
5
- export * from './elements';
6
- export * from './images';
7
- export * from './mappers';
8
- export * from './models';
9
- export * from './query';
10
- export * from './sdk-info.generated';
11
- export * from './services';
12
- export * from './utilities';
1
+ // Public API
2
+ export * from './client';
3
+ export * from './config';
4
+ export * from './contracts';
5
+ export * from './elements';
6
+ export * from './images';
7
+ export * from './mappers';
8
+ export * from './models';
9
+ export * from './query';
10
+ export * from './sdk-info.generated';
11
+ export * from './services';
12
+ export * from './utilities';