@stackbit/cms-core 1.0.21-feature-document-statuses.1 → 1.0.21

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.
Files changed (63) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/content-store-utils.d.ts +5 -1
  3. package/dist/content-store-utils.d.ts.map +1 -1
  4. package/dist/content-store-utils.js +13 -3
  5. package/dist/content-store-utils.js.map +1 -1
  6. package/dist/content-store.d.ts +3 -23
  7. package/dist/content-store.d.ts.map +1 -1
  8. package/dist/content-store.js +50 -86
  9. package/dist/content-store.js.map +1 -1
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/types/content-store-api-document-fields.d.ts +5 -1
  15. package/dist/types/content-store-api-document-fields.d.ts.map +1 -1
  16. package/dist/types/content-store-types.d.ts +18 -11
  17. package/dist/types/content-store-types.d.ts.map +1 -1
  18. package/dist/types/content-store-types.js.map +1 -1
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/dist/types/index.js +1 -0
  22. package/dist/types/index.js.map +1 -1
  23. package/dist/types/references-types.d.ts +8 -0
  24. package/dist/types/references-types.d.ts.map +1 -0
  25. package/dist/types/references-types.js +3 -0
  26. package/dist/types/references-types.js.map +1 -0
  27. package/dist/utils/document-hooks.d.ts +4 -6
  28. package/dist/utils/document-hooks.d.ts.map +1 -1
  29. package/dist/utils/document-hooks.js +1 -70
  30. package/dist/utils/document-hooks.js.map +1 -1
  31. package/dist/utils/references-utils.d.ts +4 -0
  32. package/dist/utils/references-utils.d.ts.map +1 -0
  33. package/dist/utils/references-utils.js +103 -0
  34. package/dist/utils/references-utils.js.map +1 -0
  35. package/dist/utils/site-map.d.ts +0 -5
  36. package/dist/utils/site-map.d.ts.map +1 -1
  37. package/dist/utils/site-map.js +5 -12
  38. package/dist/utils/site-map.js.map +1 -1
  39. package/dist/utils/store-to-api-v2-docs-converter.d.ts +3 -1
  40. package/dist/utils/store-to-api-v2-docs-converter.d.ts.map +1 -1
  41. package/dist/utils/store-to-api-v2-docs-converter.js +10 -3
  42. package/dist/utils/store-to-api-v2-docs-converter.js.map +1 -1
  43. package/dist/utils/user-log-utils.d.ts +2 -2
  44. package/dist/utils/user-log-utils.d.ts.map +1 -1
  45. package/dist/utils/user-log-utils.js +7 -7
  46. package/dist/utils/user-log-utils.js.map +1 -1
  47. package/package.json +5 -5
  48. package/src/content-store-utils.ts +11 -1
  49. package/src/content-store.ts +62 -132
  50. package/src/index.ts +2 -1
  51. package/src/types/content-store-api-document-fields.ts +5 -1
  52. package/src/types/content-store-types.ts +21 -11
  53. package/src/types/index.ts +1 -0
  54. package/src/types/references-types.ts +8 -0
  55. package/src/utils/document-hooks.ts +8 -80
  56. package/src/utils/references-utils.ts +104 -0
  57. package/src/utils/site-map.ts +14 -31
  58. package/src/utils/store-to-api-v2-docs-converter.ts +15 -3
  59. package/src/utils/user-log-utils.ts +8 -14
  60. package/dist/utils/custom-search-filters.d.ts +0 -12
  61. package/dist/utils/custom-search-filters.d.ts.map +0 -1
  62. package/dist/utils/custom-search-filters.js +0 -46
  63. package/dist/utils/custom-search-filters.js.map +0 -1
@@ -9,14 +9,14 @@ export declare function logCreateDocument(options: {
9
9
  object?: Record<string, any>;
10
10
  locale?: string;
11
11
  }): void;
