@isardsat/editorial-common 6.13.2 → 6.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @isardsat/editorial-common
2
2
 
3
+ ## 6.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7ff5f4d: - Adds a new /api/v1/meta-schema endpoint that returns the JSON Schema for the Editorial configuration.
8
+ - Includes optional `allowedExtraFields` parameter to allow additional fields not defined in the meta-schema.
9
+ - - Updated the CLI `init` command to automatically add the line `# yaml-language-server: $schema=http://localhost:3001/api/v1/meta-schema` to schema.yml
10
+
11
+ ## 6.14.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 61cb350: This PR adds:
16
+ - select and multiselect (with maxSelectedItems and 'minSelectedItems` optional fields) field types.
17
+ - Support for dynamic options via $field_name references to populate from other data types.
18
+ - resolve param to /api/v1/data /api/v1/data/{itemType} /api/v1/data/{itemType}/{id} GET endpoints which resolve referenced fields to full objects.
19
+
3
20
  ## 6.13.2
4
21
 
5
22
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the options value is a reference to another field.
3
+ * References are in the format $key_field
4
+ */
5
+ export declare function getOptionsReference(options: string[] | undefined): string | null;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks if the options value is a reference to another field.
3
+ * References are in the format $key_field
4
+ */
5
+ export function getOptionsReference(options) {
6
+ if (!options || options.length !== 1)
7
+ return null;
8
+ const match = options[0].match(/^\$(.+)$/);
9
+ return match ? match[1] : null;
10
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from './schemas.js';
2
- export type * from './types.js';
1
+ export * from "./data-utils.js";
2
+ export * from "./schemas.js";
3
+ export type * from "./types.js";
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- export * from './schemas.js';
1
+ export * from "./data-utils.js";
2
+ export * from "./schemas.js";
package/dist/schemas.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare const EditorialSchemaItemFieldType: z.ZodEnum<{
50
50
  markdown: "markdown";
51
51
  color: "color";
52
52
  select: "select";
53
+ multiselect: "multiselect";
53
54
  }>;
54
55
  export declare const RGBColorSchema: z.ZodString;
55
56
  export declare const EditorialSchemaItemFieldSchema: z.ZodObject<{
@@ -63,12 +64,17 @@ export declare const EditorialSchemaItemFieldSchema: z.ZodObject<{
63
64
  markdown: "markdown";
64
65
  color: "color";
65
66
  select: "select";
67
+ multiselect: "multiselect";
66
68
  }>;
67
69
  displayName: z.ZodString;
68
70
  displayExtra: z.ZodOptional<z.ZodString>;
69
71
  placeholder: z.ZodOptional<z.ZodString>;
70
- optional: z.ZodDefault<z.ZodBoolean>;
72
+ optional: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
71
73
  showInSummary: z.ZodOptional<z.ZodBoolean>;
74
+ options: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ maxSelectedOptions: z.ZodOptional<z.ZodNumber>;
76
+ minSelectedOptions: z.ZodOptional<z.ZodNumber>;
77
+ isUploadedFile: z.ZodOptional<z.ZodBoolean>;
72
78
  }, z.core.$loose>;
73
79
  export declare const EditorialSchemaItemSchema: z.ZodObject<{
74
80
  displayName: z.ZodString;
@@ -85,12 +91,17 @@ export declare const EditorialSchemaItemSchema: z.ZodObject<{
85
91
  markdown: "markdown";
86
92
  color: "color";
87
93
  select: "select";
94
+ multiselect: "multiselect";
88
95
  }>;
89
96
  displayName: z.ZodString;
90
97
  displayExtra: z.ZodOptional<z.ZodString>;
91
98
  placeholder: z.ZodOptional<z.ZodString>;
92
- optional: z.ZodDefault<z.ZodBoolean>;
99
+ optional: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
93
100
  showInSummary: z.ZodOptional<z.ZodBoolean>;
101
+ options: z.ZodOptional<z.ZodArray<z.ZodString>>;
102
+ maxSelectedOptions: z.ZodOptional<z.ZodNumber>;
103
+ minSelectedOptions: z.ZodOptional<z.ZodNumber>;
104
+ isUploadedFile: z.ZodOptional<z.ZodBoolean>;
94
105
  }, z.core.$loose>>;
95
106
  }, z.core.$strip>;
96
107
  export declare const EditorialSchemaSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -108,12 +119,17 @@ export declare const EditorialSchemaSchema: z.ZodRecord<z.ZodString, z.ZodObject
108
119
  markdown: "markdown";
109
120
  color: "color";
110
121
  select: "select";
122
+ multiselect: "multiselect";
111
123
  }>;
112
124
  displayName: z.ZodString;
113
125
  displayExtra: z.ZodOptional<z.ZodString>;
114
126
  placeholder: z.ZodOptional<z.ZodString>;
