@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
@@ -0,0 +1,8 @@
1
+ export interface ReferencedItem {
2
+ srcType: string;
3
+ srcProjectId: string;
4
+ srcDocumentId: string;
5
+ count: number;
6
+ }
7
+
8
+ export type ReferenceMap = Record<string, Record<string, Record<string, ReferencedItem[]>>>;
@@ -1,6 +1,5 @@
1
1
  import { Config } from '@stackbit/sdk';
2
2
  import * as StackbitTypes from '@stackbit/types';
3
- import type { ParametersOfCSIMethod, ReturnTypeOfCSIMethod } from '@stackbit/types';
4
3
 
5
4
  import * as ContentStoreTypes from '../types';
6
5
  import type { ContentSourceData } from '../types';
@@ -15,12 +14,13 @@ export interface DocumentHookBaseOptions {
15
14
  user?: ContentStoreTypes.User;
16
15
  logger: StackbitTypes.Logger;
17
16
  }
18
- export interface DocumentHookOptions<
19
- Action extends 'createDocument' | 'updateDocument' | 'deleteDocument' | 'publishDocuments' | 'unpublishDocuments' | 'archiveDocument' | 'unarchiveDocument'
20
- > extends DocumentHookBaseOptions {
21
- actionOptions: Parameters<NonNullable<BackCompatContentSourceInterface[Action]>>[0];
17
+ export interface DocumentHookOptions<Action extends 'createDocument' | 'updateDocument' | 'deleteDocument' | 'publishDocuments'>
18
+ extends DocumentHookBaseOptions {
19
+ actionOptions: Parameters<BackCompatContentSourceInterface[Action]>[0];
22
20
  }
23
21
 
22
+ type ReturnTypeOfCSIMethod<Method extends keyof StackbitTypes.ContentSourceInterface> = ReturnType<NonNullable<StackbitTypes.ContentSourceInterface[Method]>>;
23
+
24
24
  export async function createDocumentHooked(options: DocumentHookOptions<'createDocument'>): ReturnTypeOfCSIMethod<'createDocument'> {
25
25
  // If no onDocumentCreate defined in the config, call the original content
26
26
  // source createDocument method with the provided actionOptions.
@@ -119,81 +119,9 @@ export async function publishDocumentHooked(options: DocumentHookOptions<'publis
119
119
  });
120
120
  }
121
121
 
