@stackbit/dev 0.0.52 → 0.0.56-alpha.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.
@@ -24,12 +24,15 @@ const createLogger = ({ label }) => {
24
24
  message: true
25
25
  }));
26
26
  }
27
- return winston_1.default.createLogger({
27
+ const logger = winston_1.default.createLogger({
28
28
  level: config_1.default.logLevel,
29
29
  format: winston_1.default.format.combine(...formats),
30
30
  transports: transports
31
31
  });
32
+ logger.createLogger = exports.createLogger;
33
+ return logger;
32
34
  };
33
35
  exports.createLogger = createLogger;
36
+ logger.createLogger = exports.createLogger;
34
37
  exports.default = logger;
35
38
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,uDAA+B;AAE/B,MAAM,cAAc,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,iBAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAE5E,MAAM,UAAU,GAAG;IACf,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAC3B,MAAM,EAAE,iBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC;KACpD,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,GAAG,iBAAO,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,gBAAM,CAAC,QAAQ;IACtB,UAAU,EAAE,UAAU;CACzB,CAAC,CAAC;AAEI,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;IACvC,IAAI,KAAK,EAAE;QACP,OAAO,CAAC,IAAI,CACR,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,IA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,OAAO,CAAC,GAAG,OAAO,CAAC;QAC1C,UAAU,EAAE,UAAU;KACzB,CAAC,CAAC;IACH,MAAM,CAAC,YAAY,GAAG,oBAAY,CAAC;IACnC,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB;AAQF,MAAM,CAAC,YAAY,GAAG,oBAAY,CAAC;AAEnC,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,236 @@
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 | UpdateOperationListField;
210
+ export declare type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'list'>;
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 UpdateOperationListField = {
230
+ type: 'list';
231
+ items: any[];
232
+ };
233
+ 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';
234
+ export declare type Simplify<T> = {
235
+ [K in keyof T]: T[K];
236
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-methods.js","sourceRoot":"","sources":["../../src/types/api-methods.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbit/dev",
3
- "version": "0.0.52",
3
+ "version": "0.0.56-alpha.0",
4
4
  "description": "stackbit-dev",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,9 +22,9 @@
22
22
  "author": "Stackbit Inc.",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@stackbit/cms-core": "^0.0.17",
26
- "@stackbit/dev-common": "^0.0.48",
27
- "@stackbit/sdk": "^0.2.35",
25
+ "@stackbit/cms-core": "0.0.21-alpha.0",
26
+ "@stackbit/dev-common": "0.0.52-alpha.0",
27
+ "@stackbit/sdk": "0.2.39-alpha.0",
28
28
  "axios": "^0.25.0",
29
29
  "chalk": "^4.1.0",
30
30
  "chokidar": "^3.5.3",
@@ -58,5 +58,5 @@
58
58
  "ts-jest": "^27.1.5",
59
59
  "typescript": "^4.5.4"
60
60
  },
61
- "gitHead": "be61ec861035062e23384f341ba15e852ae26c3f"
61
+ "gitHead": "5d3055079122f4c4cc37fb1ec6916dc517a99194"
62
62
  }
package/src/dev.ts CHANGED
@@ -17,6 +17,7 @@ interface DevOptions {
17
17
  runnableDir?: string;
18
18
  autoOpen?: boolean;
19
19
  cmsType?: string;
20
+ csiEnabled?: boolean;
20
21
  contentfulAccessToken?: string;
21
22
  contentfulSpaceIds?: [string];
22
23
  contentfulPreviewTokens?: [string];
@@ -48,7 +49,7 @@ export async function start(options: DevOptions) {
48
49
 
49
50
  if (options.contentfulSpaceIds) {
50
51
  localDetails.spaceIds = options.contentfulSpaceIds;
51
- }
52
+ }
52
53
  if (options.sanityProjectId) {
53
54
  localDetails.projectId = options.sanityProjectId;
54
55
  }
@@ -58,6 +59,10 @@ export async function start(options: DevOptions) {
58
59
  apiKey: options.cloudinaryApiKey
59
60
  };
60
61
  }
62
+ if (process.env.CSI_ENABLED) {
63
+ logger.debug('CSI Enabled');
64
+ options.csiEnabled = true;
65
+ }
61
66
 
62
67
  logger.debug('Local details', { localDetails });
63
68
  const studioUrl = `${config.appUrl}/local/${Buffer.from(JSON.stringify(localDetails)).toString('base64')}`;