@stackbit/dev 1.0.10-staging.1 → 1.0.11-develop.2

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.
@@ -13,7 +13,6 @@ import {
13
13
  SSGRunOptions,
14
14
  DEFAULT_SSG_OPTIONS
15
15
  } from '@stackbit/sdk';
16
- import { ContentStoreTypes } from '@stackbit/cms-core';
17
16
  import type { FSWatcher } from 'chokidar';
18
17
 
19
18
  import { watchDir } from '../services/file-watcher';
@@ -45,9 +44,16 @@ import {
45
44
  APIMethodGetCustomActions,
46
45
  APIMethodRunCustomAction,
47
46
  APIMethodGetDocumentVersions,
48
- APIMethodGetDocumentForVersion
47
+ APIMethodGetDocumentForVersion,
48
+ APIMethodGetCollections,
49
+ APIMethodGetSiteMap,
50
+ APIMethodGetTreeViews,
51
+ APIMethodGetSchema,
52
+ APIMethodGetObjects,
53
+ APIMethodGetObjectsWithAnnotations,
54
+ APIMethodGetDocuments
49
55
  } from '../types/api-methods';
50
- import { DocumentSpecifier, Logger } from '@stackbit/types';
56
+ import { Logger } from '@stackbit/types';
51
57
  import { checkAndLogContentSourceVersions } from '@stackbit/dev-common';
52
58
 
