@open-audio-stack/core 0.0.18 → 0.0.19

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,5 +1,222 @@
1
- import { PluginFile, PresetFile, ProjectFile } from '../index-browser.js';
2
- import { PackageValidationError, PackageValidationRec, PackageVersionType } from '../types/Package.js';
1
+ import { z } from 'zod';
2
+ import { Architecture } from '../types/Architecture.js';
3
+ import { FileFormat } from '../types/FileFormat.js';
4
+ import { FileType } from '../types/FileType.js';
5
+ import { License } from '../types/License.js';
6
+ import { PluginFile } from '../types/Plugin.js';
7
+ import { PluginType } from '../types/PluginType.js';
8
+ import { PresetFile } from '../types/Preset.js';
9
+ import { PresetType } from '../types/PresetType.js';
10
+ import { ProjectFile } from '../types/Project.js';
11
+ import { ProjectType } from '../types/ProjectType.js';
12
+ import { SystemType } from '../types/SystemType.js';
13
+ import { PackageValidationRec, PackageVersionType } from '../types/Package.js';
14
+ export declare const PackageSystemValidator: z.ZodObject<{
15
+ max: z.ZodOptional<z.ZodNumber>;
16
+ min: z.ZodOptional<z.ZodNumber>;
17
+ type: z.ZodNativeEnum<typeof SystemType>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ type: SystemType;
20
+ max?: number | undefined;
21
+ min?: number | undefined;
22
+ }, {
23
+ type: SystemType;
24
+ max?: number | undefined;
25
+ min?: number | undefined;
26
+ }>;
27
+ export declare const PackageFileValidator: z.ZodObject<{
28
+ architectures: z.ZodArray<z.ZodNativeEnum<typeof Architecture>, "many">;
29
+ format: z.ZodNativeEnum<typeof FileFormat>;
30
+ sha256: z.ZodString;
31
+ size: z.ZodNumber;
32
+ systems: z.ZodArray<z.ZodObject<{
33
+ max: z.ZodOptional<z.ZodNumber>;
34
+ min: z.ZodOptional<z.ZodNumber>;
35
+ type: z.ZodNativeEnum<typeof SystemType>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ type: SystemType;
38
+ max?: number | undefined;
39
+ min?: number | undefined;
40
+ }, {
41
+ type: SystemType;
42
+ max?: number | undefined;
43
+ min?: number | undefined;
44
+ }>, "many">;
45
+ type: z.ZodNativeEnum<typeof FileType>;
46
+ url: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ url: string;
49
+ type: FileType;
50
+ architectures: Architecture[];
51
+ format: FileFormat;
52
+ sha256: string;
53
+ size: number;
54
+ systems: {
55
+ type: SystemType;
56
+ max?: number | undefined;
57
+ min?: number | undefined;
58
+ }[];
59
+ }, {
60
+ url: string;
61
+ type: FileType;
62
+ architectures: Architecture[];
63
+ format: FileFormat;
64
+ sha256: string;
65
+ size: number;
66
+ systems: {
67
+ type: SystemType;
68
+ max?: number | undefined;
69
+ min?: number | undefined;
70
+ }[];
71
+ }>;
72
+ export declare const PackageTypeObj: {
73
+ Audiobook: ProjectType.Audiobook;
74
+ DJSet: ProjectType.DJSet;
75
+ Performance: ProjectType.Performance;
76
+ Podcast: ProjectType.Podcast;
77
+ Remix: ProjectType.Remix;
78
+ Song: ProjectType.Song;
79
+ Score: ProjectType.Score;
80
+ Chain: PresetType.Chain;
81
+ Layout: PresetType.Layout;
82
+ Mapping: PresetType.Mapping;
83
+ Patch: PresetType.Patch;
84
+ Pattern: PresetType.Pattern;
85
+ Theme: PresetType.Theme;
86
+ Effect: PluginType.Effect;
87
+ Generator: PluginType.Generator;
88
+ Instrument: PluginType.Instrument;
89
+ Preset: PluginType.Preset;
90
+ Sampler: PluginType.Sampler;
91
+ Tool: PluginType.Tool;
92
+ };
93
+ export declare const PackageVersionValidator: z.ZodObject<{
94
+ audio: z.ZodString;
95
+ author: z.ZodString;
96
+ changes: z.ZodString;
97
+ date: z.ZodString;
98
+ description: z.ZodString;
99
+ files: z.ZodArray<z.ZodObject<{
100
+ architectures: z.ZodArray<z.ZodNativeEnum<typeof Architecture>, "many">;
101
+ format: z.ZodNativeEnum<typeof FileFormat>;
102
+ sha256: z.ZodString;
103
+ size: z.ZodNumber;
104
+ systems: z.ZodArray<z.ZodObject<{
105
+ max: z.ZodOptional<z.ZodNumber>;
106
+ min: z.ZodOptional<z.ZodNumber>;
107
+ type: z.ZodNativeEnum<typeof SystemType>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ type: SystemType;
110
+ max?: number | undefined;
111
+ min?: number | undefined;
112
+ }, {
113
+ type: SystemType;
114
+ max?: number | undefined;
115
+ min?: number | undefined;
116
+ }>, "many">;
117
+ type: z.ZodNativeEnum<typeof FileType>;
118
+ url: z.ZodString;
119
+ }, "strip", z.ZodTypeAny, {
120
+ url: string;
121
+ type: FileType;
122
+ architectures: Architecture[];
123
+ format: FileFormat;
124
+ sha256: string;
125
+ size: number;
126
+ systems: {
127
+ type: SystemType;
128
+ max?: number | undefined;
129
+ min?: number | undefined;
130
+ }[];
131
+ }, {
132
+ url: string;
133
+ type: FileType;
134
+ architectures: Architecture[];
135
+ format: FileFormat;
136
+ sha256: string;
137
+ size: number;
138
+ systems: {
139
+ type: SystemType;
140
+ max?: number | undefined;
141
+ min?: number | undefined;
142
+ }[];
143
+ }>, "many">;
144
+ image: z.ZodString;
145
+ license: z.ZodNativeEnum<typeof License>;
146
+ name: z.ZodString;
147
+ tags: z.ZodArray<z.ZodString, "many">;
148
+ type: z.ZodNativeEnum<{
149
+ Audiobook: ProjectType.Audiobook;
150
+ DJSet: ProjectType.DJSet;
151
+ Performance: ProjectType.Performance;
152
+ Podcast: ProjectType.Podcast;
153
+ Remix: ProjectType.Remix;
154
+ Song: ProjectType.Song;
155
+ Score: ProjectType.Score;
156
+ Chain: PresetType.Chain;
157
+ Layout: PresetType.Layout;
158
+ Mapping: PresetType.Mapping;
159
+ Patch: PresetType.Patch;
160
+ Pattern: PresetType.Pattern;
161
+ Theme: PresetType.Theme;
162
+ Effect: PluginType.Effect;
163
+ Generator: PluginType.Generator;
164
+ Instrument: PluginType.Instrument;
165
+ Preset: PluginType.Preset;
166
+ Sampler: PluginType.Sampler;
167
+ Tool: PluginType.Tool;
168
+ }>;
169
+ url: z.ZodString;
170
+ }, "strip", z.ZodTypeAny, {
171
+ audio: string;
172
+ author: string;
173
+ changes: string;
174
+ date: string;
175
+ description: string;
176
+ image: string;
177
+ license: License;
178
+ name: string;
179
+ tags: string[];
180
+ url: string;
181
+ type: PluginType | PresetType | ProjectType;
182
+ files: {
183
+ url: string;
184
+ type: FileType;
185
+ architectures: Architecture[];
186
+ format: FileFormat;
187
+ sha256: string;
188
+ size: number;
189
+ systems: {
190
+ type: SystemType;
191
+ max?: number | undefined;
192
+ min?: number | undefined;
193
+ }[];
194
+ }[];
195
+ }, {
196
+ audio: string;
197
+ author: string;
198
+ changes: string;
199
+ date: string;
200
+ description: string;
201
+ image: string;
202
+ license: License;
203
+ name: string;
204
+ tags: string[];
205
+ url: string;
206
+ type: PluginType | PresetType | ProjectType;
207
+ files: {
208
+ url: string;
209
+ type: FileType;
210
+ architectures: Architecture[];
211
+ format: FileFormat;
212
+ sha256: string;
213
+ size: number;
214
+ systems: {
215
+ type: SystemType;
216
+ max?: number | undefined;
217
+ min?: number | undefined;
218
+ }[];
219
+ }[];
220
+ }>;
3
221
  export declare function packageRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
