@isardsat/editorial-common 6.13.1 → 6.14.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,20 @@
1
1
  # @isardsat/editorial-common
2
2
 
3
+ ## 6.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 61cb350: This PR adds:
8
+ - select and multiselect (with maxSelectedItems and 'minSelectedItems` optional fields) field types.
9
+ - Support for dynamic options via $field_name references to populate from other data types.
10
+ - resolve param to /api/v1/data /api/v1/data/{itemType} /api/v1/data/{itemType}/{id} GET endpoints which resolve referenced fields to full objects.
11
+
12
+ ## 6.13.2
13
+
14
+ ### Patch Changes
15
+
16
+ - bf07080: Fix upload types
17
+
3
18
  ## 6.13.1
4
19
 
5
20
  ### 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,16 @@ 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
72
  optional: z.ZodDefault<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>;
72
77
  }, z.core.$loose>;
73
78
  export declare const EditorialSchemaItemSchema: z.ZodObject<{
74
79
  displayName: z.ZodString;
@@ -85,12 +90,16 @@ export declare const EditorialSchemaItemSchema: z.ZodObject<{
85
90
  markdown: "markdown";
86
91
  color: "color";
87
92
  select: "select";
93
+ multiselect: "multiselect";
88
94
  }>;
89
95
  displayName: z.ZodString;
90
96
  displayExtra: z.ZodOptional<z.ZodString>;
91
97
  placeholder: z.ZodOptional<z.ZodString>;
92
98
  optional: z.ZodDefault<z.ZodBoolean>;
93
99
  showInSummary: z.ZodOptional<z.ZodBoolean>;
100
+ options: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
+ maxSelectedOptions: z.ZodOptional<z.ZodNumber>;
102
+ minSelectedOptions: z.ZodOptional<z.ZodNumber>;
94
103
  }, z.core.$loose>>;
95
104
  }, z.core.$strip>;
96
105
  export declare const EditorialSchemaSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -108,12 +117,16 @@ export declare const EditorialSchemaSchema: z.ZodRecord<z.ZodString, z.ZodObject
108
117
  markdown: "markdown";
109
118
  color: "color";
110
119
  select: "select";
120
+ multiselect: "multiselect";
111
121
  }>;
112
122
  displayName: z.ZodString;
113
123
  displayExtra: z.ZodOptional<z.ZodString>;
114
124
  placeholder: z.ZodOptional<z.ZodString>;
115
125
  optional: z.ZodDefault<z.ZodBoolean>;
116
126
  showInSummary: z.ZodOptional<z.ZodBoolean>;
127
+ options: z.ZodOptional<z.ZodArray<z.ZodString>>;
128
+ maxSelectedOptions: z.ZodOptional<z.ZodNumber>;
129
+ minSelectedOptions: z.ZodOptional<z.ZodNumber>;
117
130
  }, z.core.$loose>>;
118
131
  }, z.core.$strip>>;
119
132
  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()
@@ -65,6 +67,9 @@ export const EditorialSchemaItemFieldSchema = z.looseObject({
65
67
  placeholder: z.string().optional(),
66
68
  optional: z.boolean().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(),
68
73
  });
69
74
  export const EditorialSchemaItemSchema = z.object({
70
75
  displayName: z.string(),
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { EditorialConfigSchema, EditorialDataItemSchema, EditorialDataObjec
3
3
  export interface LargeFileHandler {
4
4
  list: () => Promise<object[]>;
5
5
  delete: () => Promise<void>;
6
- upload: () => Promise<void>;
6
+ upload: (file: unknown, options?: unknown) => Promise<void>;
7
7
  }
8
8
  export type EditorialConfig = z.infer<typeof EditorialConfigSchema>;
9
9
  export type EditorialData = z.infer<typeof EditorialDataSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isardsat/editorial-common",
3
- "version": "6.13.1",
3
+ "version": "6.14.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 (
@@ -83,6 +87,9 @@ export const EditorialSchemaItemFieldSchema = z.looseObject({
83
87
  placeholder: z.string().optional(),
84
88
  optional: z.boolean().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(),
86
93
  });
87
94
 
88
95
  export const EditorialSchemaItemSchema = z.object({
@@ -94,7 +101,7 @@ export const EditorialSchemaItemSchema = z.object({
94
101
 
95
102
  export const EditorialSchemaSchema = z.record(
96
103
  z.string(),
97
- EditorialSchemaItemSchema
104
+ EditorialSchemaItemSchema,
98
105
  );
99
106
 
100
107
  export const BaseEditorialFileSchema = z.object({
package/src/types.ts CHANGED
@@ -13,7 +13,7 @@ import type {
13
13
  export interface LargeFileHandler {
14
14
  list: () => Promise<object[]>;
15
15
  delete: () => Promise<void>;
16
- upload: () => Promise<void>;
16
+ upload: (file: unknown, options?: unknown) => Promise<void>;
17
17
  }
18
18
 
19
19
  export type EditorialConfig = z.infer<typeof EditorialConfigSchema>;