12
- export declare function logDocumentEvent(event: string, options: {
12
+ export declare function logDeleteDocument(options: {
13
13
  userLogger: Logger;
14
14
  srcType: string;
15
15
  srcProjectId: string;
16
16
  srcDocumentId: string;
17
17
  locale?: string;
18
18
  }): void;
19
- export declare function logDocumentsEvent(event: string, options: {
19
+ export declare function logPublishDocuments(options: {
20
20
  userLogger: Logger;
21
21
  objects: {
22
22
  srcType: string;
@@ -1 +1 @@
1
- {"version":3,"file":"user-log-utils.d.ts","sourceRoot":"","sources":["../../src/utils/user-log-utils.ts"],"names":[],"mappings":"AAAA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gB,mBAAmB,CAAC,OAAO,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,QASA;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,iBAAiB,CAAC,eAAe,EAAE,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,QAIA;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,QAGA;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC,eAAe,EAAE,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,QAGA"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logUploadAssets = exports.logDuplicateDocument = exports.logUpdateDocument = exports.logDocumentsEvent = exports.logDocumentEvent = exports.logCreateDocument = exports.pluralize = void 0;
3
+ exports.logUploadAssets = exports.logDuplicateDocument = exports.logUpdateDocument = exports.logPublishDocuments = exports.logDeleteDocument = exports.logCreateDocument = exports.pluralize = void 0;
4
4
  function pluralize(str, count) {
5
5
  return count === 1 ? str : `${str}s`;
6
6
  }
@@ -15,20 +15,20 @@ function logCreateDocument(options) {
15
15
  userLogger.info(`Create document for ${modelName} ${encodeIdentifier({ srcType, srcProjectId, locale })}`);
16
16
  }
17
17
  exports.logCreateDocument = logCreateDocument;
18
- function logDocumentEvent(event, options) {
18
+ function logDeleteDocument(options) {
19
19
  const { userLogger, srcType, srcProjectId, srcDocumentId, locale } = options;
20
- userLogger.info(`${event} document ${encodeIdentifier({ srcType, srcProjectId, srcDocumentId, locale })}`);
20
+ userLogger.info(`Delete document ${encodeIdentifier({ srcType, srcProjectId, srcDocumentId, locale })}`);
21
21
  }
22
- exports.logDocumentEvent = logDocumentEvent;
23
- function logDocumentsEvent(event, options) {
22
+ exports.logDeleteDocument = logDeleteDocument;
23
+ function logPublishDocuments(options) {
24
24
  const { userLogger, objects, locale } = options;
25
25
  const objectCount = objects.length;
26
26
  const objectPlural = pluralize('item', objectCount);
27
- userLogger.info(`${event} ${objectCount} ${objectPlural}: ${objects.map((object) => object.srcObjectId).join(', ')} ${objects
27
+ userLogger.info(`Publish ${objectCount} ${objectPlural}: ${objects.map((object) => object.srcObjectId).join(', ')} ${objects
28
28
  .map((object) => encodeIdentifier({ srcType: object.srcType, srcProjectId: object.srcProjectId, locale }))
29
29
  .join(', ')}`);
30
30
  }
31
- exports.logDocumentsEvent = logDocumentsEvent;
31
+ exports.logPublishDocuments = logPublishDocuments;
32
32
  function logUpdateDocument(options) {
33
33
  const { userLogger, srcType, srcProjectId, srcDocumentId, updateOperations, locale } = options;
34
34
  const updates = updateOperations.map((update) => `${update.opType.toUpperCase()} ${update.fieldPath.join('.')}`).join(', ');
@@ -1 +1 @@
1
- {"version":3,"file":"user-log-utils.js","sourceRoot":"","sources":["../../src/utils/user-log-utils.ts"],"names":[],"mappings":";;;AAGA,SAAgB,SAAS,CAAC,GAAW,EAAE,KA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AC/F,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5H,UAAU,CAAC,IAAI,CAAC,mBAAmB,OAAO,IAAI,gBAAgB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AACxH,CAAC;AAXD,8CAWC;AAED,SAAgB,oBAAoB,CAAC,OAOpC;IACG,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC7E,UAAU,CAAC,IAAI,CAAC,sBAAsB,gBAAgB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAChH,CAAC;AAVD,oDAUC;AAED,SAAgB,eAAe,CAAC,OAM/B;IACG,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC9D,UAAU,CAAC,IAAI,CAAC,gBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3F,CAAC;AATD,0CASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbit/cms-core",
3
- "version": "1.0.21-feature-document-statuses.1",
3
+ "version": "1.0.21",
4
4
  "description": "stackbit-dev",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,9 +26,9 @@
26
26
  "@babel/traverse": "^7.11.5",
27
27
  "@iarna/toml": "^2.2.3",
28
28
  "@netlify/sdk": "^1.17.2",
29
- "@stackbit/sdk": "1.0.21-feature-document-statuses.1",
30
- "@stackbit/types": "0.11.10-feature-document-statuses.1",
31
- "@stackbit/utils": "0.4.10-feature-document-statuses.1",
29
+ "@stackbit/sdk": "1.0.21",
30
+ "@stackbit/types": "0.11.10",
31
+ "@stackbit/utils": "0.4.10",
32
32
  "chalk": "^4.0.1",
33
33
  "content-engine": "0.0.29",
34
34
  "esm": "^3.2.25",
@@ -44,5 +44,5 @@
44
44
  "slugify": "^1.6.5",
45
45
  "uuid": "^9.0.0"
46
46
  },
47
- "gitHead": "1633cfabeed0f393f0ff24c450d5e5c5537c5994"
47
+ "gitHead": "0288bc3c70befbc2d3498d33e13f925df7a48c73"
48
48
  }
@@ -15,6 +15,10 @@ export function getContentSourceId(contentSourceType: string, srcProjectId: stri
15
15
  return contentSourceType + ':' + srcProjectId;
16
16
  }
17
17
 
18
+ export function getObjectId(srcType: string, srcProjectId: string, srcObjectId: string) {
19
+ return `${srcType}:${srcProjectId}:${srcObjectId}`;
20
+ }
21
+
18
22
  export function getContentSourceDataByTypeAndProjectIdOrThrow(
19
23
  srcType: string,
20
24
  srcProjectId: string,
@@ -169,6 +173,9 @@ export function isContentChangesEmpty(contentChanges?: CSITypes.ContentChanges):
169
173
 
170
174
  export function isContentChangeResultEmpty(contentChangeResult: ContentStoreTypes.ContentChangeResult) {
171
175
  return (
176
+ contentChangeResult.createdDocuments.length === 0 &&
177
+ contentChangeResult.createdAssets.length === 0 &&
178
+ contentChangeResult.createdScheduledActions.length === 0 &&
172
179
  contentChangeResult.updatedDocuments.length === 0 &&
173
180
  contentChangeResult.updatedAssets.length === 0 &&
174
181
  contentChangeResult.updatedScheduledActions.length === 0 &&
@@ -180,9 +187,12 @@ export function isContentChangeResultEmpty(contentChangeResult: ContentStoreType
180
187
 
181
188
  export function contentChangeResultCounts(contentChangeResult: ContentStoreTypes.ContentChangeResult) {
182
189
  return {
190
+ createdDocumentsCount: contentChangeResult.createdDocuments.length,
191
+ createdAssetsCount: contentChangeResult.createdAssets.length,
192
+ createdScheduledActionsCount: contentChangeResult.createdScheduledActions.length,
183
193
  updatedDocumentsCount: contentChangeResult.updatedDocuments.length,
184
194
  updatedAssetsCount: contentChangeResult.updatedAssets.length,
185
- updatedScheduledActionCount: contentChangeResult.updatedScheduledActions.length,
195
+ updatedScheduledActionsCount: contentChangeResult.updatedScheduledActions.length,
186
196
  deletedDocumentsCount: contentChangeResult.deletedDocuments.length,
187
197
  deletedAssetsCount: contentChangeResult.deletedAssets.length,
188
198
  deletedScheduledActionsCount: contentChangeResult.deletedScheduledActions.length
@@ -30,7 +30,7 @@ import { append, DeferredPromise, deferredPromise, deferWhileRunning, mapPromise
30
30
 
31
31
  import * as ContentStoreTypes from './types';
32
32
  import { Timer } from './utils/timer';
33
- import { ContentSourceData, ContentSourceRawData, ContentStoreEvent, ContentStoreEventType, ProvisionalData, SearchFilter } from './types';
33
+ import { ContentSourceData, ContentSourceRawData, ContentStoreEvent, ContentStoreEventType, ProvisionalData, ReferenceMap, SearchFilter } from './types';
34
34
  import { searchDocuments } from './utils/search-utils';
35
35
  import { mapCSIAssetsToStoreAssets, mapCSIDocumentsToStoreDocuments } from './utils/csi-to-store-docs-converter';
36
36
  import {
@@ -48,13 +48,13 @@ import {
48
48
  getErrorAtLine,
49
49
  findContentSourcesDataForTypeOrId,
50
50
  getDocumentFieldForLocale,
51
- getCacheDir
51
+ getCacheDir,
52
+ getObjectId
52
53
  } from './content-store-utils';
53
54
  import {
54
55
  getSiteMapEntriesFromStackbitConfig,
55
56
  updateSiteMapEntriesWithContentChanges,
56
57
  getDocumentFieldLabelValueForSiteMapEntry,
57
- getSiteMapGroupKeyForDocument,
58
58
  SiteMapEntryGroups
59
59
  } from './utils/site-map';
60
60
  import { mapAssetsToLocalizedApiImages, mapDocumentsToLocalizedApiObjects, mapStoreAssetsToAPIAssets } from './utils/store-to-api-docs-converter';
@@ -68,22 +68,15 @@ import { BackCompatContentSourceInterface, backwardCompatibleContentSource } fro
68
68
  import { createConfigDelegate, getCreateConfigDelegateThunk } from './utils/config-delegate';
69
69
  import { GitService } from './services';
70
70
  import { getAssetSourcesForClient } from './utils/asset-sources-utils';
71
- import {
72
- archiveDocumentHooked,
73
- deleteDocumentHooked,
74
- publishDocumentHooked,
75
- unarchiveDocumentHooked,
76
- unpublishDocumentHooked,
77
- updateDocumentHooked
78
- } from './utils/document-hooks';
71
+ import { deleteDocumentHooked, publishDocumentHooked, updateDocumentHooked } from './utils/document-hooks';
79
72
  import { resolveCustomActionsById, getGlobalAndBulkAPIActions, runCustomAction } from './utils/custom-actions';
80
73
  import { getSanitizedTreeViews, removeHiddenTreeViews } from './utils/tree-views';
81
74
  import { getModelFieldAtFieldPath } from './utils/field-path-utils';
82
75
  import {
83
76
  logCreateDocument,
77
+ logDeleteDocument,
84
78
  logDuplicateDocument,
85
- logDocumentEvent,
86
- logDocumentsEvent,
79
+ logPublishDocuments,
87
80
  logUpdateDocument,
88
81
  logUploadAssets,
89
82
  pluralize
@@ -94,6 +87,8 @@ import { NoopFileCache, FileCache } from './utils/file-cache';
94
87
  import { getContentSourceFilteredModelsForUser, getFilteredAssetsForUser, getFilteredDocumentsForUser } from './utils/filtered-entities';
95
88
  import { STACKBIT_PRESET_MODEL_NAME } from './consts';
96
89
  import { syncContentSource, updateProvisionalDataFromContentSource } from './utils/content-store-data-manager';
90
+ import { getReferenceMap } from './utils/references-utils';
91
+ import { utils } from './';
97
92
 
98
93
  export type HandleConfigAssets = <T extends Model>({ models, presets }: { models?: T[]; presets?: PresetMap }) => Promise<{ models: T[]; presets: PresetMap }>;
99
94
 
@@ -144,6 +139,7 @@ export class ContentStore {
144
139
  private treeViews: CSITypes.TreeViewNode[] = [];
145
140
  private customActionRunStateMap: ContentStoreTypes.CustomActionRunStateMap = {};
146
141
  private contentEngine?: ContentEngine | null;
142
+ private referenceMap: ReferenceMap = {};
147
143
 
148
144
  constructor(options: ContentSourceOptions) {
149
145
  this.logger = options.logger.createLogger({ label: 'content-store' });
@@ -551,6 +547,8 @@ export class ContentStore {
551
547
  logger: this.userLogger
552
548
  });
553
549
 
550
+ this.calculateReferenceMap();
551
+
554
552
  if (!init) {
555
553
  this.onSchemaChangeCallback();
556
554
  }
@@ -576,6 +574,9 @@ export class ContentStore {
576
574
 
577
575
  const invalidateSchemaForContentSourceIds: string[] = [];
578
576
  const contentChanges: ContentStoreTypes.ContentChangeResult = {
577
+ createdDocuments: [],
578
+ createdAssets: [],
579
+ createdScheduledActions: [],
579
580
  updatedDocuments: [],
580
581
  updatedAssets: [],
581
582
  updatedScheduledActions: [],
@@ -629,6 +630,9 @@ export class ContentStore {
629
630
  result = this.onContentChange(contentSourceEvent.contentSourceId, contentSourceEvent.contentChanges);
630
631
  }
631
632
 
633
+ contentChanges.createdDocuments = contentChanges.createdDocuments.concat(result.contentChangeResult.createdDocuments);
634
+ contentChanges.createdAssets = contentChanges.createdAssets.concat(result.contentChangeResult.createdAssets);
635
+ contentChanges.createdScheduledActions = contentChanges.createdScheduledActions.concat(result.contentChangeResult.createdScheduledActions);
632
636
  contentChanges.updatedDocuments = contentChanges.updatedDocuments.concat(result.contentChangeResult.updatedDocuments);
633
637
  contentChanges.updatedAssets = contentChanges.updatedAssets.concat(result.contentChangeResult.updatedAssets);
634
638
  contentChanges.updatedScheduledActions = contentChanges.updatedScheduledActions.concat(result.contentChangeResult.updatedScheduledActions);
@@ -675,6 +679,7 @@ export class ContentStore {
675
679
  if (presetsUpdated) {
676
680
  this.onSchemaChangeCallback();
677
681
  } else if (!isContentChangeResultEmpty(contentChanges)) {
682
+ this.calculateReferenceMap();
678
683
  this.onContentChangeCallback(contentChanges);
679
684
  }
680
685
  }
@@ -1023,9 +1028,6 @@ export class ContentStore {
1023
1028
  );
1024
1029
 
1025
1030
  const enabledDocumentVersions = !!contentSourceInstance.getDocumentVersions;
1026
- const enabledUnpublish = !!contentSourceInstance.unpublishDocuments;
1027
- const enabledArchive = !!contentSourceInstance.archiveDocument;
1028
- const enabledUnarchive = !!contentSourceInstance.unarchiveDocument;
1029
1031
 
1030
1032
  const contentStoreAssets = mapCSIAssetsToStoreAssets({
1031
1033
  csiAssets: csiAssets,
@@ -1093,9 +1095,6 @@ export class ContentStore {
1093
1095
  scheduledActions: scheduledActions,
1094
1096
  syncContext: syncContext,
1095
1097
  enabledFeatures: {
1096
- unpublish: enabledUnpublish,
1097
- archive: enabledArchive,
1098
- unarchive: enabledUnarchive,
1099
1098
  scheduledActions: enabledScheduledActions,
1100
1099
  documentVersions: enabledDocumentVersions
1101
1100
  }
@@ -1129,6 +1128,9 @@ export class ContentStore {
1129
1128
  });
1130
1129
 
1131
1130
  const result: ContentStoreTypes.ContentChangeResult = {
1131
+ createdDocuments: [],
1132
+ createdAssets: [],
1133
+ createdScheduledActions: [],
1132
1134
  updatedDocuments: [],
1133
1135
  updatedAssets: [],
1134
1136
  updatedScheduledActions: [],
@@ -1266,7 +1268,8 @@ export class ContentStore {
1266
1268
  const document = documents[idx]!;
1267
1269
  const csiDocument = contentChangesFull.documents[idx]!;
1268
1270
  const dataIndex = contentSourceData.documents.findIndex((existingDoc) => existingDoc.srcObjectId === document.srcObjectId);
1269
- if (dataIndex === -1) {
1271
+ const isNewDoc = dataIndex === -1;
1272
+ if (isNewDoc) {
1270
1273
  contentSourceData.documents.push(document);
1271
1274
  contentSourceData.csiDocuments.push(csiDocument);
1272
1275
  } else {
@@ -1290,7 +1293,7 @@ export class ContentStore {
1290
1293
  }
1291
1294
  }
1292
1295
  }
1293
- result.updatedDocuments.push({
1296
+ result[isNewDoc ? 'createdDocuments' : 'updatedDocuments'].push({
1294
1297
  srcType: contentSourceData.srcType,
1295
1298
  srcProjectId: contentSourceData.srcProjectId,
1296
1299
  srcObjectId: document.srcObjectId
@@ -1302,7 +1305,8 @@ export class ContentStore {
1302
1305
  const asset = assets[idx]!;
1303
1306
  const csiAsset = contentChangesFull.assets[idx]!;
1304
1307
  const index = contentSourceData.assets.findIndex((existingAsset) => existingAsset.srcObjectId === asset.srcObjectId);
1305
- if (index === -1) {
1308
+ const isNewAsset = index === -1;
1309
+ if (isNewAsset) {
1306
1310
  contentSourceData.assets.push(asset);
1307
1311
  contentSourceData.csiAssets.push(csiAsset);
1308
1312
  } else {
@@ -1310,7 +1314,7 @@ export class ContentStore {
1310
1314
  contentSourceData.assets.splice(index, 1, asset);
1311
1315
  contentSourceData.csiAssets.splice(index, 1, csiAsset);
1312
1316
  }
1313
- result.updatedAssets.push({
1317
+ result[isNewAsset ? 'createdAssets' : 'updatedAssets'].push({
1314
1318
  srcType: contentSourceData.srcType,
1315
1319
  srcProjectId: contentSourceData.srcProjectId,
1316
1320
  srcObjectId: asset.srcObjectId
@@ -1322,12 +1326,13 @@ export class ContentStore {
1322
1326
  // the indexes of mapped assets and assets from changeEvent are the same
1323
1327
  const scheduledAction = scheduledActions[idx]!;
1324
1328
  const index = contentSourceData.scheduledActions.findIndex((existingScheduledAction) => existingScheduledAction.id === scheduledAction.id);
1325
- if (index === -1) {
1329
+ const isNewAction = index === -1;
1330
+ if (isNewAction) {
1326
1331
  contentSourceData.scheduledActions.push(scheduledAction);
1327
1332
  } else {
1328
1333
  contentSourceData.scheduledActions.splice(index, 1, scheduledAction);
1329
1334
  }
1330
- result.updatedScheduledActions.push({
1335
+ result[isNewAction ? 'createdScheduledActions' : 'updatedScheduledActions'].push({
1331
1336
  srcType: contentSourceData.srcType,
1332
1337
  srcProjectId: contentSourceData.srcProjectId,
1333
1338
  scheduledActionId: scheduledAction.id
@@ -1502,14 +1507,20 @@ export class ContentStore {
1502
1507
  return _.keyBy(contentSourceDataArr, 'id');
1503
1508
  }
1504
1509
 
1510
+ private calculateReferenceMap() {
1511
+ const documents = [...this.getDocuments(), ...this.getAssets()];
1512
+ this.referenceMap = utils.deepFreeze(getReferenceMap(documents));
1513
+ }
1514
+
1515
+ getReferenceMap() {
1516
+ return this.referenceMap;
1517
+ }
1518
+
1505
1519
  getContentSourceMeta(): {
1506
1520
  srcType: string;
1507
1521
  srcProjectId: string;
1508
1522
  srcVersion: string;
1509
1523
  csiVersion: string;
1510
- supportsUnpublish: boolean;
1511
- supportsArchive: boolean;
1512
- supportsUnarchive: boolean;
1513
1524
  supportsScheduledActions: boolean;
1514
1525
  supportsDocumentVersions: boolean;
1515
1526
  }[] {
@@ -1521,9 +1532,6 @@ export class ContentStore {
1521
1532
  srcProjectId: string;
1522
1533
  srcVersion: string;
1523
1534
  csiVersion: string;
1524
- supportsUnpublish: boolean;
1525
- supportsArchive: boolean;
1526
- supportsUnarchive: boolean;
1527
1535
  supportsScheduledActions: boolean;
1528
1536
  supportsDocumentVersions: boolean;
1529
1537
  }[],
@@ -1534,9 +1542,6 @@ export class ContentStore {
1534
1542
  srcProjectId: contentSourceData.srcProjectId,
1535
1543
  srcVersion: contentSourceData.version.contentSourceVersion,
1536
1544
  csiVersion: contentSourceData.version.interfaceVersion,
1537
- supportsUnpublish: contentSourceData?.enabledFeatures.unpublish ?? false,
1538
- supportsArchive: contentSourceData?.enabledFeatures.archive ?? false,
1539
- supportsUnarchive: contentSourceData?.enabledFeatures.unarchive ?? false,
1540
1545
  supportsScheduledActions: contentSourceData?.enabledFeatures.scheduledActions ?? false,
1541
1546
  supportsDocumentVersions: contentSourceData?.enabledFeatures.documentVersions ?? false
1542
1547
  });
@@ -1877,11 +1882,7 @@ export class ContentStore {
1877
1882
  srcDocumentId: string;
1878
1883
  locale?: string;
1879
1884
  }): CSITypes.SiteMapEntry[] {
1880
- const key = getSiteMapGroupKeyForDocument({
1881
- srcType: srcType,
1882
- srcProjectId: srcProjectId,
1883
- srcDocumentId: srcDocumentId
1884
- });
1885
+ const key = getObjectId(srcType, srcProjectId, srcDocumentId);
1885
1886
  const siteMapEntryGroup = this.siteMapEntryGroups[key];
1886
1887
  const siteMapEntries = _.values(siteMapEntryGroup);
1887
1888
  return _.isEmpty(locale) ? siteMapEntries : siteMapEntries.filter((siteMapEntry) => !siteMapEntry.locale || siteMapEntry.locale === locale);
@@ -1968,12 +1969,17 @@ export class ContentStore {
1968
1969
  documents: ContentStoreTypes.APIDocument[];
1969
1970
  } {
1970
1971
  let filteredDocuments: ContentStoreTypes.Document[];
1972
+ const deleteFieldsObjects: string[] = [];
1973
+
1971
1974
  if (documentSpecs?.length) {
1972
1975
  // filter over documentSpecs
1973
1976
  filteredDocuments = documentSpecs?.reduce((acc: ContentStoreTypes.Document[], docSpec) => {
1974
1977
  const contentSourceId = getContentSourceId(docSpec.srcType, docSpec.srcProjectId);
1975
1978
  const document = this.contentSourceDataById[contentSourceId]?.documentMap[docSpec.srcDocumentId];
1976
1979
  if (document && document.srcModelName !== STACKBIT_PRESET_MODEL_NAME) {
1980
+ if (docSpec.omitFields) {
1981
+ deleteFieldsObjects.push(getObjectId(document.srcType, document.srcProjectId, document.srcObjectId));
1982
+ }
1977
1983
  acc.push(document);
1978
1984
  }
1979
1985
  return acc;
@@ -2002,12 +2008,20 @@ export class ContentStore {
2002
2008
  logger: this.userLogger
2003
2009
  });
2004
2010
 
2011
+ const documents = mapDocumentsToApiDocuments({
2012
+ documents: filteredDocuments,
2013
+ contentSourceDataById: this.contentSourceDataById,
2014
+ delegate: createConfigDelegate({ contentSourceDataById: this.contentSourceDataById, logger: this.userLogger }),
2015
+ referenceMap: this.referenceMap
2016
+ });
2017
+
2018
+ deleteFieldsObjects.forEach((objectId) => {
2019
+ const document = documents.find((document) => objectId === getObjectId(document.srcType, document.srcProjectId, document.srcObjectId));
2020
+ delete document?.fields;
2021
+ });
2022
+
2005
2023
  return {
2006
- documents: mapDocumentsToApiDocuments({
2007
- documents: filteredDocuments,
2008
- contentSourceDataById: this.contentSourceDataById,
2009
- delegate: createConfigDelegate({ contentSourceDataById: this.contentSourceDataById, logger: this.userLogger })
2010
- })
2024
+ documents
2011
2025
  };
2012
2026
  }
2013
2027
 
@@ -2077,8 +2091,6 @@ export class ContentStore {
2077
2091
  shallow?: boolean;
2078
2092
  objects: { srcObjectId: string; srcProjectId: string; srcType: string; srcEnvironment?: string }[];
2079
2093
  }): Promise<ContentStoreTypes.StagedChange[]> {
2080
- const getObjectStrId = (srcType: string, srcProjectId: string, srcObjectId: string) => `${srcType}:${srcProjectId}:${srcObjectId}`;
2081
-
2082
2094
  const documents = this.getDocuments({ locale });
2083
2095
  const assets = this.getAssets({ locale });
2084
2096
  const allObjects = [...documents, ...assets];
@@ -2098,7 +2110,7 @@ export class ContentStore {
2098
2110
  publishableObjects = allObjects;
2099
2111
  }
2100
2112
 
2101
- const visited: string[] = publishableObjects.map((object) => getObjectStrId(object.srcType, object.srcProjectId, object.srcObjectId));
2113
+ const visited: string[] = publishableObjects.map((object) => getObjectId(object.srcType, object.srcProjectId, object.srcObjectId));
2102
2114
 
2103
2115
  const findUsedChangedObjects = (
2104
2116
  rootObject: ContentStoreTypes.Document,
@@ -2118,7 +2130,7 @@ export class ContentStore {
2118
2130
 
2119
2131
  const { refId } = localizedField;
2120
2132
 
2121
- const objectStrId = getObjectStrId(rootObject.srcType, rootObject.srcProjectId, refId);
2133
+ const objectStrId = getObjectId(rootObject.srcType, rootObject.srcProjectId, refId);
2122
2134
  if (visited.includes(objectStrId)) {
2123
2135
  return [];
2124
2136
  }
@@ -2975,7 +2987,7 @@ export class ContentStore {
2975
2987
  user?: ContentStoreTypes.User;
2976
2988
  }) {
2977
2989
  this.logger.debug('deleteDocument');
2978
- logDocumentEvent('Delete', { userLogger: this.userLogger, srcType, srcProjectId, srcDocumentId });
2990
+ logDeleteDocument({ userLogger: this.userLogger, srcType, srcProjectId, srcDocumentId });
2979
2991
 
2980
2992
  const userContext = getUserContextForSrcType(srcType, user);
2981
2993
  const contentSourceId = getContentSourceId(srcType, srcProjectId);
@@ -2994,68 +3006,6 @@ export class ContentStore {
2994
3006
  });
2995
3007
  }
2996
3008
 
2997
- async archiveDocument({
2998
- srcType,
2999
- srcProjectId,
3000
- srcDocumentId,
3001
- user
3002
- }: {
3003
- srcType: string;
3004
- srcProjectId: string;
3005
- srcDocumentId: string;
3006
- user?: ContentStoreTypes.User;
3007
- }) {
3008
- this.logger.debug('archiveDocument');
3009
- logDocumentEvent('Archive', { userLogger: this.userLogger, srcType, srcProjectId, srcDocumentId });
3010
-
3011
- const userContext = getUserContextForSrcType(srcType, user);
3012
- const contentSourceId = getContentSourceId(srcType, srcProjectId);
3013
- const contentSourceData = this.getContentSourceDataByIdOrThrow(contentSourceId);
3014
- const csiDocument = contentSourceData.csiDocumentMap[srcDocumentId];
3015
- if (!csiDocument) {
3016
- throw new Error(`Document not found: '${srcDocumentId}' (Source: '${contentSourceData.id}'.)`);
3017
- }
3018
- await archiveDocumentHooked({
3019
- actionOptions: { document: csiDocument, userContext },
3020
- stackbitConfig: this.stackbitConfig,
3021
- contentSourceData: contentSourceData,
3022
- getContentSourceDataById: () => this.contentSourceDataById,
3023
- user: user,
3024
- logger: this.userLogger
3025
- });
3026
- }
3027
-
3028
- async unarchiveDocument({
3029
- srcType,
3030
- srcProjectId,
3031
- srcDocumentId,
3032
- user
3033
- }: {
3034
- srcType: string;
3035
- srcProjectId: string;
3036
- srcDocumentId: string;
3037
- user?: ContentStoreTypes.User;
3038
- }) {
3039
- this.logger.debug('unarchiveDocument');
3040
- logDocumentEvent('Unarchive', { userLogger: this.userLogger, srcType, srcProjectId, srcDocumentId });
3041
-
3042
- const userContext = getUserContextForSrcType(srcType, user);
3043
- const contentSourceId = getContentSourceId(srcType, srcProjectId);
3044
- const contentSourceData = this.getContentSourceDataByIdOrThrow(contentSourceId);
3045
- const csiDocument = contentSourceData.csiDocumentMap[srcDocumentId];
3046
- if (!csiDocument) {
3047
- throw new Error(`Document not found: '${srcDocumentId}' (Source: '${contentSourceData.id}'.)`);
3048
- }
3049
- await unarchiveDocumentHooked({
3050
- actionOptions: { document: csiDocument, userContext },
3051
- stackbitConfig: this.stackbitConfig,
3052
- contentSourceData: contentSourceData,
3053
- getContentSourceDataById: () => this.contentSourceDataById,
3054
- user: user,
3055
- logger: this.userLogger
3056
- });
3057
- }
3058
-
3059
3009
  getScheduledActions(): CSITypes.ScheduledActionWithSource[] {
3060
3010
  const scheduledActions = _.reduce(
3061
3011
  this.contentSourceDataById,
@@ -3409,7 +3359,7 @@ export class ContentStore {
3409
3359
 
3410
3360
  async publishDocuments({ objects, user }: { objects: { srcType: string; srcProjectId: string; srcObjectId: string }[]; user?: ContentStoreTypes.User }) {
3411
3361
  this.logger.debug('publishDocuments');
3412
- logDocumentsEvent('Publish', { userLogger: this.userLogger, objects });
3362
+ logPublishDocuments({ userLogger: this.userLogger, objects });
3413
3363
 
3414
3364
  const objectsBySourceId = _.groupBy(objects, (object) => getContentSourceId(object.srcType, object.srcProjectId));
3415
3365
  for (const [contentSourceId, contentSourceObjects] of Object.entries(objectsBySourceId)) {
@@ -3427,26 +3377,6 @@ export class ContentStore {
3427
3377
  }
3428
3378
  }
3429
3379
 
3430
- async unpublishDocuments({ objects, user }: { objects: { srcType: string; srcProjectId: string; srcObjectId: string }[]; user?: ContentStoreTypes.User }) {
3431
- this.logger.debug('unpublishDocuments');
3432
- logDocumentsEvent('Unpublish', { userLogger: this.userLogger, objects });
3433
-
3434
- const objectsBySourceId = _.groupBy(objects, (object) => getContentSourceId(object.srcType, object.srcProjectId));
3435
- for (const [contentSourceId, contentSourceObjects] of Object.entries(objectsBySourceId)) {
3436
- const contentSourceData = this.getContentSourceDataByIdOrThrow(contentSourceId);
3437
- const userContext = getUserContextForSrcType(contentSourceData.srcType, user);
3438
- const { documents, assets } = getCSIDocumentsAndAssetsFromContentSourceDataByIds(contentSourceData, contentSourceObjects);
3439
- await unpublishDocumentHooked({
3440
- actionOptions: { documents, assets, userContext },
3441
- stackbitConfig: this.stackbitConfig,
3442
- contentSourceData: contentSourceData,
3443
- getContentSourceDataById: () => this.contentSourceDataById,
3444
- user: user,
3445
- logger: this.userLogger
3446
- });
3447
- }
3448
- }
3449
-
3450
3380
  private getContentSourceDataByIdOrThrow(contentSourceId: string): ContentSourceData {
3451
3381
  return getContentSourceDataByIdOrThrow(contentSourceId, this.contentSourceDataById);
3452
3382
  }
package/src/index.ts CHANGED
@@ -2,8 +2,9 @@ export * as stackbit from './stackbit';
2
2
  export * as annotator from './annotator';
3
3
  export * as utils from './utils';
4
4
  export * as searchUtils from './utils/search-utils';
5
+ export * as referencesUtils from './utils/references-utils';
5
6
  export * from './utils/field-path-utils';
6
- export { getDocumentFieldForLocale } from './content-store-utils';
7
+ export { getDocumentFieldForLocale, getObjectId } from './content-store-utils';
7
8
  export * as consts from './consts';
8
9
  export * from './common/common-schema';
9
10
  export * from './common/common-types';
@@ -1,10 +1,14 @@
1
1
  import { DocumentRichTextFieldValue, DocumentStringLikeFieldTypes, DocumentStyleFieldValue, ExtractByType } from './content-store-document-fields';
2
2
  import { Document } from './content-store-documents';
3
3
  import { FieldType } from '@stackbit/types';
4
+ import type { ReferencedItem } from './references-types';
4
5
 
5
6
  export interface APIDocument extends Omit<Document, 'getPreview' | 'fields'> {
6
7
  srcObjectLabel: string;
7
- fields: Record<string, DocumentFieldAPIV2>;
8
+ fields?: Record<string, DocumentFieldAPIV2>;
9
+ references?: {
10
+ direct: ReferencedItem[];
11
+ };
8
12
  }
9
13
 
10
14
  /**
@@ -38,9 +38,6 @@ export type ContentSourceRawData = {
38
38
  syncContext?: { documentsSyncContext?: unknown; assetsSyncContext?: unknown };
39
39
  /* Map of advanced features to enable in the studio client */
40
40
  enabledFeatures: {
41
- unpublish: boolean;
42
- archive: boolean;
43
- unarchive: boolean;
44
41
  scheduledActions: boolean;
45
42
  documentVersions: boolean;
46
43
  };
@@ -104,25 +101,38 @@ export interface UploadAssetData {
104
101
  };
105
102
  }
106
103
 
107
- export interface ContentChangeResultItem {
104
+ export type ContentChangeType = 'added' | 'modified' | 'deleted';
105
+
106
+ export interface ContentChangeItem {
108
107
  srcType: string;
109
108
  srcProjectId: string;
110
109
  srcObjectId: string;
111
110
  }
112
111
 
113
- export interface ContentChangeResultScheduledAction {
112
+ export interface ContentChangeResultItem extends ContentChangeItem {
113
+ type: ContentChangeType;
114
+ }
115
+
116
+ export interface ContentChangeScheduledAction {
114
117
  srcType: string;
115
118
  srcProjectId: string;
116
119
  scheduledActionId: string;
117
120
  }
118
121
 
122
+ export interface ContentChangeResultScheduledAction extends ContentChangeScheduledAction {
123
+ type: ContentChangeType;
124
+ }
125
+
119
126
  export interface ContentChangeResult {
120
- updatedDocuments: ContentChangeResultItem[];
121
- updatedAssets: ContentChangeResultItem[];
122
- updatedScheduledActions: ContentChangeResultScheduledAction[];
123
- deletedDocuments: ContentChangeResultItem[];
124
- deletedAssets: ContentChangeResultItem[];
125
- deletedScheduledActions: ContentChangeResultScheduledAction[];
127
+ createdDocuments: ContentChangeItem[];
128
+ createdAssets: ContentChangeItem[];
129
+ createdScheduledActions: ContentChangeScheduledAction[];
130
+ updatedDocuments: ContentChangeItem[];
131
+ updatedAssets: ContentChangeItem[];
132
+ updatedScheduledActions: ContentChangeScheduledAction[];
133
+ deletedDocuments: ContentChangeItem[];
134
+ deletedAssets: ContentChangeItem[];
135
+ deletedScheduledActions: ContentChangeScheduledAction[];
126
136
  }
127
137
 
128
138
  export interface User {
@@ -6,3 +6,4 @@ export * from './content-store-update-operation';
6
6
  export * from './search-filter';
7
7
  export * from './custom-actions';
8
8
  export * from './publish-types';
9
+ export * from './references-types';