4
222
  export declare function packageRecommendationsUrl(obj: PackageVersionType | PluginFile | PresetFile | ProjectFile, recs: PackageValidationRec[], field: string): void;
5
- export declare function packageValidate(pkgVersion: PackageVersionType): PackageValidationError[];
@@ -1,5 +1,44 @@
1
+ import { z } from 'zod';
2
+ import { Architecture } from '../types/Architecture.js';
3
+ import { FileFormat } from '../types/FileFormat.js';
4
+ import { FileType } from '../types/FileType.js';
1
5
  import { License } from '../types/License.js';
2
- import { PackageValidation, } from '../types/Package.js';
6
+ import { PluginType } from '../types/PluginType.js';
7
+ import { PresetType } from '../types/PresetType.js';
8
+ import { ProjectType } from '../types/ProjectType.js';
9
+ import { SystemType } from '../types/SystemType.js';
10
+ // This is a first version using zod library for validation.
11
+ // If it works well, consider updating all types to infer from Zod objects.
12
+ // This will remove duplicatation of code between types and validators.
13
+ export const PackageSystemValidator = z.object({
14
+ max: z.number().min(0).max(99).optional(),
15
+ min: z.number().min(0).max(99).optional(),
16
+ type: z.nativeEnum(SystemType),
17
+ });
18
+ export const PackageFileValidator = z.object({
19
+ architectures: z.nativeEnum(Architecture).array(),
20
+ format: z.nativeEnum(FileFormat),
21
+ sha256: z.string().length(64),
22
+ size: z.number().min(0).max(9999999999),
23
+ systems: PackageSystemValidator.array(),
24
+ type: z.nativeEnum(FileType),
25
+ url: z.string().min(0).max(256).startsWith('https://'),
26
+ });
27
+ export const PackageTypeObj = { ...PluginType, ...PresetType, ...ProjectType };
28
+ export const PackageVersionValidator = z.object({
29
+ audio: z.string().min(0).max(256).startsWith('https://'),
30
+ author: z.string().min(0).max(256),
31
+ changes: z.string().min(0).max(256),
32
+ date: z.string().datetime(),
33
+ description: z.string().min(0).max(256),
34
+ files: z.array(PackageFileValidator),
35
+ image: z.string().min(0).max(256).startsWith('https://'),
36
+ license: z.nativeEnum(License),
37
+ name: z.string().min(0).max(256),
38
+ tags: z.string().min(0).max(256).array(),
39
+ type: z.nativeEnum(PackageTypeObj),
40
+ url: z.string().min(0).max(256).startsWith('https://'),
41
+ });
3
42
  // TODO refactor all this using a proper validation library.
