@firecms/schema_inference 3.0.0-beta.1 → 3.0.0-beta.10
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/LICENSE +114 -21
- package/dist/collection_builder.d.ts +3 -2
- package/dist/index.es.js +392 -202
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +433 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +15 -7
- package/src/builders/string_property_builder.ts +1 -2
- package/src/collection_builder.ts +142 -49
- package/src/strings.ts +1 -1
- package/src/test_schemas/pop_products.json +948 -0
- package/src/test_schemas/test_schema.ts +5 -1
- package/src/util.ts +10 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { buildEntityPropertiesFromData } from "../collection_builder";
|
|
2
2
|
import { DataType } from "@firecms/core";
|
|
3
3
|
|
|
4
|
-
import usage from "./usage.json" assert {
|
|
4
|
+
// import usage from "./usage.json" assert {
|
|
5
|
+
// type: "json",
|
|
6
|
+
// integrity: "sha384-ABC123"
|
|
7
|
+
// };
|
|
8
|
+
import usage from "./pop_products.json" assert {
|
|
5
9
|
type: "json",
|
|
6
10
|
integrity: "sha384-ABC123"
|
|
7
11
|
};
|
package/src/util.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { unslugify } from "@firecms/core";
|
|
2
2
|
|
|
3
|
-
export function extractEnumFromValues(values:
|
|
3
|
+
export function extractEnumFromValues(values: unknown[]) {
|
|
4
|
+
if (!Array.isArray(values)) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
4
7
|
const enumValues = values
|
|
5
|
-
.map((value) =>
|
|
8
|
+
.map((value) => {
|
|
9
|
+
if (typeof value === "string") {
|
|
10
|
+
return ({ id: value, label: unslugify(value) });
|
|
11
|
+
} else
|
|
12
|
+
return null;
|
|
13
|
+
}).filter(Boolean) as Array<{ id: string, label: string }>;
|
|
6
14
|
enumValues.sort((a, b) => a.label.localeCompare(b.label));
|
|
7
15
|
return enumValues;
|
|
8
16
|
}
|