@sitecore/sc-contenthub-webclient-sdk 0.9.7 → 1.0.6

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 (103) hide show
  1. package/README.md +21 -0
  2. package/dist/base-types.d.ts +5 -2
  3. package/dist/caches/entity-definition-cache.d.ts +14 -1
  4. package/dist/caches/entity-definition-cache.js +35 -0
  5. package/dist/clients/aggregates-client.d.ts +19 -0
  6. package/dist/clients/aggregates-client.js +35 -0
  7. package/dist/clients/api-client.d.ts +0 -1
  8. package/dist/clients/api-client.js +7 -9
  9. package/dist/clients/content-hub-client.d.ts +13 -1
  10. package/dist/clients/content-hub-client.js +8 -0
  11. package/dist/clients/entity-definitions-client.js +7 -6
  12. package/dist/clients/internal-client.js +12 -2
  13. package/dist/clients/permissions-client.d.ts +16 -0
  14. package/dist/clients/permissions-client.js +53 -0
  15. package/dist/clients/raw-client.d.ts +1 -1
  16. package/dist/clients/request-message.d.ts +1 -1
  17. package/dist/clients/schema-querying.js +2 -2
  18. package/dist/clients/search-client.d.ts +9 -0
  19. package/dist/clients/search-client.js +11 -0
  20. package/dist/clients/upload-client.d.ts +21 -0
  21. package/dist/clients/upload-client.js +98 -0
  22. package/dist/clients/version-checker.d.ts +32 -0
  23. package/dist/clients/version-checker.js +60 -0
  24. package/dist/constants/api.d.ts +14 -0
  25. package/dist/constants/api.js +15 -1
  26. package/dist/constants/defaults.d.ts +3 -0
  27. package/dist/constants/defaults.js +4 -1
  28. package/dist/contracts/base/data-type.d.ts +1 -2
  29. package/dist/contracts/base/entity-base.d.ts +6 -0
  30. package/dist/contracts/base/entity-base.js +13 -0
  31. package/dist/contracts/base/entity-construction-args.d.ts +2 -0
  32. package/dist/contracts/base/entity-construction-args.js +1 -0
  33. package/dist/contracts/base/entity-definition.js +1 -1
  34. package/dist/contracts/base/entity.d.ts +26 -0
  35. package/dist/contracts/base/entity.js +19 -1
  36. package/dist/contracts/base/member-group.js +3 -0
  37. package/dist/contracts/base/property-definitions/string-property-definition.js +1 -1
  38. package/dist/contracts/base/related-path.d.ts +12 -0
  39. package/dist/contracts/base/related-path.js +2 -0
  40. package/dist/contracts/base/relation-definition.d.ts +5 -0
  41. package/dist/contracts/base/relation-definition.js +4 -0
  42. package/dist/contracts/base/rendition.d.ts +1 -1
  43. package/dist/contracts/base/string-content-type.d.ts +4 -4
  44. package/dist/contracts/base/string-content-type.js +4 -4
  45. package/dist/contracts/upload/upload-source.d.ts +5 -0
  46. package/dist/contracts/upload/upload-source.js +2 -0
  47. package/dist/converters/all-facet-values-children-converter.d.ts +21 -0
  48. package/dist/converters/all-facet-values-children-converter.js +45 -0
  49. package/dist/dirty-value-calculator.js +1 -5
  50. package/dist/error-messages.d.ts +1 -0
  51. package/dist/error-messages.js +1 -0
  52. package/dist/link-helper.d.ts +14 -0
  53. package/dist/link-helper.js +31 -0
  54. package/dist/link.d.ts +1 -1
  55. package/dist/link.js +3 -3
  56. package/dist/mappers/entity-mapper.d.ts +1 -0
  57. package/dist/mappers/entity-mapper.js +10 -0
  58. package/dist/mappers/filter-operator-mapper.d.ts +5 -0
  59. package/dist/mappers/filter-operator-mapper.js +14 -0
  60. package/dist/mappers/property-mapper.js +2 -11
  61. package/dist/mappers/related-path-mapper.d.ts +5 -0
  62. package/dist/mappers/related-path-mapper.js +30 -0
  63. package/dist/models/aggregate-resources/aggregate-resource.d.ts +14 -0
  64. package/dist/models/aggregate-resources/aggregate-resource.js +53 -0
  65. package/dist/models/aggregate-resources/aggregated-entity-resource.d.ts +11 -0
  66. package/dist/models/aggregate-resources/aggregated-entity-resource.js +30 -0
  67. package/dist/models/entity-resource.d.ts +3 -0
  68. package/dist/models/entity-resource.js +12 -0
  69. package/dist/models/pages/page-resource.d.ts +2 -2
  70. package/dist/models/pages/page-resource.js +1 -1
  71. package/dist/models/policies/policy-resource.js +2 -2
  72. package/dist/models/property-definition-resource.js +1 -1
  73. package/dist/models/search/all-facet-values-response.d.ts +12 -0
  74. package/dist/models/search/all-facet-values-response.js +41 -0
  75. package/dist/models/search/all-facets-request.d.ts +16 -0
  76. package/dist/models/search/all-facets-request.js +51 -0
  77. package/dist/models/search/grouped-view-response-resource.js +1 -1
  78. package/dist/models/search/search-request.d.ts +2 -3
  79. package/dist/models/search/search-response.d.ts +3 -2
  80. package/dist/models/search/search-response.js +4 -2
  81. package/dist/models/upload/array-buffer-upload-source.d.ts +0 -0
  82. package/dist/models/upload/array-buffer-upload-source.js +16 -0
  83. package/dist/models/upload/create-upload-response.d.ts +5 -0
  84. package/dist/models/upload/create-upload-response.js +31 -0
  85. package/dist/models/upload/http-upload-source.d.ts +11 -0
  86. package/dist/models/upload/http-upload-source.js +34 -0
  87. package/dist/models/upload/local-upload-source.d.ts +10 -0
  88. package/dist/models/upload/local-upload-source.js +49 -0
  89. package/dist/models/upload/upload-action.d.ts +6 -0
  90. package/dist/models/upload/upload-action.js +37 -0
  91. package/dist/models/upload/upload-configuration.d.ts +6 -0
  92. package/dist/models/upload/upload-configuration.js +37 -0
  93. package/dist/models/upload/upload-request-wrapper.d.ts +8 -0
  94. package/dist/models/upload/upload-request-wrapper.js +39 -0
  95. package/dist/models/upload/upload-request.d.ts +10 -0
  96. package/dist/models/upload/upload-request.js +18 -0
  97. package/dist/models/user-entity-permissions-resource.d.ts +14 -0
  98. package/dist/models/user-entity-permissions-resource.js +69 -0
  99. package/dist/models/versionining/compatibility.d.ts +17 -0
  100. package/dist/models/versionining/compatibility.js +21 -0
  101. package/dist/utilities/array-utilities.d.ts +1 -0
  102. package/dist/utilities/array-utilities.js +15 -0
  103. package/package.json +6 -10
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UploadClient = void 0;
16
+ const form_data_1 = __importDefault(require("form-data"));
17
+ const ta_json_1 = require("ta-json");
18
+ const api_1 = require("../constants/api");
19
+ const defaults_1 = require("../constants/defaults");
20
+ const error_messages_1 = __importDefault(require("../error-messages"));
21
+ const web_api_error_1 = require("../errors/web-api-error");
22
+ const fileversion_1 = require("../fileversion");
23
+ const guard_1 = __importDefault(require("../guard"));
24
+ const create_upload_response_1 = require("../models/upload/create-upload-response");
25
+ const upload_action_1 = require("../models/upload/upload-action");
26
+ const upload_configuration_1 = require("../models/upload/upload-configuration");
27
+ const upload_request_wrapper_1 = require("../models/upload/upload-request-wrapper");
28
+ const response_handler_1 = require("./response-handler");
29
+ class UploadClient {
30
+ constructor(client) {
31
+ this.client = client;
32
+ guard_1.default.notNull(client);
33
+ }
34
+ uploadAsync(request) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ guard_1.default.notNull(request);
37
+ yield this.client.versionChecker.compatibilityCheckAsync(new fileversion_1.FileVersion(4, 0, 0, 0));
38
+ const buffer = yield request.source.getReadableSourceAsync();
39
+ const uploadRequest = new upload_request_wrapper_1.UploadRequestWrapper();
40
+ uploadRequest.fileName = request.source.name;
41
+ uploadRequest.fileSize = buffer.byteLength;
42
+ uploadRequest.uploadConfiguration = new upload_configuration_1.UploadConfiguration(request.configurationName, request.configurationParameters);
43
+ uploadRequest.action = new upload_action_1.UploadAction(request.actionName, request.actionParameters);
44
+ return yield this.uploadFileAsync(uploadRequest, buffer);
45
+ });
46
+ }
47
+ uploadFileAsync(uploadRequest, uploadSource) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ guard_1.default.notNull(uploadRequest);
50
+ guard_1.default.notNull(uploadSource);
51
+ // 1. Request new file to be created.
52
+ const uploadLink = yield this.client.linkHelper.createUploadToLinkAsync();
53
+ const uploadResponse = yield this.client.raw.postAsync(uploadLink.href, ta_json_1.TaJson.serialize(uploadRequest));
54
+ response_handler_1.ResponseHandler.handleErrors(uploadResponse);
55
+ const uploadResponseLocation = uploadResponse.responseHeaders[api_1.HEADERS.location];
56
+ if (!uploadResponseLocation) {
57
+ throw new web_api_error_1.WebApiError(error_messages_1.default.EntitiesClient.UnableToExtractLocationHeaderFromResponse, uploadResponse.statusCode, uploadResponse);
58
+ }
59
+ const createUploadResponse = ta_json_1.TaJson.deserialize(uploadResponse.content, create_upload_response_1.CreateUploadResponse);
60
+ // 2. Upload file
61
+ if (uploadRequest.fileSize >= defaults_1.FILE_UPLOAD.chunkSize) {
62
+ let chunkCurrent = 0;
63
+ const chunkTotal = Math.ceil(uploadRequest.fileSize / defaults_1.FILE_UPLOAD.chunkSize);
64
+ const chunkUploadUri = `${uploadResponseLocation}&chunks=${chunkTotal}`;
65
+ let index = 0;
66
+ while (index < uploadSource.byteLength) {
67
+ const chunk = uploadSource.slice(index, defaults_1.FILE_UPLOAD.chunkSize + index);
68
+ yield this.uploadChunkAsync(uploadRequest.fileName, chunk, `${chunkUploadUri}&chunk=${chunkCurrent}`);
69
+ index += defaults_1.FILE_UPLOAD.chunkSize;
70
+ chunkCurrent++;
71
+ }
72
+ // Finalize chunked upload
73
+ const finalizeChunkUploadResponse = yield this.client.raw.postAsync(chunkUploadUri, "");
74
+ response_handler_1.ResponseHandler.handleErrors(finalizeChunkUploadResponse);
75
+ }
76
+ else {
77
+ yield this.uploadChunkAsync(uploadRequest.fileName, uploadSource, uploadResponseLocation);
78
+ }
79
+ // 3. Finalize upload
80
+ const finalizeUploadLink = yield this.client.linkHelper.finalizeUploadToLinkAsync();
81
+ const finalizeUploadResponse = yield this.client.raw.postAsync(finalizeUploadLink.href, createUploadResponse);
82
+ response_handler_1.ResponseHandler.handleErrors(finalizeUploadResponse);
83
+ return finalizeUploadResponse;
84
+ });
85
+ }
86
+ uploadChunkAsync(fileName, buffer, uri) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const form = new form_data_1.default({ autoDestroy: true });
89
+ const headers = {
90
+ "Content-Type": `multipart/form-data;boundary=${form.getBoundary()}`,
91
+ };
92
+ form.append("file", buffer, fileName);
93
+ const uploadResponse = yield this.client.raw.postAsync(uri, form, headers);
94
+ response_handler_1.ResponseHandler.handleErrors(uploadResponse);
95
+ });
96
+ }
97
+ }
98
+ exports.UploadClient = UploadClient;
@@ -0,0 +1,32 @@
1
+ import { FileVersion } from "../fileversion";
2
+ import { Compatibility } from "../models/versionining/compatibility";
3
+ import { IApiClient } from "./api-client";
4
+ export interface IVersionChecker {
5
+ /**
6
+ * Gets the compatibility between a Content Hub instance and SDK.
7
+ * @param serverVersion - File version of a Content Hub instance.
8
+ * @param sdkVersion - File version of the SDK.
9
+ * @param minimumSdkVersion - File version of the minimum SDK version as dictated by the Content Hub instance.
10
+ * @returns The compatibility.
11
+ */
12
+ getCompatibility(serverVersion: FileVersion, sdkVersion: FileVersion, minimumSdkVersion: FileVersion): Compatibility;
13
+ /**
14
+ * Check compatibility of a Content Hub instance with minimum required SDK version.
15
+ * @param requiredVersion - File version required.
16
+ */
17
+ compatibilityCheckAsync(requiredVersion: FileVersion): Promise<void>;
18
+ /**
19
+ * Return compatibility of the Content Hub instance.
20
+ * @param requiredVersion - File version required.
21
+ * @returns True is it's compatible, false otherwise.
22
+ */
23
+ isCompatibleAsync(requiredVersion: FileVersion): Promise<boolean>;
24
+ }
25
+ export declare class VersionChecker implements IVersionChecker {
26
+ private client;
27
+ constructor(client: IApiClient);
28
+ getCompatibility(serverVersion: FileVersion, sdkVersion: FileVersion, minimumSdkVersion: FileVersion): Compatibility;
29
+ compatibilityCheckAsync(requiredVersion: FileVersion): Promise<void>;
30
+ isCompatibleAsync(requiredVersion: FileVersion): Promise<boolean>;
31
+ private isDebugVersion;
32
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.VersionChecker = void 0;
16
+ const string_format_1 = __importDefault(require("string-format"));
17
+ const error_messages_1 = __importDefault(require("../error-messages"));
18
+ const not_supported_error_1 = require("../errors/not-supported-error");
19
+ const guard_1 = __importDefault(require("../guard"));
20
+ const compatibility_1 = require("../models/versionining/compatibility");
21
+ class VersionChecker {
22
+ constructor(client) {
23
+ this.client = client;
24
+ guard_1.default.notNull(client);
25
+ }
26
+ getCompatibility(serverVersion, sdkVersion, minimumSdkVersion) {
27
+ if (this.isDebugVersion(serverVersion) || this.isDebugVersion(sdkVersion)) {
28
+ return compatibility_1.Compatibility.Ok;
29
+ }
30
+ if (sdkVersion.smallerThan(minimumSdkVersion)) {
31
+ return compatibility_1.Compatibility.SdkOld;
32
+ }
33
+ if (sdkVersion.major > serverVersion.major ||
34
+ (sdkVersion.major === serverVersion.major && sdkVersion.minor > serverVersion.minor)) {
35
+ return compatibility_1.Compatibility.SdkNew;
36
+ }
37
+ return compatibility_1.Compatibility.Ok;
38
+ }
39
+ compatibilityCheckAsync(requiredVersion) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const apiInfo = yield this.client.getApiInfoAsync();
42
+ if (apiInfo.fileVersion.smallerThan(requiredVersion) && !this.isDebugVersion(apiInfo.fileVersion)) {
43
+ throw new not_supported_error_1.NotSupportedError(string_format_1.default(error_messages_1.default.ContentHubClient.NotSupportedFeature, apiInfo.fileVersion, requiredVersion));
44
+ }
45
+ });
46
+ }
47
+ isCompatibleAsync(requiredVersion) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const apiInfo = yield this.client.getApiInfoAsync();
50
+ if (apiInfo.fileVersion > requiredVersion || this.isDebugVersion(apiInfo.fileVersion)) {
51
+ return true;
52
+ }
53
+ return false;
54
+ });
55
+ }
56
+ isDebugVersion(version) {
57
+ return version.major <= 1;
58
+ }
59
+ }
60
+ exports.VersionChecker = VersionChecker;
@@ -76,6 +76,11 @@ export declare const PERMISSIONS_FOR_ENTITY: Readonly<{
76
76
  templateName: string;
77
77
  id: string;
78
78
  }>;
