@open-audio-stack/core 0.0.19 → 0.0.22

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.
@@ -1,7 +1,8 @@
1
- import { PackageInterface, PackageValidationError } from '../types/Package.js';
1
+ import { PackageInterface } from '../types/Package.js';
2
2
  import { PluginFile } from '../types/Plugin.js';
3
3
  import { PresetFile } from '../types/Preset.js';
4
4
  import { ProjectFile } from '../types/Project.js';
5
+ import { ZodIssue } from 'zod';
5
6
  export declare function dirApp(): string;
6
7
  export declare function dirCreate(dir: string): string | false;
7
8
  export declare function dirDelete(dir: string): false | void;
@@ -30,6 +31,6 @@ export declare function fileReadJson(filePath: string): any;
30
31
  export declare function fileReadString(filePath: string): string;
31
32
  export declare function fileReadYaml(filePath: string): unknown;
32
33
  export declare function fileSize(filePath: string): number;
33
- export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): Promise<PackageValidationError[]>;
34
+ export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): Promise<ZodIssue[]>;
34
35
  export declare function zipCreate(filesPath: string, zipPath: string): void;
35
36
  export declare function zipExtract(content: any, dirPath: string): void;
@@ -8,7 +8,7 @@ import { moveSync } from 'fs-extra/esm';
8
8
  import os from 'os';
9
9
  import path from 'path';
10
10
  import yaml from 'js-yaml';
11
- import { PackageValidation } from '../types/Package.js';
11
+ import { ZodIssueCode } from 'zod';
12
12
  export function dirApp() {
13
13
  if (process.platform === 'win32')
14
14
  return process.env.APPDATA || os.homedir();
@@ -183,18 +183,20 @@ export async function fileValidateMetadata(filePath, fileMetadata) {
183
183
  const hash = await fileHash(filePath);
184
184
  if (fileMetadata.sha256 !== hash) {
185
185
  errors.push({
186
- field: 'sha256',
187
- error: PackageValidation.INVALID_VALUE,
188
- valueExpected: hash,
189
- valueReceived: fileMetadata.sha256,
186
+ code: ZodIssueCode.invalid_type,
187
+ expected: hash,
188
+ message: 'Required',
189
+ path: ['sha256'],
190
+ received: fileMetadata.sha256,
190
191
  });
191
192
  }
192
193
  if (fileMetadata.size !== fileSize(filePath)) {
193
194
  errors.push({
194
- field: 'size',
195
- error: PackageValidation.INVALID_VALUE,
196
- valueExpected: String(fileSize(filePath)),
197
- valueReceived: String(fileMetadata.size),
195
+ code: ZodIssueCode.invalid_type,
196
+ expected: String(fileSize(filePath)),
197
+ message: 'Required',
198
+ path: ['size'],
199
+ received: String(fileMetadata.size),
198
200
  });
199
201
  }
200
202
  return errors;
@@ -1,6 +1,7 @@
1
- import { PackageValidationError, PackageValidationRec } from '../types/Package.js';
2
- export declare function logReport(info: string, errors?: PackageValidationError[], recs?: PackageValidationRec[]): void;
3
- export declare function logErrors(errors: PackageValidationError[]): void;
1
+ import { PackageValidationRec } from '../types/Package.js';
2
+ import { ZodIssue } from 'zod';
3
+ export declare function logReport(info: string, errors?: ZodIssue[], recs?: PackageValidationRec[]): void;
4
+ export declare function logErrors(errors: ZodIssue[]): void;
4
5
  export declare function logRecommendations(recs: PackageValidationRec[]): void;
5
6
  export declare function pathGetExt(path: string, sep?: string): string;
6
7
  export declare function pathGetDirectory(path: string, sep?: string): string;
@@ -12,7 +12,15 @@ export function logReport(info, errors, recs) {
12
12
  }
13
13
  export function logErrors(errors) {
14
14
  errors.forEach(error => {
15
- console.log(chalk.red(`- ${error.field} (${error.error}) received '${error.valueReceived}' expected '${error.valueExpected}'`));
15
+ // @ts-expect-error need to filter by code.
16
+ if (error.received) {
17
+ console.log(chalk.red(
18
+ // @ts-expect-error need to filter by code.
19
+ `- ${error.path} (${error.message}) received '${error.received}' expected '${error.expected}'`));
20
+ }
21
+ else {
22
+ console.log(chalk.red(`- ${error.path} (${error.message})`));
23
+ }
16
24
  });
17
25
  }
18
26
  export function logRecommendations(recs) {
@@ -1,6 +1,7 @@
1
1
  export declare enum FileFormat {
2
2
  AppImage = "appimage",
3
3
  AppleDiskImage = "dmg",
4
+ ApplePackage = "pkg",
4
5
  DebianPackage = "deb",
5
6
  ExecutableInstaller = "exe",
6
7
  RedHatPackage = "rpm",
@@ -2,6 +2,7 @@ export var FileFormat;
2
2
  (function (FileFormat) {
3
3
  FileFormat["AppImage"] = "appimage";
4
4
  FileFormat["AppleDiskImage"] = "dmg";
5
+ FileFormat["ApplePackage"] = "pkg";
5
6
  FileFormat["DebianPackage"] = "deb";
6
7
  FileFormat["ExecutableInstaller"] = "exe";
7
8
  FileFormat["RedHatPackage"] = "rpm";
@@ -22,6 +23,11 @@ export const fileFormats = [
22
23
  value: FileFormat.AppleDiskImage,
23
24
  name: 'Apple Disk Image',
24
25
  },
26
+ {
27
+ description: 'macOS and iOS software package installer.',
28
+ value: FileFormat.ApplePackage,
29
+ name: 'Apple package',
30
+ },
25
31
  {
26
32
  description: 'Package for Debian-based Linux such as Ubuntu.',
27
33
  value: FileFormat.DebianPackage,
@@ -32,12 +32,6 @@ export interface PackageValidationField {
32
32
  name: string;
33
33
  type: string;
34
34
  }
35
- export interface PackageValidationError {
36
- field: string;
37
- error: PackageValidation;
38
- valueExpected: boolean | number | string;
39
- valueReceived: boolean | number | string;
40
- }
41
35
  export interface PackageValidationRec {
42
36
  field: string;
43
37
  rec: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.19",
3
+ "version": "0.0.22",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",