@agility/content-fetch 3.0.0 → 3.0.1
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/dist/browser.js +6 -6
- package/dist/methods/getContentItem.d.ts +2 -2
- package/dist/methods/getContentList.d.ts +2 -2
- package/dist/methods/getGallery.d.ts +2 -2
- package/dist/methods/getPage.d.ts +2 -2
- package/dist/methods/getPageByPath.d.ts +2 -2
- package/dist/methods/getSitemapFlat.d.ts +2 -2
- package/dist/methods/getSitemapNested.d.ts +2 -2
- package/dist/methods/getSyncContent.d.ts +2 -2
- package/dist/methods/getSyncPages.d.ts +2 -2
- package/dist/methods/getUrlRedirections.d.ts +2 -2
- package/dist/node.js +6 -6
- package/dist/types/Config.d.ts +3 -3
- package/dist/types/generated/index.d.ts +21 -21
- package/dist/types/index.d.ts +11 -11
- package/dist/types/sdk/Config.d.ts +1 -1
- package/package.json +5 -5
- package/test-nested-data.js +126 -0
package/dist/browser.js
CHANGED
|
@@ -510,14 +510,14 @@ __export(types_exports, {
|
|
|
510
510
|
TypeError: () => TypeError2,
|
|
511
511
|
URIError: () => URIError,
|
|
512
512
|
V1: () => v1_exports,
|
|
513
|
-
|
|
513
|
+
V2: () => v2_exports
|
|
514
514
|
});
|
|
515
515
|
|
|
516
516
|
// src/types/generated/v1.ts
|
|
517
517
|
var v1_exports = {};
|
|
518
518
|
|
|
519
|
-
// src/types/generated/
|
|
520
|
-
var
|
|
519
|
+
// src/types/generated/v2.ts
|
|
520
|
+
var v2_exports = {};
|
|
521
521
|
|
|
522
522
|
// src/types/errors/Errors.ts
|
|
523
523
|
var TypeError3 = class extends Error {
|
|
@@ -538,8 +538,8 @@ var defaultConfig = {
|
|
|
538
538
|
guid: null,
|
|
539
539
|
apiKey: null,
|
|
540
540
|
locale: null,
|
|
541
|
-
apiVersion: "
|
|
542
|
-
// Default to
|
|
541
|
+
apiVersion: "v2",
|
|
542
|
+
// Default to v2 for better types and modern API
|
|
543
543
|
headers: {},
|
|
544
544
|
requiresGuidInHeaders: false,
|
|
545
545
|
logLevel: "warn",
|
|
@@ -558,7 +558,7 @@ function buildBaseUrl(guid, apiVersion) {
|
|
|
558
558
|
d: "-dev",
|
|
559
559
|
us2: "-usa2"
|
|
560
560
|
};
|
|
561
|
-
const versionPath = apiVersion === "
|
|
561
|
+
const versionPath = apiVersion === "v2" ? "/v2" : "";
|
|
562
562
|
const match = guid.match(/-(us2|[ucead])$/);
|
|
563
563
|
if (match) {
|
|
564
564
|
const env = match[1];
|
|
@@ -45,7 +45,7 @@ declare function getContentItem(this: ApiClientInstance & {
|
|
|
45
45
|
}, requestParams: ContentItemRequestParams): Promise<ApiTypes.V1.ContentItem>;
|
|
46
46
|
declare function getContentItem(this: ApiClientInstance & {
|
|
47
47
|
config: {
|
|
48
|
-
apiVersion: '
|
|
48
|
+
apiVersion: 'v2';
|
|
49
49
|
};
|
|
50
|
-
}, requestParams: ContentItemRequestParams): Promise<ApiTypes.
|
|
50
|
+
}, requestParams: ContentItemRequestParams): Promise<ApiTypes.V2.ContentItem>;
|
|
51
51
|
export default getContentItem;
|
|
@@ -120,7 +120,7 @@ declare function getContentList(this: ApiClientInstance & {
|
|
|
120
120
|
}, requestParams: ContentListRequestParams): Promise<ApiTypes.V1.ContentList>;
|
|
121
121
|
declare function getContentList(this: ApiClientInstance & {
|
|
122
122
|
config: {
|
|
123
|
-
apiVersion: '
|
|
123
|
+
apiVersion: 'v2';
|
|
124
124
|
};
|
|
125
|
-
}, requestParams: ContentListRequestParams): Promise<ApiTypes.
|
|
125
|
+
}, requestParams: ContentListRequestParams): Promise<ApiTypes.V2.ContentList>;
|
|
126
126
|
export default getContentList;
|
|
@@ -36,7 +36,7 @@ declare function getGallery(this: ApiClientInstance & {
|
|
|
36
36
|
}, requestParams: GalleryRequestParams): Promise<ApiTypes.V1.Gallery>;
|
|
37
37
|
declare function getGallery(this: ApiClientInstance & {
|
|
38
38
|
config: {
|
|
39
|
-
apiVersion: '
|
|
39
|
+
apiVersion: 'v2';
|
|
40
40
|
};
|
|
41
|
-
}, requestParams: GalleryRequestParams): Promise<ApiTypes.
|
|
41
|
+
}, requestParams: GalleryRequestParams): Promise<ApiTypes.V2.Gallery>;
|
|
42
42
|
export default getGallery;
|
|
@@ -44,7 +44,7 @@ declare function getPage(this: ApiClientInstance & {
|
|
|
44
44
|
}, requestParams: PageRequestParams): Promise<ApiTypes.V1.Page>;
|
|
45
45
|
declare function getPage(this: ApiClientInstance & {
|
|
46
46
|
config: {
|
|
47
|
-
apiVersion: '
|
|
47
|
+
apiVersion: 'v2';
|
|
48
48
|
};
|
|
49
|
-
}, requestParams: PageRequestParams): Promise<ApiTypes.
|
|
49
|
+
}, requestParams: PageRequestParams): Promise<ApiTypes.V2.Page>;
|
|
50
50
|
export default getPage;
|
|
@@ -45,7 +45,7 @@ declare function getPageByPath(this: ApiClientInstance & {
|
|
|
45
45
|
}, requestParams: PageByPathRequestParams): Promise<ApiTypes.V1.Page>;
|
|
46
46
|
declare function getPageByPath(this: ApiClientInstance & {
|
|
47
47
|
config: {
|
|
48
|
-
apiVersion: '
|
|
48
|
+
apiVersion: 'v2';
|
|
49
49
|
};
|
|
50
|
-
}, requestParams: PageByPathRequestParams): Promise<ApiTypes.
|
|
50
|
+
}, requestParams: PageByPathRequestParams): Promise<ApiTypes.V2.Page>;
|
|
51
51
|
export default getPageByPath;
|
|
@@ -40,7 +40,7 @@ declare function getSitemapFlat(this: ApiClientInstance & {
|
|
|
40
40
|
}, requestParams: SitemapFlatRequestParams): Promise<ApiTypes.V1.SitemapFlat>;
|
|
41
41
|
declare function getSitemapFlat(this: ApiClientInstance & {
|
|
42
42
|
config: {
|
|
43
|
-
apiVersion: '
|
|
43
|
+
apiVersion: 'v2';
|
|
44
44
|
};
|
|
45
|
-
}, requestParams: SitemapFlatRequestParams): Promise<ApiTypes.
|
|
45
|
+
}, requestParams: SitemapFlatRequestParams): Promise<ApiTypes.V2.SitemapFlat>;
|
|
46
46
|
export default getSitemapFlat;
|
|
@@ -40,7 +40,7 @@ declare function getSitemapNested(this: ApiClientInstance & {
|
|
|
40
40
|
}, requestParams: SitemapNestedRequestParams): Promise<ApiTypes.V1.SitemapNested>;
|
|
41
41
|
declare function getSitemapNested(this: ApiClientInstance & {
|
|
42
42
|
config: {
|
|
43
|
-
apiVersion: '
|
|
43
|
+
apiVersion: 'v2';
|
|
44
44
|
};
|
|
45
|
-
}, requestParams: SitemapNestedRequestParams): Promise<ApiTypes.
|
|
45
|
+
}, requestParams: SitemapNestedRequestParams): Promise<ApiTypes.V2.SitemapNested>;
|
|
46
46
|
export default getSitemapNested;
|
|
@@ -46,7 +46,7 @@ declare function getSyncContent(this: ApiClientInstance & {
|
|
|
46
46
|
}, requestParams: SyncContentRequestParams): Promise<ApiTypes.V1.ContentItemSync>;
|
|
47
47
|
declare function getSyncContent(this: ApiClientInstance & {
|
|
48
48
|
config: {
|
|
49
|
-
apiVersion: '
|
|
49
|
+
apiVersion: 'v2';
|
|
50
50
|
};
|
|
51
|
-
}, requestParams: SyncContentRequestParams): Promise<ApiTypes.
|
|
51
|
+
}, requestParams: SyncContentRequestParams): Promise<ApiTypes.V2.ContentItemSync>;
|
|
52
52
|
export default getSyncContent;
|
|
@@ -46,7 +46,7 @@ declare function getSyncPages(this: ApiClientInstance & {
|
|
|
46
46
|
}, requestParams: SyncPagesRequestParams): Promise<ApiTypes.V1.PageSync>;
|
|
47
47
|
declare function getSyncPages(this: ApiClientInstance & {
|
|
48
48
|
config: {
|
|
49
|
-
apiVersion: '
|
|
49
|
+
apiVersion: 'v2';
|
|
50
50
|
};
|
|
51
|
-
}, requestParams: SyncPagesRequestParams): Promise<ApiTypes.
|
|
51
|
+
}, requestParams: SyncPagesRequestParams): Promise<ApiTypes.V2.PageSync>;
|
|
52
52
|
export default getSyncPages;
|
|
@@ -38,7 +38,7 @@ declare function getUrlRedirections(this: ApiClientInstance & {
|
|
|
38
38
|
}, requestParams: UrlRedirectionsRequestParams): Promise<ApiTypes.V1.UrlRedirection[]>;
|
|
39
39
|
declare function getUrlRedirections(this: ApiClientInstance & {
|
|
40
40
|
config: {
|
|
41
|
-
apiVersion: '
|
|
41
|
+
apiVersion: 'v2';
|
|
42
42
|
};
|
|
43
|
-
}, requestParams: UrlRedirectionsRequestParams): Promise<ApiTypes.
|
|
43
|
+
}, requestParams: UrlRedirectionsRequestParams): Promise<ApiTypes.V2.UrlRedirection[]>;
|
|
44
44
|
export default getUrlRedirections;
|
package/dist/node.js
CHANGED
|
@@ -529,14 +529,14 @@ __export(types_exports, {
|
|
|
529
529
|
TypeError: () => TypeError2,
|
|
530
530
|
URIError: () => URIError,
|
|
531
531
|
V1: () => v1_exports,
|
|
532
|
-
|
|
532
|
+
V2: () => v2_exports
|
|
533
533
|
});
|
|
534
534
|
|
|
535
535
|
// src/types/generated/v1.ts
|
|
536
536
|
var v1_exports = {};
|
|
537
537
|
|
|
538
|
-
// src/types/generated/
|
|
539
|
-
var
|
|
538
|
+
// src/types/generated/v2.ts
|
|
539
|
+
var v2_exports = {};
|
|
540
540
|
|
|
541
541
|
// src/types/errors/Errors.ts
|
|
542
542
|
var TypeError3 = class extends Error {
|
|
@@ -557,8 +557,8 @@ var defaultConfig = {
|
|
|
557
557
|
guid: null,
|
|
558
558
|
apiKey: null,
|
|
559
559
|
locale: null,
|
|
560
|
-
apiVersion: "
|
|
561
|
-
// Default to
|
|
560
|
+
apiVersion: "v2",
|
|
561
|
+
// Default to v2 for better types and modern API
|
|
562
562
|
headers: {},
|
|
563
563
|
requiresGuidInHeaders: false,
|
|
564
564
|
logLevel: "warn",
|
|
@@ -577,7 +577,7 @@ function buildBaseUrl(guid, apiVersion) {
|
|
|
577
577
|
d: "-dev",
|
|
578
578
|
us2: "-usa2"
|
|
579
579
|
};
|
|
580
|
-
const versionPath = apiVersion === "
|
|
580
|
+
const versionPath = apiVersion === "v2" ? "/v2" : "";
|
|
581
581
|
const match = guid.match(/-(us2|[ucead])$/);
|
|
582
582
|
if (match) {
|
|
583
583
|
const env = match[1];
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ export interface Config {
|
|
|
19
19
|
apiKey?: string | null;
|
|
20
20
|
locale?: string | null;
|
|
21
21
|
/**
|
|
22
|
-
* The API version to use. 'v1' uses legacy string-based data types, '
|
|
23
|
-
* Default is '
|
|
22
|
+
* The API version to use. 'v1' uses legacy string-based data types, 'v2' uses proper data types.
|
|
23
|
+
* Default is 'v2'. Specify 'v1' only if you need legacy compatibility.
|
|
24
24
|
*/
|
|
25
|
-
apiVersion?: 'v1' | '
|
|
25
|
+
apiVersion?: 'v1' | 'v2';
|
|
26
26
|
/**
|
|
27
27
|
* Additional headers to include in the request.
|
|
28
28
|
*/
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Generated API Types
|
|
3
3
|
*
|
|
4
4
|
* This file provides namespaced access to generated types from Swagger specs.
|
|
5
|
-
* Types are organized by API version (V1,
|
|
5
|
+
* Types are organized by API version (V1, V2) for clear separation.
|
|
6
6
|
*/
|
|
7
7
|
import * as V1Schema from './v1';
|
|
8
|
-
import * as
|
|
8
|
+
import * as V2Schema from './v2';
|
|
9
9
|
export declare namespace ApiTypes {
|
|
10
10
|
namespace V1 {
|
|
11
11
|
type ContentItem = V1Schema.components['schemas']['HeadlessContentItem'];
|
|
@@ -28,26 +28,26 @@ export declare namespace ApiTypes {
|
|
|
28
28
|
type ContentItemSeo = V1Schema.components['schemas']['HeadlessContentItemSeo'];
|
|
29
29
|
type PageVisibility = V1Schema.components['schemas']['HeadlessContentPageVisibility'];
|
|
30
30
|
}
|
|
31
|
-
namespace
|
|
32
|
-
type ContentItem =
|
|
33
|
-
type ContentList =
|
|
34
|
-
type ContentItemSync =
|
|
35
|
-
type Page =
|
|
36
|
-
type PageByPath =
|
|
37
|
-
type PageSync =
|
|
31
|
+
namespace V2 {
|
|
32
|
+
type ContentItem = V2Schema.components['schemas']['HeadlessContentItem'];
|
|
33
|
+
type ContentList = V2Schema.components['schemas']['HeadlessContentListResponse'];
|
|
34
|
+
type ContentItemSync = V2Schema.components['schemas']['HeadlessContentItemHeadlessSync'];
|
|
35
|
+
type Page = V2Schema.components['schemas']['HeadlessContentPage'];
|
|
36
|
+
type PageByPath = V2Schema.components['schemas']['HeadlessContentPageByPath'];
|
|
37
|
+
type PageSync = V2Schema.components['schemas']['HeadlessContentPageHeadlessSync'];
|
|
38
38
|
type SitemapFlat = {
|
|
39
|
-
[key: string]:
|
|
39
|
+
[key: string]: V2Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
40
40
|
};
|
|
41
|
-
type SitemapNested =
|
|
42
|
-
type SitemapItem =
|
|
43
|
-
type SitemapNestedItem =
|
|
44
|
-
type Gallery =
|
|
45
|
-
type MediaItem =
|
|
46
|
-
type UrlRedirection =
|
|
47
|
-
type ContentZone =
|
|
48
|
-
type ContentItemProperties =
|
|
49
|
-
type ContentItemSeo =
|
|
50
|
-
type PageVisibility =
|
|
41
|
+
type SitemapNested = V2Schema.components['schemas']['HeadlessContentSiteMapNestedItem'][];
|
|
42
|
+
type SitemapItem = V2Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
43
|
+
type SitemapNestedItem = V2Schema.components['schemas']['HeadlessContentSiteMapNestedItem'];
|
|
44
|
+
type Gallery = V2Schema.components['schemas']['HeadlessGallery'];
|
|
45
|
+
type MediaItem = V2Schema.components['schemas']['HeadlessMediaItem'];
|
|
46
|
+
type UrlRedirection = V2Schema.components['schemas']['UrlRedirection'];
|
|
47
|
+
type ContentZone = V2Schema.components['schemas']['HeadlessContentZone'];
|
|
48
|
+
type ContentItemProperties = V2Schema.components['schemas']['HeadlessContentItemProperties'];
|
|
49
|
+
type ContentItemSeo = V2Schema.components['schemas']['HeadlessContentItemSeo'];
|
|
50
|
+
type PageVisibility = V2Schema.components['schemas']['HeadlessContentPageVisibility'];
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
export { V1Schema as V1,
|
|
53
|
+
export { V1Schema as V1, V2Schema as V2 };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,58 +4,58 @@
|
|
|
4
4
|
* This is the main entry point for all types used in the SDK.
|
|
5
5
|
* It combines generated API response types with SDK-specific types.
|
|
6
6
|
*/
|
|
7
|
-
export { ApiTypes, V1,
|
|
7
|
+
export { ApiTypes, V1, V2 } from './generated';
|
|
8
8
|
export * from './sdk';
|
|
9
9
|
import { ApiTypes } from './generated';
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated Use ApiTypes.V1.ContentItem or ApiTypes.
|
|
11
|
+
* @deprecated Use ApiTypes.V1.ContentItem or ApiTypes.V2.ContentItem instead
|
|
12
12
|
* This will be removed in v4.0.0
|
|
13
13
|
*/
|
|
14
14
|
export type ContentItem<T = {
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
}> = ApiTypes.V1.ContentItem;
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated Use ApiTypes.V1.Page or ApiTypes.
|
|
18
|
+
* @deprecated Use ApiTypes.V1.Page or ApiTypes.V2.Page instead
|
|
19
19
|
* This will be removed in v4.0.0
|
|
20
20
|
*/
|
|
21
21
|
export type Page = ApiTypes.V1.Page;
|
|
22
22
|
/**
|
|
23
|
-
* @deprecated Use ApiTypes.V1.Gallery or ApiTypes.
|
|
23
|
+
* @deprecated Use ApiTypes.V1.Gallery or ApiTypes.V2.Gallery instead
|
|
24
24
|
* This will be removed in v4.0.0
|
|
25
25
|
*/
|
|
26
26
|
export type Gallery = ApiTypes.V1.Gallery;
|
|
27
27
|
/**
|
|
28
|
-
* @deprecated Use ApiTypes.V1.MediaItem or ApiTypes.
|
|
28
|
+
* @deprecated Use ApiTypes.V1.MediaItem or ApiTypes.V2.MediaItem instead
|
|
29
29
|
* This will be removed in v4.0.0
|
|
30
30
|
*/
|
|
31
31
|
export type MediaItem = ApiTypes.V1.MediaItem;
|
|
32
32
|
/**
|
|
33
|
-
* @deprecated Use ApiTypes.V1.SitemapFlat or ApiTypes.
|
|
33
|
+
* @deprecated Use ApiTypes.V1.SitemapFlat or ApiTypes.V2.SitemapFlat instead
|
|
34
34
|
* This will be removed in v4.0.0
|
|
35
35
|
*/
|
|
36
36
|
export type SitemapFlat = ApiTypes.V1.SitemapFlat;
|
|
37
37
|
/**
|
|
38
|
-
* @deprecated Use ApiTypes.V1.SitemapNested or ApiTypes.
|
|
38
|
+
* @deprecated Use ApiTypes.V1.SitemapNested or ApiTypes.V2.SitemapNested instead
|
|
39
39
|
* This will be removed in v4.0.0
|
|
40
40
|
*/
|
|
41
41
|
export type SitemapNested = ApiTypes.V1.SitemapNested;
|
|
42
42
|
/**
|
|
43
|
-
* @deprecated Use ApiTypes.V1.ContentList or ApiTypes.
|
|
43
|
+
* @deprecated Use ApiTypes.V1.ContentList or ApiTypes.V2.ContentList instead
|
|
44
44
|
* This will be removed in v4.0.0
|
|
45
45
|
*/
|
|
46
46
|
export type ContentList = ApiTypes.V1.ContentList;
|
|
47
47
|
/**
|
|
48
|
-
* @deprecated Use ApiTypes.V1.ContentItemSync or ApiTypes.
|
|
48
|
+
* @deprecated Use ApiTypes.V1.ContentItemSync or ApiTypes.V2.ContentItemSync instead
|
|
49
49
|
* This will be removed in v4.0.0
|
|
50
50
|
*/
|
|
51
51
|
export type SyncContent = ApiTypes.V1.ContentItemSync;
|
|
52
52
|
/**
|
|
53
|
-
* @deprecated Use ApiTypes.V1.PageSync or ApiTypes.
|
|
53
|
+
* @deprecated Use ApiTypes.V1.PageSync or ApiTypes.V2.PageSync instead
|
|
54
54
|
* This will be removed in v4.0.0
|
|
55
55
|
*/
|
|
56
56
|
export type SyncPages = ApiTypes.V1.PageSync;
|
|
57
57
|
/**
|
|
58
|
-
* @deprecated Use ApiTypes.V1.UrlRedirection or ApiTypes.
|
|
58
|
+
* @deprecated Use ApiTypes.V1.UrlRedirection or ApiTypes.V2.UrlRedirection instead
|
|
59
59
|
* This will be removed in v4.0.0
|
|
60
60
|
*/
|
|
61
61
|
export type URLRedirection = ApiTypes.V1.UrlRedirection;
|
|
@@ -22,7 +22,7 @@ export interface Config {
|
|
|
22
22
|
* The API version to use. 'v1' uses legacy string-based data types, 'v2' uses proper data types.
|
|
23
23
|
* Default is 'v2'. Specify 'v1' only if you need legacy compatibility.
|
|
24
24
|
*/
|
|
25
|
-
apiVersion?: 'v1' | '
|
|
25
|
+
apiVersion?: 'v1' | 'v2';
|
|
26
26
|
/**
|
|
27
27
|
* Additional headers to include in the request.
|
|
28
28
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility/content-fetch",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "JS/TS library for the Agility Fetch API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"clean": "rimraf dist",
|
|
22
22
|
"types:generate": "npm run types:generate:dev",
|
|
23
|
-
"types:generate:dev": "npm run types:generate:dev:v1 && npm run types:generate:dev:
|
|
23
|
+
"types:generate:dev": "npm run types:generate:dev:v1 && npm run types:generate:dev:v2",
|
|
24
24
|
"types:generate:dev:v1": "openapi-typescript https://api-dev.aglty.io/swagger/v1/swagger.json -o src/types/generated/v1.ts",
|
|
25
|
-
"types:generate:dev:
|
|
26
|
-
"types:generate:prod": "npm run types:generate:prod:v1 && npm run types:generate:prod:
|
|
25
|
+
"types:generate:dev:v2": "openapi-typescript https://api-dev.aglty.io/swagger/v2/swagger.json -o src/types/generated/v2.ts",
|
|
26
|
+
"types:generate:prod": "npm run types:generate:prod:v1 && npm run types:generate:prod:v2",
|
|
27
27
|
"types:generate:prod:v1": "openapi-typescript https://api.aglty.io/swagger/v1/swagger.json -o src/types/generated/v1.ts",
|
|
28
|
-
"types:generate:prod:
|
|
28
|
+
"types:generate:prod:v2": "openapi-typescript https://api.aglty.io/swagger/v2/swagger.json -o src/types/generated/v2.ts",
|
|
29
29
|
"build": "node build.js",
|
|
30
30
|
"prepare": "npm run build",
|
|
31
31
|
"test": "npm run test:all",
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test script to verify nested content field handling with real-world data
|
|
3
|
+
* This tests the specific data structure from the .NET test failure
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { getApi } = require('./dist/node.js');
|
|
7
|
+
|
|
8
|
+
// Real-world nested data from the .NET test failure
|
|
9
|
+
const testData = {
|
|
10
|
+
"items": [
|
|
11
|
+
{
|
|
12
|
+
"contentID": 1673,
|
|
13
|
+
"properties": {
|
|
14
|
+
"state": 2,
|
|
15
|
+
"modified": "2025-10-06T14:20:39.84",
|
|
16
|
+
"versionID": 114816,
|
|
17
|
+
"referenceName": "nestedfetchv2testing",
|
|
18
|
+
"definitionName": "NestedFetchV2Testing",
|
|
19
|
+
"itemOrder": 0
|
|
20
|
+
},
|
|
21
|
+
"fields": {
|
|
22
|
+
"numberField": "168",
|
|
23
|
+
"decimalField": "1.68",
|
|
24
|
+
"booleanField": "true",
|
|
25
|
+
"dateTimeField": "2025-10-22T00:00:00-04:00",
|
|
26
|
+
"nestedContentField": [
|
|
27
|
+
{
|
|
28
|
+
"contentID": 1674,
|
|
29
|
+
"properties": {
|
|
30
|
+
"state": 2,
|
|
31
|
+
"modified": "2025-10-06T14:20:39.84",
|
|
32
|
+
"versionID": 114817,
|
|
33
|
+
"referenceName": "nestedfetchv2testing",
|
|
34
|
+
"definitionName": "NestedFetchV2Testing",
|
|
35
|
+
"itemOrder": 1
|
|
36
|
+
},
|
|
37
|
+
"fields": {
|
|
38
|
+
"numberField": "169",
|
|
39
|
+
"decimalField": "1.69",
|
|
40
|
+
"booleanField": "false",
|
|
41
|
+
"dateTimeField": "2025-10-23T00:00:00-04:00"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"contentID": 1674,
|
|
49
|
+
"properties": {
|
|
50
|
+
"state": 2,
|
|
51
|
+
"modified": "2025-10-06T14:20:39.84",
|
|
52
|
+
"versionID": 114817,
|
|
53
|
+
"referenceName": "nestedfetchv2testing",
|
|
54
|
+
"definitionName": "NestedFetchV2Testing",
|
|
55
|
+
"itemOrder": 1
|
|
56
|
+
},
|
|
57
|
+
"fields": {
|
|
58
|
+
"numberField": "169",
|
|
59
|
+
"decimalField": "1.69",
|
|
60
|
+
"booleanField": "false",
|
|
61
|
+
"dateTimeField": "2025-10-23T00:00:00-04:00"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"totalCount": 2
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
async function testNestedContentHandling() {
|
|
69
|
+
console.log('Testing nested content field handling...');
|
|
70
|
+
|
|
71
|
+
// Test V1 API (legacy string-based)
|
|
72
|
+
console.log('\n=== V1 API Test ===');
|
|
73
|
+
const apiV1 = getApi({
|
|
74
|
+
guid: 'test-guid-d',
|
|
75
|
+
apiKey: 'test-key',
|
|
76
|
+
apiVersion: 'v1'
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
console.log('V1 API Version:', apiV1.config.apiVersion);
|
|
80
|
+
|
|
81
|
+
// Test V2 API (proper data types)
|
|
82
|
+
console.log('\n=== V2 API Test ===');
|
|
83
|
+
const apiV2 = getApi({
|
|
84
|
+
guid: 'test-guid-d',
|
|
85
|
+
apiKey: 'test-key',
|
|
86
|
+
apiVersion: 'v2'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
console.log('V2 API Version:', apiV2.config.apiVersion);
|
|
90
|
+
|
|
91
|
+
// Validate the test data structure
|
|
92
|
+
console.log('\n=== Data Structure Validation ===');
|
|
93
|
+
console.log('Total items:', testData.totalCount);
|
|
94
|
+
console.log('First item ID:', testData.items[0].contentID);
|
|
95
|
+
console.log('First item has nested content:', !!testData.items[0].fields.nestedContentField);
|
|
96
|
+
|
|
97
|
+
if (testData.items[0].fields.nestedContentField) {
|
|
98
|
+
const nestedItem = testData.items[0].fields.nestedContentField[0];
|
|
99
|
+
console.log('Nested item ID:', nestedItem.contentID);
|
|
100
|
+
console.log('Nested item fields:', Object.keys(nestedItem.fields));
|
|
101
|
+
console.log('Nested boolean field:', nestedItem.fields.booleanField);
|
|
102
|
+
console.log('Nested number field:', nestedItem.fields.numberField);
|
|
103
|
+
console.log('Nested decimal field:', nestedItem.fields.decimalField);
|
|
104
|
+
console.log('Nested date field:', nestedItem.fields.dateTimeField);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Test field type handling
|
|
108
|
+
console.log('\n=== Field Type Analysis ===');
|
|
109
|
+
const firstItem = testData.items[0];
|
|
110
|
+
console.log('String fields (V1 format):');
|
|
111
|
+
console.log('- numberField:', typeof firstItem.fields.numberField, '=', firstItem.fields.numberField);
|
|
112
|
+
console.log('- decimalField:', typeof firstItem.fields.decimalField, '=', firstItem.fields.decimalField);
|
|
113
|
+
console.log('- booleanField:', typeof firstItem.fields.booleanField, '=', firstItem.fields.booleanField);
|
|
114
|
+
console.log('- dateTimeField:', typeof firstItem.fields.dateTimeField, '=', firstItem.fields.dateTimeField);
|
|
115
|
+
|
|
116
|
+
// Simulate V2 type conversion
|
|
117
|
+
console.log('\nV2 converted types would be:');
|
|
118
|
+
console.log('- numberField:', parseInt(firstItem.fields.numberField));
|
|
119
|
+
console.log('- decimalField:', parseFloat(firstItem.fields.decimalField));
|
|
120
|
+
console.log('- booleanField:', firstItem.fields.booleanField === 'true');
|
|
121
|
+
console.log('- dateTimeField:', new Date(firstItem.fields.dateTimeField));
|
|
122
|
+
|
|
123
|
+
console.log('\n✅ Test completed successfully - SDK can handle this data structure');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
testNestedContentHandling().catch(console.error);
|