datocms-plugin-sdk 2.0.13 → 2.0.15
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/cjs/icon.js.map +1 -1
- package/dist/cjs/manifest.js +3 -3
- package/dist/cjs/manifest.js.map +1 -1
- package/dist/esm/hooks/onBeforeItemUpsert.d.ts +9 -2
- package/dist/esm/icon.d.ts +39 -1
- package/dist/esm/icon.js.map +1 -1
- package/dist/esm/manifest.js +3 -3
- package/dist/esm/manifest.js.map +1 -1
- package/dist/types/hooks/onBeforeItemUpsert.d.ts +9 -2
- package/dist/types/icon.d.ts +39 -1
- package/manifest.json +3 -3
- package/package.json +2 -2
- package/src/hooks/onBeforeItemUpsert.ts +9 -2
- package/src/icon.ts +46 -3
- package/src/manifest.ts +3 -3
package/manifest.json
CHANGED
|
@@ -1616,7 +1616,7 @@
|
|
|
1616
1616
|
"onBeforeItemUpsert": {
|
|
1617
1617
|
"name": "onBeforeItemUpsert",
|
|
1618
1618
|
"comment": {
|
|
1619
|
-
"markdownText": "This
|
|
1619
|
+
"markdownText": "This hook is called when the user attempts to save a record. You can use it to block record saving.\n\nIf you return `false`, the record will NOT be saved. A small on-page error will say \"A plugin blocked the action\".\nHowever, for better UX, consider also using `ctx.alert()` to better explain to the user why their save was blocked.\n\nIf you return `true`, the save will proceed as normal.\n\nThis hook runs BEFORE serverside validation. You can use it to do your own additional validation before returning.\nClientside validations are not affected by this hook, since those occur on individual fields' `onBlur()` events.",
|
|
1620
1620
|
"tag": "beforeHooks"
|
|
1621
1621
|
},
|
|
1622
1622
|
"nonCtxArguments": [
|
|
@@ -1642,7 +1642,7 @@
|
|
|
1642
1642
|
},
|
|
1643
1643
|
"location": {
|
|
1644
1644
|
"filePath": "src/hooks/onBeforeItemUpsert.ts",
|
|
1645
|
-
"lineNumber":
|
|
1645
|
+
"lineNumber": 47
|
|
1646
1646
|
},
|
|
1647
1647
|
"type": "(path: string, locale?: string) => Promise<void>"
|
|
1648
1648
|
}
|
|
@@ -1653,7 +1653,7 @@
|
|
|
1653
1653
|
"returnType": "MaybePromise<boolean>",
|
|
1654
1654
|
"location": {
|
|
1655
1655
|
"filePath": "src/hooks/onBeforeItemUpsert.ts",
|
|
1656
|
-
"lineNumber":
|
|
1656
|
+
"lineNumber": 22
|
|
1657
1657
|
}
|
|
1658
1658
|
},
|
|
1659
1659
|
"manualFieldExtensions": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datocms-plugin-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.15",
|
|
4
4
|
"description": "DatoCMS Plugin SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"glob": "^11.0.0",
|
|
46
46
|
"typescript": "^5.6.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6698d6f38549b0487ee4721862483d811512bf73"
|
|
49
49
|
}
|
|
@@ -7,8 +7,15 @@ type ItemCreateSchema = SchemaTypes.ItemCreateSchema;
|
|
|
7
7
|
|
|
8
8
|
export type OnBeforeItemUpsertHook = {
|
|
9
9
|
/**
|
|
10
|
-
* This
|
|
11
|
-
*
|
|
10
|
+
* This hook is called when the user attempts to save a record. You can use it to block record saving.
|
|
11
|
+
*
|
|
12
|
+
* If you return `false`, the record will NOT be saved. A small on-page error will say "A plugin blocked the action".
|
|
13
|
+
* However, for better UX, consider also using `ctx.alert()` to better explain to the user why their save was blocked.
|
|
14
|
+
*
|
|
15
|
+
* If you return `true`, the save will proceed as normal.
|
|
16
|
+
*
|
|
17
|
+
* This hook runs BEFORE serverside validation. You can use it to do your own additional validation before returning.
|
|
18
|
+
* Clientside validations are not affected by this hook, since those occur on individual fields' `onBlur()` events.
|
|
12
19
|
*
|
|
13
20
|
* @tag beforeHooks
|
|
14
21
|
*/
|
package/src/icon.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
import { isRecord, isString } from './guardUtils.js';
|
|
2
2
|
|
|
3
|
-
export type Icon =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type Icon = AwesomeFontIconIdentifier | SvgDefinition;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines a custom SVG icon for use in DatoCMS plugins.
|
|
7
|
+
*
|
|
8
|
+
* To create an SVG definition from an existing SVG file:
|
|
9
|
+
* 1. Grab the `viewBox` attribute from your SVG element (e.g., "0 0 24 24")
|
|
10
|
+
* 2. Grab everything between the `<svg>` tags as the content (all the paths, circles, etc.)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // From this SVG:
|
|
15
|
+
* // <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
* // <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
|
|
17
|
+
* // </svg>
|
|
18
|
+
*
|
|
19
|
+
* const starIcon: SvgDefinition = {
|
|
20
|
+
* type: 'svg',
|
|
21
|
+
* viewBox: '0 0 24 24',
|
|
22
|
+
* content: '<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>'
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type SvgDefinition = {
|
|
27
|
+
/** Always set to 'svg' to indicate this is a custom SVG icon */
|
|
28
|
+
type: 'svg';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The viewBox attribute from your SVG element (e.g., "0 0 24 24").
|
|
32
|
+
* This defines the coordinate system and aspect ratio of the SVG.
|
|
33
|
+
*/
|
|
34
|
+
viewBox: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The inner content of your SVG element — everything between the opening and closing <svg> tags.
|
|
38
|
+
* This includes all paths, circles, rectangles, and other SVG elements that make up your icon.
|
|
39
|
+
*/
|
|
40
|
+
content: string;
|
|
41
|
+
};
|
|
6
42
|
|
|
7
43
|
export function isIcon(value: unknown): value is Icon {
|
|
8
44
|
return (
|
|
@@ -14,6 +50,13 @@ export function isIcon(value: unknown): value is Icon {
|
|
|
14
50
|
);
|
|
15
51
|
}
|
|
16
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Font Awesome icon identifier for use in DatoCMS plugins.
|
|
55
|
+
*
|
|
56
|
+
* Use Font Awesome icons for consistent visual styling across the admin interface.
|
|
57
|
+
* This is the recommended approach for most plugin icons, with custom SVGs reserved
|
|
58
|
+
* primarily for brand/company logos where Font Awesome doesn't have an appropriate match.
|
|
59
|
+
*/
|
|
17
60
|
export type AwesomeFontIconIdentifier =
|
|
18
61
|
| '0'
|
|
19
62
|
| '00'
|
package/src/manifest.ts
CHANGED
|
@@ -1745,7 +1745,7 @@ export const manifest: Manifest = {
|
|
|
1745
1745
|
name: 'onBeforeItemUpsert',
|
|
1746
1746
|
comment: {
|
|
1747
1747
|
markdownText:
|
|
1748
|
-
'This
|
|
1748
|
+
'This hook is called when the user attempts to save a record. You can use it to block record saving.\n\nIf you return `false`, the record will NOT be saved. A small on-page error will say "A plugin blocked the action".\nHowever, for better UX, consider also using `ctx.alert()` to better explain to the user why their save was blocked.\n\nIf you return `true`, the save will proceed as normal.\n\nThis hook runs BEFORE serverside validation. You can use it to do your own additional validation before returning.\nClientside validations are not affected by this hook, since those occur on individual fields\' `onBlur()` events.',
|
|
1749
1749
|
tag: 'beforeHooks',
|
|
1750
1750
|
},
|
|
1751
1751
|
nonCtxArguments: [
|
|
@@ -1773,7 +1773,7 @@ export const manifest: Manifest = {
|
|
|
1773
1773
|
},
|
|
1774
1774
|
location: {
|
|
1775
1775
|
filePath: 'src/hooks/onBeforeItemUpsert.ts',
|
|
1776
|
-
lineNumber:
|
|
1776
|
+
lineNumber: 47,
|
|
1777
1777
|
},
|
|
1778
1778
|
type: '(path: string, locale?: string) => Promise<void>',
|
|
1779
1779
|
},
|
|
@@ -1784,7 +1784,7 @@ export const manifest: Manifest = {
|
|
|
1784
1784
|
returnType: 'MaybePromise<boolean>',
|
|
1785
1785
|
location: {
|
|
1786
1786
|
filePath: 'src/hooks/onBeforeItemUpsert.ts',
|
|
1787
|
-
lineNumber:
|
|
1787
|
+
lineNumber: 22,
|
|
1788
1788
|
},
|
|
1789
1789
|
},
|
|
1790
1790
|
manualFieldExtensions: {
|