MCPcopy Index your code
hub / github.com/tinyplex/tinybase / toCellOrValueSchema

Function toCellOrValueSchema

src/schematizers/index.ts:25–49  ·  view source on GitHub ↗
(
    schema: any,
  )

Source from the content-addressed store, hash-verified

23 getProperties,
24) => {
25 const toCellOrValueSchema = (
26 schema: any,
27 ): CellSchema | ValueSchema | undefined => {
28 const [unwrapped, defaultValue, allowNull] = unwrapSchema(schema);
29 const type = unwrapped?.type;
30
31 if (
32 type !== STRING &&
33 type !== NUMBER &&
34 type !== BOOLEAN &&
35 type !== OBJECT &&
36 type !== ARRAY
37 ) {
38 return undefined;
39 }
40
41 const cellOrValueSchema: CellSchema = {[TYPE]: type} as CellSchema;
42 ifNotUndefined(defaultValue, (defaultValue) => {
43 (cellOrValueSchema as any)[DEFAULT] = defaultValue;
44 });
45 if (allowNull) {
46 (cellOrValueSchema as any)[ALLOW_NULL] = true;
47 }
48 return cellOrValueSchema;
49 };
50
51 const toTablesSchema = (schemas: {[tableId: string]: any}): TablesSchema => {
52 const tablesSchema: TablesSchema = objNew();

Callers 2

toTablesSchemaFunction · 0.85
toValuesSchemaFunction · 0.85

Calls 1

unwrapSchemaFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…