(
context: ImpureGraphContext,
authentication: AuthenticationContext,
params: { entityId: EntityId; key: string; includeDrafts?: boolean },
)
| 90 | blockProtocolPropertyTypes.fileUrl.propertyTypeBaseUrl in entity.properties; |
| 91 | |
| 92 | const getFileEntity = async ( |
| 93 | context: ImpureGraphContext, |
| 94 | authentication: AuthenticationContext, |
| 95 | params: { entityId: EntityId; key: string; includeDrafts?: boolean }, |
| 96 | ) => { |
| 97 | const { entityId, key, includeDrafts = false } = params; |
| 98 | const [webId, entityUuid] = splitEntityId(entityId); |
| 99 | |
| 100 | const { entities: fileEntityRevisions } = await queryEntities( |
| 101 | context, |
| 102 | authentication, |
| 103 | { |
| 104 | filter: { |
| 105 | all: [ |
| 106 | { |
| 107 | equal: [{ path: ["uuid"] }, { parameter: entityUuid }], |
| 108 | }, |
| 109 | { |
| 110 | equal: [{ path: ["webId"] }, { parameter: webId }], |
| 111 | }, |
| 112 | { |
| 113 | equal: [ |
| 114 | { |
| 115 | path: [ |
| 116 | "properties", |
| 117 | systemPropertyTypes.fileStorageKey.propertyTypeBaseUrl, |
| 118 | ], |
| 119 | }, |
| 120 | { parameter: key }, |
| 121 | ], |
| 122 | }, |
| 123 | ], |
| 124 | }, |
| 125 | temporalAxes: fullDecisionTimeAxis, |
| 126 | includeDrafts, |
| 127 | includePermissions: false, |
| 128 | }, |
| 129 | ); |
| 130 | |
| 131 | const latestFileEntityRevision = fileEntityRevisions.reduce< |
| 132 | Entity | undefined |
| 133 | >((previousLatestRevision, currentRevision) => { |
| 134 | if (!previousLatestRevision) { |
| 135 | return currentRevision; |
| 136 | } |
| 137 | |
| 138 | const currentCreatedAt = new Date( |
| 139 | currentRevision.metadata.temporalVersioning.decisionTime.start.limit, |
| 140 | ); |
| 141 | |
| 142 | const previousLatestRevisionCreatedAt = new Date( |
| 143 | previousLatestRevision.metadata.temporalVersioning.decisionTime.start |
| 144 | .limit, |
| 145 | ); |
| 146 | |
| 147 | return previousLatestRevisionCreatedAt < currentCreatedAt |
| 148 | ? currentRevision |
| 149 | : previousLatestRevision; |
no test coverage detected