@storyblok/migrations 0.1.0
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/LICENSE +8 -0
- package/README.md +73 -0
- package/dist/index.cjs +445 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +203 -0
- package/dist/index.d.mts +203 -0
- package/dist/index.mjs +420 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Story } from "@storyblok/management-api-client/resources/stories";
|
|
2
|
+
import { Component } from "@storyblok/management-api-client/resources/components";
|
|
3
|
+
import { Asset } from "@storyblok/management-api-client/resources/assets";
|
|
4
|
+
import { Datasource } from "@storyblok/management-api-client/resources/datasources";
|
|
5
|
+
import { htmlToStoryblokRichtext } from "@storyblok/richtext/html-parser";
|
|
6
|
+
import { markdownToStoryblokRichtext } from "@storyblok/richtext/markdown-parser";
|
|
7
|
+
|
|
8
|
+
//#region src/map-refs.d.ts
|
|
9
|
+
interface RefMaps {
|
|
10
|
+
assets?: Map<unknown, string | number>;
|
|
11
|
+
stories?: Map<unknown, string | number>;
|
|
12
|
+
users?: Map<unknown, string | number>;
|
|
13
|
+
tags?: Map<unknown, string | number>;
|
|
14
|
+
datasources?: Map<unknown, string | number>;
|
|
15
|
+
}
|
|
16
|
+
type ComponentSchemas = Record<string, Record<string, {
|
|
17
|
+
type: string;
|
|
18
|
+
source?: string;
|
|
19
|
+
}>>;
|
|
20
|
+
interface MapRefsOptions {
|
|
21
|
+
schemas: ComponentSchemas;
|
|
22
|
+
maps: RefMaps;
|
|
23
|
+
}
|
|
24
|
+
type ProcessedFields = Set<Component['schema']>;
|
|
25
|
+
type MissingSchemas = Set<Component['name']>;
|
|
26
|
+
declare function mapRefs(story: Story, options: MapRefsOptions): {
|
|
27
|
+
mappedStory: Story;
|
|
28
|
+
processedFields: ProcessedFields;
|
|
29
|
+
missingSchemas: MissingSchemas;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/delete-out-of-schema-fields.d.ts
|
|
33
|
+
interface RemovedField {
|
|
34
|
+
component: string;
|
|
35
|
+
field: string;
|
|
36
|
+
}
|
|
37
|
+
declare function deleteOutOfSchemaFields(story: Story, schemaDefinition: ComponentSchemas): {
|
|
38
|
+
story: Story;
|
|
39
|
+
removedFields: RemovedField[];
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/local-assets.d.ts
|
|
43
|
+
declare function getLocalAssets(dir: string): Promise<Asset[]>;
|
|
44
|
+
declare function updateLocalAsset(dir: string, asset: Asset): Promise<void>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/local-components.d.ts
|
|
47
|
+
declare function getLocalComponents(dir: string): Promise<Component[]>;
|
|
48
|
+
declare function updateLocalComponent(dir: string, component: Component): Promise<void>;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/local-datasources.d.ts
|
|
51
|
+
declare function getLocalDatasources(dir: string): Promise<Datasource[]>;
|
|
52
|
+
declare function updateLocalDatasource(dir: string, datasource: Datasource): Promise<void>;
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/local-stories.d.ts
|
|
55
|
+
declare function getLocalStories(dir: string): Promise<Story[]>;
|
|
56
|
+
declare function updateLocalStory(dir: string, story: Story): Promise<void>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/rename-datasource-value.d.ts
|
|
59
|
+
interface ComponentToUpdate {
|
|
60
|
+
field: string;
|
|
61
|
+
name: string;
|
|
62
|
+
}
|
|
63
|
+
interface Change {
|
|
64
|
+
component: string;
|
|
65
|
+
field: string;
|
|
66
|
+
path: string;
|
|
67
|
+
}
|
|
68
|
+
declare function renameDataSourceValue(story: Story, componentsToUpdate: ComponentToUpdate[], oldValue: string, newValue: string): {
|
|
69
|
+
story: Story;
|
|
70
|
+
changes: Change[];
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/types.d.ts
|
|
74
|
+
type StoryblokPropertyType = 'asset' | 'multiasset' | 'multilink' | 'table' | 'richtext';
|
|
75
|
+
interface StoryblokAsset {
|
|
76
|
+
alt: string | null;
|
|
77
|
+
copyright: string | null;
|
|
78
|
+
fieldtype: 'asset';
|
|
79
|
+
id: number;
|
|
80
|
+
filename: string | null;
|
|
81
|
+
name: string;
|
|
82
|
+
title: string | null;
|
|
83
|
+
focus: string | null;
|
|
84
|
+
meta_data: Record<string, any>;
|
|
85
|
+
source: string | null;
|
|
86
|
+
is_external_url: boolean;
|
|
87
|
+
is_private: boolean;
|
|
88
|
+
src: string;
|
|
89
|
+
updated_at: string;
|
|
90
|
+
width: number | null;
|
|
91
|
+
height: number | null;
|
|
92
|
+
aspect_ratio: number | null;
|
|
93
|
+
public_id: string | null;
|
|
94
|
+
content_type: string;
|
|
95
|
+
}
|
|
96
|
+
type StoryblokMultiasset = StoryblokAsset[];
|
|
97
|
+
interface StoryblokMultilinkStory {
|
|
98
|
+
name: string;
|
|
99
|
+
created_at: string;
|
|
100
|
+
published_at: string;
|
|
101
|
+
id: number;
|
|
102
|
+
uuid: string;
|
|
103
|
+
content: Record<string, any>;
|
|
104
|
+
slug: string;
|
|
105
|
+
full_slug: string;
|
|
106
|
+
sort_by_date?: string;
|
|
107
|
+
position?: number;
|
|
108
|
+
tag_list?: string[];
|
|
109
|
+
is_startpage?: boolean;
|
|
110
|
+
parent_id?: number | null;
|
|
111
|
+
meta_data?: Record<string, any> | null;
|
|
112
|
+
group_id?: string;
|
|
113
|
+
first_published_at?: string;
|
|
114
|
+
release_id?: number | null;
|
|
115
|
+
lang?: string;
|
|
116
|
+
path?: string | null;
|
|
117
|
+
alternates?: any[];
|
|
118
|
+
default_full_slug?: string | null;
|
|
119
|
+
translated_slugs?: any[] | null;
|
|
120
|
+
}
|
|
121
|
+
interface StoryblokMultilinkLink {
|
|
122
|
+
id: number;
|
|
123
|
+
uuid: string;
|
|
124
|
+
slug: string;
|
|
125
|
+
path: string | null;
|
|
126
|
+
parent_id: number;
|
|
127
|
+
name: string;
|
|
128
|
+
is_folder: boolean;
|
|
129
|
+
published: boolean;
|
|
130
|
+
is_startpage: boolean;
|
|
131
|
+
position: number;
|
|
132
|
+
real_path: string;
|
|
133
|
+
}
|
|
134
|
+
interface StoryblokMultilinkUrl {
|
|
135
|
+
name: string;
|
|
136
|
+
id: number;
|
|
137
|
+
uuid: string;
|
|
138
|
+
slug: string;
|
|
139
|
+
url: string;
|
|
140
|
+
full_slug: string;
|
|
141
|
+
}
|
|
142
|
+
interface StoryblokMultilink {
|
|
143
|
+
fieldtype: 'multilink';
|
|
144
|
+
id: string;
|
|
145
|
+
url: string;
|
|
146
|
+
cached_url: string;
|
|
147
|
+
target?: '_blank' | '_self';
|
|
148
|
+
anchor?: string;
|
|
149
|
+
rel?: string;
|
|
150
|
+
title?: string;
|
|
151
|
+
prep?: string;
|
|
152
|
+
linktype: 'story' | 'url' | 'email' | 'asset';
|
|
153
|
+
story?: StoryblokMultilinkStory | StoryblokMultilinkLink | StoryblokMultilinkUrl;
|
|
154
|
+
email?: string;
|
|
155
|
+
}
|
|
156
|
+
interface StoryblokTable {
|
|
157
|
+
fieldtype: 'table';
|
|
158
|
+
thead: Array<{
|
|
159
|
+
_uid: string;
|
|
160
|
+
value: string;
|
|
161
|
+
component: '_table_head';
|
|
162
|
+
_editable?: string;
|
|
163
|
+
}>;
|
|
164
|
+
tbody: Array<{
|
|
165
|
+
_uid: string;
|
|
166
|
+
component: '_table_row';
|
|
167
|
+
_editable?: string;
|
|
168
|
+
body: Array<{
|
|
169
|
+
_uid: string;
|
|
170
|
+
value: string;
|
|
171
|
+
component: '_table_col';
|
|
172
|
+
_editable?: string;
|
|
173
|
+
}>;
|
|
174
|
+
}>;
|
|
175
|
+
}
|
|
176
|
+
interface StoryblokRichtext {
|
|
177
|
+
type: string;
|
|
178
|
+
content?: StoryblokRichtext[];
|
|
179
|
+
marks?: StoryblokRichtext[];
|
|
180
|
+
attrs?: Record<string, any>;
|
|
181
|
+
text?: string;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/url-to-asset.d.ts
|
|
185
|
+
interface UrlToAssetOptions {
|
|
186
|
+
alt?: string | null;
|
|
187
|
+
title?: string | null;
|
|
188
|
+
copyright?: string | null;
|
|
189
|
+
focus?: string | null;
|
|
190
|
+
}
|
|
191
|
+
declare function urlToAsset(url: string, options?: UrlToAssetOptions): StoryblokAsset;
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/url-to-link.d.ts
|
|
194
|
+
interface UrlToLinkOptions {
|
|
195
|
+
target?: '_blank' | '_self';
|
|
196
|
+
title?: string;
|
|
197
|
+
rel?: string;
|
|
198
|
+
anchor?: string;
|
|
199
|
+
}
|
|
200
|
+
declare function urlToLink(url: string, options?: UrlToLinkOptions): StoryblokMultilink;
|
|
201
|
+
//#endregion
|
|
202
|
+
export { type ComponentSchemas, type Datasource, type MapRefsOptions, type RefMaps, StoryblokAsset, StoryblokMultiasset, StoryblokMultilink, StoryblokMultilinkLink, StoryblokMultilinkStory, StoryblokMultilinkUrl, StoryblokPropertyType, StoryblokRichtext, StoryblokTable, type UrlToAssetOptions, type UrlToLinkOptions, deleteOutOfSchemaFields, getLocalAssets, getLocalComponents, getLocalDatasources, getLocalStories, htmlToStoryblokRichtext, mapRefs, markdownToStoryblokRichtext, renameDataSourceValue, updateLocalAsset, updateLocalComponent, updateLocalDatasource, updateLocalStory, urlToAsset, urlToLink };
|
|
203
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { htmlToStoryblokRichtext } from "@storyblok/richtext/html-parser";
|
|
2
|
+
import { markdownToStoryblokRichtext } from "@storyblok/richtext/markdown-parser";
|
|
3
|
+
import { Story } from "@storyblok/management-api-client/resources/stories";
|
|
4
|
+
import { Component } from "@storyblok/management-api-client/resources/components";
|
|
5
|
+
import { Asset } from "@storyblok/management-api-client/resources/assets";
|
|
6
|
+
import { Datasource } from "@storyblok/management-api-client/resources/datasources";
|
|
7
|
+
|
|
8
|
+
//#region src/map-refs.d.ts
|
|
9
|
+
interface RefMaps {
|
|
10
|
+
assets?: Map<unknown, string | number>;
|
|
11
|
+
stories?: Map<unknown, string | number>;
|
|
12
|
+
users?: Map<unknown, string | number>;
|
|
13
|
+
tags?: Map<unknown, string | number>;
|
|
14
|
+
datasources?: Map<unknown, string | number>;
|
|
15
|
+
}
|
|
16
|
+
type ComponentSchemas = Record<string, Record<string, {
|
|
17
|
+
type: string;
|
|
18
|
+
source?: string;
|
|
19
|
+
}>>;
|
|
20
|
+
interface MapRefsOptions {
|
|
21
|
+
schemas: ComponentSchemas;
|
|
22
|
+
maps: RefMaps;
|
|
23
|
+
}
|
|
24
|
+
type ProcessedFields = Set<Component['schema']>;
|
|
25
|
+
type MissingSchemas = Set<Component['name']>;
|
|
26
|
+
declare function mapRefs(story: Story, options: MapRefsOptions): {
|
|
27
|
+
mappedStory: Story;
|
|
28
|
+
processedFields: ProcessedFields;
|
|
29
|
+
missingSchemas: MissingSchemas;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/delete-out-of-schema-fields.d.ts
|
|
33
|
+
interface RemovedField {
|
|
34
|
+
component: string;
|
|
35
|
+
field: string;
|
|
36
|
+
}
|
|
37
|
+
declare function deleteOutOfSchemaFields(story: Story, schemaDefinition: ComponentSchemas): {
|
|
38
|
+
story: Story;
|
|
39
|
+
removedFields: RemovedField[];
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/local-assets.d.ts
|
|
43
|
+
declare function getLocalAssets(dir: string): Promise<Asset[]>;
|
|
44
|
+
declare function updateLocalAsset(dir: string, asset: Asset): Promise<void>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/local-components.d.ts
|
|
47
|
+
declare function getLocalComponents(dir: string): Promise<Component[]>;
|
|
48
|
+
declare function updateLocalComponent(dir: string, component: Component): Promise<void>;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/local-datasources.d.ts
|
|
51
|
+
declare function getLocalDatasources(dir: string): Promise<Datasource[]>;
|
|
52
|
+
declare function updateLocalDatasource(dir: string, datasource: Datasource): Promise<void>;
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/local-stories.d.ts
|
|
55
|
+
declare function getLocalStories(dir: string): Promise<Story[]>;
|
|
56
|
+
declare function updateLocalStory(dir: string, story: Story): Promise<void>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/rename-datasource-value.d.ts
|
|
59
|
+
interface ComponentToUpdate {
|
|
60
|
+
field: string;
|
|
61
|
+
name: string;
|
|
62
|
+
}
|
|
63
|
+
interface Change {
|
|
64
|
+
component: string;
|
|
65
|
+
field: string;
|
|
66
|
+
path: string;
|
|
67
|
+
}
|
|
68
|
+
declare function renameDataSourceValue(story: Story, componentsToUpdate: ComponentToUpdate[], oldValue: string, newValue: string): {
|
|
69
|
+
story: Story;
|
|
70
|
+
changes: Change[];
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/types.d.ts
|
|
74
|
+
type StoryblokPropertyType = 'asset' | 'multiasset' | 'multilink' | 'table' | 'richtext';
|
|
75
|
+
interface StoryblokAsset {
|
|
76
|
+
alt: string | null;
|
|
77
|
+
copyright: string | null;
|
|
78
|
+
fieldtype: 'asset';
|
|
79
|
+
id: number;
|
|
80
|
+
filename: string | null;
|
|
81
|
+
name: string;
|
|
82
|
+
title: string | null;
|
|
83
|
+
focus: string | null;
|
|
84
|
+
meta_data: Record<string, any>;
|
|
85
|
+
source: string | null;
|
|
86
|
+
is_external_url: boolean;
|
|
87
|
+
is_private: boolean;
|
|
88
|
+
src: string;
|
|
89
|
+
updated_at: string;
|
|
90
|
+
width: number | null;
|
|
91
|
+
height: number | null;
|
|
92
|
+
aspect_ratio: number | null;
|
|
93
|
+
public_id: string | null;
|
|
94
|
+
content_type: string;
|
|
95
|
+
}
|
|
96
|
+
type StoryblokMultiasset = StoryblokAsset[];
|
|
97
|
+
interface StoryblokMultilinkStory {
|
|
98
|
+
name: string;
|
|
99
|
+
created_at: string;
|
|
100
|
+
published_at: string;
|
|
101
|
+
id: number;
|
|
102
|
+
uuid: string;
|
|
103
|
+
content: Record<string, any>;
|
|
104
|
+
slug: string;
|
|
105
|
+
full_slug: string;
|
|
106
|
+
sort_by_date?: string;
|
|
107
|
+
position?: number;
|
|
108
|
+
tag_list?: string[];
|
|
109
|
+
is_startpage?: boolean;
|
|
110
|
+
parent_id?: number | null;
|
|
111
|
+
meta_data?: Record<string, any> | null;
|
|
112
|
+
group_id?: string;
|
|
113
|
+
first_published_at?: string;
|
|
114
|
+
release_id?: number | null;
|
|
115
|
+
lang?: string;
|
|
116
|
+
path?: string | null;
|
|
117
|
+
alternates?: any[];
|
|
118
|
+
default_full_slug?: string | null;
|
|
119
|
+
translated_slugs?: any[] | null;
|
|
120
|
+
}
|
|
121
|
+
interface StoryblokMultilinkLink {
|
|
122
|
+
id: number;
|
|
123
|
+
uuid: string;
|
|
124
|
+
slug: string;
|
|
125
|
+
path: string | null;
|
|
126
|
+
parent_id: number;
|
|
127
|
+
name: string;
|
|
128
|
+
is_folder: boolean;
|
|
129
|
+
published: boolean;
|
|
130
|
+
is_startpage: boolean;
|
|
131
|
+
position: number;
|
|
132
|
+
real_path: string;
|
|
133
|
+
}
|
|
134
|
+
interface StoryblokMultilinkUrl {
|
|
135
|
+
name: string;
|
|
136
|
+
id: number;
|
|
137
|
+
uuid: string;
|
|
138
|
+
slug: string;
|
|
139
|
+
url: string;
|
|
140
|
+
full_slug: string;
|
|
141
|
+
}
|
|
142
|
+
interface StoryblokMultilink {
|
|
143
|
+
fieldtype: 'multilink';
|
|
144
|
+
id: string;
|
|
145
|
+
url: string;
|
|
146
|
+
cached_url: string;
|
|
147
|
+
target?: '_blank' | '_self';
|
|
148
|
+
anchor?: string;
|
|
149
|
+
rel?: string;
|
|
150
|
+
title?: string;
|
|
151
|
+
prep?: string;
|
|
152
|
+
linktype: 'story' | 'url' | 'email' | 'asset';
|
|
153
|
+
story?: StoryblokMultilinkStory | StoryblokMultilinkLink | StoryblokMultilinkUrl;
|
|
154
|
+
email?: string;
|
|
155
|
+
}
|
|
156
|
+
interface StoryblokTable {
|
|
157
|
+
fieldtype: 'table';
|
|
158
|
+
thead: Array<{
|
|
159
|
+
_uid: string;
|
|
160
|
+
value: string;
|
|
161
|
+
component: '_table_head';
|
|
162
|
+
_editable?: string;
|
|
163
|
+
}>;
|
|
164
|
+
tbody: Array<{
|
|
165
|
+
_uid: string;
|
|
166
|
+
component: '_table_row';
|
|
167
|
+
_editable?: string;
|
|
168
|
+
body: Array<{
|
|
169
|
+
_uid: string;
|
|
170
|
+
value: string;
|
|
171
|
+
component: '_table_col';
|
|
172
|
+
_editable?: string;
|
|
173
|
+
}>;
|
|
174
|
+
}>;
|
|
175
|
+
}
|
|
176
|
+
interface StoryblokRichtext {
|
|
177
|
+
type: string;
|
|
178
|
+
content?: StoryblokRichtext[];
|
|
179
|
+
marks?: StoryblokRichtext[];
|
|
180
|
+
attrs?: Record<string, any>;
|
|
181
|
+
text?: string;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/url-to-asset.d.ts
|
|
185
|
+
interface UrlToAssetOptions {
|
|
186
|
+
alt?: string | null;
|
|
187
|
+
title?: string | null;
|
|
188
|
+
copyright?: string | null;
|
|
189
|
+
focus?: string | null;
|
|
190
|
+
}
|
|
191
|
+
declare function urlToAsset(url: string, options?: UrlToAssetOptions): StoryblokAsset;
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/url-to-link.d.ts
|
|
194
|
+
interface UrlToLinkOptions {
|
|
195
|
+
target?: '_blank' | '_self';
|
|
196
|
+
title?: string;
|
|
197
|
+
rel?: string;
|
|
198
|
+
anchor?: string;
|
|
199
|
+
}
|
|
200
|
+
declare function urlToLink(url: string, options?: UrlToLinkOptions): StoryblokMultilink;
|
|
201
|
+
//#endregion
|
|
202
|
+
export { type ComponentSchemas, type Datasource, type MapRefsOptions, type RefMaps, StoryblokAsset, StoryblokMultiasset, StoryblokMultilink, StoryblokMultilinkLink, StoryblokMultilinkStory, StoryblokMultilinkUrl, StoryblokPropertyType, StoryblokRichtext, StoryblokTable, type UrlToAssetOptions, type UrlToLinkOptions, deleteOutOfSchemaFields, getLocalAssets, getLocalComponents, getLocalDatasources, getLocalStories, htmlToStoryblokRichtext, mapRefs, markdownToStoryblokRichtext, renameDataSourceValue, updateLocalAsset, updateLocalComponent, updateLocalDatasource, updateLocalStory, urlToAsset, urlToLink };
|
|
203
|
+
//# sourceMappingURL=index.d.mts.map
|