@firecms/schema_inference 3.0.0-alpha.4

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/src/types.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { DataType } from "firecms";
2
+
3
+ export type TypesCount = {
4
+ number?: number,
5
+ string?: number,
6
+ boolean?: number,
7
+ map?: TypesCountRecord,
8
+ array?: TypesCount,
9
+ date?: number,
10
+ geopoint?: number,
11
+ reference?: number
12
+ };
13
+
14
+ export type TypesCountRecord<K extends keyof DataType = any> = {
15
+ [P in K]: TypesCount
16
+ };
17
+
18
+ export type ValuesCountEntry = {
19
+ values: any[];
20
+ valuesCount: Map<any, number>;
21
+ mapValues?: ValuesCountRecord;
22
+ };
23
+
24
+ export type ValuesCountRecord = Record<string, ValuesCountEntry>;
25
+
26
+ export type InferencePropertyBuilderProps = {
27
+
28
+ /**
29
+ * Name of the property
30
+ */
31
+ name: string;
32
+
33
+ /**
34
+ * Total documents this props are built from
35
+ */
36
+ totalDocsCount: number;
37
+
38
+ /**
39
+ * How many times does each value show up
40
+ */
41
+ valuesResult?: ValuesCountEntry;
42
+ };
package/src/util.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { unslugify } from "firecms";
2
+
3
+ export function extractEnumFromValues(values: string[]) {
4
+ const enumValues = values
5
+ .map((value) => ({ id: value, label: unslugify(value) }));
6
+ enumValues.sort((a, b) => a.label.localeCompare(b.label));
7
+ return enumValues;
8
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "dist",
4
+ "module": "esnext",
5
+ "target": "esnext",
6
+ "lib": [
7
+ "dom",
8
+ "dom.iterable",
9
+ "esnext"
10
+ ],
11
+ "moduleResolution": "node",
12
+ "jsx": "react-jsx",
13
+ "noFallthroughCasesInSwitch": true,
14
+ "sourceMap": false,
15
+ "declaration": true,
16
+ "esModuleInterop": true,
17
+ "noImplicitReturns": true,
18
+ "noImplicitThis": true,
19
+ "noImplicitAny": true,
20
+ "strictNullChecks": true,
21
+ "allowSyntheticDefaultImports": true,
22
+ "allowJs": true,
23
+ "skipLibCheck": true,
24
+ "strict": true,
25
+ "forceConsistentCasingInFileNames": true,
26
+ "resolveJsonModule": true,
27
+ "isolatedModules": true,
28
+ "types": [
29
+ "vite/client",
30
+ "node",
31
+ "jest"
32
+ ],
33
+ "baseUrl": ".",
34
+ "paths": {
35
+ "firecms": [
36
+ "../firecms/src/index.ts"
37
+ ]
38
+ }
39
+ },
40
+ "include": [
41
+ "src",
42
+ "./src/**/*.ts"
43
+ ],
44
+ "exclude": [
45
+ "node_modules",
46
+ "dist",
47
+ "src/test"
48
+ ],
49
+ "ts-node": {
50
+ "esm": true,
51
+ "experimentalSpecifierResolution": "node"
52
+ }
53
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,32 @@
1
+ // @ts-ignore
2
+ import path from "path";
3
+
4
+ import { defineConfig } from "vite";
5
+ import react from "@vitejs/plugin-react"
6
+
7
+ const isExternal = (id: string) => !id.startsWith(".") && !path.isAbsolute(id);
8
+
9
+ export default defineConfig(() => ({
10
+ esbuild: {
11
+ logOverride: { "this-is-undefined-in-esm": "silent" }
12
+ },
13
+ build: {
14
+ lib: {
15
+ entry: path.resolve(__dirname, "src/index.ts"),
16
+ name: "FireCMS",
17
+ fileName: (format) => `index.${format}.js`
18
+ },
19
+ target: "esnext",
20
+ sourcemap: true,
21
+ rollupOptions: {
22
+ external: isExternal
23
+ }
24
+ },
25
+ resolve: {
26
+ alias: {
27
+ firecms: path.resolve(__dirname, "../firecms/src"),
28
+ "@firecms/schema_inference": path.resolve(__dirname, "../schema_inference/src"),
29
+ }
30
+ },
31
+ plugins: [react({})]
32
+ }));