@elek-io/core 0.4.2 → 0.5.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.node.ts","../../src/schema/assetSchema.ts","../../src/schema/baseSchema.ts","../../src/schema/fileSchema.ts","../../src/schema/collectionSchema.ts","../../src/schema/entrySchema.ts","../../src/schema/valueSchema.ts","../../src/schema/coreSchema.ts","../../src/schema/gitSchema.ts","../../src/schema/gitTagSchema.ts","../../src/schema/projectSchema.ts","../../src/schema/serviceSchema.ts","../../src/schema/userSchema.ts","../../src/error/GitError.ts","../../src/error/NoCurrentUserError.ts","../../src/error/ProjectUpgradeError.ts","../../src/error/RequiredParameterMissingError.ts","../../src/util/node.ts","../../src/service/AbstractCrudService.ts","../../src/service/AssetService.ts","../../src/util/shared.ts","../../src/service/JsonFileService.ts","../../src/service/CollectionService.ts","../../src/service/GitService.ts","../../src/service/GitTagService.ts","../../src/service/UserService.ts","../../src/service/EntryService.ts","../../src/service/ProjectService.ts"],"sourcesContent":["import Fs from 'fs-extra';\nimport {\n constructorElekIoCoreSchema,\n type ConstructorElekIoCoreProps,\n type ElekIoCoreOptions,\n} from './schema/index.js';\nimport {\n AssetService,\n CollectionService,\n EntryService,\n GitService,\n JsonFileService,\n ProjectService,\n UserService,\n} from './service/index.js';\nimport * as Util from './util/node.js';\n\nexport * from './schema/index.js';\nexport * from './util/shared.js';\n\n/**\n * elek.io Core\n *\n * Provides access to all services Core is offering\n */\nexport default class ElekIoCore {\n private readonly options: ElekIoCoreOptions;\n private readonly userService: UserService;\n private readonly gitService: GitService;\n private readonly jsonFileService: JsonFileService;\n private readonly assetService: AssetService;\n private readonly projectService: ProjectService;\n private readonly collectionService: CollectionService;\n private readonly entryService: EntryService;\n // private readonly sharedValueService: SharedValueService;\n\n constructor(props?: ConstructorElekIoCoreProps) {\n const parsedProps = constructorElekIoCoreSchema.parse(props);\n\n const defaults: ElekIoCoreOptions = {\n environment: 'production',\n version: '0.0.0',\n file: {\n json: {\n indentation: 2,\n },\n },\n };\n this.options = Object.assign({}, defaults, parsedProps);\n\n this.jsonFileService = new JsonFileService(this.options);\n this.userService = new UserService(this.jsonFileService);\n this.gitService = new GitService(this.options, this.userService);\n // this.gitService.getVersion(); // @todo currently throws an \"Error: Unable to find path to repository on disk.\"\n this.assetService = new AssetService(\n this.options,\n this.jsonFileService,\n this.gitService\n );\n this.collectionService = new CollectionService(\n this.options,\n this.jsonFileService,\n this.gitService\n );\n // this.sharedValueService = new SharedValueService(\n // this.options,\n // this.jsonFileService,\n // this.gitService,\n // this.assetService\n // );\n this.entryService = new EntryService(\n this.options,\n this.jsonFileService,\n this.gitService,\n this.collectionService,\n this.assetService\n // this.sharedValueService\n );\n this.projectService = new ProjectService(\n this.options,\n this.jsonFileService,\n this.userService,\n this.gitService,\n this.assetService,\n this.collectionService,\n this.entryService\n );\n\n if (this.options.environment !== 'production') {\n console.info(\n `Initializing inside an \"${this.options.environment}\" environment`,\n {\n ...this.options,\n }\n );\n }\n\n Fs.mkdirpSync(Util.pathTo.projects);\n Fs.mkdirpSync(Util.pathTo.tmp);\n Fs.emptyDirSync(Util.pathTo.tmp);\n }\n\n /**\n * Utility / helper functions\n */\n public get util() {\n return Util;\n }\n\n /**\n * Exposes git functions\n */\n public get git(): GitService {\n return this.gitService;\n }\n\n /**\n * Getter and setter methods for the User currently working with Core\n */\n public get user(): UserService {\n return this.userService;\n }\n\n /**\n * CRUD methods to work with Projects\n */\n public get projects(): ProjectService {\n return this.projectService;\n }\n\n /**\n * CRUD methods to work with Assets\n */\n public get assets(): AssetService {\n return this.assetService;\n }\n\n /**\n * CRUD methods to work with Collections\n */\n public get collections(): CollectionService {\n return this.collectionService;\n }\n\n /**\n * CRUD methods to work with Entries\n */\n public get entries(): EntryService {\n return this.entryService;\n }\n\n /**\n * CRUD methods to work with Values\n */\n // public get sharedValues(): SharedValueService {\n // return this.sharedValueService;\n // }\n}\n","import z from 'zod';\nimport {\n objectTypeSchema,\n supportedAssetExtensionSchema,\n supportedAssetMimeTypeSchema,\n uuidSchema,\n} from './baseSchema.js';\nimport { baseFileWithLanguageSchema } from './fileSchema.js';\n\nexport const assetFileSchema = baseFileWithLanguageSchema.extend({\n objectType: z.literal(objectTypeSchema.Enum.asset).readonly(),\n name: z.string(),\n description: z.string(),\n extension: supportedAssetExtensionSchema.readonly(),\n mimeType: supportedAssetMimeTypeSchema.readonly(),\n /**\n * Total size in bytes\n */\n size: z.number().readonly(),\n});\nexport type AssetFile = z.infer<typeof assetFileSchema>;\n\nexport const assetSchema = assetFileSchema.extend({\n /**\n * Absolute path on this filesystem\n */\n absolutePath: z.string().readonly(),\n});\nexport type Asset = z.infer<typeof assetSchema>;\n\nexport const assetExportSchema = assetSchema.extend({});\nexport type AssetExport = z.infer<typeof assetExportSchema>;\n\nexport const createAssetSchema = assetFileSchema\n .pick({\n name: true,\n description: true,\n language: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n /**\n * Path of the file to add as a new Asset\n */\n filePath: z.string().readonly(),\n });\nexport type CreateAssetProps = z.infer<typeof createAssetSchema>;\n\nexport const readAssetSchema = assetFileSchema\n .pick({\n id: true,\n language: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n });\nexport type ReadAssetProps = z.infer<typeof readAssetSchema>;\n\nexport const updateAssetSchema = assetFileSchema\n .pick({\n id: true,\n name: true,\n description: true,\n language: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n /**\n * Path of the new file to update the Asset with\n */\n newFilePath: z.string().readonly().optional(),\n });\nexport type UpdateAssetProps = z.infer<typeof updateAssetSchema>;\n\nexport const deleteAssetSchema = assetFileSchema\n .pick({\n id: true,\n language: true,\n extension: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n });\nexport type DeleteAssetProps = z.infer<typeof deleteAssetSchema>;\n\nexport const countAssetsSchema = z.object({ projectId: uuidSchema.readonly() });\nexport type CountAssetsProps = z.infer<typeof countAssetsSchema>;\n","import z from 'zod';\n\nexport const environmentSchema = z.enum(['production', 'development', 'test']);\nexport type Environment = z.infer<typeof environmentSchema>;\n\n/**\n * All currently supported, BCP 47 compliant language tags\n *\n * The support depends on the tools and libraries we use.\n * We can't support a given language, if there is no support\n * for it from used third parties. Currently, to check if a langauge\n * tag can be added to this list, it needs to be supported by:\n * - DeepL translation API\n *\n * @see https://www.deepl.com/docs-api/other-functions/listing-supported-languages/\n */\nexport const supportedLanguageSchema = z.enum([\n /**\n * Bulgarian\n */\n 'bg', //\n 'cs', // Czech\n 'da', // Danish\n 'de', // German\n 'el', // Greek\n 'en', // (US) English\n 'es', // Spanish\n 'et', // Estonian\n 'fi', // Finnish\n 'fr', // French\n 'hu', // Hungarian\n 'it', // Italian\n 'ja', // Japanese\n 'lt', // Lithuanian\n 'lv', // Latvian\n 'nl', // Dutch\n 'pl', // Polish\n 'pt', // Portuguese\n 'ro', // Romanian\n 'ru', // Russian\n 'sk', // Slovak\n 'sl', // Slovenian\n 'sv', // Swedish\n 'zh', // (Simplified) Chinese\n]);\nexport type SupportedLanguage = z.infer<typeof supportedLanguageSchema>;\n\nexport const supportedIconSchema = z.enum(['home', 'plus', 'foobar']);\nexport type SupportedIcon = z.infer<typeof supportedIconSchema>;\n\nexport const supportedAssetMimeTypeSchema = z.enum([\n 'image/avif',\n 'image/gif',\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/webp',\n 'application/pdf',\n 'application/zip',\n 'video/mp4',\n 'video/webm',\n 'audio/webm',\n 'audio/flac',\n]);\nexport type SupportedAssetMimeType = z.infer<\n typeof supportedAssetMimeTypeSchema\n>;\n\n/**\n * Files we currently support for Assets\n *\n * Detection of binary-based files is done by \"file-type\" dependency\n * @see https://github.com/sindresorhus/file-type?tab=readme-ov-file#supported-file-types\n */\nexport const supportedAssetExtensionSchema = z.enum([\n 'avif',\n 'gif',\n 'jpg',\n 'jpeg',\n 'png',\n 'svg',\n 'webp',\n 'pdf',\n 'zip',\n 'mp4',\n 'webm',\n 'flac',\n 'json',\n]);\nexport type SupportedAssetExtension = z.infer<\n typeof supportedAssetExtensionSchema\n>;\n\nexport const supportedAssetTypeSchema = z.object({\n extension: supportedAssetExtensionSchema,\n mimeType: supportedAssetMimeTypeSchema,\n});\nexport type SupportedAssetType = z.infer<typeof supportedAssetTypeSchema>;\n\nexport const objectTypeSchema = z.enum([\n 'project',\n 'asset',\n 'collection',\n 'entry',\n 'value',\n 'sharedValue',\n]);\nexport type ObjectType = z.infer<typeof objectTypeSchema>;\n\nexport const versionSchema = z.string();\n// .refine((version) => {\n// if (Semver.valid(version) !== null) {\n// return true;\n// }\n// return false;\n// }, 'String must follow the Semantic Versioning format (https://semver.org/)');\nexport type Version = z.infer<typeof versionSchema>;\n\nexport const uuidSchema = z.string().uuid('shared.invalidUuid');\nexport type Uuid = z.infer<typeof uuidSchema>;\n\n/**\n * A record that can be used to translate a string value into all supported languages\n */\nexport const translatableStringSchema = z.record(\n supportedLanguageSchema,\n z.string().trim().min(1, 'shared.translatableStringRequired')\n);\nexport type TranslatableString = z.infer<typeof translatableStringSchema>;\n\n/**\n * A record that can be used to translate a number value into all supported languages\n */\nexport const translatableNumberSchema = z.record(\n supportedLanguageSchema,\n z.number({ required_error: 'shared.translatableNumberRequired' })\n);\nexport type TranslatableNumber = z.infer<typeof translatableNumberSchema>;\n\n/**\n * A record that can be used to translate a boolean value into all supported languages\n */\nexport const translatableBooleanSchema = z.record(\n supportedLanguageSchema,\n z.boolean({ required_error: 'shared.translatableBooleanRequired' })\n);\nexport type TranslatableBoolean = z.infer<typeof translatableBooleanSchema>;\n\nexport function translatableArrayOf<T extends z.ZodTypeAny>(schema: T) {\n return z.record(supportedLanguageSchema, z.array(schema));\n}\n","import z from 'zod';\nimport {\n supportedAssetExtensionSchema,\n supportedLanguageSchema,\n uuidSchema,\n} from './baseSchema.js';\n\n/**\n * A basic file structure every elek.io file on disk has to follow\n */\nexport const baseFileSchema = z.object({\n /**\n * The ID of the file\n *\n * The ID is part of the files name.\n */\n id: uuidSchema.readonly(),\n /**\n * The timestamp of the file being created is set by the service of \"objectType\" while creating it\n */\n created: z.number().readonly(),\n /**\n * The timestamp of the file being updated is set by the service of \"objectType\" while updating it\n */\n updated: z.number().nullable(),\n});\nexport type BaseFile = z.infer<typeof baseFileSchema>;\n\nexport const baseFileWithLanguageSchema = baseFileSchema.extend({\n /**\n * The language of the file\n *\n * The language is part of the files name and together with it's ID the only unique identifier.\n * That's why the language cannot be changed after creating the file.\n *\n * @todo Maybe remove the above restriction by implementing logic to handle changing the files language inside all services\n */\n language: supportedLanguageSchema.readonly(),\n});\nexport type BaseFileWithLanguage = z.infer<typeof baseFileWithLanguageSchema>;\n\nexport const fileReferenceSchema = z.object({\n id: uuidSchema,\n language: supportedLanguageSchema.optional(),\n extension: supportedAssetExtensionSchema.optional(),\n});\nexport type FileReference = z.infer<typeof fileReferenceSchema>;\n","import z from 'zod';\nimport {\n objectTypeSchema,\n supportedIconSchema,\n translatableStringSchema,\n uuidSchema,\n} from './baseSchema.js';\nimport { entryExportSchema } from './entrySchema.js';\nimport { baseFileSchema } from './fileSchema.js';\nimport { valueDefinitionSchema } from './valueSchema.js';\n\nexport const collectionFileSchema = baseFileSchema.extend({\n objectType: z.literal(objectTypeSchema.Enum.collection).readonly(),\n name: z.object({\n singular: translatableStringSchema,\n plural: translatableStringSchema,\n }),\n slug: z.object({\n singular: z.string(),\n plural: z.string(),\n }),\n description: translatableStringSchema,\n icon: supportedIconSchema,\n valueDefinitions: z.array(valueDefinitionSchema),\n});\nexport type CollectionFile = z.infer<typeof collectionFileSchema>;\n\nexport const collectionSchema = collectionFileSchema.extend({});\nexport type Collection = z.infer<typeof collectionSchema>;\n\nexport const collectionExportSchema = collectionSchema.extend({\n entries: z.array(entryExportSchema),\n});\nexport type CollectionExport = z.infer<typeof collectionExportSchema>;\n\nexport const createCollectionSchema = collectionSchema\n .omit({\n id: true,\n objectType: true,\n created: true,\n updated: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n });\nexport type CreateCollectionProps = z.infer<typeof createCollectionSchema>;\n\nexport const readCollectionSchema = z.object({\n id: uuidSchema.readonly(),\n projectId: uuidSchema.readonly(),\n});\nexport type ReadCollectionProps = z.infer<typeof readCollectionSchema>;\n\nexport const updateCollectionSchema = collectionFileSchema\n .pick({\n id: true,\n name: true,\n slug: true,\n description: true,\n icon: true,\n valueDefinitions: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n });\nexport type UpdateCollectionProps = z.infer<typeof updateCollectionSchema>;\n\nexport const deleteCollectionSchema = readCollectionSchema.extend({});\nexport type DeleteCollectionProps = z.infer<typeof deleteCollectionSchema>;\n\nexport const countCollectionsSchema = z.object({\n projectId: uuidSchema.readonly(),\n});\nexport type CountCollectionsProps = z.infer<typeof countCollectionsSchema>;\n","import z from 'zod';\nimport type { Asset } from './assetSchema.js';\nimport {\n objectTypeSchema,\n uuidSchema,\n type SupportedLanguage,\n} from './baseSchema.js';\nimport { baseFileSchema } from './fileSchema.js';\nimport {\n resolvedValueSchema,\n valueSchema,\n type DirectValue,\n type ReferencedValue,\n} from './valueSchema.js';\n\nexport const entryFileSchema = baseFileSchema.extend({\n objectType: z.literal(objectTypeSchema.Enum.entry).readonly(),\n values: z.array(valueSchema),\n});\nexport type EntryFile = z.infer<typeof entryFileSchema>;\n\n// @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types\nexport type Entry = z.infer<typeof entryFileSchema> & {\n values: (\n | DirectValue\n | (ReferencedValue & {\n content: Partial<Record<SupportedLanguage, (Asset | Entry)[]>>;\n })\n )[];\n};\nexport const entrySchema = entryFileSchema.extend({\n values: z.array(z.lazy(() => resolvedValueSchema)),\n}) satisfies z.ZodType<Entry>;\n\nexport const entryExportSchema = entrySchema.extend({});\nexport type EntryExport = z.infer<typeof entryExportSchema>;\n\nexport const createEntrySchema = entryFileSchema\n .omit({\n id: true,\n objectType: true,\n created: true,\n updated: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n collectionId: uuidSchema.readonly(),\n values: z.array(valueSchema),\n });\nexport type CreateEntryProps = z.infer<typeof createEntrySchema>;\n\nexport const readEntrySchema = z.object({\n id: uuidSchema.readonly(),\n projectId: uuidSchema.readonly(),\n collectionId: uuidSchema.readonly(),\n});\nexport type ReadEntryProps = z.infer<typeof readEntrySchema>;\n\nexport const updateEntrySchema = entrySchema\n .omit({\n objectType: true,\n created: true,\n updated: true,\n })\n .extend({\n projectId: uuidSchema.readonly(),\n collectionId: uuidSchema.readonly(),\n });\nexport type UpdateEntryProps = z.infer<typeof updateEntrySchema>;\n\nexport const deleteEntrySchema = readEntrySchema.extend({});\nexport type DeleteEntryProps = z.infer<typeof deleteEntrySchema>;\n\nexport const countEntriesSchema = z.object({\n projectId: uuidSchema.readonly(),\n collectionId: uuidSchema.readonly(),\n});\nexport type CountEntriesProps = z.infer<typeof countEntriesSchema>;\n","import z from 'zod';\nimport { assetSchema, type Asset } from './assetSchema.js';\nimport {\n objectTypeSchema,\n supportedAssetMimeTypeSchema,\n supportedLanguageSchema,\n translatableArrayOf,\n translatableBooleanSchema,\n translatableNumberSchema,\n translatableStringSchema,\n uuidSchema,\n} from './baseSchema.js';\nimport { entrySchema, type Entry } from './entrySchema.js';\n\nexport const ValueTypeSchema = z.enum([\n 'string',\n 'number',\n 'boolean',\n 'reference',\n]);\nexport type ValueType = z.infer<typeof ValueTypeSchema>;\n\nexport const ValueInputTypeSchema = z.enum([\n // String\n 'text',\n 'textarea',\n 'email',\n // 'password', @todo maybe if there is a usecase\n 'url',\n 'ip',\n 'date',\n 'time',\n 'datetime',\n 'telephone',\n // Number\n 'number',\n 'range',\n // Boolean\n 'toggle',\n // Reference\n 'asset',\n 'entry',\n // 'sharedValue', // @todo\n]);\nexport type ValueInputType = z.infer<typeof ValueInputTypeSchema>;\n\nexport const ValueInputWidthSchema = z.enum(['12', '6', '4', '3']);\n\nexport const ValueDefinitionBaseSchema = z.object({\n id: uuidSchema.readonly(),\n label: translatableStringSchema,\n description: translatableStringSchema,\n isRequired: z.boolean(),\n isDisabled: z.boolean(),\n isUnique: z.boolean(),\n inputWidth: ValueInputWidthSchema,\n});\nexport type ValueDefinitionBase = z.infer<typeof ValueDefinitionBaseSchema>;\n\n/**\n * String based Values\n */\n\nexport const StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(\n {\n valueType: z.literal(ValueTypeSchema.Enum.string),\n defaultValue: z.string().nullable(),\n }\n);\n\nexport const textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(\n {\n inputType: z.literal(ValueInputTypeSchema.Enum.text),\n min: z.number().nullable(),\n max: z.number().nullable(),\n }\n);\nexport type TextValueDefinition = z.infer<typeof textValueDefinitionSchema>;\n\nexport const textareaValueDefinitionSchema =\n StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.textarea),\n min: z.number().nullable(),\n max: z.number().nullable(),\n });\nexport type TextareaValueDefinition = z.infer<\n typeof textareaValueDefinitionSchema\n>;\n\nexport const emailValueDefinitionSchema =\n StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.email),\n defaultValue: z.string().email().nullable(),\n });\nexport type EmailValueDefinition = z.infer<typeof emailValueDefinitionSchema>;\n\n// @todo why should we support password Values? Client saves it in clear text anyways\n// export const passwordFieldDefinitionSchema =\n// StringFieldDefinitionBaseSchema.extend({\n// inputType: z.literal(FieldInputTypeSchema.Enum.password),\n// });\n\nexport const urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.url),\n defaultValue: z.string().url().nullable(),\n});\nexport type UrlValueDefinition = z.infer<typeof urlValueDefinitionSchema>;\n\nexport const ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.ip),\n defaultValue: z.string().ip().nullable(),\n});\nexport type IpValueDefinition = z.infer<typeof ipValueDefinitionSchema>;\n\nexport const dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(\n {\n inputType: z.literal(ValueInputTypeSchema.Enum.date),\n defaultValue: z.string().date().nullable(),\n }\n);\nexport type DateValueDefinition = z.infer<typeof dateValueDefinitionSchema>;\n\nexport const timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(\n {\n inputType: z.literal(ValueInputTypeSchema.Enum.time),\n defaultValue: z.string().time().nullable(),\n }\n);\nexport type TimeValueDefinition = z.infer<typeof timeValueDefinitionSchema>;\n\nexport const datetimeValueDefinitionSchema =\n StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.datetime),\n defaultValue: z.string().datetime().nullable(),\n });\nexport type DatetimeValueDefinition = z.infer<\n typeof datetimeValueDefinitionSchema\n>;\n\nexport const telephoneValueDefinitionSchema =\n StringValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.telephone),\n // defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476\n });\nexport type TelephoneValueDefinition = z.infer<\n typeof telephoneValueDefinitionSchema\n>;\n\nexport const stringValueDefinitionSchema = z.union([\n textValueDefinitionSchema,\n textareaValueDefinitionSchema,\n emailValueDefinitionSchema,\n urlValueDefinitionSchema,\n ipValueDefinitionSchema,\n dateValueDefinitionSchema,\n timeValueDefinitionSchema,\n datetimeValueDefinitionSchema,\n telephoneValueDefinitionSchema,\n]);\nexport type StringValueDefinition = z.infer<typeof stringValueDefinitionSchema>;\n\n/**\n * Number based Values\n */\n\nexport const NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(\n {\n valueType: z.literal(ValueTypeSchema.Enum.number),\n min: z.number().nullable(),\n max: z.number().nullable(),\n isUnique: z.literal(false),\n defaultValue: z.number().nullable(),\n }\n);\n\nexport const numberValueDefinitionSchema =\n NumberValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.number),\n });\nexport type NumberValueDefinition = z.infer<typeof numberValueDefinitionSchema>;\n\nexport const rangeValueDefinitionSchema =\n NumberValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.range),\n // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number\n isRequired: z.literal(true),\n min: z.number(),\n max: z.number(),\n defaultValue: z.number(),\n });\nexport type RangeValueDefinition = z.infer<typeof rangeValueDefinitionSchema>;\n\n/**\n * Boolean based Values\n */\n\nexport const BooleanValueDefinitionBaseSchema =\n ValueDefinitionBaseSchema.extend({\n valueType: z.literal(ValueTypeSchema.Enum.boolean),\n // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false\n isRequired: z.literal(true),\n defaultValue: z.boolean(),\n isUnique: z.literal(false),\n });\n\nexport const toggleValueDefinitionSchema =\n BooleanValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.toggle),\n });\nexport type ToggleValueDefinition = z.infer<typeof toggleValueDefinitionSchema>;\n\n/**\n * Reference based Values\n */\n\nexport const ReferenceValueDefinitionBaseSchema =\n ValueDefinitionBaseSchema.extend({\n valueType: z.literal(ValueTypeSchema.Enum.reference),\n });\n\nexport const assetValueDefinitionSchema =\n ReferenceValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.asset),\n allowedMimeTypes: z.array(supportedAssetMimeTypeSchema).min(1),\n min: z.number().nullable(),\n max: z.number().nullable(),\n });\nexport type AssetValueDefinition = z.infer<typeof assetValueDefinitionSchema>;\n\nexport const entryValueDefinitionSchema =\n ReferenceValueDefinitionBaseSchema.extend({\n inputType: z.literal(ValueInputTypeSchema.Enum.entry),\n ofCollections: z.array(uuidSchema),\n min: z.number().nullable(),\n max: z.number().nullable(),\n });\nexport type EntryValueDefinition = z.infer<typeof entryValueDefinitionSchema>;\n\n// export const sharedValueDefinitionSchema =\n// ReferenceValueDefinitionBaseSchema.extend({\n// inputType: z.literal(ValueInputTypeSchema.Enum.sharedValue),\n// // The shared Value can have any of the direct types\n// // but not any reference itself (a shared Value cannot have a reference to another shared Value / Asset or any other future reference)\n// sharedValueType: z.union([\n// z.literal(ValueTypeSchema.Enum.boolean),\n// z.literal(ValueTypeSchema.Enum.number),\n// z.literal(ValueTypeSchema.Enum.string),\n// ]),\n// });\n// export type SharedValueValueDefinition = z.infer<\n// typeof sharedValueDefinitionSchema\n// >;\n\n/**\n * A Value definition can be any of the listed definitions above\n */\n\nexport const valueDefinitionSchema = z.union([\n stringValueDefinitionSchema,\n numberValueDefinitionSchema,\n rangeValueDefinitionSchema,\n toggleValueDefinitionSchema,\n assetValueDefinitionSchema,\n entryValueDefinitionSchema,\n // sharedValueDefinitionSchema,\n]);\nexport type ValueDefinition = z.infer<typeof valueDefinitionSchema>;\n\nexport const valueContentReferenceBase = z.object({\n id: uuidSchema,\n});\n\nexport const valueContentReferenceWithLanguageBase =\n valueContentReferenceBase.extend({\n language: supportedLanguageSchema,\n });\n\nexport const valueContentReferenceToAssetSchema =\n valueContentReferenceWithLanguageBase.extend({\n objectType: z.literal(objectTypeSchema.Enum.asset),\n });\nexport type ValueContentReferenceToAsset = z.infer<\n typeof valueContentReferenceToAssetSchema\n>;\n\nexport const valueContentReferenceToCollectionSchema =\n valueContentReferenceBase.extend({\n objectType: z.literal(objectTypeSchema.Enum.collection),\n });\nexport type ValueContentReferenceToCollection = z.infer<\n typeof valueContentReferenceToCollectionSchema\n>;\n\nexport const valueContentReferenceToEntrySchema =\n valueContentReferenceBase.extend({\n objectType: z.literal(objectTypeSchema.Enum.entry),\n });\nexport type ValueContentReferenceToEntry = z.infer<\n typeof valueContentReferenceToEntrySchema\n>;\n\n// export const valueContentReferenceToSharedValueSchema = z.object({\n// referenceObjectType: z.literal(objectTypeSchema.Enum.sharedValue),\n// references: z.object({\n// id: uuidSchema,\n// language: supportedLanguageSchema,\n// }),\n// });\n// export type ValueContentReferenceToSharedValue = z.infer<\n// typeof valueContentReferenceToSharedValueSchema\n// >;\n\n// export const sharedValueFileSchema = baseFileWithLanguageSchema.extend({\n// objectType: z.literal(objectTypeSchema.Enum.sharedValue).readonly(),\n// valueType: ValueTypeSchema.exclude(['reference']).readonly(),\n// // valueType: ValueTypeSchema.readonly(), @todo do we allow shared Values to reference assets or others?\n// content: z.union([\n// z.string(),\n// z.number(),\n// z.boolean(),\n// z.string().optional(),\n// z.number().optional(),\n// z.boolean().optional(),\n// // valueContentReferenceToAssetSchema, @todo do we allow shared Values to reference assets or others?\n// // valueContentReferenceToSharedValueSchema,\n// ]),\n// });\n// export type SharedValueFile = z.infer<typeof sharedValueFileSchema>;\n\n// export const sharedValueSchema = sharedValueFileSchema.extend({});\n// export type SharedValue = z.infer<typeof sharedValueSchema>;\n\n// export const sharedValueExportSchema = sharedValueSchema.extend({});\n// export type SharedValueExport = z.infer<typeof sharedValueExportSchema>;\n\n// export const resolvedValueContentReferenceToSharedValueSchema =\n// valueContentReferenceToSharedValueSchema.extend({\n// references: z.object({\n// id: uuidSchema,\n// language: supportedLanguageSchema,\n// resolved: sharedValueSchema,\n// }),\n// });\n// export type ResolvedValueContentReferenceToSharedValue = z.infer<\n// typeof resolvedValueContentReferenceToSharedValueSchema\n// >;\n\nexport const valueContentReferenceSchema = z.union([\n valueContentReferenceToAssetSchema,\n valueContentReferenceToCollectionSchema,\n valueContentReferenceToEntrySchema,\n // valueContentReferenceToSharedValueSchema,\n]);\nexport type ValueContentReference = z.infer<typeof valueContentReferenceSchema>;\n\nexport const resolvedValueContentReferenceSchema: z.ZodUnion<\n [z.ZodType<Asset>, z.ZodType<Entry>]\n> = z.union([\n assetSchema,\n z.lazy(() => entrySchema), // Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types\n // resolvedValueContentReferenceToSharedValueSchema,\n]);\nexport type ResolvedValueContentReference = z.infer<\n typeof resolvedValueContentReferenceSchema\n>;\n\nexport const directValueBaseSchema = z.object({\n objectType: z.literal(objectTypeSchema.Enum.value).readonly(),\n definitionId: uuidSchema.readonly(),\n});\n\nexport const directStringValueSchema = directValueBaseSchema.extend({\n valueType: z.literal(ValueTypeSchema.Enum.string).readonly(),\n content: translatableStringSchema,\n});\nexport type DirectStringValue = z.infer<typeof directStringValueSchema>;\n\nexport const directNumberValueSchema = directValueBaseSchema.extend({\n valueType: z.literal(ValueTypeSchema.Enum.number).readonly(),\n content: translatableNumberSchema,\n});\nexport type DirectNumberValue = z.infer<typeof directNumberValueSchema>;\n\nexport const directBooleanValueSchema = directValueBaseSchema.extend({\n valueType: z.literal(ValueTypeSchema.Enum.boolean).readonly(),\n content: translatableBooleanSchema,\n});\nexport type DirectBooleanValue = z.infer<typeof directBooleanValueSchema>;\n\nexport const directValueSchema = z.union([\n directStringValueSchema,\n directNumberValueSchema,\n directBooleanValueSchema,\n]);\nexport type DirectValue = z.infer<typeof directValueSchema>;\n\nexport const referencedValueSchema = z.object({\n objectType: z.literal(objectTypeSchema.Enum.value).readonly(),\n definitionId: uuidSchema.readonly(),\n valueType: z.literal(ValueTypeSchema.Enum.reference).readonly(),\n content: translatableArrayOf(valueContentReferenceSchema),\n});\nexport type ReferencedValue = z.infer<typeof referencedValueSchema>;\n\nexport const valueSchema = z.union([directValueSchema, referencedValueSchema]);\nexport type Value = z.infer<typeof valueSchema>;\n\nexport const resolvedReferencedValueSchema = referencedValueSchema.extend({\n content: translatableArrayOf(resolvedValueContentReferenceSchema),\n});\nexport type ResolvedReferencedValue = z.infer<\n typeof resolvedReferencedValueSchema\n>;\n\nexport const resolvedValueSchema = z.union([\n directValueSchema,\n resolvedReferencedValueSchema,\n]);\nexport type ResolvedValue = z.infer<typeof resolvedValueSchema>;\n\n/**\n * Dynamic zod schema generation\n */\n\n/**\n * Generates a zod schema to check a Values content, based on given ValueDefinition\n */\nexport function getValueContentSchemaFromDefinition(\n definition: ValueDefinition\n) {\n switch (definition.valueType) {\n case ValueTypeSchema.Enum.boolean:\n return getBooleanValueContentSchema(definition);\n case ValueTypeSchema.Enum.number:\n return getNumberValueContentSchema(definition);\n case ValueTypeSchema.Enum.string:\n return getStringValueContentSchema(definition);\n case ValueTypeSchema.Enum.reference:\n return getReferenceValueContentSchema(definition);\n default:\n throw new Error(\n // @ts-expect-error\n `Error generating schema for unsupported ValueType \"${definition.valueType}\"`\n );\n }\n}\n\nfunction getBooleanValueContentSchema(definition: ToggleValueDefinition) {\n return z.boolean();\n}\n\nfunction getNumberValueContentSchema(\n definition: NumberValueDefinition | RangeValueDefinition\n) {\n let schema = z.number();\n\n if (definition.min) {\n schema = schema.min(definition.min);\n }\n if (definition.max) {\n schema = schema.max(definition.max);\n }\n\n if (definition.isRequired === false) {\n return schema.nullable();\n }\n\n return schema;\n}\n\nfunction getStringValueContentSchema(definition: StringValueDefinition) {\n let schema = z.string().trim(); // Additionally trim whitespace\n\n if ('min' in definition && definition.min) {\n schema = schema.min(definition.min);\n }\n if ('max' in definition && definition.max) {\n schema = schema.max(definition.max);\n }\n\n switch (definition.inputType) {\n case ValueInputTypeSchema.Enum.email:\n schema = schema.email();\n break;\n case ValueInputTypeSchema.Enum.url:\n schema = schema.url();\n break;\n case ValueInputTypeSchema.Enum.ip:\n schema = schema.ip();\n break;\n case ValueInputTypeSchema.Enum.date:\n schema = schema.date();\n break;\n case ValueInputTypeSchema.Enum.time:\n schema = schema.time();\n break;\n case ValueInputTypeSchema.Enum.datetime:\n schema = schema.datetime();\n break;\n case ValueInputTypeSchema.Enum.telephone:\n // @todo z.string().e164() when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476\n break;\n }\n\n if (definition.isRequired === false) {\n return schema.nullable();\n }\n\n return schema.min(1, 'shared.stringValueRequired'); // @see https://github.com/colinhacks/zod/issues/2466\n}\n\nfunction getReferenceValueContentSchema(\n definition: AssetValueDefinition | EntryValueDefinition // | SharedValueValueDefinition\n) {\n let schema;\n\n switch (definition.inputType) {\n case ValueInputTypeSchema.Enum.asset:\n {\n schema = z.array(valueContentReferenceToAssetSchema);\n }\n break;\n case ValueInputTypeSchema.Enum.entry:\n {\n schema = z.array(valueContentReferenceToEntrySchema);\n }\n break;\n // case ValueInputTypeSchema.Enum.sharedValue: {\n // let schema = valueContentReferenceToSharedValueSchema.extend({}); // Deep copy to not overwrite the base schema\n\n // if (definition.isRequired) {\n // const requiredReferences = schema.shape.references.min(\n // 1,\n // 'shared.assetValueRequired'\n // );\n // schema = schema.extend({\n // references: requiredReferences,\n // });\n // }\n\n // return valueContentReferenceToSharedValueSchema;\n // }\n }\n\n if (definition.isRequired) {\n schema = schema.min(1, 'shared.referenceRequired');\n }\n\n if (definition.min) {\n schema = schema.min(definition.min);\n }\n\n if (definition.max) {\n schema = schema.max(definition.max);\n }\n\n return schema;\n}\n\n/**\n * ---\n */\n\n// export const createSharedValueSchema = sharedValueFileSchema\n// .pick({\n// valueType: true,\n// content: true,\n// language: true,\n// })\n// .extend({\n// projectId: uuidSchema.readonly(),\n// });\n// export type CreateSharedValueProps = z.infer<typeof createSharedValueSchema>;\n\n// export const readSharedValueSchema = sharedValueFileSchema\n// .pick({\n// id: true,\n// language: true,\n// })\n// .extend({\n// projectId: uuidSchema.readonly(),\n// });\n// export type ReadSharedValueProps = z.infer<typeof readSharedValueSchema>;\n\n// export const updateSharedValueSchema = sharedValueFileSchema\n// .pick({\n// id: true,\n// language: true,\n// content: true,\n// })\n// .extend({\n// projectId: uuidSchema.readonly(),\n// });\n// export type UpdateSharedValueProps = z.infer<typeof updateSharedValueSchema>;\n\n// export const deleteSharedValueSchema = sharedValueFileSchema\n// .pick({\n// id: true,\n// language: true,\n// })\n// .extend({\n// projectId: uuidSchema.readonly(),\n// });\n// export type DeleteSharedValueProps = z.infer<typeof deleteSharedValueSchema>;\n\n/**\n * @todo maybe we need to validate Values and shared Values\n */\n// export const validateValueSchema = sharedValueFileSchema\n// .pick({\n// id: true,\n// language: true,\n// })\n// .extend({\n// projectId: uuidSchema.readonly(),\n// definition: valueDefinitionSchema.readonly(),\n// });\n// export type ValidateValueProps = z.infer<typeof validateValueSchema>;\n\n// export const countValuesSchema = z.object({ projectId: uuidSchema.readonly() });\n// export type CountValuesProps = z.infer<typeof countValuesSchema>;\n","import { z } from 'zod';\nimport { environmentSchema, versionSchema } from './baseSchema.js';\n\n/**\n * Options that can be passed to elek.io core\n */\nexport const elekIoCoreOptionsSchema = z.object({\n /**\n * The environment elek.io Core is currently running in\n */\n environment: environmentSchema,\n /**\n * The current version of elek.io Core\n */\n version: versionSchema,\n file: z.object({\n json: z.object({\n /**\n * If set, adds indentation with spaces (number) or escape character (string)\n * and line break characters to saved JSON files on disk, to make them easier to read.\n * Defaults to 2 spaces of indentation.\n */\n indentation: z.union([z.number(), z.string()]),\n }),\n }),\n});\nexport type ElekIoCoreOptions = z.infer<typeof elekIoCoreOptionsSchema>;\n\nexport const constructorElekIoCoreSchema = elekIoCoreOptionsSchema\n .omit({\n version: true,\n })\n .partial({\n environment: true,\n file: true,\n })\n .optional();\nexport type ConstructorElekIoCoreProps = z.infer<\n typeof constructorElekIoCoreSchema\n>;\n","import { z } from 'zod';\n\n/**\n * Path to the git repository\n */\nexport const gitRepositoryPathSchema = z.string();\n\n/**\n * Signature git uses to identify users\n */\nexport const gitSignatureSchema = z.object({\n name: z.string(),\n email: z.string(),\n});\nexport type GitSignature = z.infer<typeof gitSignatureSchema>;\n\nexport const gitCommitSchema = z.object({\n /**\n * SHA-1 hash of the commit\n */\n hash: z.string(),\n message: z.string(),\n author: gitSignatureSchema,\n timestamp: z.number(),\n tag: z.string().nullable(),\n});\nexport type GitCommit = z.infer<typeof gitCommitSchema>;\n\n/**\n * Icons for usage in commit messages\n *\n * @see https://gitmoji.dev/\n */\nenum GitCommitIconNative {\n INIT = ':tada:',\n CREATE = ':heavy_plus_sign:',\n UPDATE = ':wrench:',\n DELETE = ':fire:',\n}\nexport const gitCommitIconSchema = z.nativeEnum(GitCommitIconNative);\nexport type GitCommitIcon = z.infer<typeof gitCommitIconSchema>;\n\nexport const gitInitOptionsSchema = z.object({\n /**\n * Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).\n */\n initialBranch: z.string(),\n});\nexport type GitInitOptions = z.infer<typeof gitInitOptionsSchema>;\n\nexport const gitCloneOptionsSchema = z.object({\n /**\n * Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.\n */\n depth: z.number(),\n /**\n * Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.\n */\n singleBranch: z.boolean(),\n /**\n * Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.\n */\n branch: z.string(),\n});\nexport type GitCloneOptions = z.infer<typeof gitCloneOptionsSchema>;\n\nexport const gitSwitchOptionsSchema = z.object({\n /**\n * If true, creates a new local branch and then switches to it\n *\n * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt\n */\n isNew: z.boolean().optional(),\n});\nexport type GitSwitchOptions = z.infer<typeof gitSwitchOptionsSchema>;\n\nexport const gitLogOptionsSchema = z.object({\n /**\n * Limit the result to given number of commits\n */\n limit: z.number().optional(),\n /**\n * Only list commits that are between given SHAs or tag names\n *\n * Note that the commits of from and to are not included in the result\n */\n between: z.object({\n /**\n * From the oldest commit\n */\n from: z.string(),\n /**\n * To the newest commit\n *\n * Defaults to the current HEAD\n */\n to: z.string().optional(),\n }),\n});\nexport type GitLogOptions = z.infer<typeof gitLogOptionsSchema>;\n","import { z } from 'zod';\nimport { uuidSchema } from './baseSchema.js';\nimport {\n gitCommitSchema,\n gitRepositoryPathSchema,\n gitSignatureSchema,\n} from './gitSchema.js';\n\nexport const gitTagSchema = z.object({\n id: uuidSchema,\n message: z.string(),\n author: gitSignatureSchema,\n timestamp: z.number(),\n});\nexport type GitTag = z.infer<typeof gitTagSchema>;\n\nexport const createGitTagSchema = gitTagSchema\n .pick({\n message: true,\n })\n .extend({\n path: gitRepositoryPathSchema,\n hash: gitCommitSchema.shape.hash.optional(),\n });\nexport type CreateGitTagProps = z.infer<typeof createGitTagSchema>;\n\nexport const readGitTagSchema = z.object({\n path: gitRepositoryPathSchema,\n id: uuidSchema.readonly(),\n});\nexport type ReadGitTagProps = z.infer<typeof readGitTagSchema>;\n\nexport const deleteGitTagSchema = readGitTagSchema.extend({});\nexport type DeleteGitTagProps = z.infer<typeof deleteGitTagSchema>;\n\nexport const countGitTagsSchema = z.object({\n path: gitRepositoryPathSchema,\n});\nexport type CountGitTagsProps = z.infer<typeof countGitTagsSchema>;\n","import { z } from 'zod';\nimport { assetExportSchema } from './assetSchema.js';\nimport {\n objectTypeSchema,\n supportedLanguageSchema,\n uuidSchema,\n versionSchema,\n} from './baseSchema.js';\nimport { collectionExportSchema } from './collectionSchema.js';\nimport { baseFileSchema } from './fileSchema.js';\nimport { gitSwitchOptionsSchema } from './gitSchema.js';\n\nexport const projectStatusSchema = z.enum(['foo', 'bar', 'todo']);\nexport type ProjectStatus = z.infer<typeof projectStatusSchema>;\n\nexport const projectSettingsSchema = z.object({\n language: z.object({\n default: supportedLanguageSchema,\n supported: z.array(supportedLanguageSchema),\n }),\n});\nexport type ProjectSettings = z.infer<typeof projectSettingsSchema>;\n\nexport const projectFolderSchema = z.enum([\n 'assets',\n 'collections',\n 'shared-values',\n 'lfs',\n // 'logs',\n // 'public',\n // 'theme',\n]);\nexport type ProjectFolder = z.infer<typeof projectFolderSchema>;\n\nexport const projectFileSchema = baseFileSchema.extend({\n objectType: z.literal(objectTypeSchema.Enum.project).readonly(),\n coreVersion: versionSchema,\n name: z.string().trim().min(1, 'shared.projectNameRequired'),\n description: z.string().trim().min(1, 'shared.projectDescriptionRequired'),\n version: versionSchema,\n status: projectStatusSchema,\n settings: projectSettingsSchema,\n});\nexport type ProjectFile = z.infer<typeof projectFileSchema>;\n\nexport const projectSchema = projectFileSchema.extend({});\nexport type Project = z.infer<typeof projectSchema>;\n\nexport const projectExportSchema = projectSchema.extend({\n assets: z.array(assetExportSchema),\n collections: z.array(collectionExportSchema),\n});\nexport type ProjectExport = z.infer<typeof projectExportSchema>;\n\nexport const createProjectSchema = projectSchema\n .pick({\n name: true,\n description: true,\n settings: true,\n })\n .partial({\n description: true,\n settings: true,\n });\nexport type CreateProjectProps = z.infer<typeof createProjectSchema>;\n\nexport const readProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type ReadProjectProps = z.infer<typeof readProjectSchema>;\n\nexport const updateProjectSchema = projectSchema\n .pick({\n id: true,\n name: true,\n description: true,\n settings: true,\n })\n .partial({\n name: true,\n description: true,\n settings: true,\n });\nexport type UpdateProjectProps = z.infer<typeof updateProjectSchema>;\n\nexport const upgradeProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type UpgradeProjectProps = z.infer<typeof upgradeProjectSchema>;\n\nexport const deleteProjectSchema = readProjectSchema.extend({});\nexport type DeleteProjectProps = z.infer<typeof deleteProjectSchema>;\n\nexport const projectUpgradeSchema = z.object({\n /**\n * The Core version the Project will be upgraded to\n */\n to: versionSchema.readonly(),\n /**\n * Function that will be executed in the process of upgrading a Project\n */\n run: z.function().args(projectFileSchema).returns(z.promise(z.void())),\n});\nexport type ProjectUpgrade = z.infer<typeof projectUpgradeSchema>;\n\nexport const cloneProjectSchema = z.object({\n url: z.string(),\n});\nexport type CloneProjectProps = z.infer<typeof cloneProjectSchema>;\n\nexport const listBranchesProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type ListBranchesProjectProps = z.infer<\n typeof listBranchesProjectSchema\n>;\n\nexport const currentBranchProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type CurrentBranchProjectProps = z.infer<\n typeof currentBranchProjectSchema\n>;\n\nexport const switchBranchProjectSchema = z.object({\n id: uuidSchema.readonly(),\n branch: z.string(),\n options: gitSwitchOptionsSchema.optional(),\n});\nexport type SwitchBranchProjectProps = z.infer<\n typeof switchBranchProjectSchema\n>;\n\nexport const getRemoteOriginUrlProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type GetRemoteOriginUrlProjectProps = z.infer<\n typeof getRemoteOriginUrlProjectSchema\n>;\n\nexport const setRemoteOriginUrlProjectSchema = z.object({\n id: uuidSchema.readonly(),\n url: z.string(),\n});\nexport type SetRemoteOriginUrlProjectProps = z.infer<\n typeof setRemoteOriginUrlProjectSchema\n>;\n\nexport const getChangesProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type GetChangesProjectProps = z.infer<typeof getChangesProjectSchema>;\n\nexport const synchronizeProjectSchema = z.object({\n id: uuidSchema.readonly(),\n});\nexport type SynchronizeProjectProps = z.infer<typeof synchronizeProjectSchema>;\n\nexport const searchProjectSchema = z.object({\n id: uuidSchema.readonly(),\n query: z.string(),\n language: supportedLanguageSchema,\n type: z.array(objectTypeSchema).optional(),\n});\nexport type SearchProjectProps = z.infer<typeof searchProjectSchema>;\n","import { z } from 'zod';\nimport { uuidSchema } from './baseSchema.js';\nimport { gitRepositoryPathSchema } from './gitSchema.js';\n\nexport const serviceTypeSchema = z.enum([\n 'Git',\n 'GitTag',\n 'User',\n 'Project',\n 'Asset',\n 'JsonFile',\n 'Search',\n 'Collection',\n 'Entry',\n 'Value',\n]);\nexport type ServiceType = z.infer<typeof serviceTypeSchema>;\n\nexport interface PaginatedList<T> {\n total: number;\n limit: number;\n offset: number;\n list: T[];\n}\n\nexport interface PaginationOptions {\n limit: number;\n offset: number;\n}\n\n/**\n * Implements create, read, update and delete methods\n */\nexport interface CrudService<T> {\n create: (props: any) => Promise<T>;\n read: (props: any) => Promise<T>;\n update: (props: any) => Promise<T>;\n delete: (props: any) => Promise<void>;\n}\n\n/**\n * Implements list and count methods additionally\n * to create, read, update and delete\n */\nexport interface ExtendedCrudService<T> extends CrudService<T> {\n /**\n * Returns a list of this services objects\n */\n list: (...props: any) => Promise<PaginatedList<T>>;\n /**\n * Returns the total number of this services objects\n */\n count: (...props: any) => Promise<number>;\n}\n\nconst listSchema = z.object({\n projectId: uuidSchema,\n limit: z.number().optional(),\n offset: z.number().optional(),\n});\n\nexport const listCollectionsSchema = listSchema;\nexport type ListCollectionsProps = z.infer<typeof listCollectionsSchema>;\n\nexport const listEntriesSchema = listSchema.extend({\n collectionId: uuidSchema,\n});\nexport type ListEntriesProps = z.infer<typeof listEntriesSchema>;\n\nexport const listAssetsSchema = listSchema;\nexport type ListAssetsProps = z.infer<typeof listAssetsSchema>;\n\n// export const listSharedValuesSchema = listSchema(sharedValueSchema);\n// export type ListSharedValuesProps = z.infer<typeof listSharedValuesSchema>;\n\nexport const listProjectsSchema = listSchema.omit({\n projectId: true,\n});\nexport type ListProjectsProps = z.infer<typeof listProjectsSchema>;\n\nexport const listGitTagsSchema = z.object({\n path: gitRepositoryPathSchema,\n});\nexport type ListGitTagsProps = z.infer<typeof listGitTagsSchema>;\n","import z from 'zod';\nimport { supportedLanguageSchema, uuidSchema } from './baseSchema.js';\nimport { gitSignatureSchema } from './gitSchema.js';\n\nexport const UserTypeSchema = z.enum(['local', 'cloud']);\n\nexport const baseUserSchema = gitSignatureSchema.extend({\n userType: UserTypeSchema,\n language: supportedLanguageSchema,\n});\nexport type BaseUser = z.infer<typeof baseUserSchema>;\n\nexport const localUserSchema = baseUserSchema.extend({\n userType: z.literal(UserTypeSchema.Enum.local),\n});\nexport type LocalUser = z.infer<typeof localUserSchema>;\n\nexport const cloudUserSchema = baseUserSchema.extend({\n userType: z.literal(UserTypeSchema.Enum.cloud),\n id: uuidSchema,\n});\nexport type CloudUser = z.infer<typeof cloudUserSchema>;\n\nexport const userFileSchema = z.union([localUserSchema, cloudUserSchema]);\nexport type UserFile = z.infer<typeof userFileSchema>;\n\nexport const userSchema = userFileSchema;\nexport type User = z.infer<typeof userSchema>;\n\nexport const setUserSchema = userSchema;\nexport type SetUserProps = z.infer<typeof setUserSchema>;\n","export class GitError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = 'GitError';\n }\n}\n","export class NoCurrentUserError extends Error {\n constructor() {\n super('Make sure to set a User via Core before using other methods');\n\n this.name = 'NoCurrentUserError';\n }\n}\n","export class ProjectUpgradeError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = 'ProjectUpgradeError';\n }\n}\n","export class RequiredParameterMissingError extends Error {\n constructor(parameter: string) {\n super(`Missing required parameter \"${parameter}\"`);\n\n this.name = 'RequiredParameterMissingError';\n }\n}\n","import { spawn, type SpawnOptionsWithoutStdio } from 'child_process';\nimport Fs from 'fs-extra';\nimport { filter, flatten, groupBy, uniq } from 'lodash-es';\nimport Os from 'os';\nimport Path from 'path';\nimport { uuidSchema } from '../schema/baseSchema.js';\nimport { projectFolderSchema } from '../schema/projectSchema.js';\n\n/**\n * The directory in which everything is stored and will be worked in\n *\n * @todo make the workingDirectory an elek option to be set via app.getPath('home') (electron instead of node)?\n */\nexport const workingDirectory = Path.join(Os.homedir(), 'elek.io');\n\n/**\n * A collection of often used paths\n */\nexport const pathTo = {\n tmp: Path.join(workingDirectory, 'tmp'),\n userFile: Path.join(workingDirectory, 'user.json'),\n // logs: Path.join(workingDirectory, 'logs'),\n\n projects: Path.join(workingDirectory, 'projects'),\n project: (projectId: string): string => {\n return Path.join(pathTo.projects, projectId);\n },\n projectFile: (projectId: string): string => {\n return Path.join(pathTo.project(projectId), 'project.json');\n },\n // projectLogs: (projectId: string): string => {\n // return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);\n // },\n\n // public: (projectId: string): string => {\n // return Path.join(pathTo.project(projectId), 'public');\n // },\n\n lfs: (projectId: string): string => {\n return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);\n },\n\n collections: (projectId: string): string => {\n return Path.join(\n pathTo.project(projectId),\n projectFolderSchema.Enum.collections\n );\n },\n collection: (projectId: string, id: string) => {\n return Path.join(pathTo.collections(projectId), id);\n },\n collectionFile: (projectId: string, id: string) => {\n return Path.join(pathTo.collection(projectId, id), 'collection.json');\n },\n\n entries: (projectId: string, collectionId: string): string => {\n return Path.join(pathTo.collection(projectId, collectionId));\n },\n entryFile: (projectId: string, collectionId: string, id: string) => {\n return Path.join(pathTo.entries(projectId, collectionId), `${id}.json`);\n },\n\n sharedValues: (projectId: string): string => {\n return Path.join(pathTo.project(projectId), 'shared-values');\n },\n sharedValueFile: (projectId: string, id: string, language: string) => {\n return Path.join(pathTo.sharedValues(projectId), `${id}.${language}.json`);\n },\n\n assets: (projectId: string): string => {\n return Path.join(\n pathTo.project(projectId),\n projectFolderSchema.Enum.assets\n );\n },\n assetFile: (projectId: string, id: string, language: string): string => {\n return Path.join(pathTo.assets(projectId), `${id}.${language}.json`);\n },\n asset: (\n projectId: string,\n id: string,\n language: string,\n extension: string\n ): string => {\n return Path.join(pathTo.lfs(projectId), `${id}.${language}.${extension}`);\n },\n};\n\n/**\n * Searches for a potential project ID in given path string and returns it\n *\n * Mainly used for logging inside the GitService, where we don't have a project ID,\n * but always have a path which could contain one. The ID is then used,\n * to log to the current project log, instead of logging to the main log file.\n *\n * @todo I really dont like this and I do not know how much performance we loose here\n */\nexport const fromPath = {\n projectId: (path: string): string | undefined => {\n const startsWith = 'projects/';\n const endsWith = '/';\n const start = path.indexOf(startsWith) + startsWith.length;\n // Return early\n if (start === -1) {\n return undefined;\n }\n const end = path.indexOf(endsWith, start);\n // Use path length if there is no ending \"/\"\n const result = path.substring(start, end === -1 ? path.length : end);\n if (result && uuidSchema.safeParse(result).success) {\n return result;\n }\n return undefined;\n },\n};\n\n/**\n * Returns a complete default type, hydrated with the partials of value\n */\nexport function assignDefaultIfMissing<T extends {}>(\n value: Partial<T> | undefined | null,\n defaultsTo: T\n): T {\n return Object.assign(defaultsTo, value);\n}\n\n/**\n * Used as parameter for filter() methods to assure,\n * only values not null, undefined or empty strings are returned\n *\n * @param value Value to check\n */\nexport function notEmpty<T>(value: T | null | undefined): value is T {\n if (value === null || value === undefined) {\n return false;\n }\n if (typeof value === 'string') {\n if (value.trim() === '') {\n return false;\n }\n }\n return true;\n}\n\nexport function isNoError<T>(item: T | Error): item is T {\n return item instanceof Error !== true;\n}\n\n/**\n * Basically a Promise.all() without rejecting if one promise fails to resolve\n */\nexport async function returnResolved<T>(promises: Promise<T>[]) {\n const toCheck: Promise<T | Error>[] = [];\n for (let index = 0; index < promises.length; index++) {\n const promise = promises[index];\n if (!promise) {\n throw new Error(`No promise found at index \"${index}\"`);\n }\n // Here comes the trick:\n // By using \"then\" and \"catch\" we are able to create an array of Project and Error types\n // without throwing and stopping the later Promise.all() call prematurely\n toCheck.push(\n promise\n .then((result) => {\n return result;\n })\n .catch((error) => {\n // Because the error parameter could be anything,\n // we need to specifically call an Error\n return new Error(error);\n })\n );\n }\n // Resolve all promises\n // Here we do not expect any error to fail the call to Promise.all()\n // because we caught it earlier and returning an Error type instead of throwing it\n const checked = await Promise.all(toCheck);\n // This way we can easily filter out any Errors by type\n // Note that we also need to use a User-Defined Type Guard here,\n // because otherwise TS does not recognize we are filtering the errors out\n // > | <\n return checked.filter(isNoError);\n}\n\n/**\n * Custom async typescript ready implementation of Node.js child_process\n *\n * @see https://nodejs.org/api/child_process.html\n * @see https://github.com/ralphtheninja/await-spawn\n */\nexport function spawnChildProcess(\n command: string,\n args: ReadonlyArray<string>,\n options?: SpawnOptionsWithoutStdio\n): Promise<string> {\n return new Promise((resolve, reject) => {\n const childProcess = spawn(command, args, options);\n let log = '';\n\n childProcess.stdout.on('data', (data) => {\n log += data;\n });\n\n childProcess.stderr.on('data', (data) => {\n log += data;\n });\n\n childProcess.on('error', (error) => {\n throw error;\n });\n\n childProcess.on('exit', (code) => {\n if (code === 0) {\n return resolve(log);\n }\n return reject(log);\n });\n });\n}\n\n/**\n * Returns all folders of given path\n */\nexport async function folders(path: string): Promise<Fs.Dirent[]> {\n const dirent = await Fs.readdir(path, { withFileTypes: true });\n return dirent.filter((dirent) => {\n return dirent.isDirectory();\n });\n}\n\n/**\n * Returns all files of given path which can be filtered by extension\n */\nexport async function files(\n path: string,\n extension?: string\n): Promise<Fs.Dirent[]> {\n const dirent = await Fs.readdir(path, { withFileTypes: true });\n return dirent.filter((dirent) => {\n if (extension && dirent.isFile() === true) {\n if (dirent.name.endsWith(extension)) {\n return true;\n }\n return false;\n }\n return dirent.isFile();\n });\n}\n\n/**\n * Returns the relative path for given path\n * by stripping out everything up to the working directory\n */\nexport function getRelativePath(path: string): string {\n let relativePath = path.replace(workingDirectory, '');\n if (relativePath.startsWith('/')) {\n relativePath = relativePath.substr(1);\n }\n return relativePath;\n}\n\n/**\n * Searches given array of objects for duplicates of given key and returns them\n *\n * @param arr Array with possible duplicate values\n * @param key Key of object T to get duplicates of\n */\nexport function getDuplicates<T>(arr: T[], key: keyof T) {\n const grouped = groupBy(arr, (item) => {\n return item[key];\n });\n return uniq(\n flatten(\n filter(grouped, (item) => {\n return item.length > 1;\n })\n )\n );\n}\n","import { RequiredParameterMissingError } from '../error/index.js';\nimport {\n fileReferenceSchema,\n gitCommitIconSchema,\n objectTypeSchema,\n type ElekIoCoreOptions,\n type FileReference,\n type ObjectType,\n type ServiceType,\n type SupportedAssetExtension,\n type SupportedLanguage,\n} from '../schema/index.js';\nimport { files, folders, notEmpty, pathTo } from '../util/node.js';\n\n/**\n * A base service that provides properties for most other services\n */\nexport abstract class AbstractCrudService {\n public readonly type: ServiceType;\n public readonly options: ElekIoCoreOptions;\n\n /**\n * Dynamically generated git messages for operations\n */\n public readonly gitMessage: {\n create: string;\n update: string;\n delete: string;\n };\n\n /**\n * Do not instantiate directly as this is an abstract class\n */\n protected constructor(type: ServiceType, options: ElekIoCoreOptions) {\n this.type = type;\n this.options = options;\n this.gitMessage = {\n create: `${gitCommitIconSchema.enum.CREATE} Created ${this.type}`,\n update: `${gitCommitIconSchema.enum.UPDATE} Updated ${this.type}`,\n delete: `${gitCommitIconSchema.enum.DELETE} Deleted ${this.type}`,\n };\n }\n\n /**\n * Returns a list of all file references of given project and type\n *\n * @param type File type of the references wanted\n * @param projectId Project to get all asset references from\n * @param collectionId Only needed when requesting files of type \"Entry\"\n */\n protected async listReferences(\n type: ObjectType,\n projectId?: string,\n collectionId?: string\n ): Promise<FileReference[]> {\n switch (type) {\n case objectTypeSchema.Enum.asset:\n if (!projectId) {\n throw new RequiredParameterMissingError('projectId');\n }\n return this.getFileReferences(pathTo.lfs(projectId)); // LFS folder is correct, since we want the extension of the file itself, not the AssetFile (.json)\n\n case objectTypeSchema.Enum.project:\n return this.getFolderReferences(pathTo.projects);\n\n case objectTypeSchema.Enum.collection:\n if (!projectId) {\n throw new RequiredParameterMissingError('projectId');\n }\n return this.getFolderReferences(pathTo.collections(projectId));\n\n case objectTypeSchema.Enum.entry:\n if (!projectId) {\n throw new RequiredParameterMissingError('projectId');\n }\n if (!collectionId) {\n throw new RequiredParameterMissingError('collectionId');\n }\n return this.getFileReferences(\n pathTo.collection(projectId, collectionId)\n );\n\n case objectTypeSchema.Enum.sharedValue:\n if (!projectId) {\n throw new RequiredParameterMissingError('projectId');\n }\n return this.getFileReferences(pathTo.sharedValues(projectId));\n\n default:\n throw new Error(`Trying to list files of unsupported type \"${type}\"`);\n }\n }\n\n private async getFolderReferences(path: string): Promise<FileReference[]> {\n const possibleFolders = await folders(path);\n const results = possibleFolders.map((possibleFolder) => {\n const folderReference: FileReference = {\n id: possibleFolder.name,\n };\n\n try {\n return fileReferenceSchema.parse(folderReference);\n } catch (error) {\n return null;\n }\n });\n\n return results.filter(notEmpty);\n }\n\n /**\n * Searches for all files inside given folder,\n * parses their names and returns them as FileReference\n *\n * Ignores files not matching the [id].[language].[extension]\n * or [id].[extension] format for their names\n */\n private async getFileReferences(path: string): Promise<FileReference[]> {\n const possibleFiles = await files(path);\n\n const results = await Promise.all(\n possibleFiles.map(async (possibleFile) => {\n const fileNameArray = possibleFile.name.split('.');\n\n const fileReference: FileReference = {\n id: fileNameArray[0],\n language:\n fileNameArray.length === 3\n ? (fileNameArray[1] as SupportedLanguage)\n : undefined,\n extension:\n fileNameArray.length === 2\n ? (fileNameArray[1] as SupportedAssetExtension)\n : (fileNameArray[2] as SupportedAssetExtension),\n };\n\n try {\n return fileReferenceSchema.parse(fileReference);\n } catch (error) {\n return null;\n }\n })\n );\n\n return results.filter(notEmpty);\n }\n}\n","import Fs from 'fs-extra';\nimport IsSvg from 'is-svg';\nimport { RequiredParameterMissingError } from '../error/index.js';\nimport {\n assetFileSchema,\n assetSchema,\n countAssetsSchema,\n createAssetSchema,\n deleteAssetSchema,\n listAssetsSchema,\n objectTypeSchema,\n readAssetSchema,\n serviceTypeSchema,\n supportedAssetExtensionSchema,\n supportedAssetMimeTypeSchema,\n supportedAssetTypeSchema,\n updateAssetSchema,\n type Asset,\n type AssetFile,\n type BaseFile,\n type CountAssetsProps,\n type CreateAssetProps,\n type DeleteAssetProps,\n type ElekIoCoreOptions,\n type ExtendedCrudService,\n type ListAssetsProps,\n type PaginatedList,\n type ReadAssetProps,\n type UpdateAssetProps,\n} from '../schema/index.js';\nimport { pathTo, returnResolved } from '../util/node.js';\nimport { currentTimestamp, uuid } from '../util/shared.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\nimport type { GitService } from './GitService.js';\nimport { JsonFileService } from './JsonFileService.js';\n\n/**\n * Service that manages CRUD functionality for Asset files on disk\n */\nexport class AssetService\n extends AbstractCrudService\n implements ExtendedCrudService<Asset>\n{\n private readonly jsonFileService: JsonFileService;\n private readonly gitService: GitService;\n\n constructor(\n options: ElekIoCoreOptions,\n jsonFileService: JsonFileService,\n gitService: GitService\n ) {\n super(serviceTypeSchema.Enum.Asset, options);\n\n this.jsonFileService = jsonFileService;\n this.gitService = gitService;\n }\n\n /**\n * Creates a new Asset\n */\n public async create(props: CreateAssetProps): Promise<Asset> {\n createAssetSchema.parse(props);\n\n const id = uuid();\n const projectPath = pathTo.project(props.projectId);\n const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);\n const size = await this.getAssetSize(props.filePath);\n const assetPath = pathTo.asset(\n props.projectId,\n id,\n props.language,\n fileType.extension\n );\n const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);\n\n const assetFile: AssetFile = {\n ...props,\n objectType: 'asset',\n id,\n created: currentTimestamp(),\n updated: null,\n extension: fileType.extension,\n mimeType: fileType.mimeType,\n size,\n };\n\n try {\n await Fs.copyFile(props.filePath, assetPath);\n await this.jsonFileService.create(\n assetFile,\n assetFilePath,\n assetFileSchema\n );\n } catch (error) {\n // To avoid partial data being added to the repository / git status reporting uncommitted files\n await this.delete({ ...assetFile, projectId: props.projectId });\n throw error;\n }\n\n await this.gitService.add(projectPath, [assetFilePath, assetPath]);\n await this.gitService.commit(projectPath, this.gitMessage.create);\n\n return this.toAsset(props.projectId, assetFile);\n }\n\n /**\n * Returns an Asset by ID and language\n */\n public async read(props: ReadAssetProps): Promise<Asset> {\n readAssetSchema.parse(props);\n\n const assetFile = await this.jsonFileService.read(\n pathTo.assetFile(props.projectId, props.id, props.language),\n assetFileSchema\n );\n\n return this.toAsset(props.projectId, assetFile);\n }\n\n /**\n * Updates given Asset\n *\n * Use the optional \"newFilePath\" prop to update the Asset itself\n */\n public async update(props: UpdateAssetProps): Promise<Asset> {\n updateAssetSchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const assetFilePath = pathTo.assetFile(\n props.projectId,\n props.id,\n props.language\n );\n const prevAssetFile = await this.read(props);\n\n // Overwrite old data with new\n // It's ok to have projectId inside props, since the prevAssetFile is read with the same data\n const assetFile: AssetFile = {\n ...prevAssetFile,\n ...props,\n updated: currentTimestamp(),\n };\n\n if (props.newFilePath) {\n // Overwrite the file itself (in LFS folder)...\n\n const fileType = await this.getSupportedFileTypeOrThrow(\n props.newFilePath\n );\n const size = await this.getAssetSize(props.newFilePath);\n const prevAssetPath = pathTo.asset(\n props.projectId,\n props.id,\n props.language,\n prevAssetFile.extension\n );\n const assetPath = pathTo.asset(\n props.projectId,\n props.id,\n props.language,\n fileType.extension\n );\n\n // @todo use try catch to handle FS error and restore previous state\n await Fs.remove(prevAssetPath); // Need to explicitly remove old Asset, because it could have a different extension\n await Fs.copyFile(props.newFilePath, assetPath);\n\n // ...and update meta information\n assetFile.extension = fileType.extension;\n assetFile.mimeType = fileType.mimeType;\n assetFile.size = size;\n }\n\n await this.jsonFileService.update(\n assetFile,\n assetFilePath,\n assetFileSchema\n );\n await this.gitService.add(projectPath, [assetFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.update);\n\n return this.toAsset(props.projectId, assetFile);\n }\n\n /**\n * Deletes given Asset\n */\n public async delete(props: DeleteAssetProps): Promise<void> {\n deleteAssetSchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const assetFilePath = pathTo.assetFile(\n props.projectId,\n props.id,\n props.language\n );\n const assetPath = pathTo.asset(\n props.projectId,\n props.id,\n props.language,\n props.extension\n );\n await Fs.remove(assetPath);\n await Fs.remove(assetFilePath);\n await this.gitService.add(projectPath, [assetFilePath, assetPath]);\n await this.gitService.commit(projectPath, this.gitMessage.delete);\n }\n\n public async list(props: ListAssetsProps): Promise<PaginatedList<Asset>> {\n listAssetsSchema.parse(props);\n\n const offset = props.offset || 0;\n const limit = props.limit || 15;\n\n const assetReferences = await this.listReferences(\n objectTypeSchema.Enum.asset,\n props.projectId\n );\n\n const partialAssetReferences = assetReferences.slice(offset, limit);\n\n const assets = await returnResolved(\n partialAssetReferences.map((assetReference) => {\n if (!assetReference.language) {\n throw new RequiredParameterMissingError('language');\n }\n return this.read({\n projectId: props.projectId,\n id: assetReference.id,\n language: assetReference.language,\n });\n })\n );\n\n return {\n total: assetReferences.length,\n limit,\n offset,\n list: assets,\n };\n }\n\n public async count(props: CountAssetsProps): Promise<number> {\n countAssetsSchema.parse(props);\n\n const count = (\n await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)\n ).length;\n\n return count;\n }\n\n /**\n * Checks if given object is of type Asset\n */\n public isAsset(obj: BaseFile | unknown): obj is Asset {\n return assetSchema.safeParse(obj).success;\n }\n\n /**\n * Returns the size of an Asset in bytes\n *\n * @param path Path of the Asset to get the size from\n */\n private async getAssetSize(path: string) {\n return (await Fs.stat(path)).size;\n }\n\n /**\n * Creates an Asset from given AssetFile\n *\n * @param projectId The project's ID\n * @param assetFile The AssetFile to convert\n */\n private async toAsset(\n projectId: string,\n assetFile: AssetFile\n ): Promise<Asset> {\n const assetPath = pathTo.asset(\n projectId,\n assetFile.id,\n assetFile.language,\n assetFile.extension\n );\n\n const asset: Asset = {\n ...assetFile,\n absolutePath: assetPath,\n };\n\n return asset;\n }\n\n /**\n * Returns the found and supported extension as well as mime type,\n * otherwise throws an error\n *\n * @param filePath Path to the file to check\n */\n private async getSupportedFileTypeOrThrow(filePath: string) {\n const fileSize = (await Fs.stat(filePath)).size;\n\n // Only try to parse potential SVG's\n // that are smaller than 500 kB\n if (fileSize / 1000 <= 500) {\n const fileBuffer = await Fs.readFile(filePath);\n if (IsSvg(fileBuffer.toString()) === true) {\n return {\n extension: supportedAssetExtensionSchema.Enum.svg,\n mimeType: supportedAssetMimeTypeSchema.Enum['image/svg+xml'],\n };\n }\n }\n\n // We do not use fileBuffer here again because fromFile() is recommended\n const { fileTypeFromFile } = await import('file-type');\n const fileType = await fileTypeFromFile(filePath);\n\n const result = supportedAssetTypeSchema.parse({\n extension: fileType?.ext,\n mimeType: fileType?.mime,\n });\n\n return result;\n }\n}\n","import slugify from 'slugify';\nimport { v4 as generateUuid } from 'uuid';\nimport { type Uuid } from '../schema/baseSchema.js';\n\n// Hack to make slugify work with ESM\n// @see https://github.com/simov/slugify/issues/24\n// @ts-ignore\nconst Slugify = slugify.default || slugify;\n\n/**\n * Returns a new UUID\n */\nexport function uuid(): Uuid {\n return generateUuid();\n}\n\n/**\n * Returns the current UNIX timestamp\n *\n * Since the UNIX timestamp is the number of seconds\n * that have elapsed from January 1, 1970, UTC and\n * `Date.now()` returns the time in milliseconds,\n * we need to convert this into seconds.\n */\nexport function currentTimestamp() {\n return Math.floor(Date.now() / 1000);\n}\n\n/**\n * Returns the slug of given string\n */\nexport function slug(string: string): string {\n return Slugify(string, {\n replacement: '-', // replace spaces with replacement character, defaults to `-`\n remove: undefined, // remove characters that match regex, defaults to `undefined`\n lower: true, // convert to lower case, defaults to `false`\n strict: true, // strip special characters except replacement, defaults to `false`\n });\n}\n","import Fs from 'fs-extra';\nimport type { z } from 'zod';\nimport type { ElekIoCoreOptions } from '../schema/coreSchema.js';\nimport type { BaseFile } from '../schema/fileSchema.js';\nimport { serviceTypeSchema } from '../schema/serviceSchema.js';\nimport type { UserFile } from '../schema/userSchema.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\n\n/**\n * Service that manages CRUD functionality for JSON files on disk\n */\nexport class JsonFileService extends AbstractCrudService {\n private cache: Map<string, any> = new Map();\n\n constructor(options: ElekIoCoreOptions) {\n super(serviceTypeSchema.Enum.JsonFile, options);\n }\n\n /**\n * Creates a new file on disk. Fails if path already exists\n *\n * @param data Data to write into the file\n * @param path Path to write the file to\n * @param schema Schema of the file to validate against\n * @returns Validated content of the file from disk\n */\n public async create<T extends z.ZodType<BaseFile>>(\n data: unknown,\n path: string,\n schema: T\n ): Promise<z.output<T>> {\n const parsedData = schema.parse(data);\n const string = this.serialize(parsedData);\n await Fs.writeFile(path, string, {\n flag: 'wx',\n encoding: 'utf8',\n });\n this.cache.set(path, parsedData);\n\n return parsedData;\n }\n\n /**\n * Reads the content of a file on disk. Fails if path does not exist\n *\n * @param path Path to read the file from\n * @param schema Schema of the file to validate against\n * @returns Validated content of the file from disk\n */\n public async read<T extends z.ZodType<BaseFile | UserFile>>(\n path: string,\n schema: T\n ): Promise<z.output<T>> {\n if (this.cache.has(path)) {\n // console.log(`Cache hit for \"${path}\"`);\n return this.cache.get(path);\n }\n\n // console.log(`Cache miss for \"${path}\"`);\n const data = await Fs.readFile(path, {\n flag: 'r',\n encoding: 'utf8',\n });\n const json = this.deserialize(data);\n const parsedData = schema.parse(json);\n this.cache.set(path, parsedData);\n\n return parsedData;\n }\n\n /**\n * Overwrites an existing file on disk\n *\n * @todo Check how to error out if the file does not exist already\n *\n * @param data Data to write into the file\n * @param path Path to the file to overwrite\n * @param schema Schema of the file to validate against\n * @returns Validated content of the file from disk\n */\n public async update<T extends z.ZodType<BaseFile | UserFile>>(\n data: unknown,\n path: string,\n schema: T\n ): Promise<z.output<T>> {\n const parsedData = schema.parse(data);\n const string = this.serialize(parsedData);\n await Fs.writeFile(path, string, {\n flag: 'w',\n encoding: 'utf8',\n });\n this.cache.set(path, parsedData);\n\n return parsedData;\n }\n\n private serialize(data: unknown): string {\n return JSON.stringify(data, null, this.options.file.json.indentation);\n }\n\n private deserialize(data: string): unknown {\n return JSON.parse(data);\n }\n}\n","import Fs from 'fs-extra';\nimport {\n collectionFileSchema,\n countCollectionsSchema,\n createCollectionSchema,\n deleteCollectionSchema,\n listCollectionsSchema,\n objectTypeSchema,\n readCollectionSchema,\n serviceTypeSchema,\n updateCollectionSchema,\n type BaseFile,\n type Collection,\n type CollectionFile,\n type CountCollectionsProps,\n type CreateCollectionProps,\n type DeleteCollectionProps,\n type ElekIoCoreOptions,\n type ExtendedCrudService,\n type ListCollectionsProps,\n type PaginatedList,\n type ReadCollectionProps,\n type UpdateCollectionProps,\n} from '../schema/index.js';\nimport { pathTo, returnResolved } from '../util/node.js';\nimport { currentTimestamp, slug, uuid } from '../util/shared.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\nimport { GitService } from './GitService.js';\nimport { JsonFileService } from './JsonFileService.js';\n\n/**\n * Service that manages CRUD functionality for Collection files on disk\n */\nexport class CollectionService\n extends AbstractCrudService\n implements ExtendedCrudService<Collection>\n{\n private jsonFileService: JsonFileService;\n private gitService: GitService;\n\n constructor(\n options: ElekIoCoreOptions,\n jsonFileService: JsonFileService,\n gitService: GitService\n ) {\n super(serviceTypeSchema.Enum.Collection, options);\n\n this.jsonFileService = jsonFileService;\n this.gitService = gitService;\n }\n\n /**\n * Creates a new Collection\n */\n public async create(props: CreateCollectionProps): Promise<Collection> {\n createCollectionSchema.parse(props);\n\n const id = uuid();\n const projectPath = pathTo.project(props.projectId);\n const collectionPath = pathTo.collection(props.projectId, id);\n const collectionFilePath = pathTo.collectionFile(props.projectId, id);\n\n const collectionFile: CollectionFile = {\n ...props,\n objectType: 'collection',\n id,\n slug: {\n singular: slug(props.slug.singular),\n plural: slug(props.slug.plural),\n },\n created: currentTimestamp(),\n updated: null,\n };\n\n await Fs.ensureDir(collectionPath);\n await this.jsonFileService.create(\n collectionFile,\n collectionFilePath,\n collectionFileSchema\n );\n await this.gitService.add(projectPath, [collectionFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.create);\n\n return collectionFile;\n }\n\n /**\n * Returns a Collection by ID\n */\n public async read(props: ReadCollectionProps): Promise<Collection> {\n readCollectionSchema.parse(props);\n\n const collection = await this.jsonFileService.read(\n pathTo.collectionFile(props.projectId, props.id),\n collectionFileSchema\n );\n\n return collection;\n }\n\n /**\n * Updates given Collection\n *\n * @todo finish implementing checks for FieldDefinitions and extract methods\n *\n * @param projectId Project ID of the collection to update\n * @param collection Collection to write to disk\n * @returns An object containing information about the actions needed to be taken,\n * before given update can be executed or void if the update was executed successfully\n */\n public async update(props: UpdateCollectionProps): Promise<Collection> {\n updateCollectionSchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const collectionFilePath = pathTo.collectionFile(props.projectId, props.id);\n const prevCollectionFile = await this.read(props);\n\n const collectionFile: CollectionFile = {\n ...prevCollectionFile,\n ...props,\n updated: currentTimestamp(),\n };\n\n // @todo Collection Service has to check if any of the updated fieldDefinitions do not validate against the used Fields in each CollectionItem of the Collection\n // and return a list of mismatches, so the user can choose what to do in the UI / a wizard\n // For that:\n // - Iterate over all CollectionItems inside Collection\n // - Create an array with all FieldReferences of those CollectionItems\n // - Load all Fields by those references and check if the Field still complies with the new definition\n\n // const result: CollectionUpdateResult = {\n // create: [],\n // update: [],\n // delete: [],\n // };\n\n // const currentCollection = await this.read(props);\n // Iterate over all FieldDefinitions and check each for changes\n // for (let index = 0; index < collection.fieldDefinitions.length; index++) {\n // const nextFieldDefinition = collection.fieldDefinitions[index];\n // if (!nextFieldDefinition) {\n // throw new Error('Could not find any field definition');\n // }\n // // Get the correct FieldDefinition by ID\n // const currentFieldDefinition = currentCollection.fieldDefinitions.find(\n // (current) => {\n // return current.id === nextFieldDefinition.id;\n // }\n // );\n // if (currentFieldDefinition) {\n // if (\n // currentFieldDefinition.isRequired === false &&\n // nextFieldDefinition.isRequired === true\n // ) {\n // // Case 1.\n // // A FieldDefinition was not required to be filled, but is now\n // // -> Check if all CollectionItems have a FieldReference to this definition (if not create)\n // // -> Check all values of referenced fields of this definition for null (if not update)\n // // -> If the value is null, this is a violation\n // const collectionItems = (\n // await this.collectionItemService.list(\n // projectId,\n // collection.id,\n // undefined,\n // undefined,\n // 0,\n // 0\n // )\n // ).list;\n // for (let index = 0; index < collectionItems.length; index++) {\n // const collectionItem = collectionItems[index];\n // if (!collectionItem) {\n // throw new Error('Blaa');\n // }\n // const fieldReference = collectionItem.fieldReferences.find(\n // (fieldReference) => {\n // return (\n // fieldReference.fieldDefinitionId === nextFieldDefinition.id\n // );\n // }\n // );\n // if (!fieldReference) {\n // result.create.push({\n // violation: Violation.FIELD_REQUIRED_BUT_UNDEFINED,\n // collectionItem,\n // fieldDefinition: nextFieldDefinition,\n // });\n // } else {\n // const field = await this.fieldService.read(\n // projectId,\n // fieldReference.field.id,\n // fieldReference.field.language\n // );\n // if (field.value === null) {\n // result.update.push({\n // violation: Violation.FIELD_VALUE_REQUIRED_BUT_NULL,\n // collectionItem,\n // fieldReference,\n // });\n // }\n // }\n // }\n // }\n // if (\n // currentFieldDefinition.isUnique !== nextFieldDefinition.isUnique &&\n // nextFieldDefinition.isUnique === true\n // ) {\n // // Case 2.\n // // A FieldDefinition was not required to be unique, but is now\n // // -> Check all current values of referenced fields\n // // -> If a value is not unique, this is a violation\n // // const fieldReferences = await this.collectionItemService.getAllFieldReferences(project, currentCollection, currentFieldDefinition.id);\n // // const fields = await this.fieldService.readAll(project, fieldReferences);\n // // const duplicates = getDuplicates(fields, 'value');\n // // for (let index = 0; index < duplicates.length; index++) {\n // // const duplicate = duplicates[index];\n // // result.update.push({\n // // violation: Violation.FIELD_VALUE_NOT_UNIQUE,\n // // collectionItem: ,\n // // fieldReference\n // // });\n // // }\n // }\n // if (\n // isEqual(currentFieldDefinition.input, nextFieldDefinition.input) ===\n // false\n // ) {\n // // Case 3.\n // // A FieldDefinition has a new input specification\n // // -> Check if this input is valid for given FieldType\n // // -> If not, this is a violation\n // }\n // } else {\n // // It's a new FieldDefinition that was not existing before\n // if (nextFieldDefinition.isRequired) {\n // // Case 4.\n // // A FieldDefinition is new and a field (with value) required\n // // -> The user needs to add a field reference (either through a new or existing field)\n // // for every CollectionItem of this Collection\n // const collectionItems = (\n // await this.collectionItemService.list(\n // projectId,\n // collection.id,\n // undefined,\n // undefined,\n // 0,\n // 0\n // )\n // ).list;\n // collectionItems.forEach((collectionItem) => {\n // result.create.push({\n // violation: Violation.FIELD_REQUIRED_BUT_UNDEFINED,\n // collectionItem,\n // fieldDefinition: nextFieldDefinition,\n // });\n // });\n // }\n // }\n // }\n\n // // Return early to notify the user of changes he has to do before this update is working\n // if (\n // result.create.length !== 0 ||\n // result.update.length !== 0 ||\n // result.delete.length !== 0\n // ) {\n // return result;\n // }\n\n await this.jsonFileService.update(\n collectionFile,\n collectionFilePath,\n collectionFileSchema\n );\n await this.gitService.add(projectPath, [collectionFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.update);\n return collectionFile;\n }\n\n /**\n * Deletes given Collection (folder), including it's items\n *\n * The Fields that Collection used are not deleted.\n */\n public async delete(props: DeleteCollectionProps): Promise<void> {\n deleteCollectionSchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const collectionPath = pathTo.collection(props.projectId, props.id);\n\n await Fs.remove(collectionPath);\n await this.gitService.add(projectPath, [collectionPath]);\n await this.gitService.commit(projectPath, this.gitMessage.delete);\n }\n\n public async list(\n props: ListCollectionsProps\n ): Promise<PaginatedList<Collection>> {\n listCollectionsSchema.parse(props);\n\n const offset = props.offset || 0;\n const limit = props.limit || 15;\n\n const collectionReferences = await this.listReferences(\n objectTypeSchema.Enum.collection,\n props.projectId\n );\n\n const partialCollectionReferences = collectionReferences.slice(\n offset,\n limit\n );\n\n const collections = await returnResolved(\n partialCollectionReferences.map((reference) => {\n return this.read({\n projectId: props.projectId,\n id: reference.id,\n });\n })\n );\n\n return {\n total: collectionReferences.length,\n limit,\n offset,\n list: collections,\n };\n }\n\n public async count(props: CountCollectionsProps): Promise<number> {\n countCollectionsSchema.parse(props);\n\n const count = (\n await this.listReferences(\n objectTypeSchema.Enum.collection,\n props.projectId\n )\n ).length;\n\n return count;\n }\n\n /**\n * Checks if given object is of type Collection\n */\n public isCollection(obj: BaseFile | unknown): obj is Collection {\n return collectionFileSchema.safeParse(obj).success;\n }\n}\n","import { GitProcess, type IGitResult } from 'dugite';\nimport { EOL } from 'os';\nimport PQueue from 'p-queue';\nimport { GitError, NoCurrentUserError } from '../error/index.js';\nimport {\n gitCommitSchema,\n uuidSchema,\n type ElekIoCoreOptions,\n type GitCloneOptions,\n type GitCommit,\n type GitInitOptions,\n type GitLogOptions,\n type GitSwitchOptions,\n} from '../schema/index.js';\nimport { GitTagService } from './GitTagService.js';\nimport { UserService } from './UserService.js';\n\n/**\n * Service that manages Git functionality\n *\n * Uses dugite Node.js bindings for Git to be fully compatible\n * and be able to leverage Git LFS functionality\n * @see https://github.com/desktop/dugite\n *\n * Heavily inspired by the GitHub Desktop app\n * @see https://github.com/desktop/desktop\n *\n * Git operations are sequential!\n * We use a FIFO queue to translate async calls\n * into a sequence of git operations\n *\n * @todo All public methods should recieve only a single object as parameter and the type should be defined through the shared library to be accessible in Core and Client\n */\nexport class GitService {\n private version: string | null;\n private gitPath: string | null;\n private queue: PQueue;\n private gitTagService: GitTagService;\n private userService: UserService;\n\n public constructor(options: ElekIoCoreOptions, userService: UserService) {\n this.version = null;\n this.gitPath = null;\n this.queue = new PQueue({\n concurrency: 1, // No concurrency because git operations are sequencial\n });\n this.gitTagService = new GitTagService(options, this.git);\n this.userService = userService;\n\n this.updateVersion();\n this.updateGitPath();\n }\n\n /**\n * CRUD methods to work with git tags\n */\n public get tags(): GitTagService {\n return this.gitTagService;\n }\n\n /**\n * Create an empty Git repository or reinitialize an existing one\n *\n * @see https://git-scm.com/docs/git-init\n *\n * @param path Path to initialize in. Fails if path does not exist\n * @param options Options specific to the init operation\n */\n public async init(\n path: string,\n options?: Partial<GitInitOptions>\n ): Promise<void> {\n let args = ['init'];\n\n if (options?.initialBranch) {\n args = [...args, `--initial-branch=${options.initialBranch}`];\n }\n\n await this.git(path, args);\n await this.setLocalConfig(path);\n await this.installLfs(path);\n }\n\n /**\n * Clone a repository into a directory\n *\n * @see https://git-scm.com/docs/git-clone\n *\n * @todo Implement progress callback / events\n *\n * @param url The remote repository URL to clone from\n * @param path The destination path for the cloned repository.\n * Which is only working if the directory is existing and empty.\n * @param options Options specific to the clone operation\n */\n public async clone(\n url: string,\n path: string,\n options?: Partial<GitCloneOptions>\n ): Promise<void> {\n let args = ['clone', '--progress'];\n\n if (options?.branch) {\n args = [...args, '--branch', options.branch];\n }\n\n if (options?.depth) {\n args = [...args, '--depth', options.depth.toString()];\n }\n\n if (options?.singleBranch === true) {\n args = [...args, '--single-branch'];\n }\n\n await this.git('', [...args, url, path]);\n await this.setLocalConfig(path);\n }\n\n /**\n * Add file contents to the index\n *\n * @see https://git-scm.com/docs/git-add\n *\n * @param path Path to the repository\n * @param files Files to add\n */\n public async add(path: string, files: string[]): Promise<void> {\n const args = ['add', '--', ...files];\n\n await this.git(path, args);\n }\n\n public branches = {\n /**\n * List branches\n *\n * @see https://www.git-scm.com/docs/git-branch\n *\n * @param path Path to the repository\n */\n list: async (path: string) => {\n const args = ['branch', '--list', '--all'];\n const result = await this.git(path, args);\n\n const normalizedLinesArr = result.stdout\n .split(EOL)\n .filter((line) => {\n return line.trim() !== '';\n })\n .map((line) => {\n return line.trim().replace('* ', '');\n });\n\n const local: string[] = [];\n const remote: string[] = [];\n normalizedLinesArr.forEach((line) => {\n if (line.startsWith('remotes/')) {\n remote.push(line.replace('remotes/', ''));\n } else {\n local.push(line);\n }\n });\n return {\n local,\n remote,\n };\n },\n /**\n * Returns the name of the current branch. In detached HEAD state, an empty string is returned.\n *\n * @see https://www.git-scm.com/docs/git-branch#Documentation/git-branch.txt---show-current\n *\n * @param path Path to the repository\n */\n current: async (path: string) => {\n const args = ['branch', '--show-current'];\n const result = await this.git(path, args);\n\n return result.stdout.trim();\n },\n /**\n * Switch branches\n *\n * @see https://git-scm.com/docs/git-switch/\n *\n * @param path Path to the repository\n * @param branch Name of the branch to switch to\n * @param options Options specific to the switch operation\n */\n switch: async (\n path: string,\n branch: string,\n options?: GitSwitchOptions\n ) => {\n await this.checkBranchOrTagName(path, branch);\n\n let args = ['switch'];\n\n if (options?.isNew === true) {\n args = [...args, '--create', branch];\n } else {\n args = [...args, branch];\n }\n\n await this.git(path, args);\n },\n };\n\n public remotes = {\n /**\n * Returns a list of currently tracked remotes\n *\n * @see https://git-scm.com/docs/git-remote\n *\n * @param path Path to the repository\n */\n list: async (path: string) => {\n const args = ['remote'];\n const result = await this.git(path, args);\n const normalizedLinesArr = result.stdout.split(EOL).filter((line) => {\n return line.trim() !== '';\n });\n\n return normalizedLinesArr;\n },\n /**\n * Returns true if the `origin` remote exists, otherwise false\n *\n * @param path Path to the repository\n */\n hasOrigin: async (path: string) => {\n const remotes = await this.remotes.list(path);\n\n if (remotes.includes('origin')) {\n return true;\n }\n return false;\n },\n /**\n * Adds the `origin` remote with given URL\n *\n * Throws if `origin` remote is added already.\n *\n * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emaddem\n *\n * @param path Path to the repository\n */\n addOrigin: async (path: string, url: string) => {\n const args = ['remote', 'add', 'origin', url];\n await this.git(path, args);\n },\n /**\n * Returns the current `origin` remote URL\n *\n * Throws if no `origin` remote is added yet.\n *\n * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emget-urlem\n *\n * @param path Path to the repository\n */\n getOriginUrl: async (path: string) => {\n const args = ['remote', 'get-url', 'origin'];\n const result = (await this.git(path, args)).stdout.trim();\n\n return result.length === 0 ? null : result;\n },\n /**\n * Sets the current `origin` remote URL\n *\n * Throws if no `origin` remote is added yet.\n *\n * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emset-urlem\n *\n * @param path Path to the repository\n */\n setOriginUrl: async (path: string, url: string) => {\n const args = ['remote', 'set-url', 'origin', url];\n await this.git(path, args);\n },\n };\n\n /**\n * Reset current HEAD to the specified state\n *\n * @todo maybe add more options\n * @see https://git-scm.com/docs/git-reset\n *\n * @param path Path to the repository\n * @param mode Modifies the working tree depending on given mode\n * @param commit Resets the current branch head to this commit / tag\n */\n public async reset(path: string, mode: 'soft' | 'hard', commit: string) {\n const args = ['reset', `--${mode}`, commit];\n await this.git(path, args);\n }\n\n /**\n * Restore working tree files\n *\n * @see https://git-scm.com/docs/git-restore/\n *\n * @todo It's probably a good idea to not use restore\n * for a use case where someone just wants to have a look\n * and maybe copy something from a deleted file.\n * We should use `checkout` without `add .` and `commit` for that\n *\n * @param path Path to the repository\n * @param source Git commit SHA or tag name to restore to\n * @param files Files to restore\n */\n // public async restore(\n // path: string,\n // source: string,\n // files: string[]\n // ): Promise<void> {\n // const args = ['restore', `--source=${source}`, ...files];\n // await this.git(path, args);\n // }\n\n /**\n * Download objects and refs from remote `origin`\n *\n * @see https://www.git-scm.com/docs/git-fetch\n *\n * @param path Path to the repository\n */\n public async fetch(path: string): Promise<void> {\n const args = ['fetch'];\n await this.git(path, args);\n }\n\n /**\n * Fetch from and integrate (rebase or merge) with a local branch\n *\n * @see https://git-scm.com/docs/git-pull\n *\n * @param path Path to the repository\n */\n public async pull(path: string): Promise<void> {\n const args = ['pull'];\n await this.git(path, args);\n }\n\n /**\n * Update remote refs along with associated objects to remote `origin`\n *\n * @see https://git-scm.com/docs/git-push\n *\n * @param path Path to the repository\n */\n public async push(\n path: string,\n // branch: string,\n options?: Partial<{ all: boolean; force: boolean }>\n ): Promise<void> {\n let args = ['push', 'origin'];\n\n // if (options?.trackRemoteBranch === true) {\n // args = [...args, '--set-upstream'];\n // }\n\n // args = [...args, 'origin'];\n\n if (options?.all === true) {\n args = [...args, '--all'];\n }\n\n if (options?.force === true) {\n args = [...args, '--force'];\n }\n\n await this.git(path, args);\n }\n\n /**\n * Record changes to the repository\n *\n * @see https://git-scm.com/docs/git-commit\n *\n * @param path Path to the repository\n * @param message A message that describes the changes\n */\n public async commit(path: string, message: string): Promise<void> {\n const user = await this.userService.get();\n if (!user) {\n throw new NoCurrentUserError();\n }\n\n const args = [\n 'commit',\n `--message=${message}`,\n `--author=${user.name} <${user.email}>`,\n ];\n await this.git(path, args);\n }\n\n /**\n * Gets local commit history\n *\n * @see https://git-scm.com/docs/git-log\n *\n * @todo Check if there is a need to trim the git commit message of chars\n * @todo Use this method in a service. Decide if we need a HistoryService for example\n *\n * @param path Path to the repository\n * @param options Options specific to the log operation\n */\n public async log(\n path: string,\n options?: Partial<GitLogOptions>\n ): Promise<GitCommit[]> {\n let args = ['log'];\n\n if (options?.between?.from) {\n args = [\n ...args,\n `${options.between.from}..${options.between.to || 'HEAD'}`,\n ];\n }\n\n if (options?.limit) {\n args = [...args, `--max-count=${options.limit}`];\n }\n\n const result = await this.git(path, [\n ...args,\n '--format=%H|%s|%an|%ae|%at|%D',\n ]);\n\n const noEmptyLinesArr = result.stdout.split(EOL).filter((line) => {\n return line.trim() !== '';\n });\n\n const lineObjArr = noEmptyLinesArr.map((line) => {\n const lineArray = line.split('|');\n return {\n hash: lineArray[0],\n message: lineArray[1],\n author: {\n name: lineArray[2],\n email: lineArray[3],\n },\n timestamp: parseInt(lineArray[4]),\n tag: this.refNameToTagName(lineArray[5]),\n };\n });\n\n return lineObjArr.filter(this.isGitCommit.bind(this));\n }\n\n public refNameToTagName(refName: string) {\n const tagName = refName.replace('tag: ', '').trim();\n\n // Return null for anything else than UUIDs (tag names are UUIDs)\n if (tagName === '' || uuidSchema.safeParse(tagName).success === false) {\n return null;\n }\n\n return tagName;\n }\n\n /**\n * Returns a timestamp of given files creation\n *\n * Git only returns the timestamp the file was added,\n * which could be different from the file being created.\n * But since file operations will always be committed\n * immediately, this is practically the same.\n *\n * @param path Path to the repository\n * @param file File to get timestamp from\n */\n public async getFileCreatedTimestamp(path: string, file: string) {\n const result = await this.git(path, [\n 'log',\n '--diff-filter=A',\n '--follow',\n '--format=%at',\n '--max-count=1',\n '--',\n file,\n ]);\n return parseInt(result.stdout);\n }\n\n /**\n * Returns a timestamp of the files last modification\n *\n * @param path Path to the repository\n * @param file File to get timestamp from\n */\n public async getFileLastUpdatedTimestamp(path: string, file: string) {\n const result = await this.git(path, [\n 'log',\n '--follow',\n '--format=%at',\n '--max-count=1',\n '--',\n file,\n ]);\n return parseInt(result.stdout);\n }\n\n /**\n * Returns created and updated timestamps from given file\n *\n * @param path Path to the project\n * @param file Path to the file\n */\n public async getFileCreatedUpdatedMeta(path: string, file: string) {\n const meta = await Promise.all([\n this.getFileCreatedTimestamp(path, file),\n this.getFileLastUpdatedTimestamp(path, file),\n ]);\n return {\n created: meta[0],\n updated: meta[1],\n };\n }\n\n /**\n * Reads the currently used version of Git\n *\n * This can help debugging\n */\n private async updateVersion(): Promise<void> {\n const result = await this.git('', ['--version']);\n this.version = result.stdout.replace('git version', '').trim();\n }\n\n /**\n * Reads the path to the executable of Git that is used\n *\n * This can help debugging, since dugite is shipping their own executable\n * but in some cases resolves another executable\n * @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts\n */\n private async updateGitPath(): Promise<void> {\n const result = await this.git('', ['--exec-path']);\n this.gitPath = result.stdout.trim();\n }\n\n /**\n * A reference is used in Git to specify branches and tags.\n * This method checks if given name matches the required format\n *\n * @see https://git-scm.com/docs/git-check-ref-format\n *\n * @param path Path to the repository\n * @param name Name to check\n */\n private async checkBranchOrTagName(path: string, name: string) {\n await this.git(path, ['check-ref-format', '--allow-onelevel', name]);\n }\n\n /**\n * Installs LFS support and starts tracking\n * all files inside the lfs folder\n *\n * @param path Path to the repository\n */\n private async installLfs(path: string): Promise<void> {\n await this.git(path, ['lfs', 'install']);\n await this.git(path, ['lfs', 'track', 'lfs/*']);\n }\n\n /**\n * Sets the git config of given local repository from ElekIoCoreOptions\n *\n * @param path Path to the repository\n */\n private async setLocalConfig(path: string) {\n const user = await this.userService.get();\n if (!user) {\n throw new NoCurrentUserError();\n }\n\n // Setup the local User\n const userNameArgs = ['config', '--local', 'user.name', user.name];\n const userEmailArgs = ['config', '--local', 'user.email', user.email];\n // By default new branches that are pushed are automatically tracking\n // their remote without the need of using the `--set-upstream` argument of `git push`\n const autoSetupRemoteArgs = [\n 'config',\n '--local',\n 'push.autoSetupRemote',\n 'true',\n ];\n\n await this.git(path, userNameArgs);\n await this.git(path, userEmailArgs);\n await this.git(path, autoSetupRemoteArgs);\n }\n\n /**\n * Type guard for GitCommit\n *\n * @param obj The object to check\n */\n private isGitCommit(obj: unknown): obj is GitCommit {\n return gitCommitSchema.safeParse(obj).success;\n }\n\n /**\n * Wraps the execution of any git command\n * to use a FIFO queue for sequential processing\n *\n * @param path Path to the repository\n * @param args Arguments to append after the `git` command\n */\n private async git(path: string, args: string[]): Promise<IGitResult> {\n const result = await this.queue.add(() =>\n GitProcess.exec(args, path, {\n env: {\n // @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available\n // @see https://github.com/git-lfs/git-lfs/issues/5749\n GIT_CLONE_PROTECTION_ACTIVE: 'false',\n },\n })\n );\n if (!result) {\n throw new GitError(\n `Git ${this.version} (${this.gitPath}) command \"git ${args.join(\n ' '\n )}\" failed to return a result`\n );\n }\n if (result.exitCode !== 0) {\n throw new GitError(\n `Git ${this.version} (${this.gitPath}) command \"git ${args.join(\n ' '\n )}\" failed with exit code \"${result.exitCode}\" and message \"${\n result.stderr\n }\"`\n );\n }\n\n return result;\n }\n}\n","import { EOL } from 'os';\nimport { GitError } from '../error/index.js';\nimport {\n countGitTagsSchema,\n createGitTagSchema,\n deleteGitTagSchema,\n gitTagSchema,\n listGitTagsSchema,\n readGitTagSchema,\n serviceTypeSchema,\n type CountGitTagsProps,\n type CreateGitTagProps,\n type DeleteGitTagProps,\n type ElekIoCoreOptions,\n type ExtendedCrudService,\n type GitTag,\n type ListGitTagsProps,\n type PaginatedList,\n type ReadGitTagProps,\n} from '../schema/index.js';\nimport { uuid } from '../util/shared.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\nimport { GitService } from './GitService.js';\n\n/**\n * Service that manages CRUD functionality for GitTags\n */\nexport class GitTagService\n extends AbstractCrudService\n implements ExtendedCrudService<GitTag>\n{\n private git: GitService['git'];\n\n public constructor(options: ElekIoCoreOptions, git: GitService['git']) {\n super(serviceTypeSchema.Enum.GitTag, options);\n\n this.git = git;\n }\n\n /**\n * Creates a new tag\n *\n * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate\n */\n public async create(props: CreateGitTagProps): Promise<GitTag> {\n createGitTagSchema.parse(props);\n\n const id = uuid();\n let args = ['tag', '--annotate', id];\n\n if (props.hash) {\n args = [...args, props.hash];\n }\n\n args = [...args, '-m', props.message];\n\n await this.git(props.path, args);\n const tag = await this.read({ path: props.path, id });\n\n return tag;\n }\n\n /**\n * Returns a tag by ID\n *\n * Internally uses list() but only returns the tag with matching ID.\n */\n public async read(props: ReadGitTagProps): Promise<GitTag> {\n readGitTagSchema.parse(props);\n\n const tags = await this.list({ path: props.path });\n const tag = tags.list.find((tag) => {\n return tag.id === props.id;\n });\n\n if (!tag) {\n throw new GitError(\n `Provided tag with UUID \"${props.id}\" did not match any known tags`\n );\n }\n\n return tag;\n }\n\n /**\n * Updating a git tag is not supported.\n * Please delete the old and create a new one\n *\n * @see https://git-scm.com/docs/git-tag#_on_re_tagging\n */\n public async update(): Promise<never> {\n throw new Error(\n 'Updating a git tag is not supported. Please delete the old and create a new one'\n );\n }\n\n /**\n * Deletes a tag\n *\n * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---delete\n *\n * @param path Path to the repository\n * @param id UUID of the tag to delete\n */\n public async delete(props: DeleteGitTagProps): Promise<void> {\n deleteGitTagSchema.parse(props);\n\n const args = ['tag', '--delete', props.id];\n await this.git(props.path, args);\n }\n\n /**\n * Gets all local tags or filter them by pattern\n *\n * They are sorted by authordate of the commit, not the timestamp the tag is created.\n * This ensures tags are sorted correctly in the timeline of their commits.\n *\n * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list\n */\n public async list(props: ListGitTagsProps): Promise<PaginatedList<GitTag>> {\n listGitTagsSchema.parse(props);\n\n let args = ['tag', '--list'];\n\n args = [\n ...args,\n '--sort=-*authordate',\n '--format=%(refname:short)|%(subject)|%(*authorname)|%(*authoremail)|%(*authordate:unix)',\n ];\n const result = await this.git(props.path, args);\n\n const noEmptyLinesArr = result.stdout.split(EOL).filter((line) => {\n return line.trim() !== '';\n });\n\n const lineObjArr = noEmptyLinesArr.map((line) => {\n const lineArray = line.split('|');\n return {\n id: lineArray[0],\n message: lineArray[1],\n author: {\n name: lineArray[2],\n email: lineArray[3],\n },\n timestamp: parseInt(lineArray[4]),\n };\n });\n\n const gitTags = lineObjArr.filter(this.isGitTag.bind(this));\n\n return {\n total: gitTags.length,\n limit: 0,\n offset: 0,\n list: gitTags,\n };\n }\n\n /**\n * Returns the total number of tags inside given repository\n *\n * Internally uses list(), so do not use count()\n * in conjuncion with it to avoid multiple git calls.\n *\n * @param path Path to the repository\n */\n public async count(props: CountGitTagsProps): Promise<number> {\n countGitTagsSchema.parse(props);\n\n const gitTags = await this.list({ path: props.path });\n return gitTags.total;\n }\n\n /**\n * Type guard for GitTag\n *\n * @param obj The object to check\n */\n private isGitTag(obj: unknown): obj is GitTag {\n return gitTagSchema.safeParse(obj).success;\n }\n}\n","import {\n UserTypeSchema,\n setUserSchema,\n userFileSchema,\n type SetUserProps,\n type User,\n type UserFile,\n} from '../schema/index.js';\nimport { pathTo } from '../util/node.js';\nimport { JsonFileService } from './JsonFileService.js';\n\n/**\n * Service to handle the User that is currently working with Core\n */\nexport class UserService {\n private readonly jsonFileService: JsonFileService;\n\n constructor(jsonFileService: JsonFileService) {\n this.jsonFileService = jsonFileService;\n }\n\n /**\n * Returns the User currently working with Core\n */\n public async get(): Promise<User | undefined> {\n try {\n return await this.jsonFileService.read(pathTo.userFile, userFileSchema);\n } catch (error) {\n // Should probably be logged in some way or another\n return undefined;\n }\n }\n\n /**\n * Sets the User currently working with Core\n *\n * By doing so all git operations are done with the signature of this User\n */\n public async set(props: SetUserProps): Promise<User> {\n setUserSchema.parse(props);\n\n const userFilePath = pathTo.userFile;\n\n const userFile: UserFile = {\n ...props,\n };\n\n if (userFile.userType === UserTypeSchema.Enum.cloud) {\n // Try logging in the user\n // Throw on Error\n }\n\n await this.jsonFileService.update(userFile, userFilePath, userFileSchema);\n\n return userFile;\n }\n}\n","import Fs from 'fs-extra';\nimport {\n ValueTypeSchema,\n countEntriesSchema,\n createEntrySchema,\n deleteEntrySchema,\n entryFileSchema,\n entrySchema,\n getValueContentSchemaFromDefinition,\n listEntriesSchema,\n objectTypeSchema,\n readEntrySchema,\n serviceTypeSchema,\n updateEntrySchema,\n type BaseFile,\n type CountEntriesProps,\n type CreateEntryProps,\n type DeleteEntryProps,\n type ElekIoCoreOptions,\n type Entry,\n type EntryFile,\n type ExtendedCrudService,\n type ListEntriesProps,\n type ReadEntryProps,\n type ReferencedValue,\n type ResolvedValueContentReference,\n type SupportedLanguage,\n type UpdateEntryProps,\n type Value,\n type ValueContentReference,\n type ValueDefinition,\n} from '../schema/index.js';\nimport { pathTo, returnResolved } from '../util/node.js';\nimport { currentTimestamp, uuid } from '../util/shared.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\nimport type { AssetService } from './AssetService.js';\nimport type { CollectionService } from './CollectionService.js';\nimport type { GitService } from './GitService.js';\nimport { JsonFileService } from './JsonFileService.js';\n\n/**\n * Service that manages CRUD functionality for Entry files on disk\n */\nexport class EntryService\n extends AbstractCrudService\n implements ExtendedCrudService<Entry>\n{\n private jsonFileService: JsonFileService;\n private gitService: GitService;\n private collectionService: CollectionService;\n private assetService: AssetService;\n // private sharedValueService: SharedValueService;\n\n constructor(\n options: ElekIoCoreOptions,\n jsonFileService: JsonFileService,\n gitService: GitService,\n collectionService: CollectionService,\n assetService: AssetService\n // sharedValueService: SharedValueService\n ) {\n super(serviceTypeSchema.Enum.Entry, options);\n\n this.jsonFileService = jsonFileService;\n this.gitService = gitService;\n this.collectionService = collectionService;\n this.assetService = assetService;\n // this.sharedValueService = sharedValueService;\n }\n\n /**\n * Creates a new Entry for given Collection\n */\n public async create(props: CreateEntryProps): Promise<Entry> {\n createEntrySchema.parse(props);\n\n const id = uuid();\n const projectPath = pathTo.project(props.projectId);\n const entryFilePath = pathTo.entryFile(\n props.projectId,\n props.collectionId,\n id\n );\n const collection = await this.collectionService.read({\n projectId: props.projectId,\n id: props.collectionId,\n });\n\n const entryFile: EntryFile = {\n objectType: 'entry',\n id,\n values: props.values,\n created: currentTimestamp(),\n updated: null,\n };\n\n const entry: Entry = await this.toEntry({\n projectId: props.projectId,\n collectionId: props.collectionId,\n entryFile,\n });\n\n this.validateValues({\n collectionId: props.collectionId,\n valueDefinitions: collection.valueDefinitions,\n values: entry.values,\n });\n\n await this.jsonFileService.create(\n entryFile,\n entryFilePath,\n entryFileSchema\n );\n await this.gitService.add(projectPath, [entryFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.create);\n\n return entry;\n }\n\n /**\n * Returns an Entry from given Collection by ID and language\n */\n public async read(props: ReadEntryProps): Promise<Entry> {\n readEntrySchema.parse(props);\n\n const entryFile: EntryFile = await this.jsonFileService.read(\n pathTo.entryFile(props.projectId, props.collectionId, props.id),\n entryFileSchema\n );\n\n return await this.toEntry({\n projectId: props.projectId,\n collectionId: props.collectionId,\n entryFile,\n });\n }\n\n /**\n * Updates an Entry of given Collection with new Values and shared Values\n */\n public async update(props: UpdateEntryProps): Promise<Entry> {\n updateEntrySchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const entryFilePath = pathTo.entryFile(\n props.projectId,\n props.collectionId,\n props.id\n );\n const collection = await this.collectionService.read({\n projectId: props.projectId,\n id: props.collectionId,\n });\n\n const prevEntryFile = await this.read({\n projectId: props.projectId,\n collectionId: props.collectionId,\n id: props.id,\n });\n\n const entryFile: EntryFile = {\n ...prevEntryFile,\n values: props.values,\n updated: currentTimestamp(),\n };\n\n const entry: Entry = await this.toEntry({\n projectId: props.projectId,\n collectionId: props.collectionId,\n entryFile,\n });\n\n this.validateValues({\n collectionId: props.collectionId,\n valueDefinitions: collection.valueDefinitions,\n values: entry.values,\n });\n\n await this.jsonFileService.update(\n entryFile,\n entryFilePath,\n entryFileSchema\n );\n await this.gitService.add(projectPath, [entryFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.update);\n\n return entry;\n }\n\n /**\n * Deletes given Entry from it's Collection\n */\n public async delete(props: DeleteEntryProps): Promise<void> {\n deleteEntrySchema.parse(props);\n\n const projectPath = pathTo.project(props.projectId);\n const entryFilePath = pathTo.entryFile(\n props.projectId,\n props.collectionId,\n props.id\n );\n\n await Fs.remove(entryFilePath);\n await this.gitService.add(projectPath, [entryFilePath]);\n await this.gitService.commit(projectPath, this.gitMessage.delete);\n }\n\n public async list(props: ListEntriesProps) {\n listEntriesSchema.parse(props);\n\n const offset = props.offset || 0;\n const limit = props.limit || 15;\n\n const entryReferences = await this.listReferences(\n objectTypeSchema.Enum.entry,\n props.projectId,\n props.collectionId\n );\n\n const partialEntryReferences = entryReferences.slice(offset, limit);\n\n const entries = await returnResolved(\n partialEntryReferences.map((reference) => {\n return this.read({\n projectId: props.projectId,\n collectionId: props.collectionId,\n id: reference.id,\n });\n })\n );\n\n return {\n total: entryReferences.length,\n limit,\n offset,\n list: entries,\n };\n }\n\n public async count(props: CountEntriesProps): Promise<number> {\n countEntriesSchema.parse(props);\n\n return (\n await this.listReferences(\n objectTypeSchema.Enum.entry,\n props.projectId,\n props.collectionId\n )\n ).length;\n }\n\n /**\n * Checks if given object is of type Entry\n */\n public isEntry(obj: BaseFile | unknown): obj is Entry {\n return entrySchema.safeParse(obj).success;\n }\n\n /**\n * Returns a Value definition by ID\n */\n private getValueDefinitionById(props: {\n valueDefinitions: ValueDefinition[];\n id: string;\n collectionId: string;\n }) {\n const definition = props.valueDefinitions.find((def) => {\n if (def.id === props.id) {\n return true;\n }\n return false;\n });\n\n if (!definition) {\n throw new Error(\n `No definition with ID \"${props.id}\" found in Collection \"${props.collectionId}\" for given Value reference`\n );\n }\n\n return definition;\n }\n\n /**\n * Validates given Values against it's Collections definitions\n */\n private validateValues(props: {\n collectionId: string;\n valueDefinitions: ValueDefinition[];\n values: Value[];\n }) {\n props.values.map((value) => {\n const definition = this.getValueDefinitionById({\n collectionId: props.collectionId,\n valueDefinitions: props.valueDefinitions,\n id: value.definitionId,\n });\n const schema = getValueContentSchemaFromDefinition(definition);\n\n try {\n for (const [language, content] of Object.entries(value.content)) {\n schema.parse(content);\n }\n } catch (error) {\n console.log('Definition:', definition);\n console.log('Value:', value);\n throw error;\n }\n });\n }\n\n /**\n * Validates given shared Value references against it's Collections definitions\n */\n // private validateResolvedSharedValues(props: {\n // collectionId: string;\n // valueDefinitions: ValueDefinition[];\n // resolvedSharedValues: ResolvedSharedValueReference[];\n // }) {\n // props.resolvedSharedValues.map((value) => {\n // const definition = this.getValueDefinitionById({\n // collectionId: props.collectionId,\n // valueDefinitions: props.valueDefinitions,\n // id: value.definitionId,\n // });\n // const schema = getValueSchemaFromDefinition(definition);\n // schema.parse(value.resolved.content);\n // });\n // }\n\n private async resolveValueContentReference(props: {\n projectId: string;\n collectionId: string;\n valueContentReference: ValueContentReference;\n }): Promise<ResolvedValueContentReference> {\n switch (props.valueContentReference.objectType) {\n case objectTypeSchema.Enum.asset:\n return await this.assetService.read({\n projectId: props.projectId,\n id: props.valueContentReference.id,\n language: props.valueContentReference.language,\n });\n case objectTypeSchema.Enum.entry:\n return await this.read({\n projectId: props.projectId,\n collectionId: props.collectionId,\n id: props.valueContentReference.id,\n });\n // case objectTypeSchema.Enum.sharedValue:\n // return this.resolveValueContentReferenceToSharedValue({\n // projectId: props.projectId,\n // valueContentReferenceToSharedValue: props.valueContentReference,\n // });\n\n default:\n throw new Error(\n // @ts-ignore\n `Tried to resolve unsupported Value reference \"${props.valueContentReference.referenceObjectType}\"`\n );\n }\n }\n\n private async resolveValueContentReferences(props: {\n projectId: string;\n collectionId: string;\n valueReference: ReferencedValue;\n }): Promise<\n Partial<Record<SupportedLanguage, ResolvedValueContentReference>>\n > {\n let resolvedContent: Partial<\n Record<SupportedLanguage, ResolvedValueContentReference>\n > = {};\n\n for (const language in props.valueReference.content) {\n const referencesOfLanguage =\n props.valueReference.content[language as SupportedLanguage];\n if (!referencesOfLanguage) {\n throw new Error(\n `Trying to access content references by language \"${language}\" failed`\n );\n }\n\n const resolvedReferencesOfLanguage = await Promise.all(\n referencesOfLanguage.map(async (reference) => {\n return await this.resolveValueContentReference({\n projectId: props.projectId,\n collectionId: props.collectionId,\n valueContentReference: reference,\n });\n })\n );\n\n resolvedContent = {\n ...resolvedContent,\n [language as SupportedLanguage]: resolvedReferencesOfLanguage,\n };\n }\n\n return resolvedContent;\n }\n\n /**\n * Creates an Entry from given EntryFile by resolving it's Values\n */\n private async toEntry(props: {\n projectId: string;\n collectionId: string;\n entryFile: EntryFile;\n }): Promise<Entry> {\n return {\n ...props.entryFile,\n // @ts-ignore @todo fixme - I have no idea why this happens. The types seem to be compatible to me and they work\n values: await Promise.all(\n props.entryFile.values.map(async (value) => {\n if (value.valueType === ValueTypeSchema.Enum.reference) {\n const resolvedContentReferences =\n await this.resolveValueContentReferences({\n projectId: props.projectId,\n collectionId: props.collectionId,\n valueReference: value,\n });\n\n return {\n ...value,\n content: resolvedContentReferences,\n };\n }\n\n return value;\n })\n ),\n };\n }\n}\n","import Fs from 'fs-extra';\nimport Os from 'os';\nimport Path from 'path';\nimport Semver from 'semver';\nimport { NoCurrentUserError, ProjectUpgradeError } from '../error/index.js';\nimport {\n cloneProjectSchema,\n createProjectSchema,\n currentBranchProjectSchema,\n deleteProjectSchema,\n getChangesProjectSchema,\n getRemoteOriginUrlProjectSchema,\n gitCommitIconSchema,\n listBranchesProjectSchema,\n listProjectsSchema,\n objectTypeSchema,\n projectFileSchema,\n projectFolderSchema,\n readProjectSchema,\n serviceTypeSchema,\n setRemoteOriginUrlProjectSchema,\n switchBranchProjectSchema,\n synchronizeProjectSchema,\n updateProjectSchema,\n upgradeProjectSchema,\n type BaseFile,\n type CloneProjectProps,\n type CollectionExport,\n type CreateProjectProps,\n type CurrentBranchProjectProps,\n type DeleteProjectProps,\n type ElekIoCoreOptions,\n type ExtendedCrudService,\n type GetChangesProjectProps,\n type GetRemoteOriginUrlProjectProps,\n type ListBranchesProjectProps,\n type ListProjectsProps,\n type PaginatedList,\n type Project,\n type ProjectExport,\n type ProjectFile,\n type ProjectSettings,\n type ReadProjectProps,\n type SetRemoteOriginUrlProjectProps,\n type SwitchBranchProjectProps,\n type SynchronizeProjectProps,\n type UpdateProjectProps,\n type UpgradeProjectProps,\n} from '../schema/index.js';\nimport type { ProjectUpgradeImport } from '../upgrade/example.js';\nimport { files, pathTo, returnResolved } from '../util/node.js';\nimport { currentTimestamp, uuid } from '../util/shared.js';\nimport { AbstractCrudService } from './AbstractCrudService.js';\nimport { AssetService } from './AssetService.js';\nimport { CollectionService } from './CollectionService.js';\nimport type { EntryService } from './EntryService.js';\nimport { GitService } from './GitService.js';\nimport { JsonFileService } from './JsonFileService.js';\nimport { UserService } from './UserService.js';\n\n/**\n * Service that manages CRUD functionality for Project files on disk\n */\nexport class ProjectService\n extends AbstractCrudService\n implements ExtendedCrudService<Project>\n{\n private jsonFileService: JsonFileService;\n private userService: UserService;\n private gitService: GitService;\n private assetService: AssetService;\n private collectionService: CollectionService;\n private entryService: EntryService;\n\n constructor(\n options: ElekIoCoreOptions,\n jsonFileService: JsonFileService,\n userService: UserService,\n gitService: GitService,\n assetService: AssetService,\n collectionService: CollectionService,\n entryService: EntryService\n ) {\n super(serviceTypeSchema.Enum.Project, options);\n\n this.jsonFileService = jsonFileService;\n this.userService = userService;\n this.gitService = gitService;\n this.assetService = assetService;\n this.collectionService = collectionService;\n this.entryService = entryService;\n }\n\n /**\n * Creates a new Project\n */\n public async create(props: CreateProjectProps): Promise<Project> {\n createProjectSchema.parse(props);\n\n const user = await this.userService.get();\n if (!user) {\n throw new NoCurrentUserError();\n }\n\n const id = uuid();\n const defaultSettings: ProjectSettings = {\n language: {\n default: user.language,\n supported: [user.language],\n },\n };\n\n const projectFile: ProjectFile = {\n ...props,\n objectType: 'project',\n id,\n description: props.description || '',\n settings: Object.assign({}, defaultSettings, props.settings),\n created: currentTimestamp(),\n updated: null,\n coreVersion: this.options.version, // @todo should be read from package.json to avoid duplicates\n status: 'todo',\n version: '0.0.1',\n };\n\n const projectPath = pathTo.project(id);\n\n await Fs.ensureDir(projectPath);\n\n try {\n await this.createFolderStructure(projectPath);\n await this.createGitignore(projectPath);\n await this.gitService.init(projectPath, { initialBranch: 'main' });\n await this.jsonFileService.create(\n projectFile,\n pathTo.projectFile(id),\n projectFileSchema\n );\n await this.gitService.add(projectPath, ['.']);\n await this.gitService.commit(\n projectPath,\n `${gitCommitIconSchema.enum.INIT} Created this new elek.io project`\n );\n await this.gitService.branches.switch(projectPath, 'stage', {\n isNew: true,\n });\n } catch (error) {\n // To avoid partial data being added to the repository / git status reporting uncommitted files\n await this.delete({\n id,\n });\n throw error;\n }\n\n return await this.toProject({\n projectFile,\n });\n }\n\n /**\n * Clones a Project by URL\n */\n public async clone(props: CloneProjectProps): Promise<Project> {\n cloneProjectSchema.parse(props);\n\n const tmpId = uuid();\n const tmpProjectPath = Path.join(pathTo.tmp, tmpId);\n // await Fs.ensureDir(tmpProjectPath);\n await this.gitService.clone(props.url, tmpProjectPath);\n\n // Check if it is actually a Project by trying to read it\n const projectFile = await this.jsonFileService.read(\n Path.join(tmpProjectPath, 'project.json'),\n projectFileSchema\n );\n\n // If so, copy it into the correct directory\n const projectPath = pathTo.project(projectFile.id);\n const alreadyExists = await Fs.pathExists(projectPath);\n if (alreadyExists) {\n throw new Error(\n `Tried to clone Project \"${projectFile.id}\" from \"${props.url}\" - but the Project already exists locally`\n );\n }\n await Fs.copy(tmpProjectPath, projectPath);\n await Fs.remove(tmpProjectPath);\n\n return await this.toProject({\n projectFile,\n });\n }\n\n /**\n * Returns a Project by ID\n */\n public async read(props: ReadProjectProps): Promise<Project> {\n readProjectSchema.parse(props);\n\n const projectFile = await this.jsonFileService.read(\n pathTo.projectFile(props.id),\n projectFileSchema\n );\n\n return await this.toProject({\n projectFile,\n });\n }\n\n /**\n * Updates given Project\n */\n public async update(props: UpdateProjectProps): Promise<Project> {\n updateProjectSchema.parse(props);\n\n const projectPath = pathTo.project(props.id);\n const filePath = pathTo.projectFile(props.id);\n const prevProjectFile = await this.read(props);\n\n const projectFile: ProjectFile = {\n ...prevProjectFile,\n ...props,\n updated: currentTimestamp(),\n };\n\n await this.jsonFileService.update(projectFile, filePath, projectFileSchema);\n await this.gitService.add(projectPath, [filePath]);\n await this.gitService.commit(projectPath, this.gitMessage.update);\n\n return await this.toProject({\n projectFile,\n });\n }\n\n /**\n * Upgrades given Project to the latest version of this client\n *\n * Needed when a new core version is requiring changes to existing files or structure.\n *\n * @todo Find out why using this.snapshotService is throwing isObjWithKeyAndValueOfString of undefined error in gitService (maybe binding issue)\n */\n public async upgrade(props: UpgradeProjectProps): Promise<void> {\n upgradeProjectSchema.parse(props);\n\n const project = await this.read(props);\n const projectPath = pathTo.project(project.id);\n\n if (Semver.gt(project.coreVersion, this.options.version)) {\n // Upgrade of the client needed before the project can be upgraded\n throw new Error(\n `Failed upgrading project. The projects core version \"${project.coreVersion}\" is higher than the current core version \"${this.options.version}\" of this client. A client upgrade is needed beforehand.`\n );\n }\n\n if (Semver.eq(project.coreVersion, this.options.version)) {\n // Nothing, since both are equal\n return;\n }\n\n // Get all available upgrade scripts\n const upgradeFiles = await files(\n Path.resolve(__dirname, '../upgrade'),\n 'ts'\n );\n\n // Import all objects\n const upgrades = (\n await Promise.all(\n upgradeFiles.map((file) => {\n return import(\n Path.join('../upgrade', file.name)\n ) as Promise<ProjectUpgradeImport>;\n })\n )\n ).map((upgradeImport) => {\n return upgradeImport.default;\n });\n\n // Sort them by core version and filter out the example one\n const sortedUpgrades = upgrades\n .sort((a, b) => {\n return Semver.compare(a.to, b.to);\n })\n .filter((upgrade) => {\n if (upgrade.to !== '0.0.0') {\n return upgrade;\n }\n });\n\n for (let index = 0; index < sortedUpgrades.length; index++) {\n const upgrade = sortedUpgrades[index];\n if (!upgrade) {\n throw new Error('Expected ProjectUpgrade but got undefined');\n }\n\n // Make a tag to revert to on failure\n const failsafeTag = await this.gitService.tags.create({\n path: projectPath,\n message: `Attempting to upgrade Project to Core version \"${upgrade.to}\"`,\n });\n\n try {\n await upgrade.run(project);\n\n // Override the projects core version\n project.coreVersion = upgrade.to;\n await this.update(project);\n\n // And create another tag to show successfull upgrade in git log\n await this.gitService.tags.create({\n path: projectPath,\n message: `Upgraded Project to Core version \"${upgrade.to}\"`,\n });\n\n // Done, remove the failsafe tag again\n await this.gitService.tags.delete({\n path: projectPath,\n id: failsafeTag.id,\n });\n } catch (error) {\n // Reset Project to the tag made before\n await this.gitService.reset(projectPath, 'hard', failsafeTag.id);\n\n throw new ProjectUpgradeError(\n `Failed to upgrade Project to Core version \"${upgrade.to}\"`\n );\n }\n }\n }\n\n public branches = {\n list: async (props: ListBranchesProjectProps) => {\n listBranchesProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n await this.gitService.fetch(projectPath);\n return await this.gitService.branches.list(projectPath);\n },\n current: async (props: CurrentBranchProjectProps) => {\n currentBranchProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n return await this.gitService.branches.current(projectPath);\n },\n switch: async (props: SwitchBranchProjectProps) => {\n switchBranchProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n return await this.gitService.branches.switch(\n projectPath,\n props.branch,\n props.options\n );\n },\n };\n\n public remotes = {\n getOriginUrl: async (props: GetRemoteOriginUrlProjectProps) => {\n getRemoteOriginUrlProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n return await this.gitService.remotes.getOriginUrl(projectPath);\n },\n setOriginUrl: async (props: SetRemoteOriginUrlProjectProps) => {\n setRemoteOriginUrlProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n const hasOrigin = await this.gitService.remotes.hasOrigin(projectPath);\n if (!hasOrigin) {\n await this.gitService.remotes.addOrigin(projectPath, props.url);\n } else {\n await this.gitService.remotes.setOriginUrl(projectPath, props.url);\n }\n },\n };\n\n /**\n * Returns the differences of the given Projects current branch\n * between the local and remote `origin` (commits ahead & behind)\n *\n * - `behind` contains a list of commits on the current branch that are available on the remote `origin` but not yet locally\n * - `ahead` contains a list of commits on the current branch that are available locally but not yet on the remote `origin`\n */\n public async getChanges(props: GetChangesProjectProps) {\n getChangesProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n const currentBranch = await this.gitService.branches.current(projectPath);\n\n await this.gitService.fetch(projectPath);\n const behind = await this.gitService.log(projectPath, {\n between: { from: currentBranch, to: `origin/${currentBranch}` },\n });\n const ahead = await this.gitService.log(projectPath, {\n between: { from: `origin/${currentBranch}`, to: currentBranch },\n });\n\n return {\n behind,\n ahead,\n };\n }\n\n /**\n * Pulls remote changes of `origin` down to the local repository\n * and then pushes local commits to the upstream branch\n */\n public async synchronize(props: SynchronizeProjectProps) {\n synchronizeProjectSchema.parse(props);\n const projectPath = pathTo.project(props.id);\n\n await this.gitService.pull(projectPath);\n await this.gitService.push(projectPath);\n }\n\n /**\n * Deletes given Project\n *\n * Deletes the whole Project folder including the history, not only the config file.\n * Use with caution, since a Project that is only available locally could be lost forever.\n * Or changes that are not pushed to a remote yet, will be lost too.\n */\n public async delete(props: DeleteProjectProps): Promise<void> {\n deleteProjectSchema.parse(props);\n\n await Fs.remove(pathTo.project(props.id));\n }\n\n public async list(\n props?: ListProjectsProps\n ): Promise<PaginatedList<Project>> {\n if (props) {\n listProjectsSchema.parse(props);\n }\n\n const offset = props?.offset || 0;\n const limit = props?.limit || 15;\n\n const projectReferences = await this.listReferences(\n objectTypeSchema.Enum.project\n );\n\n const partialProjectReferences = projectReferences.slice(offset, limit);\n\n const projects = await returnResolved(\n partialProjectReferences.map((reference) => {\n return this.read({ id: reference.id });\n })\n );\n\n return {\n total: projectReferences.length,\n limit,\n offset,\n list: projects,\n };\n }\n\n public async count(): Promise<number> {\n return (await this.listReferences(objectTypeSchema.Enum.project)).length;\n }\n\n /**\n * Checks if given object is of type Project\n */\n public isProject(obj: BaseFile | unknown): obj is Project {\n return projectFileSchema.safeParse(obj).success;\n }\n\n /**\n * Exports given Project to JSON\n *\n * @todo do not read everything before writing to disk -> stream into file given via props\n * @todo performance tests\n * @todo add progress callback\n */\n public async exportToJson(projectId: string): Promise<ProjectExport> {\n const project = await this.read({ id: projectId });\n const assets = (await this.assetService.list({ projectId, limit: 0 })).list;\n const collections = (\n await this.collectionService.list({ projectId, limit: 0 })\n ).list;\n\n const collectionExport: CollectionExport[] = await Promise.all(\n collections.map(async (collection) => {\n const entries = (\n await this.entryService.list({\n projectId,\n collectionId: collection.id,\n limit: 0,\n })\n ).list;\n\n return {\n ...collection,\n entries,\n };\n })\n );\n\n return {\n ...project,\n assets,\n collections: collectionExport,\n };\n }\n\n /**\n * Creates a Project from given ProjectFile by adding git information\n */\n private async toProject(props: {\n projectFile: ProjectFile;\n }): Promise<Project> {\n return {\n ...props.projectFile,\n };\n }\n\n /**\n * Creates the projects folder structure and makes sure to\n * write empty .gitkeep files inside them to ensure they are\n * committed\n */\n private async createFolderStructure(path: string): Promise<void> {\n const folders = Object.values(projectFolderSchema.Values);\n\n await Promise.all(\n folders.map(async (folder) => {\n await Fs.mkdirp(Path.join(path, folder));\n await Fs.writeFile(Path.join(path, folder, '.gitkeep'), '');\n })\n );\n }\n\n /**\n * Writes the Projects main .gitignore file to disk\n *\n * @todo Add general things to ignore\n * @see https://github.com/github/gitignore/tree/master/Global\n */\n private async createGitignore(path: string): Promise<void> {\n const lines = [\n '# Ignore all hidden files and folders...',\n '.*',\n '# ...but these',\n '!/.gitignore',\n '!/.gitattributes',\n '!/**/.gitkeep',\n '',\n '# elek.io related ignores',\n // projectFolderSchema.Enum.theme + '/',\n // projectFolderSchema.Enum.public + '/',\n // projectFolderSchema.Enum.logs + '/',\n ];\n await Fs.writeFile(Path.join(path, '.gitignore'), lines.join(Os.EOL));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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V;AAAA,MACF;AAAA,IACF;AAEA,qBAAAC,QAAG,WAAgB,OAAO,QAAQ;AAClC,qBAAAA,QAAG,WAAgB,OAAO,GAAG;AAC7B,qBAAAA,QAAG,aAAkB,OAAO,GAAG;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,MAAkB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,OAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,WAA2B;AACpC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,SAAuB;AAChC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,cAAiC;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,UAAwB;AACjC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQF;","names":["import_fs_extra","import_zod","z","import_zod","z","z","import_zod","import_zod","import_zod","z","z","z","import_zod","import_zod","GitCommitIconNative","import_zod","import_zod","import_zod","import_zod","z","Path","Os","Fs","dirent","import_fs_extra","slugify","generateUuid","import_fs_extra","Fs","Fs","IsSvg","import_fs_extra","import_os","import_os","tag","GitService","PQueue","files","Fs","import_fs_extra","Fs","import_fs_extra","import_os","import_path","Fs","Path","Semver","folders","Os","GitService","Fs"]}