Skip to content

Commit f830039

Browse files
Merge pull request #282 from balena-io-modules/remove-json-schema
Remove unnecessary `json-schema` lib
2 parents b50336a + 89daae1 commit f830039

28 files changed

Lines changed: 89 additions & 88 deletions

src/components/RJST/Actions/Tags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
2+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
33
import type { RJSTContext, RJSTBaseResource } from '../schemaOps';
44
import { parseDescriptionProperty } from '../schemaOps';
55
import { get } from '../../../utils/objects';

src/components/RJST/DataTypes/array.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
1+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
22
import {
33
FULL_TEXT_SLUG,
44
createModelFilter,

src/components/RJST/DataTypes/boolean.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CreateFilter } from './utils';
22
import { getDataTypeSchema } from './utils';
3-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
3+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
44

55
export const operators = () => ({
66
is: 'is',

src/components/RJST/DataTypes/date-time.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CreateFilter } from './utils';
22
import { getDataTypeSchema, normalizeDateTime } from './utils';
3-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
3+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
44

55
export const operators = () => ({
66
is: 'is',

src/components/RJST/DataTypes/enum.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isEqual } from 'es-toolkit';
22
import { FULL_TEXT_SLUG } from '../components/Filters/SchemaSieve';
33
import type { CreateFilter } from './utils';
44
import { getDataTypeSchema, regexEscape } from './utils';
5-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
5+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
66

77
export const operators = () => ({
88
is: 'is',

src/components/RJST/DataTypes/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ import * as enumType from './enum';
77
import * as oneOfType from './oneOf';
88
import * as dateTimeType from './date-time';
99

10-
import {
11-
type JSONSchema7 as JSONSchema,
12-
type JSONSchema7Definition as JSONSchemaDefinition,
13-
type JSONSchema7TypeName as JSONSchemaTypeName,
14-
} from 'json-schema';
10+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
1511
import { getPropertySchema } from '../components/Filters/SchemaSieve';
1612
import { getRefSchema } from '../schemaOps';
17-
18-
type ExcludeLiteral<T, U> = T extends U ? never : T;
19-
20-
type PartialJSONSchemaTypeName = ExcludeLiteral<JSONSchemaTypeName, 'null'>;
13+
import type {
14+
JSONSchemaDefinition,
15+
PartialJSONSchemaTypeName,
16+
} from '../../../typings/shared';
2117

2218
type DataTypeModule =
2319
| typeof arrayType
@@ -89,7 +85,7 @@ export const getDataModel = (
8985
}
9086
const typeSet = Array.isArray(type) ? type : [type];
9187
const dataTypeKey = Object.keys(dataTypeMap).find((t) =>
92-
typeSet.includes(t as JSONSchemaTypeName),
88+
typeSet.includes(t as PartialJSONSchemaTypeName),
9389
);
9490
if (!dataTypeKey) {
9591
return null;

src/components/RJST/DataTypes/number.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FULL_TEXT_SLUG } from '../components/Filters/SchemaSieve';
22
import type { CreateFilter } from './utils';
33
import { getDataTypeSchema } from './utils';
4-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
4+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
55

66
// This is the max safe integer supported DB: 2**31-1
77
const MAX_SAFE_DB_INT4 = 2147483647;

src/components/RJST/DataTypes/object.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
1+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
22
import type { CreateFilter, KeysOfUnion } from './utils';
33
import { getDataTypeSchema, regexEscape } from './utils';
44
import type { FormData } from '../components/Filters/SchemaSieve';

src/components/RJST/DataTypes/oneOf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isJSONSchema } from '../schemaOps';
22
import { FULL_TEXT_SLUG } from '../components/Filters/SchemaSieve';
33
import type { CreateFilter } from './utils';
44
import { getDataTypeSchema } from './utils';
5-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
5+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
66
export const operators = () => ({
77
is: 'is',
88
is_not: 'is not',

src/components/RJST/DataTypes/string.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { CreateFilter } from './utils';
22
import { getDataTypeSchema, regexEscape } from './utils';
33
import { FULL_TEXT_SLUG } from '../components/Filters/SchemaSieve';
4-
import type { JSONSchema7 as JSONSchema } from 'json-schema';
4+
import type { StrictRJSFSchema as JSONSchema } from '@rjsf/utils';
55

66
// TODO: we should make it an object as soon as we will be able to remove custom Tags logic in DataTypes/object.tsx.
77
export const operators = () => ({

0 commit comments

Comments
 (0)