@stackbit/dev 0.0.48-alpha.1 → 0.0.51

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.
@@ -1,232 +0,0 @@
1
- import { ContentStoreTypes } from '@stackbit/cms-core';
2
- import { CommitAuthor } from '@stackbit/dev-common';
3
- export declare type APIMethodName = APIMethod['method'];
4
- export declare type APIMethodForMethod<T, U> = U extends {
5
- method: T;
6
- } ? U : never;
7
- export declare type APIMethodByMethod<T extends APIMethodName> = APIMethodForMethod<T, APIMethod>;
8
- export declare type APIMethodDataForMethod<T extends APIMethodName> = APIMethodByMethod<T>['data'];
9
- export declare type APIMethodResultForMethod<T extends APIMethodName> = APIMethodByMethod<T>['result'];
10
- export declare type APIMethod = APIMethodCreateDocument | APIMethodCreateAndLinkDocument | APIMethodUploadAndLinkAsset | APIMethodDuplicateDocument | APIMethodUpdateDocument | APIMethodValidateDocuments | APIMethodDeleteDocument | APIMethodGetAssets | APIMethodUploadAssets | APIMethodCreatePreset | APIMethodDeletePreset;
11
- export declare type APIMethodCreateDocument = {
12
- method: 'createDocument';
13
- data: {
14
- srcType: string;
15
- srcProjectId: string;
16
- modelName: string;
17
- object?: Record<string, any>;
18
- locale?: string;
19
- };
20
- result: {
21
- srcDocumentId: string;
22
- };
23
- };
24
- export declare type APIMethodCreateAndLinkDocument = {
25
- method: 'createAndLinkDocument';
26
- data: {
27
- srcType: string;
28
- srcProjectId: string;
29
- srcDocumentId: string;
30
- fieldPath: (string | number)[];
31
- modelName: string;
32
- object?: Record<string, any>;
33
- index?: number;
34
- locale?: string;
35
- };
36
- result: {
37
- srcDocumentId: string;
38
- };
39
- };
40
- export declare type APIMethodUploadAndLinkAsset = {
41
- method: 'uploadAndLinkAsset';
42
- data: {
43
- srcType: string;
44
- srcProjectId: string;
45
- srcDocumentId: string;
46
- fieldPath: (string | number)[];
47
- asset: UploadAssetData;
48
- index?: number;
49
- locale?: string;
50
- };
51
- result: {
52
- srcDocumentId: string;
53
- };
54
- };
55
- export declare type APIMethodDuplicateDocument = {
56
- method: 'duplicateDocument';
57
- data: {
58
- srcType: string;
59
- srcProjectId: string;
60
- srcDocumentId: string;
61
- object?: Record<string, any>;
62
- };
63
- result: {
64
- srcDocumentId: string;
65
- };
66
- };
67
- export declare type APIMethodUpdateDocument = {
68
- method: 'updateDocument';
69
- data: {
70
- srcType: string;
71
- srcProjectId: string;
72
- srcDocumentId: string;
73
- updateOperations: UpdateOperation[];
74
- };
75
- result: {
76
- srcDocumentId: string;
77
- };
78
- };
79
- export declare type APIMethodDeleteDocument = {
80
- method: 'deleteDocument';
81
- data: {
82
- srcType: string;
83
- srcProjectId: string;
84
- srcDocumentId: string;
85
- };
86
- result: void;
87
- };
88
- export declare type APIMethodValidateDocuments = {
89
- method: 'validateDocuments';
90
- data: {
91
- objects: {
92
- srcType: string;
93
- srcProjectId: string;
94
- srcObjectId: string;
95
- }[];
96
- locale?: string;
97
- };
98
- result: {
99
- errors: ContentStoreTypes.ValidationError[];
100
- };
101
- };
102
- export declare type APIMethodPublishDocuments = {
103
- method: 'publishDocuments';
104
- data: {
105
- objects: {
106
- srcType: string;
107
- srcProjectId: string;
108
- srcObjectId: string;
109
- }[];
110
- };
111
- result: void;
112
- };
113
- export declare type APIMethodGetAssets = {
114
- method: 'getAssets';
115
- data: {
116
- srcType?: string;
117
- srcProjectId?: string;
118
- pageSize?: number;
119
- pageNum?: number;
120
- searchQuery?: string;
121
- };
122
- result: {
123
- assets: ContentStoreTypes.APIAsset[];
124
- pageSize: number;
125
- pageNum: number;
126
- totalPages: number;
127
- };
128
- };
129
- export declare type APIMethodUploadAssets = {
130
- method: 'uploadAssets';
131
- data: {
132
- srcType: string;
133
- srcProjectId: string;
134
- assets: UploadAssetData[];
135
- locale?: string;
136
- user: any;
137
- };
138
- result: ContentStoreTypes.APIAsset[];
139
- };
140
- export declare type APIMethodCreatePreset = {
141
- method: 'createPreset';
142
- data: {
143
- label: string;
144
- metadata: any;
145
- thumbnail: string;
146
- fieldDataPath: string[];
147
- user: CommitAuthor;
148
- dryRun: boolean;
149
- };
150
- result: {
151
- files: string[];
152
- preset: {
153
- modelName: string;
154
- thumbnail?: string;
155
- data: any;
156
- label: string;
157
- metadata: any;
158
- };
159
- };
160
- };
161
- export declare type APIMethodDeletePreset = {
162
- method: 'deletePreset';
163
- data: {
164
- presetId: string;
165
- user: CommitAuthor;
166
- };
167
- result: {
168
- changes: {
169
- filePath: string;
170
- description: string;
171
- }[];
172
- filesRemoved: string[];
173
- };
174
- };
175
- export interface UploadAssetData {
176
- url: string;
177
- data?: string;
178
- metadata: {
179
- name: string;
180
- type: string;
181
- };
182
- }
183
- export declare type UpdateOperation = UpdateOperationSet | UpdateOperationUnset | UpdateOperationInsert | UpdateOperationRemove | UpdateOperationReorder;
184
- export declare type UpdateOperationBase = {
185
- opType: string;
186
- fieldPath: (string | number)[];
187
- locale?: string;
188
- };
189
- export declare type UpdateOperationSet = Simplify<UpdateOperationBase & {
190
- opType: 'set';
191
- field: UpdateOperationField;
192
- }>;
193
- export declare type UpdateOperationUnset = Simplify<UpdateOperationBase & {
194
- opType: 'unset';
195
- }>;
196
- export declare type UpdateOperationInsert = Simplify<UpdateOperationBase & {
197
- opType: 'insert';
198
- index?: number;
199
- item: UpdateOperationField;
200
- }>;
201
- export declare type UpdateOperationRemove = Simplify<UpdateOperationBase & {
202
- opType: 'remove';
203
- index: number;
204
- }>;
205
- export declare type UpdateOperationReorder = Simplify<UpdateOperationBase & {
206
- opType: 'reorder';
207
- order: number[];
208
- }>;
209
- export declare type UpdateOperationField = UpdateOperationValueField | UpdateOperationObjectField | UpdateOperationModelField | UpdateOperationReferenceField;
210
- export declare type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference'>;
211
- export declare type UpdateOperationValueField = {
212
- type: UpdateOperationValueFieldType;
213
- value: any;
214
- };
215
- export declare type UpdateOperationObjectField = {
216
- type: 'object';
217
- object: Record<string, any>;
218
- };
219
- export declare type UpdateOperationModelField = {
220
- type: 'model';
221
- modelName: string;
222
- object: Record<string, any>;
223
- };
224
- export declare type UpdateOperationReferenceField = {
225
- type: 'reference';
226
- refType: 'document' | 'asset';
227
- refId: string;
228
- };
229
- export declare type FieldType = 'string' | 'url' | 'slug' | 'text' | 'markdown' | 'html' | 'number' | 'boolean' | 'enum' | 'date' | 'datetime' | 'color' | 'image' | 'file' | 'json' | 'richText' | 'object' | 'model' | 'reference' | 'style' | 'list';
230
- export declare type Simplify<T> = {
231
- [K in keyof T]: T[K];
232
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=api-methods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-methods.js","sourceRoot":"","sources":["../../src/types/api-methods.ts"],"names":[],"mappings":""}
@@ -1,282 +0,0 @@
1
- import { ContentStoreTypes } from '@stackbit/cms-core';
2
- import { CommitAuthor } from '@stackbit/dev-common';
3
-
4
- export type APIMethodName = APIMethod['method'];
5
- export type APIMethodForMethod<T, U> = U extends { method: T } ? U : never;
6
- export type APIMethodByMethod<T extends APIMethodName> = APIMethodForMethod<T, APIMethod>;
7
- export type APIMethodDataForMethod<T extends APIMethodName> = APIMethodByMethod<T>['data'];
8
- export type APIMethodResultForMethod<T extends APIMethodName> = APIMethodByMethod<T>['result'];
9
-
10
- export type APIMethod =
11
- | APIMethodCreateDocument
12
- | APIMethodCreateAndLinkDocument
13
- | APIMethodUploadAndLinkAsset
14
- | APIMethodDuplicateDocument
15
- | APIMethodUpdateDocument
16
- | APIMethodValidateDocuments
17
- | APIMethodDeleteDocument
18
- | APIMethodGetAssets
19
- | APIMethodUploadAssets
20
- | APIMethodCreatePreset
21
- | APIMethodDeletePreset;
22
-
23
- export type APIMethodCreateDocument = {
24
- method: 'createDocument';
25
- data: {
26
- srcType: string;
27
- srcProjectId: string;
28
- modelName: string;
29
- object?: Record<string, any>;
30
- locale?: string;
31
- };
32
- result: { srcDocumentId: string };
33
- };
34
-
35
- export type APIMethodCreateAndLinkDocument = {
36
- method: 'createAndLinkDocument';
37
- data: {
38
- srcType: string;
39
- srcProjectId: string;
40
- srcDocumentId: string;
41
- fieldPath: (string | number)[];
42
- modelName: string;
43
- object?: Record<string, any>;
44
- index?: number;
45
- locale?: string;
46
- };
47
- result: { srcDocumentId: string };
48
- };
49
-
50
- export type APIMethodUploadAndLinkAsset = {
51
- method: 'uploadAndLinkAsset';
52
- data: {
53
- srcType: string;
54
- srcProjectId: string;
55
- srcDocumentId: string;
56
- fieldPath: (string | number)[];
57
- asset: UploadAssetData;
58
- index?: number;
59
- locale?: string;
60
- };
61
- result: { srcDocumentId: string };
62
- };
63
-
64
- export type APIMethodDuplicateDocument = {
65
- method: 'duplicateDocument';
66
- data: {
67
- srcType: string;
68
- srcProjectId: string;
69
- srcDocumentId: string;
70
- object?: Record<string, any>;
71
- };
72
- result: { srcDocumentId: string };
73
- };
74
-
75
- export type APIMethodUpdateDocument = {
76
- method: 'updateDocument';
77
- data: {
78
- srcType: string;
79
- srcProjectId: string;
80
- srcDocumentId: string;
81
- updateOperations: UpdateOperation[];
82
- };
83
- result: { srcDocumentId: string };
84
- };
85
-
86
- export type APIMethodDeleteDocument = {
87
- method: 'deleteDocument';
88
- data: {
89
- srcType: string;
90
- srcProjectId: string;
91
- srcDocumentId: string;
92
- };
93
- result: void;
94
- };
95
-
96
- export type APIMethodValidateDocuments = {
97
- method: 'validateDocuments';
98
- data: {
99
- objects: { srcType: string; srcProjectId: string; srcObjectId: string }[];
100
- locale?: string;
101
- };
102
- result: {
103
- errors: ContentStoreTypes.ValidationError[];
104
- };
105
- };
106
-
107
- export type APIMethodPublishDocuments = {
108
- method: 'publishDocuments';
109
- data: {
110
- objects: { srcType: string; srcProjectId: string; srcObjectId: string }[];
111
- };
112
- result: void;
113
- };
114
-
115
- export type APIMethodGetAssets = {
116
- method: 'getAssets';
117
- data: {
118
- srcType?: string;
119
- srcProjectId?: string;
120
- pageSize?: number;
121
- pageNum?: number;
122
- searchQuery?: string;
123
- };
124
- result: {
125
- assets: ContentStoreTypes.APIAsset[];
126
- pageSize: number;
127
- pageNum: number;
128
- totalPages: number;
129
- };
130
- };
131
- export type APIMethodUploadAssets = {
132
- method: 'uploadAssets';
133
- data: {
134
- srcType: string;
135
- srcProjectId: string;
136
- assets: UploadAssetData[];
137
- locale?: string;
138
- user: any;
139
- };
140
- result: ContentStoreTypes.APIAsset[];
141
- };
142
-
143
- export type APIMethodCreatePreset = {
144
- method: 'createPreset';
145
- data: {
146
- label: string;
147
- metadata: any;
148
- thumbnail: string;
149
- fieldDataPath: string[];
150
- user: CommitAuthor;
151
- dryRun: boolean;
152
- };
153
- result: {
154
- files: string[];
155
- preset: {
156
- modelName: string;
157
- thumbnail?: string;
158
- data: any;
159
- label: string;
160
- metadata: any
161
- }
162
- };
163
- };
164
-
165
- export type APIMethodDeletePreset = {
166
- method: 'deletePreset';
167
- data: {
168
- presetId: string;
169
- user: CommitAuthor;
170
- };
171
- result: {
172
- changes: {
173
- filePath: string;
174
- description: string;
175
- }[];
176
- filesRemoved: string[];
177
- };
178
- };
179
-
180
- export interface UploadAssetData {
181
- url: string;
182
- data?: string;
183
- metadata: {
184
- name: string;
185
- type: string;
186
- };
187
- }
188
-
189
- export type UpdateOperation = UpdateOperationSet | UpdateOperationUnset | UpdateOperationInsert | UpdateOperationRemove | UpdateOperationReorder;
190
-
191
- export type UpdateOperationBase = {
192
- opType: string;
193
- fieldPath: (string | number)[];
194
- locale?: string;
195
- };
196
-
197
- export type UpdateOperationSet = Simplify<
198
- UpdateOperationBase & {
199
- opType: 'set';
200
- field: UpdateOperationField;
201
- }
202
- >;
203
-
204
- export type UpdateOperationUnset = Simplify<
205
- UpdateOperationBase & {
206
- opType: 'unset';
207
- }
208
- >;
209
-
210
- export type UpdateOperationInsert = Simplify<
211
- UpdateOperationBase & {
212
- opType: 'insert';
213
- index?: number;
214
- item: UpdateOperationField;
215
- }
216
- >;
217
-
218
- export type UpdateOperationRemove = Simplify<
219
- UpdateOperationBase & {
220
- opType: 'remove';
221
- index: number;
222
- }
223
- >;
224
-
225
- export type UpdateOperationReorder = Simplify<
226
- UpdateOperationBase & {
227
- opType: 'reorder';
228
- order: number[];
229
- }
230
- >;
231
-
232
- export type UpdateOperationField = UpdateOperationValueField | UpdateOperationObjectField | UpdateOperationModelField | UpdateOperationReferenceField;
233
-
234
- export type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference'>;
235
- export type UpdateOperationValueField = {
236
- type: UpdateOperationValueFieldType;
237
- value: any;
238
- };
239
-
240
- export type UpdateOperationObjectField = {
241
- type: 'object';
242
- object: Record<string, any>;
243
- };
244
-
245
- export type UpdateOperationModelField = {
246
- type: 'model';
247
- modelName: string;
248
- object: Record<string, any>;
249
- };
250
-
251
- export type UpdateOperationReferenceField = {
252
- type: 'reference';
253
- refType: 'document' | 'asset';
254
- refId: string;
255
- };
256
-
257
- export type FieldType =
258
- | 'string'
259
- | 'url'
260
- | 'slug'
261
- | 'text'
262
- | 'markdown'
263
- | 'html'
264
- | 'number'
265
- | 'boolean'
266
- | 'enum'
267
- | 'date'
268
- | 'datetime'
269
- | 'color'
270
- | 'image'
271
- | 'file'
272
- | 'json'
273
- | 'richText'
274
- | 'object'
275
- | 'model'
276
- | 'reference'
277
- | 'style'
278
- | 'list';
279
-
280
- export type Simplify<T> = {
281
- [K in keyof T]: T[K];
282
- };