@logion/csv
Advanced tools
+2
-2
| { | ||
| "name": "@logion/csv", | ||
| "version": "0.1.1-1", | ||
| "version": "0.1.1", | ||
| "description": "Logion CSV Validator", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
| "dependencies": { | ||
| "@logion/node-api": "^0.27.0-2" | ||
| "@logion/node-api": "^0.28.0" | ||
| }, | ||
@@ -31,0 +31,0 @@ "bugs": { |
| import { CsvItem } from "./CsvValidator.js"; | ||
| import { HashOrContent, ItemTokenWithRestrictedType, LogionClassificationParameters, SpecificLicense, CreativeCommonsCode } from "@logion/client"; | ||
| import { Hash } from "@logion/node-api"; | ||
| export interface Item { | ||
| id?: Hash; | ||
| displayId: string; | ||
| description: string; | ||
| files: HashOrContent[]; | ||
| restrictedDelivery: boolean; | ||
| token?: ItemTokenWithRestrictedType; | ||
| upload: boolean; | ||
| logionClassification?: LogionClassificationParameters; | ||
| specificLicense?: SpecificLicense; | ||
| creativeCommons?: CreativeCommonsCode; | ||
| } | ||
| export declare function toItem(csvItem: CsvItem, collectionAcceptsUpload: boolean): Item; |
| import { HashOrContent, MimeType, SpecificLicense } from "@logion/client"; | ||
| import { UUID } from "@logion/node-api"; | ||
| export function toItem(csvItem, collectionAcceptsUpload) { | ||
| const id = csvItem.id; | ||
| const displayId = csvItem.displayId; | ||
| const description = csvItem.description; | ||
| let files = []; | ||
| if ("fileName" in csvItem) { | ||
| files = [ | ||
| HashOrContent.fromDescription({ | ||
| hash: csvItem.fileHash, | ||
| mimeType: MimeType.from(csvItem.fileContentType), | ||
| name: csvItem.fileName, | ||
| size: BigInt(csvItem.fileSize), | ||
| }), | ||
| ]; | ||
| } | ||
| let restrictedDelivery = false; | ||
| if ("restrictedDelivery" in csvItem) { | ||
| restrictedDelivery = csvItem.restrictedDelivery; | ||
| } | ||
| let token; | ||
| if ("tokenType" in csvItem) { | ||
| if (csvItem.tokenType && csvItem.tokenId && csvItem.tokenIssuance) { | ||
| token = { | ||
| type: csvItem.tokenType, | ||
| id: csvItem.tokenId, | ||
| issuance: BigInt(csvItem.tokenIssuance), | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| id, | ||
| displayId, | ||
| description, | ||
| files, | ||
| restrictedDelivery, | ||
| token, | ||
| upload: collectionAcceptsUpload && files.length > 0, | ||
| logionClassification: csvItem.termsAndConditionsType === "logion_classification" ? JSON.parse(csvItem.termsAndConditionsParameters) : undefined, | ||
| specificLicense: csvItem.termsAndConditionsType === "specific_license" ? new SpecificLicense(UUID.fromAnyString(csvItem.termsAndConditionsParameters), "") : undefined, | ||
| creativeCommons: csvItem.termsAndConditionsType === "CC4.0" ? csvItem.termsAndConditionsParameters : undefined, | ||
| }; | ||
| } |
15859
-13.18%11
-15.38%366
-14.08%+ Added
- Removed
Updated