115
- optional: z.ZodDefault<z.ZodBoolean>;
127
+ optional: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
116
128
  showInSummary: z.ZodOptional<z.ZodBoolean>;
129
+ options: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
+ maxSelectedOptions: z.ZodOptional<z.ZodNumber>;
131
+ minSelectedOptions: z.ZodOptional<z.ZodNumber>;
132
+ isUploadedFile: z.ZodOptional<z.ZodBoolean>;
117
133
  }, z.core.$loose>>;
118
134
  }, z.core.$strip>>;
119
135
  export declare const BaseEditorialFileSchema: z.ZodObject<{
package/dist/schemas.js CHANGED
@@ -42,6 +42,8 @@ export const EditorialSchemaItemFieldType = z.enum([
42
42
  "color",
43
43
  "select",
44
44
  "url",
45
+ "select",
46
+ "multiselect",
45
47
  ]);
46
48
  export const RGBColorSchema = z
47
49
  .string()
@@ -63,8 +65,12 @@ export const EditorialSchemaItemFieldSchema = z.looseObject({
63
65
  displayName: z.string(),
64
66
  displayExtra: z.string().optional(),
65
67
  placeholder: z.string().optional(),
66
- optional: z.boolean().default(false),
68
+ optional: z.boolean().optional().default(false),
67
69
  showInSummary: z.boolean().optional(),
70
+ options: z.array(z.string()).optional(),
71
+ maxSelectedOptions: z.number().optional(),
72
+ minSelectedOptions: z.number().optional(),
73
+ isUploadedFile: z.boolean().optional(),
68
74
  });
69
75
  export const EditorialSchemaItemSchema = z.object({
70
76
  displayName: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isardsat/editorial-common",
3
- "version": "6.13.2",
3
+ "version": "6.15.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks if the options value is a reference to another field.
3
+ * References are in the format $key_field
4
+ */
5
+ export function getOptionsReference(
6
+ options: string[] | undefined,
7
+ ): string | null {
8
+ if (!options || options.length !== 1) return null;
9
+
10
+ const match = options[0].match(/^\$(.+)$/);
11
+ return match ? match[1] : null;
12
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from './schemas.js';
2
- export type * from './types.js';
1
+ export * from "./data-utils.js";
2
+ export * from "./schemas.js";
3
+ export type * from "./types.js";
package/src/schemas.ts CHANGED
@@ -36,12 +36,12 @@ export const EditorialDataItemSchema = z.looseObject({
36
36
 
37
37
  export const EditorialDataTypeSchema = z.record(
38
38
  z.string(),
39
- EditorialDataItemSchema
39
+ EditorialDataItemSchema,
40
40
  );
41
41
 
42
42
  export const EditorialDataSchema = z.record(
43
43
  z.string(),
44
- EditorialDataTypeSchema
44
+ EditorialDataTypeSchema,
45
45
  );
46
46
 
47
47
  export const EditorialSchemaItemFieldType = z.enum([
@@ -54,16 +54,20 @@ export const EditorialSchemaItemFieldType = z.enum([
54
54
  "color",
55
55
  "select",
56
56
  "url",
57
+ "select",
58
+ "multiselect",
57
59
  ]);
58
60
 
59
61
  export const RGBColorSchema = z
60
62
  .string()
61
63
  .regex(
62
64
  /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/,
63
- "Must be a valid RGB color format: rgb(r, g, b)"
65
+ "Must be a valid RGB color format: rgb(r, g, b)",
64
66
  )
65
67
  .refine((value) => {
66
- const match = value.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
68
+ const match = value.match(
69
+ /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/,
70
+ );
67
71
  if (!match) return false;
68
72
  const [, r, g, b] = match;
69
73
  return (
@@ -81,8 +85,12 @@ export const EditorialSchemaItemFieldSchema = z.looseObject({
81
85
  displayName: z.string(),
82
86
  displayExtra: z.string().optional(),
83
87
  placeholder: z.string().optional(),
84
- optional: z.boolean().default(false),
88
+ optional: z.boolean().optional().default(false),
85
89
  showInSummary: z.boolean().optional(),
90
+ options: z.array(z.string()).optional(),
91
+ maxSelectedOptions: z.number().optional(),
92
+ minSelectedOptions: z.number().optional(),
93
+ isUploadedFile: z.boolean().optional(),
86
94
  });
87
95
 
88
96
  export const EditorialSchemaItemSchema = z.object({
@@ -94,7 +102,7 @@ export const EditorialSchemaItemSchema = z.object({
94
102
 
95
103
  export const EditorialSchemaSchema = z.record(
96
104
  z.string(),
97
- EditorialSchemaItemSchema
105
+ EditorialSchemaItemSchema,
98
106
  );
99
107
 
100
108
  export const BaseEditorialFileSchema = z.object({