fairspec-extension 0.1.1 → 0.2.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.
package/index.ts CHANGED
@@ -1,7 +1,11 @@
1
- import type * as standard from "@fairspec/metadata"
2
- import type * as extension from "./models/dataset.ts"
1
+ import * as standard from "@fairspec/metadata"
2
+ import { z } from "zod"
3
+ import * as extension from "./models/dataset.ts"
3
4
 
4
- export type Resource = standard.Resource & extension.Resource
5
- export type Dataset = standard.Dataset & extension.Dataset
5
+ export * from "./models/index.ts"
6
6
 
7
- export type * from "./models/index.ts"
7
+ export const Dataset = z.intersection(standard.Dataset, extension.Dataset)
8
+ export const Resource = z.intersection(standard.Resource, extension.Resource)
9
+
10
+ export type Dataset = z.infer<typeof Dataset>
11
+ export type Resource = z.infer<typeof Resource>
package/models/dataset.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  // biome-ignore-all format: DO NOT UPDATE this @generated file
2
+ import { z } from "zod";
2
3
 
3
- export type FairspecExtensionProfile = Dataset
4
- export type Resource = Table1Resource | Table2Resource
4
+ export const Table1Resource = z.object({
5
+ name: z.literal("table1"),
6
+ Table: z.literal("https://fairspec.github.io/schemas/0.2.0/table1.json")
7
+ });
5
8
 
6
- export interface Dataset {
7
- $schema: "https://fairspec.github.io/profiles/0.1.1/dataset.json"
8
- /**
9
- * @minItems 1
10
- */
11
- resources: [Resource, ...Resource[]]
12
- }
13
- /**
14
- * Data records have to conform to the Table1 schema
15
- */
16
- export interface Table1Resource {
17
- name: "table1"
18
- tableSchema: "https://fairspec.github.io/schemas/0.1.1/table1.json"
19
- }
20
- /**
21
- * Data items have to conform to the Table2 schema
22
- */
23
- export interface Table2Resource {
24
- name: "table2"
25
- tableSchema: "https://fairspec.github.io/schemas/0.1.1/table2.json"
26
- }
9
+ export const Table2Resource = z.object({
10
+ name: z.literal("table2"),
11
+ Table: z.literal("https://fairspec.github.io/schemas/0.2.0/table2.json")
12
+ });
13
+
14
+ export const Resource = z.union([Table1Resource, Table2Resource]);
15
+
16
+ export const Dataset = z.object({
17
+ $schema: z.literal("https://fairspec.github.io/profiles/0.2.0/dataset.json"),
18
+ resources: z.tuple([Resource]).rest(Resource)
19
+ });
20
+
21
+ export const FairspecExtensionProfile = Dataset;
22
+ export type Table1Resource = z.infer<typeof Table1Resource>
23
+ export type Table2Resource = z.infer<typeof Table2Resource>
24
+ export type Resource = z.infer<typeof Resource>
25
+ export type Dataset = z.infer<typeof Dataset>
26
+ export type FairspecExtensionProfile = z.infer<typeof FairspecExtensionProfile>
package/models/table1.ts CHANGED
@@ -1,39 +1,14 @@
1
1
  // biome-ignore-all format: DO NOT UPDATE this @generated file
2
+ import { z } from "zod";
2
3
 
3
- /**
4
- * An exemplar schema demonstrating various field types and constraints
5
- */
6
- export interface Table1 {
7
- /**
8
- * Unique identifier for the record
9
- */
10
- id: string
11
- /**
12
- * Name of the entity
13
- */
14
- name: string
15
- /**
16
- * Current status of the entity
17
- */
18
- status: "active" | "inactive" | "pending"
19
- /**
20
- * Numeric value associated with the entity
21
- */
22
- value: number
23
- /**
24
- * Count of items
25
- */
26
- itemCount?: number
27
- /**
28
- * Whether the entity has been verified
29
- */
30
- isVerified: boolean
31
- /**
32
- * Date when the entity was created
33
- */
34
- createdDate: string
35
- /**
36
- * Optional description of the entity
37
- */
38
- description?: string
39
- }
4
+ export const Table1 = z.object({
5
+ id: z.string(),
6
+ name: z.string(),
7
+ status: z.union([z.literal("active"), z.literal("inactive"), z.literal("pending")]),
8
+ value: z.number(),
9
+ itemCount: z.number().optional(),
10
+ isVerified: z.boolean(),
11
+ createdDate: z.string(),
12
+ description: z.string().optional()
13
+ });
14
+ export type Table1 = z.infer<typeof Table1>
package/models/table2.ts CHANGED
@@ -1,39 +1,14 @@
1
1
  // biome-ignore-all format: DO NOT UPDATE this @generated file
2
+ import { z } from "zod";
2
3
 
3
- /**
4
- * An exemplar schema demonstrating foreign key relationships and additional constraints
5
- */
6
- export interface Table2 {
7
- /**
8
- * Unique identifier for the record
9
- */
10
- id: string
11
- /**
12
- * Reference to the parent table1 record. If not provided, the record is independent
13
- */
14
- table1Id?: string
15
- /**
16
- * Title or name of the item
17
- */
18
- title: string
19
- /**
20
- * Monetary or numeric amount
21
- */
22
- amount: number
23
- /**
24
- * Priority level of the item
25
- */
26
- priority: "low" | "medium" | "high"
27
- /**
28
- * Percentage value between 0 and 100
29
- */
30
- percentage?: number
31
- /**
32
- * Additional notes or comments
33
- */
34
- notes?: string
35
- /**
36
- * Whether the item is currently active
37
- */
38
- isActive: boolean
39
- }
4
+ export const Table2 = z.object({
5
+ id: z.string(),
6
+ table1Id: z.string().optional(),
7
+ title: z.string(),
8
+ amount: z.number(),
9
+ priority: z.union([z.literal("low"), z.literal("medium"), z.literal("high")]),
10
+ percentage: z.number().optional(),
11
+ notes: z.string().optional(),
12
+ isActive: z.boolean()
13
+ });
14
+ export type Table2 = z.infer<typeof Table2>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fairspec-extension",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "slug": "fairspec-extension",
6
6
  "title": "Fairspec Extension",
7
7
  "description": "Fairspec Extension is a Git repository template for rapid Fairspec extension development",
@@ -10,7 +10,8 @@
10
10
  "author": "Evgeny Karev",
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@fairspec/metadata": "^0.2.2"
13
+ "@fairspec/metadata": "^0.2.2",
14
+ "zod": "^4.3.5"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "tsc",