122
- export async function unpublishDocumentHooked(options: DocumentHookOptions<'unpublishDocuments'>): ReturnTypeOfCSIMethod<'unpublishDocuments'> {
123
- // If no onDocumentsUnpublish defined in the config, call the original content
124
- // source publishDocuments method with the provided actionOptions.
125
- if (!options.stackbitConfig?.onDocumentsUnpublish) {
126
- return options.contentSourceData.instance.unpublishDocuments?.(options.actionOptions);
127
- }
128
-
129
- return options.stackbitConfig.onDocumentsUnpublish({
130
- // Spread actionOptions to clone them shallowly to prevent accidental
131
- // property overrides within user methods.
132
- unpublishDocumentsOptions: { ...options.actionOptions },
133
- unpublishDocuments: async (actionOptions?: ParametersOfCSIMethod<'unpublishDocuments'>[0]) => {
134
- if (!actionOptions) {
135
- actionOptions = options.actionOptions;
136
- }
137
- return options.contentSourceData.instance.unpublishDocuments?.({
138
- ...actionOptions,
139
- userContext: actionOptions.userContext ?? options.actionOptions.userContext
140
- });
141
- },
142
- ...getDocumentHookOptions<'unpublishDocuments'>(options)
143
- });
144
- }
145
-
146
- export async function archiveDocumentHooked(options: DocumentHookOptions<'archiveDocument'>): ReturnTypeOfCSIMethod<'archiveDocument'> {
147
- // If no onDocumentArchive defined in the config, call the original content
148
- // source archiveDocument method with the provided actionOptions.
149
- if (!options.stackbitConfig?.onDocumentArchive) {
150
- return options.contentSourceData.instance.archiveDocument?.(options.actionOptions);
151
- }
152
-
153
- return options.stackbitConfig.onDocumentArchive({
154
- // Spread actionOptions to clone them shallowly to prevent accidental
155
- // property overrides within user methods.
156
- archiveDocumentOptions: { ...options.actionOptions },
157
- archiveDocument: async (actionOptions?: ParametersOfCSIMethod<'archiveDocument'>[0]) => {
158
- if (!actionOptions) {
159
- actionOptions = options.actionOptions;
160
- }
161
- return options.contentSourceData.instance.archiveDocument?.({
162
- ...actionOptions,
163
- userContext: actionOptions.userContext ?? options.actionOptions.userContext
164
- });
165
- },
166
- ...getDocumentHookOptions<'archiveDocument'>(options)
167
- });
168
- }
169
-
170
- export async function unarchiveDocumentHooked(options: DocumentHookOptions<'unarchiveDocument'>): ReturnTypeOfCSIMethod<'unarchiveDocument'> {
171
- // If no onDocumentUnarchive defined in the config, call the original content
172
- // source unarchiveDocument method with the provided actionOptions.
173
- if (!options.stackbitConfig?.onDocumentUnarchive) {
174
- return options.contentSourceData.instance.unarchiveDocument?.(options.actionOptions);
175
- }
176
-
177
- return options.stackbitConfig.onDocumentUnarchive({
178
- // Spread actionOptions to clone them shallowly to prevent accidental
179
- // property overrides within user methods.
180
- unarchiveDocumentOptions: { ...options.actionOptions },
181
- unarchiveDocument: async (actionOptions?: ParametersOfCSIMethod<'unarchiveDocument'>[0]) => {
182
- if (!actionOptions) {
183
- actionOptions = options.actionOptions;
184
- }
185
- return options.contentSourceData.instance.unarchiveDocument?.({
186
- ...actionOptions,
187
- userContext: actionOptions.userContext ?? options.actionOptions.userContext
188
- });
189
- },
190
- ...getDocumentHookOptions<'unarchiveDocument'>(options)
191
- });
192
- }
193
-
194
- function getDocumentHookOptions<
195
- Action extends 'createDocument' | 'updateDocument' | 'deleteDocument' | 'publishDocuments' | 'unpublishDocuments' | 'archiveDocument' | 'unarchiveDocument'
196
- >(options: DocumentHookOptions<Action>): StackbitTypes.DocumentHookBaseOptions {
122
+ function getDocumentHookOptions<Action extends 'createDocument' | 'updateDocument' | 'deleteDocument' | 'publishDocuments'>(
123
+ options: DocumentHookOptions<Action>
124
+ ): StackbitTypes.DocumentHookBaseOptions {
197
125
  const srcType = options.contentSourceData.srcType;
198
126
  const srcProjectId = options.contentSourceData.srcProjectId;
199
127
  const contentSourceDataById = options.getContentSourceDataById();
@@ -0,0 +1,104 @@
1
+ import _ from 'lodash';
2
+ import { ContentStoreTypes } from '../index';
3
+ import type { ReferencedItem, ReferenceMap } from '../types/';
4
+
5
+ export const getReferenceMap = (documents: (ContentStoreTypes.Document | ContentStoreTypes.APIDocumentObject | ContentStoreTypes.Asset)[]): ReferenceMap => {
6
+ const referenceMap: ReferenceMap = {};
7
+
8
+ const iterateFields = (
9
+ fields: Record<string, ContentStoreTypes.DocumentField | ContentStoreTypes.DocumentFieldAPI> | ContentStoreTypes.AssetFields,
10
+ rootObject: ContentStoreTypes.Document | ContentStoreTypes.APIDocumentObject | ContentStoreTypes.Asset
11
+ ) => {
12
+ let fieldName: keyof typeof fields;
13
+ for (fieldName in fields) {
14
+ iterateField(fields[fieldName], rootObject);
15
+ }
16
+ };
17
+
18
+ const iterateField = (
19
+ field: ContentStoreTypes.DocumentField | ContentStoreTypes.DocumentFieldAPI | ContentStoreTypes.AssetFileField,
20
+ rootObject: ContentStoreTypes.Document | ContentStoreTypes.APIDocumentObject | ContentStoreTypes.Asset
21
+ ) => {
22
+ if (field.type === 'reference' || field.type === 'unresolved_reference' || field.type === 'cross-reference') {
23
+ let references: { srcType: string; srcProjectId: string; srcDocumentId: string }[] = [];
24
+ if (field.type === 'unresolved_reference') {
25
+ if ('refId' in field) {
26
+ references = [
27
+ {
28
+ srcType: rootObject.srcType,
29
+ srcProjectId: rootObject.srcProjectId,
30
+ srcDocumentId: field.refId
31
+ }
32
+ ];
33
+ }
34
+ } else if (field.type === 'reference') {
35
+ if ('locales' in field) {
36
+ references = _.values(field.locales).map((ref) => ({
37
+ srcType: rootObject.srcType,
38
+ srcProjectId: rootObject.srcProjectId,
39
+ srcDocumentId: ref.refId
40
+ }));
41
+ } else if (!field.isUnset) {
42
+ references = [
43
+ {
44
+ srcType: rootObject.srcType,
45
+ srcProjectId: rootObject.srcProjectId,
46
+ srcDocumentId: field.refId
47
+ }
48
+ ];
49
+ }
50
+ } else {
51
+ if ('locales' in field) {
52
+ references = _.values(field.locales).map((ref) => ({
53
+ srcType: ref.refSrcType,
54
+ srcProjectId: ref.refProjectId,
55
+ srcDocumentId: ref.refId
56
+ }));
57
+ } else if ('refId' in field) {
58
+ references = [
59
+ {
60
+ srcType: field.refSrcType,
61
+ srcProjectId: field.refProjectId,
62
+ srcDocumentId: field.refId
63
+ }
64
+ ];
65
+ }
66
+ }
67
+ for (const reference of references) {
68
+ const currentObjectPath = [reference.srcType, reference.srcProjectId, reference.srcDocumentId];
69
+ const currentReferences: ReferencedItem[] = _.get(referenceMap, currentObjectPath) || [];
70
+
71
+ const existingDef = currentReferences.find(
72
+ (ref) => ref.srcType === rootObject.srcType && ref.srcProjectId === rootObject.srcProjectId && ref.srcDocumentId === rootObject.srcObjectId
73
+ );
74
+ if (existingDef) {
75
+ existingDef.count += 1;
76
+ } else {
77
+ currentReferences.push({
78
+ srcType: rootObject.srcType,
79
+ srcProjectId: rootObject.srcProjectId,
80
+ srcDocumentId: rootObject.srcObjectId,
81
+ count: 1
82
+ });
83
+ _.set(referenceMap, currentObjectPath, currentReferences);
84
+ }
85
+ }
86
+ } else if (field.type === 'object' || field.type === 'model') {
87
+ const fieldSets = 'locales' in field ? _.values(field.locales).map((fieldSet) => fieldSet.fields) : field.isUnset === true ? [] : [field.fields];
88
+ for (const fields of fieldSets) {
89
+ iterateFields(fields, rootObject);
90
+ }
91
+ } else if (field.type === 'list') {
92
+ const itemSets = 'locales' in field ? _.values(field.locales).map((fieldSet) => fieldSet.items) : [field.items];
93
+ for (const items of itemSets) {
94
+ items.forEach((item) => iterateField(item, rootObject));
95
+ }
96
+ }
97
+ };
98
+
99
+ for (const document of documents) {
100
+ iterateFields(document.fields, document);
101
+ }
102
+
103
+ return referenceMap;
104
+ };
@@ -5,7 +5,7 @@ import { SiteMapEntry } from '@stackbit/types';
5
5
  import * as CSITypes from '@stackbit/types';
6
6
  import * as ContentStoreTypes from '../types';
7
7
  import { mapStoreDocumentsToCSIDocumentsWithSource } from './store-to-csi-docs-converter';
8
- import { getContentSourceId, getDocumentFieldForLocale } from '../content-store-utils';
8
+ import { getContentSourceId, getDocumentFieldForLocale, getObjectId } from '../content-store-utils';
9
9
 
10
10
  export const SiteMapStaticEntriesKey = Symbol.for('SiteMapStaticEntriesKey');
11
11
  export type SiteMapEntriesSourceKeys = string | symbol;
@@ -108,22 +108,21 @@ export async function updateSiteMapEntriesWithContentChanges({
108
108
  return {};
109
109
  }
110
110
 
111
- if (contentChanges.updatedDocuments.length === 0 && contentChanges.deletedDocuments.length === 0) {
111
+ const updatedDocuments = [...contentChanges.createdDocuments, ...contentChanges.updatedDocuments];
112
+
113
+ if (updatedDocuments.length === 0 && contentChanges.deletedDocuments.length === 0) {
112
114
  return siteMapEntryGroups;
113
115
  }
114
116
 
115
117
  // Create a map of changed documents by content source id
116
- const changedDocumentsByContentSourceId = contentChanges.updatedDocuments.reduce(
117
- (accum: Record<string, ContentStoreTypes.Document[]>, contentChangeResultItem) => {
118
- const contentSourceId = getContentSourceId(contentChangeResultItem.srcType, contentChangeResultItem.srcProjectId);
119
- const document = contentSourceDataById[contentSourceId]?.documentMap[contentChangeResultItem.srcObjectId];
120
- if (document) {
121
- append(accum, [contentSourceId], document);
122
- }
123
- return accum;
124
- },
125
- {}
126
- );
118
+ const changedDocumentsByContentSourceId = updatedDocuments.reduce((accum: Record<string, ContentStoreTypes.Document[]>, contentChangeResultItem) => {
119
+ const contentSourceId = getContentSourceId(contentChangeResultItem.srcType, contentChangeResultItem.srcProjectId);
120
+ const document = contentSourceDataById[contentSourceId]?.documentMap[contentChangeResultItem.srcObjectId];
121
+ if (document) {
122
+ append(accum, [contentSourceId], document);
123
+ }
124
+ return accum;
125
+ }, {});
127
126
 
128
127
  // Create siteMap parameters from changed documents
129
128
  const partialSiteMapOptions = _.reduce(
@@ -160,7 +159,7 @@ export async function updateSiteMapEntriesWithContentChanges({
160
159
 
161
160
  siteMapEntryGroups = _.reduce(
162
161
  contentChanges.deletedDocuments,
163
- (accum, contentChangeResultItem: ContentStoreTypes.ContentChangeResultItem) => {
162
+ (accum, contentChangeResultItem: ContentStoreTypes.ContentChangeItem) => {
164
163
  const siteMapGroupKey = `${contentChangeResultItem.srcType}:${contentChangeResultItem.srcProjectId}:${contentChangeResultItem.srcObjectId}`;
165
164
  delete accum[siteMapGroupKey];
166
165
  return accum;
@@ -221,26 +220,10 @@ function sanitizeAndGroupSiteMapEntries(siteMapEntries: SiteMapEntry[]): SiteMap
221
220
 
222
221
  function getSiteMapGroupKey(siteMapEntry: SiteMapEntry): string {
223
222
  return 'document' in siteMapEntry
224
- ? getSiteMapGroupKeyForDocument({
225
- srcType: siteMapEntry.document.srcType,
226
- srcProjectId: siteMapEntry.document.srcProjectId,
227
- srcDocumentId: siteMapEntry.document.id
228
- })
223
+ ? getObjectId(siteMapEntry.document.srcType, siteMapEntry.document.srcProjectId, siteMapEntry.document.id)
229
224
  : SiteMapStaticEntriesKey.toString();
230
225
  }
231
226
 
232
- export function getSiteMapGroupKeyForDocument({
233
- srcType,
234
- srcProjectId,
235
- srcDocumentId
236
- }: {
237
- srcType: string;
238
- srcProjectId: string;
239
- srcDocumentId: string;
240
- }): string {
241
- return `${srcType}:${srcProjectId}:${srcDocumentId}`;
242
- }
243
-
244
227
  export function getDocumentFieldLabelValueForSiteMapEntry({
245
228
  siteMapEntry,
246
229
  locale,
@@ -3,24 +3,28 @@ import { omitByUndefined } from '@stackbit/utils';
3
3
  import * as CSITypes from '@stackbit/types';
4
4
  import * as ContentStoreTypes from '../types';
5
5
  import { getContentSourceId, getDocumentFieldForLocale } from '../content-store-utils';
6
+ import { ReferenceMap } from '../types';
6
7
 
7
8
  export function mapDocumentsToApiDocuments({
8
9
  documents,
9
10
  allowedLocales,
10
11
  contentSourceDataById,
11
- delegate
12
+ delegate,
13
+ referenceMap
12
14
  }: {
13
15
  documents: ContentStoreTypes.Document[];
14
16
  allowedLocales?: string[];
15
17
  contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
16
18
  delegate: CSITypes.ConfigDelegate;
19
+ referenceMap?: ReferenceMap;
17
20
  }): ContentStoreTypes.APIDocument[] {
18
21
  return documents.map((document) =>
19
22
  documentToApiV2Object({
20
23
  document,
21
24
  allowedLocales,
22
25
  contentSourceDataById,
23
- delegate
26
+ delegate,
27
+ referenceMap
24
28
  })
25
29
  );
26
30
  }
@@ -29,17 +33,25 @@ function documentToApiV2Object({
29
33
  document,
30
34
  allowedLocales,
31
35
  contentSourceDataById,
32
- delegate
36
+ delegate,
37
+ referenceMap
33
38
  }: {
34
39
  document: ContentStoreTypes.Document;
35
40
  allowedLocales?: string[];
36
41
  contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
37
42
  delegate: CSITypes.ConfigDelegate;
43
+ referenceMap?: ReferenceMap;
38
44
  }): ContentStoreTypes.APIDocument {
39
45
  const { fields, getPreview, ...rest } = document;
46
+ const directReferences = referenceMap?.[document.srcType]?.[document.srcProjectId]?.[document.srcObjectId];
40
47
  return omitByUndefined({
41
48
  ..._.omit(rest),
42
49
  srcObjectLabel: getPreview({ delegate /*, locale*/ }).previewTitle,
50
+ references: directReferences
51
+ ? {
52
+ direct: directReferences
53
+ }
54
+ : undefined,
43
55
  fields: toAPIV2Fields({
44
56
  docFields: fields,
45
57
  delegate,
@@ -23,27 +23,21 @@ export function logCreateDocument(options: {
23
23
  userLogger.info(`Create document for ${modelName} ${encodeIdentifier({ srcType, srcProjectId, locale })}`);
24
24
  }
25
25
 
26
- export function logDocumentEvent(
27
- event: string,
28
- options: { userLogger: Logger; srcType: string; srcProjectId: string; srcDocumentId: string; locale?: string }
29
- ) {
26
+ export function logDeleteDocument(options: { userLogger: Logger; srcType: string; srcProjectId: string; srcDocumentId: string; locale?: string }) {
30
27
  const { userLogger, srcType, srcProjectId, srcDocumentId, locale } = options;
31
- userLogger.info(`${event} document ${encodeIdentifier({ srcType, srcProjectId, srcDocumentId, locale })}`);
28
+ userLogger.info(`Delete document ${encodeIdentifier({ srcType, srcProjectId, srcDocumentId, locale })}`);
32
29
  }
33
30
 
34
- export function logDocumentsEvent(
35
- event: string,
36
- options: {
37
- userLogger: Logger;
38
- objects: { srcType: string; srcProjectId: string; srcObjectId: string }[];
39
- locale?: string;
40
- }
41
- ) {
31
+ export function logPublishDocuments(options: {
32
+ userLogger: Logger;
33
+ objects: { srcType: string; srcProjectId: string; srcObjectId: string }[];
34
+ locale?: string;
35
+ }) {
42
36
  const { userLogger, objects, locale } = options;
43
37
  const objectCount = objects.length;
44
38
  const objectPlural = pluralize('item', objectCount);
45
39
  userLogger.info(
46
- `${event} ${objectCount} ${objectPlural}: ${objects.map((object) => object.srcObjectId).join(', ')} ${objects
40
+ `Publish ${objectCount} ${objectPlural}: ${objects.map((object) => object.srcObjectId).join(', ')} ${objects
47
41
  .map((object) => encodeIdentifier({ srcType: object.srcType, srcProjectId: object.srcProjectId, locale }))
48
42
  .join(', ')}`
49
43
  );
@@ -1,12 +0,0 @@
1
- import * as ContentStoreTypes from '../types';
2
- import { SearchFilterItem } from '../types';
3
- import { ScheduledAction } from '@stackbit/types';
4
- import { SchemaForSearch } from './search-utils';
5
- declare type CustomFilterMethod = (filter: SearchFilterItem, document: ContentStoreTypes.Document, opts: {
6
- locale?: string;
7
- schema: SchemaForSearch;
8
- activeScheduledActionsByDocumentId: Record<string, ScheduledAction[]>;
9
- }) => boolean;
10
- export declare const CUSTOM_FILTERS: Record<string, CustomFilterMethod>;
11
- export {};
12
- //# sourceMappingURL=custom-search-filters.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-search-filters.d.ts","sourceRoot":"","sources":["../../src/utils/custom-search-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAqB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAiE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEhH,aAAK,kBAAkB,GAAG,CACtB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EACpC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,kCAAkC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;CAAE,KACxH,OAAO,CAAC;AAEb,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAwC7D,CAAC"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CUSTOM_FILTERS = void 0;
4
- const search_utils_1 = require("./search-utils");
5
- exports.CUSTOM_FILTERS = {
6
- hasSchedules: (filter, document, opts) => {
7
- var _a;
8
- const field = {
9
- type: 'boolean',
10
- value: !!((_a = opts.activeScheduledActionsByDocumentId[document.srcObjectId]) === null || _a === void 0 ? void 0 : _a.length)
11
- };
12
- return (0, search_utils_1.isBooleanFieldMatches)({ field, filter, locale: opts.locale });
13
- },
14
- scheduledActionId: (filter, document, opts) => {
15
- var _a, _b;
16
- const field = {
17
- type: 'list',
18
- items: (_b = (_a = opts.activeScheduledActionsByDocumentId[document.srcObjectId]) === null || _a === void 0 ? void 0 : _a.map((scheduledAction) => ({
19
- type: 'string',
20
- value: scheduledAction.id
21
- }))) !== null && _b !== void 0 ? _b : []
22
- };
23
- const model = {
24
- type: 'object',
25
- name: '',
26
- fields: [
27
- {
28
- name: '',
29
- type: 'list',
30
- items: {
31
- type: 'string'
32
- }
33
- }
34
- ]
35
- };
36
- return (0, search_utils_1.isListFieldMatches)({ field, filter, model, locale: opts.locale, document });
37
- },
38
- scheduledActionDate: (filter, document, opts) => {
39
- var _a, _b;
40
- return ((_b = (_a = opts.activeScheduledActionsByDocumentId[document.srcObjectId]) === null || _a === void 0 ? void 0 : _a.some((scheduledAction) => {
41
- const field = { type: 'date', value: scheduledAction.executeAt };
42
- return (0, search_utils_1.isDateFieldMatches)({ field, filter, locale: opts.locale });
43
- })) !== null && _b !== void 0 ? _b : false);
44
- }
45
- };
46
- //# sourceMappingURL=custom-search-filters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-search-filters.js","sourceRoot":"","sources":["../../src/utils/custom-search-filters.ts"],"names":[],"mappings":";;;AAIA,iDAAgH;AAQnG,QAAA,cAAc,GAAuC;IAC9D,YAAY,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;;QACrC,MAAM,KAAK,GAAG;YACV,IAAI,EAAE,SAAkB;YACxB,KAAK,EAAE,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,kCAAkC,CAAC,QAAQ,CAAC,WAAW,CAAC,0CAAE,MAAM,CAAA;SACjF,CAAC;QACF,OAAO,IAAA,oCAAqB,EAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,iBAAiB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;;QAC1C,MAAM,KAAK,GAAsB;YAC7B,IAAI,EAAE,MAAM;YACZ,KAAK,EACD,MAAA,MAAA,IAAI,CAAC,kCAAkC,CAAC,QAAQ,CAAC,WAAW,CAAC,0CAAE,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;gBACrF,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,eAAe,CAAC,EAAE;aAC5B,CAAC,CAAC,mCAAI,EAAE;SAChB,CAAC;QACF,MAAM,KAAK,GAAU;YACjB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,EAAE;YACR,MAAM,EAAE;gBACJ;oBACI,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE;wBACH,IAAI,EAAE,QAAQ;qBACjB;iBACJ;aACJ;SACJ,CAAC;QACF,OAAO,IAAA,iCAAkB,EAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,mBAAmB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;;QAC5C,OAAO,CACH,MAAA,MAAA,IAAI,CAAC,kCAAkC,CAAC,QAAQ,CAAC,WAAW,CAAC,0CAAE,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YACpF,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,MAAe,EAAE,KAAK,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC;YAC1E,OAAO,IAAA,iCAAkB,EAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACtE,CAAC,CAAC,mCAAI,KAAK,CACd,CAAC;IACN,CAAC;CACJ,CAAC"}