Skip to content

Commit 1fa263f

Browse files
Merge pull request #23 from contentstack/develop
Add: Dynamic display type support and Custom upload handler
2 parents f6712e2 + 5bc0855 commit 1fa263f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1467
-27
lines changed

README.md

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,54 @@ This is a callback function that is executed after you unpublish an asset.
6464

6565
It is the property that you can modify using the setData() method.
6666

67-
## Metadata SDK Reference
67+
## Metadata
6868

69-
**IMetadata**
70-
This object represents the structure of the metadata.
69+
Metadata is a piece of information that lets you describe or classify an asset/entry. You can manage your digital entities effectively and enable improved accessibility with additional metadata. This object manages all the CRUD operations you can perform with metadata, e.g., adding, updating, or deleting additional metadata.
70+
71+
72+
> Note: The Metadata feature allows users to update their asset metadata or entry metadata without incrementing the asset or entry version.
73+
74+
### createMetadata(metadataConfig: IMetadataCreate)
7175

7276
```ts
73-
{
74-
uid: string;
75-
type: "asset" | "entry";
77+
IMetadataCreate {
78+
entity_uid: string;
79+
type?: "asset" | "entry"; // default: "asset"
7680
_content_type_uid?: string;
7781
locale?: string;
78-
[key: string]: any;
82+
[key: string]: any; // other fields you want to add
83+
}
84+
```
85+
86+
This method adds new metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the metadata object and other data you need for your app.
87+
88+
### retrieveMetadata(metadataConfig: IMetadataRetrieve)
89+
90+
```ts
91+
IMetadateRetrieve {
92+
uid: string;
7993
}
8094
```
8195

82-
**createMetaData(metadataConfig: IMetadata)**
83-
This method adds new metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object and other data you need for your app.
96+
This method retrieves metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the metadata object you want to retrieve.
8497

85-
**retrieveMetaData(metadataConfig: IMetadata)**
86-
This method retrieves metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object you want to retrieve.
98+
### updateMetadata(metadataConfig: IMetadataUpdate)
8799

88-
**updateMetaData(metadataConfig: IMetadata)**
89-
This method updates existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object and other data you want to update.
100+
```ts
101+
IMetadataUpdate {
102+
uid: string;
103+
[key: string]: any; // other fields you want to update
104+
}
105+
```
106+
107+
This method updates existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the metadata object and other data you want to update.
108+
109+
### deleteMetadata(metadataConfig: IMetadataDelete)
110+
111+
```ts
112+
IMetadateDelete {
113+
uid: string;
114+
}
115+
```
90116

91-
**deleteMetaData(metadataConfig: IMetadata)**
92-
This method deletes existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object you want to delete.
117+
This method deletes existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the metadata object you want to delete.

__test__/entry.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ describe("Entry", () => {
138138
);
139139
});
140140

141+
it("getField within Create page", function () {
142+
const dataWithoutEntry = JSON.parse(JSON.stringify(testData));
143+
dataWithoutEntry.entry = {};
144+
// @ts-ignore
145+
entry = new Entry({ data: dataWithoutEntry }, connection, emitter);
146+
expect(() => entry.getField("invaliduid")).toThrowError(
147+
"The data is unsaved. Save the data before requesting the field."
148+
);
149+
});
150+
141151
it("onSave Callback must be a function", function () {
142152
// @ts-ignore
143153
expect(() => entry.onSave()).toThrow("Callback must be a function");

dist/__test__/entry.test.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {};
2+
//# sourceMappingURL=entry.test.d.ts.map

dist/__test__/entry.test.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/__test__/field.test.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {};
2+
//# sourceMappingURL=field.test.d.ts.map

dist/__test__/field.test.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/__test__/frame.test.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {};
2+
//# sourceMappingURL=frame.test.d.ts.map

dist/__test__/frame.test.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/__test__/helpers/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare const _default: {
2+
clone: (source: {
3+
[key: string]: any;
4+
}) => any;
5+
};
6+
export default _default;
7+
//# sourceMappingURL=index.d.ts.map

dist/__test__/helpers/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)