@open-audio-stack/core 0.0.14 → 0.0.15

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,26 +1,23 @@
1
- import { PackageInterface, PackageVersions, PackageVersionType } from './types/Package.js';
2
- import { RegistryInterface, RegistryPackages } from './types/Registry.js';
3
- import { PluginType } from './types/PluginType.js';
4
- import { PresetType } from './types/PresetType.js';
5
- import { ProjectType } from './types/ProjectType.js';
1
+ import { PackageInterface, PackageVersion, PackageVersions, PackageVersionType } from './types/Package.js';
2
+ import { RegistryInterface, RegistryPackages, RegistryType } from './types/Registry.js';
6
3
  export declare class Registry {
7
4
  registry: RegistryInterface;
8
5
  constructor(registry?: RegistryInterface);
9
- packageAdd(slug: string): {
6
+ packageAdd(slug: string, type: RegistryType): {
10
7
  slug: string;
11
8
  version: string;
12
9
  versions: {};
13
10
  };
14
- packageVersionAdd(slug: string, version: string, pkgVersion: PackageVersionType): void;
15
- package(slug: string): PackageInterface;
16
- packages(): RegistryPackages;
17
- packagesFilter(type: typeof PluginType | typeof PresetType | typeof ProjectType): RegistryPackages;
18
- packageLatest(slug: string, version?: string): PackageVersionType;
11
+ packageVersionAdd(slug: string, type: RegistryType, version: string, pkgVersion: PackageVersionType): void;
12
+ package(slug: string, type: RegistryType): PackageInterface;
13
+ packages(type: RegistryType): RegistryPackages;
14
+ packagesFilter(type: RegistryType, field: keyof PackageVersion, value: string | number | object): RegistryPackages;
15
+ packageLatest(slug: string, type: RegistryType, version?: string): PackageVersionType;
19
16
  packageVersionLatest(versions: PackageVersions): string;
20
17
  get(): RegistryInterface;
21
18
  name(): string;
22
19
  url(): string;
23
20
  version(): string;
24
- packageRemove(slug: string): void;
25
- packageVersionRemove(slug: string, version: string): void;
21
+ packageRemove(slug: string, type: RegistryType): void;
22
+ packageVersionRemove(slug: string, type: RegistryType, version: string): void;
26
23
  }
package/build/Registry.js CHANGED
@@ -4,37 +4,38 @@ export class Registry {
4
4
  constructor(registry) {
5
5
  this.registry = Object.assign({}, registry);
6
6
  }
7
- packageAdd(slug) {
8
- return (this.registry.packages[slug] = {
7
+ packageAdd(slug, type) {
8
+ return (this.registry[type][slug] = {
9
9
  slug,
10
10
  version: '',
11
11
  versions: {},
12
12
  });
13
13
  }
14
- packageVersionAdd(slug, version, pkgVersion) {
15
- let pkg = this.package(slug);
14
+ packageVersionAdd(slug, type, version, pkgVersion) {
15
+ let pkg = this.package(slug, type);
16
16
  if (!pkg) {
17
- pkg = this.packageAdd(slug);
17
+ pkg = this.packageAdd(slug, type);
18
18
  }
19
19
  pkg.versions[version] = pkgVersion;
20
20
  pkg.version = this.packageVersionLatest(pkg.versions);
21
21
  }
22
- package(slug) {
23
- return this.registry.packages[slug];
22
+ package(slug, type) {
23
+ return this.registry[type][slug];
24
24
  }
25
- packages() {
26
- return this.registry.packages;
25
+ packages(type) {
26
+ return this.registry[type];
27
27
  }
28
- packagesFilter(type) {
28
+ packagesFilter(type, field, value) {
29
29
  const registryFiltered = {};
30
- Object.keys(this.registry.packages).forEach((slug) => {
31
- if (Object.values(type).includes(this.packageLatest(slug).type))
32
- registryFiltered[slug] = this.registry.packages[slug];
30
+ Object.keys(this.registry[type]).forEach((slug) => {
31
+ if (this.packageLatest(slug, type)[field] === value) {
32
+ registryFiltered[slug] = this.registry[type][slug];
33
+ }
33
34
  });
34
35
  return registryFiltered;
35
36
  }
36
- packageLatest(slug, version) {
37
- const pkg = this.package(slug);
37
+ packageLatest(slug, type, version) {
38
+ const pkg = this.package(slug, type);
38
39
  const pkgVersion = this.packageVersionLatest(pkg.versions);
39
40
  return pkg.versions[version || pkgVersion];
40
41
  }
@@ -59,17 +60,17 @@ export class Registry {
59
60
  version() {
60
61
  return this.registry.version;
61
62
  }
62
- packageRemove(slug) {
63
- delete this.registry.packages[slug];
63
+ packageRemove(slug, type) {
64
+ delete this.registry[type][slug];
64
65
  }
65
- packageVersionRemove(slug, version) {
66
- const pkg = this.package(slug);
66
+ packageVersionRemove(slug, type, version) {
67
+ const pkg = this.package(slug, type);
67
68
  if (pkg && pkg.versions[version]) {
68
69
  delete pkg.versions[version];
69
70
  pkg.version = this.packageVersionLatest(pkg.versions);
70
71
  }
71
72
  if (!Object.keys(pkg.versions).length) {
72
- this.packageRemove(slug);
73
+ this.packageRemove(slug, type);
73
74
  }
74
75
  }
75
76
  }
@@ -177,12 +177,12 @@ export function fileSize(filePath) {
177
177
  }
178
178
  export function fileValidateMetadata(filePath, fileMetadata) {
179
179
  const errors = [];
180
- if (fileMetadata.hash !== fileHash(filePath)) {
180
+ if (fileMetadata.sha256 !== fileHash(filePath)) {
181
181
  errors.push({
182
- field: 'hash',
182
+ field: 'sha256',
183
183
  error: PackageValidation.INVALID_VALUE,
184
184
  valueExpected: fileHash(filePath),
185
- valueReceived: fileMetadata.hash,
185
+ valueReceived: fileMetadata.sha256,
186
186
  });
187
187
  }
188
188
  if (fileMetadata.size !== fileSize(filePath)) {
@@ -5,7 +5,7 @@ import { System } from './System.js';
5
5
  export interface FileInterface {
6
6
  architectures: Architecture[];
7
7
  format: FileFormat;
8
- hash: string;
8
+ sha256: string;
9
9
  size: number;
10
10
  systems: System[];
11
11
  type: FileType;
@@ -1,10 +1,17 @@
1
1
  import { PackageInterface } from './Package.js';
2
2
  export interface RegistryInterface {
3
3
  name: string;
4
- packages: RegistryPackages;
4
+ [RegistryType.Plugins]: RegistryPackages;
5
+ [RegistryType.Presets]: RegistryPackages;
6
+ [RegistryType.Projects]: RegistryPackages;
5
7
  url: string;
6
8
  version: string;
7
9
  }
10
+ export declare enum RegistryType {
11
+ Plugins = "plugins",
12
+ Presets = "presets",
13
+ Projects = "projects"
14
+ }
8
15
  export interface RegistryPackages {
9
16
  [slug: string]: PackageInterface;
10
17
  }
@@ -1 +1,6 @@
1
- export {};
1
+ export var RegistryType;
2
+ (function (RegistryType) {
3
+ RegistryType["Plugins"] = "plugins";
4
+ RegistryType["Presets"] = "presets";
5
+ RegistryType["Projects"] = "projects";
6
+ })(RegistryType || (RegistryType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",