53
59
  interface RunnerOptions {
@@ -268,12 +274,12 @@ export default class Runner implements APIMethodInterface {
268
274
  return this.ssg.directChangeSocketOrigin;
269
275
  }
270
276
 
271
- async getObjects({ objectIds, locale }: { objectIds?: string[]; locale?: string }): Promise<{ objects: ContentStoreTypes.APIObject[] }> {
272
- return this.editor.getObjects({ objectIds, locale });
277
+ async getObjects({ objectIds, locale, user }: APIMethodGetObjects['data']): Promise<APIMethodGetObjects['result']> {
278
+ return this.editor.getObjects({ objectIds, locale, user });
273
279
  }
274
280
 
275
- async getDocuments({ documentSpecs }: { documentSpecs?: DocumentSpecifier[] }) {
276
- return this.contentStoreAdapter.getApiDocuments({ documentSpecs });
281
+ async getDocuments({ documentSpecs, user }: APIMethodGetDocuments['data']): Promise<APIMethodGetDocuments['result']> {
282
+ return this.contentStoreAdapter.getApiDocuments({ documentSpecs, user });
277
283
  }
278
284
 
279
285
  async getObjectsWithAnnotations({
@@ -281,19 +287,15 @@ export default class Runner implements APIMethodInterface {
281
287
  clientAnnotationErrors = [],
282
288
  resolveAllReferences,
283
289
  sourcemaps,
284
- locale
285
- }: {
286
- annotationTree: any;
287
- clientAnnotationErrors: any;
288
- resolveAllReferences?: boolean;
289
- sourcemaps?: any;
290
- locale?: string;
291
- }) {
290
+ locale,
291
+ user
292
+ }: APIMethodGetObjectsWithAnnotations['data']): Promise<APIMethodGetObjectsWithAnnotations['result']> {
292
293
  const result = await this.editor.getObjectsWithAnnotations({
293
294
  annotationTree,
294
295
  clientAnnotationErrors,
295
296
  resolveAllReferences,
296
297
  locale,
298
+ user,
297
299
  reportAllErrors: true
298
300
  });
299
301
  const errors = [...(result.errors ?? []), ...clientAnnotationErrors];
@@ -301,20 +303,20 @@ export default class Runner implements APIMethodInterface {
301
303
  return result;
302
304
  }
303
305
 
304
- async getCollections({ locale }: { locale?: string }) {
305
- return this.editor.getCollections({ locale });
306
+ async getCollections({ locale, user }: APIMethodGetCollections['data']): Promise<APIMethodGetCollections['result']> {
307
+ return this.editor.getCollections({ locale, user });
306
308
  }
307
309
 
308
- async getSiteMap({ locale }: { locale?: string }) {
309
- return this.editor.getSiteMap({ locale });
310
+ async getSiteMap({ locale, user }: APIMethodGetSiteMap['data']): Promise<APIMethodGetSiteMap['result']> {
311
+ return this.editor.getSiteMap({ locale, user });
310
312
  }
311
313
 
312
- async getTreeViews() {
313
- return this.contentStoreAdapter.getTreeViews();
314
+ async getTreeViews({ user }: APIMethodGetTreeViews['data']): Promise<APIMethodGetTreeViews['result']> {
315
+ return this.contentStoreAdapter.getTreeViews({ user });
314
316
  }
315
317
 
316
- async getSchema({ locale }: { locale?: string }) {
317
- return this.editor.getSchema({ locale });
318
+ async getSchema({ locale, user }: APIMethodGetSchema['data']): Promise<APIMethodGetSchema['result']> {
319
+ return this.editor.getSchema({ locale, user });
318
320
  }
319
321
 
320
322
  async getUrl(srcDocumentId: string, srcProjectId: string, srcType: string, locale?: string): Promise<string | null> {
@@ -4,7 +4,7 @@ import bodyParser from 'body-parser';
4
4
  import Runner from '../runner';
5
5
  import logger from '../services/logger';
6
6
  import { PageNotFoundError } from '@stackbit/dev-common/dist/services/response-errors';
7
- import { APIMethod, APIMethodDataForMethod, APIMethodName, APIMethodResultForMethod } from '../types/api-methods';
7
+ import { APIMethod, APIMethodName } from '../types/api-methods';
8
8
 
9
9
  const authMiddleware = (uuid: string) => {
10
10
  return (req: Request, res: Response, next: NextFunction) => {
@@ -1,5 +1,5 @@
1
1
  import { ContentStoreTypes } from '@stackbit/cms-core';
2
- import { CollectionItemWithModel } from '@stackbit/dev-common';
2
+ import { CollectionItemWithModel, SiteMap, Collections, Schema } from '@stackbit/dev-common';
3
3
  import { Preset } from '@stackbit/sdk';
4
4
  import { DocumentSpecifier, ScheduledActionWithSource, TreeViewNode } from '@stackbit/types';
5
5
 
@@ -25,7 +25,12 @@ export type APIMethod =
25
25
  | APIMethodDeletePreset
26
26
  | APIMethodSearchDocuments
27
27
  | APIMethodOnWebhook
28
- | APIMethodTreeViews
28
+ | APIMethodGetTreeViews
29
+ | APIMethodGetSiteMap
30
+ | APIMethodGetCollections
31
+ | APIMethodGetSchema
32
+ | APIMethodGetObjects
33
+ | APIMethodGetObjectsWithAnnotations
29
34
  | APIMethodGetDocuments
30
35
  | APIMethodGetScheduledActions
31
36
  | APIMethodCreateScheduledAction
@@ -216,6 +221,7 @@ export type APIMethodGetAssets = {
216
221
  pageSize?: number;
217
222
  pageNum?: number;
218
223
  searchQuery?: string;
224
+ user?: ContentStoreTypes.User;
219
225
  };
220
226
  result: {
221
227
  assets: ContentStoreTypes.APIAsset[];
@@ -285,6 +291,7 @@ export type APIMethodSearchDocuments = {
285
291
  }>;
286
292
  locale?: string;
287
293
  filter: ContentStoreTypes.SearchFilter;
294
+ user?: ContentStoreTypes.User;
288
295
  };
289
296
  result: {
290
297
  items: CollectionItemWithModel[];
@@ -299,6 +306,7 @@ export type APIMethodGetDocumentVersions = {
299
306
  srcProjectId: string;
300
307
  documentId: string;
301
308
  locale?: string;
309
+ user?: ContentStoreTypes.User;
302
310
  };
303
311
  result: { versions: ContentStoreTypes.APIDocumentVersion[] };
304
312
  };
@@ -311,6 +319,7 @@ export type APIMethodGetDocumentForVersion = {
311
319
  documentId: string;
312
320
  versionId: string;
313
321
  locale?: string;
322
+ user?: ContentStoreTypes.User;
314
323
  };
315
324
  result: { version: ContentStoreTypes.APIDocumentVersionWithDocument };
316
325
  };
@@ -338,18 +347,75 @@ export type APIMethodRunCustomAction = {
338
347
  result: void;
339
348
  };
340
349
 
341
- export type APIMethodTreeViews = {
350
+ export type APIMethodGetTreeViews = {
342
351
  method: 'getTreeViews';
343
- data: void;
352
+ data: { user?: ContentStoreTypes.User };
344
353
  result: TreeViewNode[];
345
354
  };
346
355
 
356
+ export type APIMethodGetSiteMap = {
357
+ method: 'getSiteMap';
358
+ data: {
359
+ locale?: string;
360
+ user?: ContentStoreTypes.User;
361
+ };
362
+ result: SiteMap;
363
+ };
364
+
365
+ export type APIMethodGetCollections = {
366
+ method: 'getCollections';
367
+ data: {
368
+ locale?: string;
369
+ user?: ContentStoreTypes.User;
370
+ };
371
+ result: Collections;
372
+ };
373
+
374
+ export type APIMethodGetSchema = {
375
+ method: 'getSchema';
376
+ data: {
377
+ locale?: string;
378
+ user?: ContentStoreTypes.User;
379
+ };
380
+ result: Schema;
381
+ };
382
+
347
383
  export type APIMethodGetDocuments = {
348
384
  method: 'getDocuments';
349
- data: { documentSpecs?: DocumentSpecifier[] };
385
+ data: {
386
+ documentSpecs?: DocumentSpecifier[];
387
+ user?: ContentStoreTypes.User;
388
+ };
350
389
  result: { documents: ContentStoreTypes.APIDocument[] };
351
390
  };
352
391
 
392
+ export type APIMethodGetObjects = {
393
+ method: 'getObjects';
394
+ data: {
395
+ objectIds?: string[];
396
+ locale?: string;
397
+ user?: ContentStoreTypes.User;
398
+ };
399
+ result: { objects: ContentStoreTypes.APIObject[] };
400
+ };
401
+
402
+ export type APIMethodGetObjectsWithAnnotations = {
403
+ method: 'getObjectsWithAnnotations';
404
+ data: {
405
+ annotationTree: any;
406
+ clientAnnotationErrors: any;
407
+ resolveAllReferences?: boolean;
408
+ sourcemaps?: any;
409
+ locale?: string;
410
+ user?: ContentStoreTypes.User;
411
+ };
412
+ result: {
413
+ objects: ContentStoreTypes.APIObject[];
414
+ pathMap: any;
415
+ errors: any[];
416
+ };
417
+ };
418
+
353
419
  export interface UploadAssetData {
354
420
  url: string;
355
421
  data?: string;
@@ -1,8 +0,0 @@
1
- declare const _default: {
2
- directPaths: string[];
3
- directRoutes: {};
4
- directChangeSocketOrigin: boolean;
5
- directChangeOrigin: boolean;
6
- };
7
- export default _default;
8
- //# sourceMappingURL=ssg.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/runner/ssg.ts"],"names":[],"mappings":";;;;;;AAAA,wBAKE"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- directPaths: ['/_next/**', '/nextjs-live-updates/**'],
5
- directRoutes: {},
6
- directChangeSocketOrigin: false,
7
- directChangeOrigin: true
8
- };
9
- //# sourceMappingURL=ssg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssg.js","sourceRoot":"","sources":["../../src/runner/ssg.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACX,WAAW,EAAE,CAAC,WAAW,EAAE,yBAAyB,CAAC;IACrD,YAAY,EAAE,EAAE;IAChB,wBAAwB,EAAE,KAAK;IAC/B,kBAAkB,EAAE,IAAI;CAC3B,CAAC"}