4
43
  export function packageRecommendations(pkgVersion) {
5
44
  const recs = [];
@@ -72,40 +111,3 @@ export function packageRecommendationsUrl(obj, recs, field) {
72
111
  });
73
112
  }
74
113
  }
75
- export function packageValidate(pkgVersion) {
76
- const fields = [
77
- { name: 'audio', type: 'string' },
78
- { name: 'author', type: 'string' },
79
- { name: 'changes', type: 'string' },
80
- { name: 'date', type: 'string' },
81
- { name: 'description', type: 'string' },
82
- { name: 'files', type: 'object' },
83
- { name: 'image', type: 'string' },
84
- { name: 'license', type: 'string' },
85
- { name: 'name', type: 'string' },
86
- { name: 'tags', type: 'object' },
87
- { name: 'type', type: 'string' },
88
- { name: 'url', type: 'string' },
89
- ];
90
- const errors = [];
91
- fields.forEach((field) => {
92
- const versionField = pkgVersion[field.name];
93
- if (versionField === undefined) {
94
- errors.push({
95
- field: field.name,
96
- error: PackageValidation.MISSING_FIELD,
97
- valueExpected: field.type,
98
- valueReceived: 'undefined',
99
- });
100
- }
101
- else if (typeof versionField !== field.type) {
102
- errors.push({
103
- field: field.name,
104
- error: PackageValidation.INVALID_TYPE,
105
- valueExpected: field.type,
106
- valueReceived: typeof versionField,
107
- });
108
- }
109
- });
110
- return errors;
111
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",
@@ -56,7 +56,8 @@
56
56
  "fs-extra": "^11.2.0",
57
57
  "glob": "^11.0.0",
58
58
  "js-yaml": "^4.1.0",
59
- "semver": "^7.6.3"
59
+ "semver": "^7.6.3",
60
+ "zod": "^3.23.8"
60
61
  },
61
62
  "repository": {
62
63
  "type": "git",