79
+ export declare const EXPLAIN_USER_PERMISSIONS_FOR_ENTITY: Readonly<{
80
+ templateName: string;
81
+ id: string;
82
+ userId: string;
83
+ }>;
79
84
  export declare const COMMANDS: Readonly<{
80
85
  templateName: string;
81
86
  folder: string;
@@ -128,3 +133,12 @@ export declare const PAGE_BY_ID: Readonly<{
128
133
  export declare const SEARCH: Readonly<{
129
134
  templateName: string;
130
135
  }>;
136
+ export declare const ALL_FACETS: Readonly<{
137
+ templateName: string;
138
+ }>;
139
+ export declare const UPLOAD: Readonly<{
140
+ templateName: string;
141
+ }>;
142
+ export declare const UPLOAD_FINALIZE: Readonly<{
143
+ templateName: string;
144
+ }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEARCH = exports.PAGE_BY_ID = exports.PAGE_BY_IDENTIFIER = exports.AGGREGATES = exports.RESET_PASSWORD = exports.SET_USER_PASSWORD = exports.EXECUTE_SCRIPT = exports.PACKAGE = exports.DOWNLOAD_ORDER_BY_ID = exports.SEND_NOTIFICATION = exports.SEND_CONFIRMATION_MAIL = exports.COMMANDS = exports.PERMISSIONS_FOR_ENTITY = exports.FETCH_JOB_BY_ID = exports.FETCH_JOBS = exports.ENTITY_DEFINITION_BY_ID = exports.ENTITY_DEFINITION_BY_NAME_V2 = exports.ENTITY_DEFINITION_BY_NAME = exports.ENTITY_DEFINITIONS = exports.POLICY_BY_ID = exports.ENTITY_RELATION_BY_NAME = exports.ENTITY_BY_IDENTIFIER = exports.ENTITY_BY_ID = exports.ENTITIES = exports.DATA_SOURCE_BY_NAME = exports.DATA_SOURCES = exports.SCROLL = exports.QUERY = exports.EXTENSION_DATA_KEYS = exports.HEADERS = exports.API_ROOT = void 0;
3
+ exports.UPLOAD_FINALIZE = exports.UPLOAD = exports.ALL_FACETS = exports.SEARCH = exports.PAGE_BY_ID = exports.PAGE_BY_IDENTIFIER = exports.AGGREGATES = exports.RESET_PASSWORD = exports.SET_USER_PASSWORD = exports.EXECUTE_SCRIPT = exports.PACKAGE = exports.DOWNLOAD_ORDER_BY_ID = exports.SEND_NOTIFICATION = exports.SEND_CONFIRMATION_MAIL = exports.COMMANDS = exports.EXPLAIN_USER_PERMISSIONS_FOR_ENTITY = exports.PERMISSIONS_FOR_ENTITY = exports.FETCH_JOB_BY_ID = exports.FETCH_JOBS = exports.ENTITY_DEFINITION_BY_ID = exports.ENTITY_DEFINITION_BY_NAME_V2 = exports.ENTITY_DEFINITION_BY_NAME = exports.ENTITY_DEFINITIONS = exports.POLICY_BY_ID = exports.ENTITY_RELATION_BY_NAME = exports.ENTITY_BY_IDENTIFIER = exports.ENTITY_BY_ID = exports.ENTITIES = exports.DATA_SOURCE_BY_NAME = exports.DATA_SOURCES = exports.SCROLL = exports.QUERY = exports.EXTENSION_DATA_KEYS = exports.HEADERS = exports.API_ROOT = void 0;
4
4
  exports.API_ROOT = "/api";
5
5
  exports.HEADERS = Object.freeze({
6
6
  apiVersion: "X-ApiVersion",
@@ -79,6 +79,11 @@ exports.PERMISSIONS_FOR_ENTITY = Object.freeze({
79
79
  templateName: "permissions_for_entity",
80
80
  id: "id",
81
81
  });
82
+ exports.EXPLAIN_USER_PERMISSIONS_FOR_ENTITY = Object.freeze({
83
+ templateName: "explain_permissions",
84
+ id: "id",
85
+ userId: "userId",
86
+ });
82
87
  exports.COMMANDS = Object.freeze({
83
88
  templateName: "commands",
84
89
  folder: "folder",
@@ -131,3 +136,12 @@ exports.PAGE_BY_ID = Object.freeze({
131
136
  exports.SEARCH = Object.freeze({
132
137
  templateName: "search",
133
138
  });
139
+ exports.ALL_FACETS = Object.freeze({
140
+ templateName: "allfacets",
141
+ });
142
+ exports.UPLOAD = Object.freeze({
143
+ templateName: "upload",
144
+ });
145
+ exports.UPLOAD_FINALIZE = Object.freeze({
146
+ templateName: "upload_finalize",
147
+ });
@@ -5,3 +5,6 @@ export declare const ENTITIES: Readonly<{
5
5
  skip: number;
6
6
  take: number;
7
7
  }>;
8
+ export declare const FILE_UPLOAD: Readonly<{
9
+ chunkSize: number;
10
+ }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENTITIES = exports.ITERATING = void 0;
3
+ exports.FILE_UPLOAD = exports.ENTITIES = exports.ITERATING = void 0;
4
4
  exports.ITERATING = Object.freeze({
5
5
  pageSize: 50,
6
6
  });
@@ -8,3 +8,6 @@ exports.ENTITIES = Object.freeze({
8
8
  skip: 0,
9
9
  take: 25,
10
10
  });
11
+ exports.FILE_UPLOAD = Object.freeze({
12
+ chunkSize: 10000000,
13
+ });
@@ -1,4 +1,3 @@
1
- import { Moment } from "moment";
2
1
  import { JsonValue, MapCultureTo, Nullable, UnionKeyToValue } from "../../base-types";
3
2
  declare type DataType = "Relation" | "String" | "Integer" | "Long" | "Decimal" | "Boolean" | "DateTime" | "DateTimeOffset" | "Json";
4
3
  declare type PropertyDataType = Exclude<DataType, "Relation">;
@@ -14,5 +13,5 @@ export declare class TypeInfo<T extends PropertyDataType | unknown = PropertyDat
14
13
  }
15
14
  export declare type PropertyValue<T extends PropertyDataType | unknown = unknown, B extends boolean = false> = B extends true ? Nullable<Array<Type<T>>> : Nullable<Type<T>>;
16
15
  export declare type PropertyValuePerCulture<T extends PropertyDataType | unknown = unknown, B extends boolean = false> = MapCultureTo<PropertyValue<T, B>>;
17
- export declare type Type<T extends PropertyDataType | unknown> = T extends "String" ? string : T extends "Integer" ? number : T extends "Long" ? number : T extends "Decimal" ? number : T extends "Boolean" ? boolean : T extends "DateTime" ? Date | Moment : T extends "DateTimeOffset" ? Date | Moment : T extends "Json" ? JsonValue : T extends unknown ? unknown : never;
16
+ export declare type Type<T extends PropertyDataType | unknown> = T extends "String" ? string : T extends "Integer" ? number : T extends "Long" ? number : T extends "Decimal" ? number : T extends "Boolean" ? boolean : T extends "DateTime" ? string : T extends "DateTimeOffset" ? string : T extends "Json" ? JsonValue : T extends unknown ? unknown : never;
18
17
  export default DataType;
@@ -11,6 +11,7 @@ import { IEntityDefinition } from "./entity-definition";
11
11
  import { IMember } from "./member";
12
12
  import { IProperty } from "./property";
13
13
  import { PropertyManager } from "./property-manager";
14
+ import { IRelatedPath } from "./related-path";
14
15
  import { IRelation, RelationType } from "./relation";
15
16
  import { RelationManager } from "./relation-manager";
16
17
  import { RelationRole } from "./relation-role";
@@ -31,6 +32,9 @@ export declare abstract class EntityBase implements IEntity {
31
32
  isSystemOwned: boolean;
32
33
  version: number;
33
34
  cultures: Array<CultureInfo>;
35
+ isCurrentUserDefault?: boolean;
36
+ isEnabled?: boolean;
37
+ modules?: Array<string>;
34
38
  protected _properties: Array<IProperty>;
35
39
  get properties(): ReadonlyArray<IProperty>;
36
40
  protected _relations: Array<IRelation>;
@@ -44,6 +48,7 @@ export declare abstract class EntityBase implements IEntity {
44
48
  get isDirty(): boolean;
45
49
  get isNew(): boolean;
46
50
  abstract get renditions(): Array<IRendition>;
51
+ abstract get relatedPaths(): Array<IRelatedPath>;
47
52
  constructor(client: IContentHubClient, args: EntityConstructionArgs);
48
53
  private isProperty;
49
54
  getProperty<T extends IProperty = IProperty>(name: string): Nullable<T>;
@@ -58,6 +63,7 @@ export declare abstract class EntityBase implements IEntity {
58
63
  loadMembersAsync(propertyLoadOption: IPropertyLoadOption, relationLoadOption: IRelationLoadOption): Promise<boolean>;
59
64
  getEntityDefinitionAsync(): Promise<IEntityDefinition>;
60
65
  abstract getRendition(name: string): Nullable<IRendition>;
66
+ abstract getRelatedPath(name: string): Nullable<IRelatedPath>;
61
67
  abstract getPermissionsAsync(): Promise<Array<string>>;
62
68
  startTracking(): void;
63
69
  markClean(): void;
@@ -329,6 +329,19 @@ __decorate([
329
329
  ta_json_1.JsonElementType(String),
330
330
  __metadata("design:type", Array)
331
331
  ], EntityBase.prototype, "cultures", void 0);
332
+ __decorate([
333
+ ta_json_1.JsonProperty("is_current_user_default"),
334
+ __metadata("design:type", Boolean)
335
+ ], EntityBase.prototype, "isCurrentUserDefault", void 0);
336
+ __decorate([
337
+ ta_json_1.JsonProperty("is_enabled"),
338
+ __metadata("design:type", Boolean)
339
+ ], EntityBase.prototype, "isEnabled", void 0);
340
+ __decorate([
341
+ ta_json_1.JsonProperty("modules"),
342
+ ta_json_1.JsonElementType(String),
343
+ __metadata("design:type", Array)
344
+ ], EntityBase.prototype, "modules", void 0);
332
345
  __decorate([
333
346
  ta_json_1.JsonProperty("properties"),
334
347
  ta_json_1.JsonElementType(property_1.PropertyBase),
@@ -1,6 +1,7 @@
1
1
  import { Nullable } from "../../base-types";
2
2
  import CultureInfo from "../../culture-info";
3
3
  import { IProperty } from "./property";
4
+ import { IRelatedPath } from "./related-path";
4
5
  import { IRelation } from "./relation";
5
6
  import { IRendition } from "./rendition";
6
7
  export declare class EntityConstructionArgs {
@@ -11,5 +12,6 @@ export declare class EntityConstructionArgs {
11
12
  relations: Array<IRelation>;
12
13
  cultures: Array<CultureInfo>;
13
14
  renditions: Array<IRendition>;
15
+ relatedPaths: Array<IRelatedPath>;
14
16
  constructor(definitionName: string, init?: Omit<Partial<EntityConstructionArgs>, "definitionName">);
15
17
  }
@@ -9,6 +9,7 @@ class EntityConstructionArgs {
9
9
  this.relations = [];
10
10
  this.cultures = [];
11
11
  this.renditions = [];
12
+ this.relatedPaths = [];
12
13
  this.definitionName = definitionName;
13
14
  Object.assign(this, init);
14
15
  }
@@ -45,7 +45,7 @@ let EntityDefinition = class EntityDefinition {
45
45
  const relationDefinition = this.getRelationDefinitions().find(relationDefinition => {
46
46
  return relationDefinition.name === name && (role == null || relationDefinition.role === role);
47
47
  });
48
- if ((relationDefinition === null || relationDefinition === void 0 ? void 0 : relationDefinition.associatedEntityDefinitionName) === this.name) {
48
+ if ((relationDefinition === null || relationDefinition === void 0 ? void 0 : relationDefinition.associatedEntityDefinitionName) === this.name && role == null) {
49
49
  const errorMessage = string_format_1.default(error_messages_1.default.NoRoleSpecifiedForSelfRelation, name);
50
50
  throw new invalid_operation_error_1.InvalidOperationError(errorMessage);
51
51
  }
@@ -10,6 +10,7 @@ import { EntityBase } from "./entity-base";
10
10
  import { EntityConstructionArgs } from "./entity-construction-args";
11
11
  import { IEntityDefinition } from "./entity-definition";
12
12
  import { IProperty } from "./property";
13
+ import { IRelatedPath } from "./related-path";
13
14
  import { IRelation } from "./relation";
14
15
  import { RelationRole } from "./relation-role";
15
16
  import { IRendition } from "./rendition";
@@ -75,6 +76,18 @@ export interface IEntity extends IResource, IDirtyTracking {
75
76
  * All {@link ICultureSensitiveProperty} properties can only contains values for these cultures.
76
77
  */
77
78
  cultures: ReadonlyArray<CultureInfo>;
79
+ /**
80
+ * Gets or sets a value indicating whether the entity is the default for the given entity definition for the current user.
81
+ */
82
+ isCurrentUserDefault?: boolean;
83
+ /**
84
+ * Gets or sets a value indicating whether the entity is enabled or not.
85
+ */
86
+ isEnabled?: boolean;
87
+ /**
88
+ * Gets a list of modules.
89
+ */
90
+ modules?: Array<string>;
78
91
  /**
79
92
  * Gets a list of all properties that are currently loaded on the entity. Never returns null.
80
93
  * New properties can still be added by lazy loading them.
@@ -89,6 +102,10 @@ export interface IEntity extends IResource, IDirtyTracking {
89
102
  * Gets a list of all renditions for this entity. Never returns null.
90
103
  */
91
104
  renditions: ReadonlyArray<IRendition>;
105
+ /**
106
+ * Gets the related paths for this entity.
107
+ */
108
+ relatedPaths?: ReadonlyArray<IRelatedPath>;
92
109
  /**
93
110
  * Checks if lazy loading is possible. Lazy loading is only possible on persisted entities.
94
111
  */
@@ -215,6 +232,12 @@ export interface IEntity extends IResource, IDirtyTracking {
215
232
  * @returns Rendition.
216
233
  */
217
234
  getRendition(name: string): Nullable<IRendition>;
235
+ /**
236
+ * Gets an {@link IRelatedPath} by name.
237
+ * @param name - The name of the related path
238
+ * @returns Related path.
239
+ */
240
+ getRelatedPath(name: string): Nullable<IRelatedPath>;
218
241
  /**
219
242
  * Gets the {@link IEntityDefinition} of the entity.
220
243
  * @returns Promise which resolves to the entity definition.
@@ -230,8 +253,11 @@ export interface IEntity extends IResource, IDirtyTracking {
230
253
  export declare class Entity extends EntityBase {
231
254
  _client: IExtendedContentHubClient;
232
255
  private readonly _renditions;
256
+ private readonly _relatedPaths;
233
257
  get renditions(): Array<IRendition>;
258
+ get relatedPaths(): Array<IRelatedPath>;
234
259
  constructor(client: IExtendedContentHubClient, args: EntityConstructionArgs);
235
260
  getRendition(name: string): Nullable<IRendition>;
261
+ getRelatedPath(name: string): Nullable<IRelatedPath>;
236
262
  getPermissionsAsync(): Promise<Array<string>>;
237
263
  }
@@ -40,17 +40,31 @@ let Entity = class Entity extends entity_base_1.EntityBase {
40
40
  this._renditions[rendition.name] = rendition;
41
41
  }
42
42
  }
43
+ this._relatedPaths = new base_types_1.CaseInsensitiveStringMap();
44
+ if (args.relatedPaths != null) {
45
+ for (const relatedPath of args.relatedPaths) {
46
+ this._relatedPaths[relatedPath.name] = relatedPath;
47
+ }
48
+ }
43
49
  }
44
- // extensionData: MapStringTo<object>;
45
50
  get renditions() {
46
51
  return Object.values(this._renditions);
47
52
  }
53
+ get relatedPaths() {
54
+ return Object.values(this._relatedPaths);
55
+ }
48
56
  getRendition(name) {
49
57
  var _a, _b;
50
58
  guard_1.default.stringNotNullOrEmpty(name);
51
59
  const rendition = (_b = (_a = this._renditions) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null;
52
60
  return rendition;
53
61
  }
62
+ getRelatedPath(name) {
63
+ var _a, _b;
64
+ guard_1.default.stringNotNullOrEmpty(name);
65
+ const relatedPath = (_b = (_a = this._relatedPaths) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null;
66
+ return relatedPath;
67
+ }
54
68
  getPermissionsAsync() {
55
69
  return __awaiter(this, void 0, void 0, function* () {
56
70
  //TODO HashSet?
@@ -69,6 +83,10 @@ __decorate([
69
83
  ta_json_1.JsonProperty("renditions"),
70
84
  __metadata("design:type", base_types_1.CaseInsensitiveStringMap)
71
85
  ], Entity.prototype, "_renditions", void 0);
86
+ __decorate([
87
+ ta_json_1.JsonProperty("related_paths"),
88
+ __metadata("design:type", base_types_1.CaseInsensitiveStringMap)
89
+ ], Entity.prototype, "_relatedPaths", void 0);
72
90
  Entity = __decorate([
73
91
  ta_json_1.JsonObject(),
74
92
  __metadata("design:paramtypes", [Object, entity_construction_args_1.EntityConstructionArgs])
@@ -16,6 +16,9 @@ const member_condition_1 = require("./member-condition");
16
16
  const member_definition_1 = require("./member-definition");
17
17
  let MemberGroup = class MemberGroup {
18
18
  constructor(init) {
19
+ this.conditions = [];
20
+ this.memberDefinitions = [];
21
+ this.labels = {};
19
22
  Object.assign(this, init);
20
23
  }
21
24
  // @JsonProperty("is_conditional")
@@ -41,7 +41,7 @@ let StringPropertyDefinition = class StringPropertyDefinition extends property_d
41
41
  };
42
42
  __decorate([
43
43
  ta_json_1.JsonProperty("content_type"),
44
- __metadata("design:type", Number)
44
+ __metadata("design:type", String)
45
45
  ], StringPropertyDefinition.prototype, "contentType", void 0);
46
46
  __decorate([
47
47
  ta_json_1.JsonProperty("validation_expression"),
@@ -0,0 +1,12 @@
1
+ /// <reference types="urijs" />
2
+ import { MapCultureTo, MapStringTo, Nullable } from "../../base-types";
3
+ export interface IRelatedPath {
4
+ readonly name: string;
5
+ readonly items: ReadonlyArray<IRelatedPathItem>;
6
+ }
7
+ export interface IRelatedPathItem {
8
+ readonly values: MapCultureTo<string>;
9
+ readonly entity: URI | string;
10
+ readonly definition: URI | string;
11
+ readonly properties: Nullable<MapStringTo<unknown>>;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -97,6 +97,10 @@ export interface IRelationDefinition extends IMemberDefinition {
97
97
  * Collection of the culture specific member labels of the associated relation definition.
98
98
  */
99
99
  associatedLabels: MapCultureTo<string>;
100
+ /**
101
+ * Indicates whether this relation is multi-value or not.
102
+ */
103
+ isMultiValue: boolean;
100
104
  }
101
105
  export declare class RelationDefinition extends MemberDefinition implements IRelationDefinition {
102
106
  role: RelationRole;
@@ -119,5 +123,6 @@ export declare class RelationDefinition extends MemberDefinition implements IRel
119
123
  isRenditionRelation: boolean;
120
124
  associatedLabels: MapCultureTo<string>;
121
125
  get definitionType(): MemberDefinitionType;
126
+ get isMultiValue(): boolean;
122
127
  constructor(name: string, init?: Omit<Partial<RelationDefinition>, "name">);
123
128
  }
@@ -30,6 +30,10 @@ let RelationDefinition = class RelationDefinition extends member_definition_1.Me
30
30
  get definitionType() {
31
31
  return member_definition_type_1.MemberDefinitionType.Relation;
32
32
  }
33
+ get isMultiValue() {
34
+ return (this.cardinality === relation_cardinality_1.RelationCardinality.ManyToMany ||
35
+ (this.cardinality === relation_cardinality_1.RelationCardinality.OneToMany && this.role === relation_role_1.RelationRole.Parent));
36
+ }
33
37
  };
34
38
  __decorate([
35
39
  ta_json_1.JsonProperty("role"),
@@ -1,4 +1,4 @@
1
- import URI = require("urijs");
1
+ /// <reference types="urijs" />
2
2
  export interface IRendition {
3
3
  readonly name: string;
4
4
  readonly items: ReadonlyArray<IRenditionItem>;
@@ -5,17 +5,17 @@ export declare enum StringContentType {
5
5
  /**
6
6
  * Content represents a single line string.
7
7
  */
8
- SingleLine = 0,
8
+ SingleLine = "SingleLine",
9
9
  /**
10
10
  * Content represents multiple lines of string.
11
11
  */
12
- MultiLine = 1,
12
+ MultiLine = "MultiLine",
13
13
  /**
14
14
  * Content represents a HTML code.
15
15
  */
16
- Html = 2,
16
+ Html = "Html",
17
17
  /**
18
18
  * Content represents programming syntax, scripts, data formats like JSON...
19
19
  */
20
- Code = 3
20
+ Code = "Code"
21
21
  }
@@ -9,17 +9,17 @@ var StringContentType;
9
9
  /**
10
10
  * Content represents a single line string.
11
11
  */
12
- StringContentType[StringContentType["SingleLine"] = 0] = "SingleLine";
12
+ StringContentType["SingleLine"] = "SingleLine";
13
13
  /**
14
14
  * Content represents multiple lines of string.
15
15
  */
16
- StringContentType[StringContentType["MultiLine"] = 1] = "MultiLine";
16
+ StringContentType["MultiLine"] = "MultiLine";
17
17
  /**
18
18
  * Content represents a HTML code.
19
19
  */
20
- StringContentType[StringContentType["Html"] = 2] = "Html";
20
+ StringContentType["Html"] = "Html";
21
21
  /**
22
22
  * Content represents programming syntax, scripts, data formats like JSON...
23
23
  */
24
- StringContentType[StringContentType["Code"] = 3] = "Code";
24
+ StringContentType["Code"] = "Code";
25
25
  })(StringContentType = exports.StringContentType || (exports.StringContentType = {}));
@@ -0,0 +1,5 @@
1
+ import { ReadableUploadSource } from "../../base-types";
2
+ export interface IUploadSource {
3
+ name: string;
4
+ getReadableSourceAsync(): Promise<ReadableUploadSource>;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import { IPropertyConverter } from "ta-json";
2
+ import { JsonValue } from "../base-types";
3
+ import { FacetResponseResource } from "../models/search/facet-response-resource";
4
+ export declare class AllFacetValuesChildrenConverter implements IPropertyConverter {
5
+ /**
6
+ * Serializes a mapping of strings to array of FacetResponseResource into a JSON object.
7
+ *
8
+ * @param value - A mapping of strings to array of FacetResponseResource
9
+ *
10
+ * @returns The serialized value.
11
+ */
12
+ serialize(children: Record<string, Array<FacetResponseResource>>): JsonValue;
13
+ /**
14
+ * Deserializes a JSON object into a mapping of strings to array of FacetResponseResource.
15
+ *
16
+ * @param value - The serialized value
17
+ *
18
+ * @returns A mapping of strings to array of FacetResponseResource.
19
+ */
20
+ deserialize(value: Record<string, Array<JsonValue>>): Record<string, Array<FacetResponseResource>>;
21
+ }