@dyrected/core 2.5.62 → 2.5.63
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.
- package/dist/chunk-T626OZMH.js +2602 -0
- package/dist/chunk-TEGRS6J7.js +2609 -0
- package/dist/index.cjs +28 -6
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/server.cjs +47 -8
- package/dist/server.js +23 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ __export(index_exports, {
|
|
|
81
81
|
parseMongoWhere: () => parseMongoWhere,
|
|
82
82
|
parseSort: () => parseSort,
|
|
83
83
|
parseSqlWhere: () => parseSqlWhere,
|
|
84
|
+
publishedStateName: () => publishedStateName,
|
|
84
85
|
publishingWorkflow: () => publishingWorkflow,
|
|
85
86
|
resolveAdminAuthCollection: () => resolveAdminAuthCollection,
|
|
86
87
|
runCollectionHooks: () => runCollectionHooks,
|
|
@@ -222,6 +223,7 @@ function publishedStateName(workflow) {
|
|
|
222
223
|
}
|
|
223
224
|
function materializeWorkflowDocument(doc, workflow, user) {
|
|
224
225
|
const meta = doc.__workflow;
|
|
226
|
+
const publishedState = publishedStateName(workflow);
|
|
225
227
|
if (!meta) {
|
|
226
228
|
const { __published: _legacyPublished, __workflow: _legacyWorkflow, ...working2 } = doc;
|
|
227
229
|
const state = publishedStateName(workflow);
|
|
@@ -236,7 +238,12 @@ function materializeWorkflowDocument(doc, workflow, user) {
|
|
|
236
238
|
}
|
|
237
239
|
const { __published, __workflow, ...working } = doc;
|
|
238
240
|
if (!canViewWorkflowDraft(workflow, user)) {
|
|
239
|
-
if (!__published || typeof __published !== "object")
|
|
241
|
+
if (!__published || typeof __published !== "object") {
|
|
242
|
+
if (meta.state === publishedState) {
|
|
243
|
+
return { ...working, _workflow: publicMetadata(meta) };
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
240
247
|
return { id: doc.id, ...__published, _workflow: publicMetadata(meta) };
|
|
241
248
|
}
|
|
242
249
|
return {
|
|
@@ -316,20 +323,34 @@ async function saveWorkflowDraft(args) {
|
|
|
316
323
|
const workflow = collection.workflow;
|
|
317
324
|
if (!db.transaction) throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
318
325
|
const previous = originalDoc.__workflow;
|
|
326
|
+
const isLegacyPublishedDoc = !previous;
|
|
327
|
+
const baselineRevision = previous?.revision ?? 1;
|
|
319
328
|
const event = createLifecycleEvent({
|
|
320
329
|
name: "revision.created",
|
|
321
330
|
collection: collection.slug,
|
|
322
331
|
documentId: id,
|
|
323
332
|
actorId: user?.sub,
|
|
324
|
-
payload: {
|
|
333
|
+
payload: {
|
|
334
|
+
revision: baselineRevision + 1,
|
|
335
|
+
previousRevision: isLegacyPublishedDoc ? baselineRevision : previous?.revision ?? null
|
|
336
|
+
}
|
|
325
337
|
});
|
|
326
338
|
const doc = await db.transaction(async (tx) => {
|
|
327
339
|
const nextMeta = {
|
|
328
|
-
...previous,
|
|
329
|
-
state: originalDoc.__published ? workflow.draftState ?? workflow.initialState : previous.state,
|
|
330
|
-
revision:
|
|
340
|
+
...previous ?? {},
|
|
341
|
+
state: isLegacyPublishedDoc ? workflow.draftState ?? workflow.initialState : originalDoc.__published ? workflow.draftState ?? workflow.initialState : previous.state,
|
|
342
|
+
revision: baselineRevision + 1,
|
|
343
|
+
...isLegacyPublishedDoc ? { publishedRevision: baselineRevision } : {}
|
|
331
344
|
};
|
|
332
|
-
const
|
|
345
|
+
const updateData = {
|
|
346
|
+
...data,
|
|
347
|
+
__workflow: nextMeta
|
|
348
|
+
};
|
|
349
|
+
if (isLegacyPublishedDoc) {
|
|
350
|
+
const { __workflow: _legacyWorkflow, __published: _legacyPublished, ...publishedSnapshot } = originalDoc;
|
|
351
|
+
updateData.__published = publishedSnapshot;
|
|
352
|
+
}
|
|
353
|
+
const updated = await tx.update({ collection: collection.slug, id, data: updateData });
|
|
333
354
|
await persistEvent(tx, event);
|
|
334
355
|
return updated;
|
|
335
356
|
});
|
|
@@ -2319,6 +2340,7 @@ function defineTab(args) {
|
|
|
2319
2340
|
parseMongoWhere,
|
|
2320
2341
|
parseSort,
|
|
2321
2342
|
parseSqlWhere,
|
|
2343
|
+
publishedStateName,
|
|
2322
2344
|
publishingWorkflow,
|
|
2323
2345
|
resolveAdminAuthCollection,
|
|
2324
2346
|
runCollectionHooks,
|
package/dist/index.d.cts
CHANGED
|
@@ -282,6 +282,8 @@ declare function initializeWorkflowDocument(data: Record<string, unknown>, workf
|
|
|
282
282
|
revision: number;
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
|
+
/** The state a legacy document is treated as: the published one, else the last. */
|
|
286
|
+
declare function publishedStateName(workflow: WorkflowConfig): string;
|
|
285
287
|
declare function materializeWorkflowDocument(doc: BaseDocument, workflow: WorkflowConfig, user?: AuthenticatedUser): BaseDocument | null;
|
|
286
288
|
declare function createLifecycleEvent(args: {
|
|
287
289
|
name: LifecycleEventName;
|
|
@@ -569,4 +571,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
569
571
|
fields: T;
|
|
570
572
|
}): T;
|
|
571
573
|
|
|
572
|
-
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
|
574
|
+
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -282,6 +282,8 @@ declare function initializeWorkflowDocument(data: Record<string, unknown>, workf
|
|
|
282
282
|
revision: number;
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
|
+
/** The state a legacy document is treated as: the published one, else the last. */
|
|
286
|
+
declare function publishedStateName(workflow: WorkflowConfig): string;
|
|
285
287
|
declare function materializeWorkflowDocument(doc: BaseDocument, workflow: WorkflowConfig, user?: AuthenticatedUser): BaseDocument | null;
|
|
286
288
|
declare function createLifecycleEvent(args: {
|
|
287
289
|
name: LifecycleEventName;
|
|
@@ -569,4 +571,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
569
571
|
fields: T;
|
|
570
572
|
}): T;
|
|
571
573
|
|
|
572
|
-
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
|
574
|
+
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
initializeWorkflowDocument,
|
|
17
17
|
materializeWorkflowDocument,
|
|
18
18
|
normalizeConfig,
|
|
19
|
+
publishedStateName,
|
|
19
20
|
publishingWorkflow,
|
|
20
21
|
resolveAdminAuthCollection,
|
|
21
22
|
runCollectionHooks,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
simplePublishingWorkflow,
|
|
24
25
|
transitionWorkflow,
|
|
25
26
|
workflowCapabilities
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-TEGRS6J7.js";
|
|
27
28
|
|
|
28
29
|
// src/types/workflows.ts
|
|
29
30
|
var LIFECYCLE_EVENT_NAMES = [
|
|
@@ -334,6 +335,7 @@ export {
|
|
|
334
335
|
parseMongoWhere,
|
|
335
336
|
parseSort,
|
|
336
337
|
parseSqlWhere,
|
|
338
|
+
publishedStateName,
|
|
337
339
|
publishingWorkflow,
|
|
338
340
|
resolveAdminAuthCollection,
|
|
339
341
|
runCollectionHooks,
|
package/dist/server.cjs
CHANGED
|
@@ -1630,6 +1630,7 @@ function publishedStateName(workflow) {
|
|
|
1630
1630
|
}
|
|
1631
1631
|
function materializeWorkflowDocument(doc, workflow, user) {
|
|
1632
1632
|
const meta = doc.__workflow;
|
|
1633
|
+
const publishedState = publishedStateName(workflow);
|
|
1633
1634
|
if (!meta) {
|
|
1634
1635
|
const { __published: _legacyPublished, __workflow: _legacyWorkflow, ...working2 } = doc;
|
|
1635
1636
|
const state = publishedStateName(workflow);
|
|
@@ -1644,7 +1645,12 @@ function materializeWorkflowDocument(doc, workflow, user) {
|
|
|
1644
1645
|
}
|
|
1645
1646
|
const { __published, __workflow, ...working } = doc;
|
|
1646
1647
|
if (!canViewWorkflowDraft(workflow, user)) {
|
|
1647
|
-
if (!__published || typeof __published !== "object")
|
|
1648
|
+
if (!__published || typeof __published !== "object") {
|
|
1649
|
+
if (meta.state === publishedState) {
|
|
1650
|
+
return { ...working, _workflow: publicMetadata(meta) };
|
|
1651
|
+
}
|
|
1652
|
+
return null;
|
|
1653
|
+
}
|
|
1648
1654
|
return { id: doc.id, ...__published, _workflow: publicMetadata(meta) };
|
|
1649
1655
|
}
|
|
1650
1656
|
return {
|
|
@@ -1708,20 +1714,34 @@ async function saveWorkflowDraft(args) {
|
|
|
1708
1714
|
const workflow = collection.workflow;
|
|
1709
1715
|
if (!db.transaction) throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
1710
1716
|
const previous = originalDoc.__workflow;
|
|
1717
|
+
const isLegacyPublishedDoc = !previous;
|
|
1718
|
+
const baselineRevision = previous?.revision ?? 1;
|
|
1711
1719
|
const event = createLifecycleEvent({
|
|
1712
1720
|
name: "revision.created",
|
|
1713
1721
|
collection: collection.slug,
|
|
1714
1722
|
documentId: id,
|
|
1715
1723
|
actorId: user?.sub,
|
|
1716
|
-
payload: {
|
|
1724
|
+
payload: {
|
|
1725
|
+
revision: baselineRevision + 1,
|
|
1726
|
+
previousRevision: isLegacyPublishedDoc ? baselineRevision : previous?.revision ?? null
|
|
1727
|
+
}
|
|
1717
1728
|
});
|
|
1718
1729
|
const doc = await db.transaction(async (tx) => {
|
|
1719
1730
|
const nextMeta = {
|
|
1720
|
-
...previous,
|
|
1721
|
-
state: originalDoc.__published ? workflow.draftState ?? workflow.initialState : previous.state,
|
|
1722
|
-
revision:
|
|
1731
|
+
...previous ?? {},
|
|
1732
|
+
state: isLegacyPublishedDoc ? workflow.draftState ?? workflow.initialState : originalDoc.__published ? workflow.draftState ?? workflow.initialState : previous.state,
|
|
1733
|
+
revision: baselineRevision + 1,
|
|
1734
|
+
...isLegacyPublishedDoc ? { publishedRevision: baselineRevision } : {}
|
|
1723
1735
|
};
|
|
1724
|
-
const
|
|
1736
|
+
const updateData = {
|
|
1737
|
+
...data,
|
|
1738
|
+
__workflow: nextMeta
|
|
1739
|
+
};
|
|
1740
|
+
if (isLegacyPublishedDoc) {
|
|
1741
|
+
const { __workflow: _legacyWorkflow, __published: _legacyPublished, ...publishedSnapshot } = originalDoc;
|
|
1742
|
+
updateData.__published = publishedSnapshot;
|
|
1743
|
+
}
|
|
1744
|
+
const updated = await tx.update({ collection: collection.slug, id, data: updateData });
|
|
1725
1745
|
await persistEvent(tx, event);
|
|
1726
1746
|
return updated;
|
|
1727
1747
|
});
|
|
@@ -1954,7 +1974,25 @@ var CollectionController = class {
|
|
|
1954
1974
|
where = beforeReadResult;
|
|
1955
1975
|
}
|
|
1956
1976
|
if (this.collection.workflow && !canViewWorkflowDraft(this.collection.workflow, user)) {
|
|
1957
|
-
|
|
1977
|
+
const publicWorkflowState = publishedStateName(this.collection.workflow);
|
|
1978
|
+
where = where ? {
|
|
1979
|
+
AND: [
|
|
1980
|
+
where,
|
|
1981
|
+
{
|
|
1982
|
+
OR: [
|
|
1983
|
+
{ __published: { exists: true } },
|
|
1984
|
+
{ __workflow: { exists: false } },
|
|
1985
|
+
{ "__workflow.state": { equals: publicWorkflowState } }
|
|
1986
|
+
]
|
|
1987
|
+
}
|
|
1988
|
+
]
|
|
1989
|
+
} : {
|
|
1990
|
+
OR: [
|
|
1991
|
+
{ __published: { exists: true } },
|
|
1992
|
+
{ __workflow: { exists: false } },
|
|
1993
|
+
{ "__workflow.state": { equals: publicWorkflowState } }
|
|
1994
|
+
]
|
|
1995
|
+
};
|
|
1958
1996
|
}
|
|
1959
1997
|
const access = await this.evaluateAccess(c, "read");
|
|
1960
1998
|
if (!access.allowed) {
|
|
@@ -2504,8 +2542,9 @@ var CollectionController = class {
|
|
|
2504
2542
|
},
|
|
2505
2543
|
{ isolated: true }
|
|
2506
2544
|
);
|
|
2545
|
+
const responseDoc = this.collection.workflow ? materializeWorkflowDocument(doc, this.collection.workflow, user) : doc;
|
|
2507
2546
|
const readDoc = await runCollectionHooks(this.collection.hooks?.afterRead, {
|
|
2508
|
-
doc,
|
|
2547
|
+
doc: responseDoc,
|
|
2509
2548
|
req: c.req,
|
|
2510
2549
|
user,
|
|
2511
2550
|
db: readonlyDb
|
package/dist/server.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
materializeWorkflowDocument,
|
|
25
25
|
mergeDynamicConfig,
|
|
26
26
|
normalizeConfig,
|
|
27
|
+
publishedStateName,
|
|
27
28
|
redactHeaders,
|
|
28
29
|
renderPrometheusMetrics,
|
|
29
30
|
revokeAllAuthSessions,
|
|
@@ -35,7 +36,7 @@ import {
|
|
|
35
36
|
touchAuthSession,
|
|
36
37
|
transitionWorkflow,
|
|
37
38
|
verifyCollectionToken
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-TEGRS6J7.js";
|
|
39
40
|
|
|
40
41
|
// src/app.ts
|
|
41
42
|
import { Hono } from "hono";
|
|
@@ -785,7 +786,25 @@ var CollectionController = class {
|
|
|
785
786
|
where = beforeReadResult;
|
|
786
787
|
}
|
|
787
788
|
if (this.collection.workflow && !canViewWorkflowDraft(this.collection.workflow, user)) {
|
|
788
|
-
|
|
789
|
+
const publicWorkflowState = publishedStateName(this.collection.workflow);
|
|
790
|
+
where = where ? {
|
|
791
|
+
AND: [
|
|
792
|
+
where,
|
|
793
|
+
{
|
|
794
|
+
OR: [
|
|
795
|
+
{ __published: { exists: true } },
|
|
796
|
+
{ __workflow: { exists: false } },
|
|
797
|
+
{ "__workflow.state": { equals: publicWorkflowState } }
|
|
798
|
+
]
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
} : {
|
|
802
|
+
OR: [
|
|
803
|
+
{ __published: { exists: true } },
|
|
804
|
+
{ __workflow: { exists: false } },
|
|
805
|
+
{ "__workflow.state": { equals: publicWorkflowState } }
|
|
806
|
+
]
|
|
807
|
+
};
|
|
789
808
|
}
|
|
790
809
|
const access = await this.evaluateAccess(c, "read");
|
|
791
810
|
if (!access.allowed) {
|
|
@@ -1335,8 +1354,9 @@ var CollectionController = class {
|
|
|
1335
1354
|
},
|
|
1336
1355
|
{ isolated: true }
|
|
1337
1356
|
);
|
|
1357
|
+
const responseDoc = this.collection.workflow ? materializeWorkflowDocument(doc, this.collection.workflow, user) : doc;
|
|
1338
1358
|
const readDoc = await runCollectionHooks(this.collection.hooks?.afterRead, {
|
|
1339
|
-
doc,
|
|
1359
|
+
doc: responseDoc,
|
|
1340
1360
|
req: c.req,
|
|
1341
1361
|
user,
|
|
1342
1362
|
db: readonlyDb
|