synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
132 lines (131 loc) • 3.41 kB
JavaScript
import { convertToConcreteEntityType as l, isContainerType as s } from "../../utils/functions/EntityTypeUtils.js";
import { normalizeNumericId as f } from "../../utils/functions/StringUtils.js";
import { faker as i } from "@faker-js/faker";
import { EntityType as m } from "@sage-bionetworks/synapse-client";
import { RestrictionLevel as g } from "@sage-bionetworks/synapse-types";
import t from "../entity/mockProject.js";
import { pickRandomMockUser as c } from "./fakerUtils.js";
function b(a = {}) {
const {
id: n = i.number.int({ min: 1e4, max: 99999 }),
type: r = m.file,
entity: y,
acl: o,
permissions: u
} = a, e = {
id: `syn${n}`,
name: i.lorem.words({ min: 1, max: 4 }),
createdBy: String(c().id),
createdOn: i.date.anytime().toISOString(),
etag: i.string.uuid(),
modifiedBy: String(c().id),
modifiedOn: i.date.anytime().toISOString(),
concreteType: l(r),
parentId: t.id,
...y
}, p = {
id: e.id,
name: e.name,
type: e.concreteType,
createdBy: e.createdBy,
createdOn: e.createdOn,
modifiedBy: e.modifiedBy,
modifiedOn: e.modifiedOn,
benefactorId: f(
o ? e.id : t.id
),
isLatestVersion: !0,
versionLabel: "versionLabel" in e ? e.versionLabel : void 0,
versionNumber: "versionNumber" in e ? e.versionNumber : void 0
}, d = o ? {
...o,
id: e.id,
etag: i.string.uuid(),
createdBy: e.createdBy,
modifiedBy: e.modifiedBy,
modifiedOn: e.modifiedOn
} : void 0;
return {
id: e.id,
entity: e,
name: e.name,
entityHeader: p,
bundle: {
entity: e,
entityType: r,
accessControlList: d,
benefactorAcl: d ?? t.bundle.accessControlList,
permissions: {
ownerPrincipalId: parseInt(e.createdBy),
canView: !0,
canEdit: !0,
canMove: !0,
canAddChild: s(r),
canCertifiedUserEdit: !0,
canCertifiedUserAddChild: s(r),
isCertifiedUser: !0,
canChangePermissions: !0,
canChangeSettings: !0,
canDelete: !0,
canDownload: !0,
canUpload: !0,
canEnableInheritance: !0,
canPublicRead: !0,
canModerate: !0,
isCertificationRequired: !0,
isEntityOpenData: !1,
isUserDataContributor: !0,
...u
},
annotations: {
id: e.id,
etag: i.string.uuid(),
annotations: {}
},
path: {
// TODO: Properly generate a path given the parent entity
path: [
{
name: "Redacted",
id: "syn4489",
type: "org.sagebionetworks.repo.model.Folder"
},
{
name: t.name,
id: t.id,
type: t.entity.concreteType
},
{
name: e.name,
id: e.id,
type: e.concreteType
}
]
},
hasChildren: !1,
fileHandles: [],
threadCount: 0,
restrictionInformation: {
objectId: n,
restrictionDetails: [],
restrictionLevel: g.OPEN,
hasUnmetAccessRequirement: !1
}
}
};
}
function T(a, n) {
return b({
id: n,
type: m.project,
entity: {
name: i.lorem.words({ min: 1, max: 4 }),
...a
}
});
}
export {
b as generateBaseEntity,
T as generateProject
};
//# sourceMappingURL=generateFakeEntity.js.map