From d2b924a5777448088a779a64da58f82474e21be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Po=C5=9Bpiech?= <37746259+piotrpospiech@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:27:28 +0200 Subject: [PATCH] Deprecate `uniforms-bridge-simple-schema` package (#1323) --- .eslintrc.json | 3 +- .github/labeler.yml | 5 - README.md | 1 - docs/api-bridges.md | 21 +- jest.config.js | 3 - .../uniforms-bridge-simple-schema/README.md | 11 - .../__tests__/SimpleSchemaBridge.ts | 360 ------------------ .../__tests__/index.ts | 8 - .../package.json | 41 -- .../src/SimpleSchemaBridge.ts | 184 --------- .../src/index.ts | 2 - .../src/register.ts | 56 --- .../tsconfig.cjs.json | 12 - .../tsconfig.esm.json | 12 - .../__mocks__/meteor/aldeed_simple-schema.ts | 6 - packages/uniforms/__mocks__/meteor/check.ts | 5 - reproductions/package.json | 1 - tsconfig.build.json | 2 - tsconfig.global.json | 3 - website/package.json | 1 - .../types/meteor_aldeed_simple-schema.d.ts | 9 - 21 files changed, 20 insertions(+), 726 deletions(-) delete mode 100644 packages/uniforms-bridge-simple-schema/README.md delete mode 100644 packages/uniforms-bridge-simple-schema/__tests__/SimpleSchemaBridge.ts delete mode 100644 packages/uniforms-bridge-simple-schema/__tests__/index.ts delete mode 100644 packages/uniforms-bridge-simple-schema/package.json delete mode 100644 packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts delete mode 100644 packages/uniforms-bridge-simple-schema/src/index.ts delete mode 100644 packages/uniforms-bridge-simple-schema/src/register.ts delete mode 100644 packages/uniforms-bridge-simple-schema/tsconfig.cjs.json delete mode 100644 packages/uniforms-bridge-simple-schema/tsconfig.esm.json delete mode 100644 packages/uniforms/__mocks__/meteor/aldeed_simple-schema.ts delete mode 100644 packages/uniforms/__mocks__/meteor/check.ts delete mode 100644 website/types/meteor_aldeed_simple-schema.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index 07af91d88..4ccc8504e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,7 +6,7 @@ ], "overrides": [ { - "files": ["**/__mocks__/**/*", "**/__tests__/**/*"], + "files": ["**/__tests__/**/*"], "env": { "jest": true } @@ -72,7 +72,6 @@ "valid-jsdoc": "off" }, "settings": { - "import/core-modules": ["meteor/aldeed:simple-schema", "meteor/check"], "import/resolver": { "typescript": {} }, diff --git a/.github/labeler.yml b/.github/labeler.yml index a643b0c42..875cd6fa2 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -3,7 +3,6 @@ - any-glob-to-any-file: - packages/uniforms-bridge-json-schema/**/* - packages/uniforms-bridge-simple-schema-2/**/* - - packages/uniforms-bridge-simple-schema/**/* - packages/uniforms-bridge-zod/**/* 'Area: Core': - changed-files: @@ -53,10 +52,6 @@ - changed-files: - any-glob-to-any-file: - packages/uniforms-bridge-json-schema/**/* -'Bridge: SimpleSchema': - - changed-files: - - any-glob-to-any-file: - - packages/uniforms-bridge-simple-schema/**/* 'Bridge: SimpleSchema (v2)': - changed-files: - any-glob-to-any-file: diff --git a/README.md b/README.md index a49b7ccb1..a00cb2ffd 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,6 @@ - **Inline and asynchronous form validation** - **Integrations with various schemas:** - **[JSON Schema](http://json-schema.org/)** - - **[SimpleSchema](https://github.com/aldeed/meteor-simple-schema)** - **[SimpleSchema@2](https://github.com/aldeed/node-simple-schema)** - **[Zod](https://github.com/colinhacks/zod)** - **And any other - only [a small wrapper](https://vazco.github.io/uniforms/#/introduction) is needed!** diff --git a/docs/api-bridges.md b/docs/api-bridges.md index e4044e7eb..e3f584e04 100644 --- a/docs/api-bridges.md +++ b/docs/api-bridges.md @@ -13,11 +13,11 @@ Currently available bridges: - `JSONSchemaBridge` in `uniforms-bridge-json-schema` ([schema documentation](https://json-schema.org/)) - `SimpleSchema2Bridge` in `uniforms-bridge-simple-schema-2` ([schema documentation](https://github.com/longshotlabs/simpl-schema#readme)) -- `SimpleSchemaBridge` in `uniforms-bridge-simple-schema` ([schema documentation](https://github.com/Meteor-Community-Packages/meteor-simple-schema/blob/master/DOCS.md)) - `ZodBridge` in `uniforms-bridge-zod` ([schema documentation](https://zod.dev/)) -Deprecated packages: +Deprecated bridges: +- `SimpleSchemaBridge` in `uniforms-bridge-simple-schema` ([schema documentation](https://github.com/Meteor-Community-Packages/meteor-simple-schema/blob/master/DOCS.md)) - `GraphQLBridge` in `uniforms-bridge-graphql` ([schema documentation](https://graphql.org/)) If you see a lot of [`Warning: Unknown props...`](https://fb.me/react-unknown-prop) logs, check if your schema or theme doesn't provide extra props. If so, consider [registering it with `filterDOMProps`](/docs/api-helpers#filterdomprops). @@ -141,8 +141,25 @@ const schema = new SimpleSchema({ const bridge = new SimpleSchema2Bridge({ schema }); ``` +## `ZodBridge` + +```tsx +import ZodBridge from 'uniforms-bridge-zod'; +import z from 'zod'; + +const schema = z.object({ aboutMe: z.string() }); + +const bridge = new ZodBridge({ schema }); +``` + ## `SimpleSchemaBridge` +:::caution + +SimpleSchemaBridge is deprecated since uniforms v4. + +::: + ```tsx import SimpleSchemaBridge from 'uniforms-bridge-simple-schema'; import { SimpleSchema } from 'aldeed:simple-schema'; diff --git a/jest.config.js b/jest.config.js index 5db2e632d..612d9cdcc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,9 +2,6 @@ module.exports = { collectCoverageFrom: ['packages/*/src/*.{ts,tsx}'], coverageReporters: ['html', 'lcovonly', 'text-summary'], moduleNameMapper: { - '^meteor/([^:]*):(.*)$': - '/packages/uniforms/__mocks__/meteor/$1_$2.ts', - '^meteor/([^:]*)$': '/packages/uniforms/__mocks__/meteor/$1.ts', '^simpl-schema$': '/node_modules/simpl-schema', '^uniforms/__suites__$': '/packages/uniforms/__suites__', '^uniforms([^/]*)(.*)$': '/packages/uniforms$1/src$2', diff --git a/packages/uniforms-bridge-simple-schema/README.md b/packages/uniforms-bridge-simple-schema/README.md deleted file mode 100644 index c008712cd..000000000 --- a/packages/uniforms-bridge-simple-schema/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# uniforms-bridge-simple-schema - -> Simple Schema (from Atmosphere) bridge for `uniforms`. - -## Install - -```sh -$ npm install uniforms-bridge-simple-schema -``` - -For more in depth documentation see [uniforms.tools](https://uniforms.tools). diff --git a/packages/uniforms-bridge-simple-schema/__tests__/SimpleSchemaBridge.ts b/packages/uniforms-bridge-simple-schema/__tests__/SimpleSchemaBridge.ts deleted file mode 100644 index 5895527dc..000000000 --- a/packages/uniforms-bridge-simple-schema/__tests__/SimpleSchemaBridge.ts +++ /dev/null @@ -1,360 +0,0 @@ -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; -import { UnknownObject } from 'uniforms'; -import { SimpleSchemaBridge } from 'uniforms-bridge-simple-schema'; - -jest.mock('meteor/aldeed:simple-schema'); -jest.mock('meteor/check'); - -describe('SimpleSchemaBridge', () => { - const noopComponent = () => null; - const schema = { - getDefinition(name: string) { - // Simulate SimpleSchema. - name = name.replace(/\d+/g, '$'); - - const field: UnknownObject | undefined = { - a: { type: Object, label: name }, - 'a.b': { type: Object, label: name }, - 'a.b.c': { type: String, label: name }, - aa: { type: String, uniforms: { type: 'password' } }, - d: { type: String, defaultValue: 'D' }, - e: { type: String, allowedValues: ['E'] }, - f: { type: Number, min: 42 }, - g: { type: Number, max: 42 }, - h: { type: Number }, - i: { type: Date }, - j: { type: Array, minCount: 3 }, - 'j.$': { type: Object }, - 'j.$.a': { type: String, defaultValue: 'x' }, - k: { type: Array }, - 'k.$': { type: Object }, - 'k.$.a': { type: String, defaultValue: 'y' }, - l: { type: String, uniforms: 'div' }, - m: { type: String, uniforms: noopComponent }, - n: { type: String, uniforms: { component: 'div' } }, - o: { type: Array }, - 'o.$': { type: String, allowedValues: ['O'] }, - r: { - type: String, - uniforms: { - options: [ - { key: 'k1', label: 'A', value: 1 }, - { key: 'k2', label: 'B', value: 2 }, - ], - }, - }, - rr: { - type: String, - uniforms: { - options: () => [ - { key: 'k1', label: 'A', value: 1 }, - { key: 'k2', label: 'B', value: 2 }, - ], - }, - }, - s: { type: String, allowedValues: ['a', 'b'] }, - t: { type: String, allowedValues: () => ['a', 'b'] }, - u: { type: Array, defaultValue: ['u'] }, - 'u.$': { type: String }, - v: { type: Object, defaultValue: { a: 'a' } }, - 'v.a': { type: String }, - w: { type: Array, defaultValue: [{ a: 'a' }] }, - 'w.$': { type: Object }, - 'w.$.a': { type: String }, - x: { type: Array }, - 'x.$': { type: String }, - }[name]; - - if (field) { - return { - label: name.split('.').join(' ').toUpperCase(), - ...field, - }; - } - - return undefined; - }, - - messageForError(type: string, name: string) { - return `(${name})`; - }, - - objectKeys(name: 'a' | 'a.b' | 'j' | 'j.$' | 'k' | 'k.$') { - return ( - { - a: ['b'], - 'a.b': ['c'], - j: ['$'], - 'j.$': ['a'], - k: ['$'], - 'k.$': ['a'], - }[name] || [] - ); - }, - - validator() { - return () => { - throw 'ValidationError'; - }; - }, - } as unknown as SimpleSchema; - - const bridge = new SimpleSchemaBridge({ schema }); - - describe('#getError', () => { - it('works without error', () => { - expect(bridge.getError('a', null)).toBe(null); - }); - - it('works with invalid error', () => { - expect(bridge.getError('a', {})).toBe(null); - expect(bridge.getError('a', { invalid: true })).toBe(null); - }); - - it('works with correct error', () => { - expect(bridge.getError('a', { details: [{ name: 'a' }] })).toEqual({ - name: 'a', - }); - expect(bridge.getError('a', { details: [{ name: 'b' }] })).toBe(null); - }); - }); - - describe('#getErrorMessage', () => { - it('works without error', () => { - expect(bridge.getErrorMessage('a', undefined)).toBe(''); - }); - - it('works with invalid error', () => { - expect(bridge.getErrorMessage('a', {})).toBe(''); - expect(bridge.getErrorMessage('a', { invalid: true })).toBe(''); - }); - - it('works with correct error', () => { - expect( - bridge.getErrorMessage('a', { - details: [{ name: 'a', details: { value: 1 } }], - }), - ).toBe('(a)'); - expect( - bridge.getErrorMessage('a', { - details: [{ name: 'b', details: { value: 1 } }], - }), - ).toBe(''); - }); - }); - - describe('#getErrorMessages', () => { - it('works without error', () => { - expect(bridge.getErrorMessages(null)).toEqual([]); - expect(bridge.getErrorMessages(undefined)).toEqual([]); - }); - - it('works with other errors', () => { - expect(bridge.getErrorMessages('correct')).toEqual(['correct']); - expect(bridge.getErrorMessages(999999999)).toEqual([999999999]); - }); - - it('works with Error', () => { - expect(bridge.getErrorMessages(new Error('correct'))).toEqual([ - 'correct', - ]); - }); - - it('works with ValidationError', () => { - expect( - bridge.getErrorMessages({ - details: [{ name: 'a', details: { value: 1 } }], - }), - ).toEqual(['(a)']); - expect( - bridge.getErrorMessages({ - details: [{ name: 'b', details: { value: 1 } }], - }), - ).toEqual(['(b)']); - }); - }); - - describe('#getField', () => { - it('return correct definition', () => { - expect(bridge.getField('a')).toEqual(schema.getDefinition('a')); - }); - - it('throws on not found field', () => { - expect(() => bridge.getField('xxx')).toThrow(/Field not found in schema/); - }); - }); - - describe('#getInitialValue', () => { - it('works with arrays', () => { - expect(bridge.getInitialValue('k')).toEqual([]); - expect(bridge.getInitialValue('x')).toEqual([]); - }); - - it('works with arrays (minCount)', () => { - expect(bridge.getInitialValue('j')).toEqual([ - { a: 'x' }, - { a: 'x' }, - { a: 'x' }, - ]); - }); - - it('works with arrays (defaultValue)', () => { - expect(bridge.getInitialValue('u')).toEqual(['u']); - }); - - it('works with arrays of objects (defaultValue)', () => { - expect(bridge.getInitialValue('w')).toEqual([{ a: 'a' }]); - }); - - it('works with objects', () => { - expect(bridge.getInitialValue('a')).toEqual({ b: {} }); - }); - - it('works with objects (defaultValue)', () => { - expect(bridge.getInitialValue('v')).toEqual({ a: 'a' }); - }); - }); - - describe('#getProps', () => { - it('works with label in schema', () => { - expect(bridge.getProps('a')).toEqual({ - label: 'a', - required: true, - }); - }); - it('works with default label', () => { - expect(bridge.getProps('h')).toEqual({ - label: 'H', - required: true, - }); - }); - it('works with allowedValues (inferred from children)', () => { - expect(bridge.getProps('o')).toEqual({ - label: 'O', - required: true, - options: [{ value: 'O' }], - }); - }); - - it('works with custom component', () => { - expect(bridge.getProps('l')).toEqual({ - label: 'L', - required: true, - component: 'div', - }); - expect(bridge.getProps('m')).toEqual({ - label: 'M', - required: true, - component: noopComponent, - }); - }); - - it('works with custom component (field)', () => { - expect(bridge.getProps('n')).toEqual({ - label: 'N', - required: true, - component: 'div', - }); - }); - - it('works with allowedValues (array)', () => { - expect(bridge.getProps('s').options[0]).toStrictEqual({ value: 'a' }); - expect(bridge.getProps('s').options[1]).toStrictEqual({ value: 'b' }); - expect(bridge.getProps('s').allowedValues).toBeUndefined(); - }); - - it('works with allowedValues (function)', () => { - expect(bridge.getProps('t').options[0]).toStrictEqual({ value: 'a' }); - expect(bridge.getProps('t').options[1]).toStrictEqual({ value: 'b' }); - expect(bridge.getProps('t').allowedValues).toBeUndefined(); - }); - - it('works with options (array)', () => { - expect(bridge.getProps('r').options[0]).toStrictEqual({ - key: 'k1', - label: 'A', - value: 1, - }); - expect(bridge.getProps('r').options[1]).toStrictEqual({ - key: 'k2', - label: 'B', - value: 2, - }); - }); - - it('works with options (function)', () => { - expect(bridge.getProps('rr').options[0]).toStrictEqual({ - key: 'k1', - label: 'A', - value: 1, - }); - expect(bridge.getProps('rr').options[1]).toStrictEqual({ - key: 'k2', - label: 'B', - value: 2, - }); - }); - - it('works with type', () => { - expect(bridge.getProps('aa')).toEqual({ - label: 'AA', - type: 'password', - required: true, - }); - }); - - it('returns no field type', () => { - expect(bridge.getProps('a')).not.toHaveProperty('type'); - expect(bridge.getProps('j')).not.toHaveProperty('type'); - expect(bridge.getProps('d')).not.toHaveProperty('type'); - expect(bridge.getProps('f')).not.toHaveProperty('type'); - expect(bridge.getProps('i')).not.toHaveProperty('type'); - }); - }); - - describe('#getSubfields', () => { - it('works with objects', () => { - expect(bridge.getSubfields('a')).toEqual(['b']); - expect(bridge.getSubfields('a.b')).toEqual(['c']); - }); - - it('works with primitives', () => { - expect(bridge.getSubfields('d')).toEqual([]); - expect(bridge.getSubfields('e')).toEqual([]); - }); - }); - - describe('#getType', () => { - it('works with any type', () => { - expect(bridge.getType('a')).toBe(Object); - expect(bridge.getType('j')).toBe(Array); - expect(bridge.getType('d')).toBe(String); - expect(bridge.getType('f')).toBe(Number); - expect(bridge.getType('i')).toBe(Date); - }); - }); - - describe('#getValidator', () => { - it('calls correct validator', () => { - const bridge = new SimpleSchemaBridge({ - schema: { - ...schema, - validator() { - return (model: UnknownObject) => { - if (typeof model.x !== 'number') { - throw new Error(); - } - - return true; - }; - }, - } as SimpleSchema, - }); - - expect(bridge.getValidator()({})).not.toEqual(null); - expect(bridge.getValidator({})({})).not.toEqual(null); - expect(bridge.getValidator()({ x: 1 })).toEqual(null); - expect(bridge.getValidator({})({ x: 1 })).toEqual(null); - }); - }); -}); diff --git a/packages/uniforms-bridge-simple-schema/__tests__/index.ts b/packages/uniforms-bridge-simple-schema/__tests__/index.ts deleted file mode 100644 index 1c1b5ef31..000000000 --- a/packages/uniforms-bridge-simple-schema/__tests__/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import * as uniformsSimpleSchema from 'uniforms-bridge-simple-schema'; - -it('exports everything', () => { - expect(uniformsSimpleSchema).toEqual({ - default: expect.any(Function), - SimpleSchemaBridge: expect.any(Function), - }); -}); diff --git a/packages/uniforms-bridge-simple-schema/package.json b/packages/uniforms-bridge-simple-schema/package.json deleted file mode 100644 index d87b209d6..000000000 --- a/packages/uniforms-bridge-simple-schema/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "uniforms-bridge-simple-schema", - "version": "4.0.0-alpha.5", - "license": "MIT", - "main": "./cjs/index.js", - "module": "./esm/index.js", - "sideEffects": [ - "cjs/index.js", - "cjs/register.js", - "esm/index.js", - "esm/register.js", - "src/index.ts", - "src/register.ts" - ], - "description": "SimpleSchema bridge for uniforms.", - "repository": "https://github.com/vazco/uniforms/tree/master/packages/uniforms-bridge-simple-schema", - "bugs": "https://github.com/vazco/uniforms/issues", - "funding": "https://github.com/vazco/uniforms?sponsor=1", - "keywords": [ - "form", - "forms", - "react", - "schema", - "simple-schema", - "validation" - ], - "files": [ - "cjs/*.d.ts", - "cjs/*.js", - "esm/*.d.ts", - "esm/*.js", - "src/*.ts", - "src/*.tsx" - ], - "dependencies": { - "invariant": "^2.0.0", - "lodash": "^4.0.0", - "tslib": "^2.2.0", - "uniforms": "^4.0.0-alpha.5" - } -} diff --git a/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts b/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts deleted file mode 100644 index 878312a5a..000000000 --- a/packages/uniforms-bridge-simple-schema/src/SimpleSchemaBridge.ts +++ /dev/null @@ -1,184 +0,0 @@ -import invariant from 'invariant'; -import cloneDeep from 'lodash/cloneDeep'; -import memoize from 'lodash/memoize'; -// @ts-ignore -- This package _is_ typed, but not in all environments. -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; -import { Bridge, UnknownObject, joinName } from 'uniforms'; - -const propsToRemove = ['optional', 'uniforms', 'allowedValues']; - -/** Option type used in SelectField or RadioField */ -type Option = { - disabled?: boolean; - label?: string; - key?: string; - value: Value; -}; - -export default class SimpleSchemaBridge extends Bridge { - schema: SimpleSchema; - - constructor({ schema }: { schema: SimpleSchema }) { - super(); - - this.schema = schema; - - // Memoize for performance and referential equality. - this.getField = memoize(this.getField.bind(this)); - this.getInitialValue = memoize(this.getInitialValue.bind(this)); - this.getProps = memoize(this.getProps.bind(this)); - this.getSubfields = memoize(this.getSubfields.bind(this)); - this.getType = memoize(this.getType.bind(this)); - } - - // TODO: Get rid of this `any`. - getError(name: string, error: any) { - const details = error?.details; - if (!Array.isArray(details)) { - return null; - } - - return details.find(error => error.name === name) || null; - } - - // TODO: Get rid of this `any`. - getErrorMessage(name: string, error: any) { - const scopedError = this.getError(name, error); - return !scopedError - ? '' - : this.schema.messageForError( - scopedError.type, - scopedError.name, - null, - scopedError.details && scopedError.details.value, - ); - } - - // TODO: Get rid of this `any`. - getErrorMessages(error: any) { - if (!error) { - return []; - } - - const { details } = error; - return Array.isArray(details) - ? details.map(error => - this.schema.messageForError( - error.type, - error.name, - null, - error.details && error.details.value, - ), - ) - : [error.message || error]; - } - - getField(name: string) { - const definition = this.schema.getDefinition(name); - - invariant(definition, 'Field not found in schema: "%s"', name); - - return definition; - } - - getInitialValue(name: string): unknown { - const field = this.getField(name); - const defaultValue = field.defaultValue; - if (defaultValue !== undefined) { - return cloneDeep(defaultValue); - } - - if (field.type === Array) { - const item = this.getInitialValue(joinName(name, '$')); - if (item === undefined) { - return []; - } - - const length = field.minCount || 0; - return Array.from({ length }, () => item); - } - - if (field.type === Object) { - const value: UnknownObject = {}; - this.getSubfields(name).forEach(key => { - const initialValue = this.getInitialValue(joinName(name, key)); - if (initialValue !== undefined) { - value[key] = initialValue; - } - }); - return value; - } - - return undefined; - } - - getProps(name: string) { - const { type: fieldType, ...props } = this.getField(name); - props.required = !props.optional; - - if ( - typeof props.uniforms === 'function' || - typeof props.uniforms === 'string' - ) { - props.component = props.uniforms; - } else { - Object.assign(props, props.uniforms); - } - - type OptionList = Option[]; - type Options = OptionList | (() => OptionList); - let options: Options | undefined = props.options; - let allowedValues: unknown[] | (() => unknown[]) | undefined = - props.allowedValues; - - if (typeof options === 'function') { - options = options(); - } - - if (!options && typeof allowedValues === 'function') { - allowedValues = allowedValues(); - } - - if (!options && Array.isArray(allowedValues)) { - options = allowedValues.map(value => ({ value })); - } else if (fieldType === Array) { - try { - const itemProps = this.getProps(`${name}.$`); - if (itemProps.options) { - options = itemProps.options as OptionList; - } - } catch (_) { - // It's fine. - } - } - - propsToRemove.forEach(key => { - if (key in props) { - delete props[key]; - } - }); - - return Object.assign(props, { options }); - } - - getSubfields(name?: string): string[] { - return this.schema.objectKeys(SimpleSchema._makeGeneric(name)); - } - - getType(name: string) { - return this.getField(name).type; - } - - getValidator(options: UnknownObject = { clean: true }) { - const validator = this.schema.validator(options); - return (model: any) => { - try { - // Clean mutate its argument. - validator(options.clean ? cloneDeep({ ...model }) : model); - return null; - } catch (error) { - return error; - } - }; - } -} diff --git a/packages/uniforms-bridge-simple-schema/src/index.ts b/packages/uniforms-bridge-simple-schema/src/index.ts deleted file mode 100644 index 5ee541797..000000000 --- a/packages/uniforms-bridge-simple-schema/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './register'; -export { default, default as SimpleSchemaBridge } from './SimpleSchemaBridge'; diff --git a/packages/uniforms-bridge-simple-schema/src/register.ts b/packages/uniforms-bridge-simple-schema/src/register.ts deleted file mode 100644 index 3d4672fe6..000000000 --- a/packages/uniforms-bridge-simple-schema/src/register.ts +++ /dev/null @@ -1,56 +0,0 @@ -// @ts-ignore -- This package _is_ typed, but not in all environments. -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; -import { Match } from 'meteor/check'; -import { filterDOMProps } from 'uniforms'; - -// Register custom property. -SimpleSchema.extendOptions({ - uniforms: Match.Optional( - Match.OneOf( - String, - Function, - Match.ObjectIncluding({ - component: Match.Optional(Match.OneOf(String, Function)), - }), - ), - ), -}); - -// There's no possibility to retrieve them at runtime. -declare module 'uniforms' { - interface FilterDOMProps { - autoValue: never; - blackbox: never; - custom: never; - decimal: never; - defaultValue: never; - exclusiveMax: never; - exclusiveMin: never; - max: never; - maxCount: never; - min: never; - minCount: never; - optional: never; - regEx: never; - trim: never; - type: never; - } -} - -filterDOMProps.register( - 'autoValue', - 'blackbox', - 'custom', - 'decimal', - 'defaultValue', - 'exclusiveMax', - 'exclusiveMin', - 'max', - 'maxCount', - 'min', - 'minCount', - 'optional', - 'regEx', - 'trim', - 'type', -); diff --git a/packages/uniforms-bridge-simple-schema/tsconfig.cjs.json b/packages/uniforms-bridge-simple-schema/tsconfig.cjs.json deleted file mode 100644 index efc5ca26e..000000000 --- a/packages/uniforms-bridge-simple-schema/tsconfig.cjs.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "baseUrl": "src", - "outDir": "cjs", - "rootDir": "src", - "module": "CommonJS", - "tsBuildInfoFile": "../../node_modules/.cache/uniforms-bridge-simple-schema.cjs.tsbuildinfo" - }, - "include": ["src"], - "references": [{ "path": "../uniforms/tsconfig.cjs.json" }] -} diff --git a/packages/uniforms-bridge-simple-schema/tsconfig.esm.json b/packages/uniforms-bridge-simple-schema/tsconfig.esm.json deleted file mode 100644 index 805301825..000000000 --- a/packages/uniforms-bridge-simple-schema/tsconfig.esm.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "baseUrl": "src", - "outDir": "esm", - "rootDir": "src", - "module": "ES6", - "tsBuildInfoFile": "../../node_modules/.cache/uniforms-bridge-simple-schema.esm.tsbuildinfo" - }, - "include": ["src"], - "references": [{ "path": "../uniforms/tsconfig.esm.json" }] -} diff --git a/packages/uniforms/__mocks__/meteor/aldeed_simple-schema.ts b/packages/uniforms/__mocks__/meteor/aldeed_simple-schema.ts deleted file mode 100644 index 183d458d8..000000000 --- a/packages/uniforms/__mocks__/meteor/aldeed_simple-schema.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const SimpleSchema = { - extendOptions: jest.fn(), - _makeGeneric: jest.fn(name => - typeof name === 'string' ? name.replace(/\.[0-9]+(?=\.|$)/g, '.$') : null, - ), -}; diff --git a/packages/uniforms/__mocks__/meteor/check.ts b/packages/uniforms/__mocks__/meteor/check.ts deleted file mode 100644 index af3fcdef1..000000000 --- a/packages/uniforms/__mocks__/meteor/check.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const Match = { - OneOf: jest.fn(), - Optional: jest.fn(), - ObjectIncluding: jest.fn(), -}; diff --git a/reproductions/package.json b/reproductions/package.json index 9f7a497e0..549e9fd56 100644 --- a/reproductions/package.json +++ b/reproductions/package.json @@ -27,7 +27,6 @@ "uniforms-bootstrap4": "^4.0.0-alpha.0", "uniforms-bootstrap5": "^4.0.0-alpha.0", "uniforms-bridge-json-schema": "^4.0.0-alpha.0", - "uniforms-bridge-simple-schema": "^4.0.0-alpha.0", "uniforms-bridge-simple-schema-2": "^4.0.0-alpha.0", "uniforms-material": "^4.0.0-alpha.0", "uniforms-mui": "^4.0.0-alpha.0", diff --git a/tsconfig.build.json b/tsconfig.build.json index aac9aa6bf..382337b4a 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -14,8 +14,6 @@ { "path": "packages/uniforms-bootstrap5/tsconfig.esm.json" }, { "path": "packages/uniforms-bridge-json-schema/tsconfig.cjs.json" }, { "path": "packages/uniforms-bridge-json-schema/tsconfig.esm.json" }, - { "path": "packages/uniforms-bridge-simple-schema/tsconfig.cjs.json" }, - { "path": "packages/uniforms-bridge-simple-schema/tsconfig.esm.json" }, { "path": "packages/uniforms-bridge-simple-schema-2/tsconfig.cjs.json" }, { "path": "packages/uniforms-bridge-simple-schema-2/tsconfig.esm.json" }, { "path": "packages/uniforms-bridge-zod/tsconfig.cjs.json" }, diff --git a/tsconfig.global.json b/tsconfig.global.json index 5e6861fee..09343ce44 100644 --- a/tsconfig.global.json +++ b/tsconfig.global.json @@ -6,7 +6,6 @@ "tsBuildInfoFile": "node_modules/.cache/global.tsbuildinfo" }, "include": [ - "packages/*/__mocks__", "packages/*/__tests__", "packages/uniforms/__suites__", "scripts", @@ -25,8 +24,6 @@ { "path": "packages/uniforms-bootstrap5/tsconfig.cjs.json" }, { "path": "packages/uniforms-bridge-json-schema/tsconfig.esm.json" }, { "path": "packages/uniforms-bridge-json-schema/tsconfig.cjs.json" }, - { "path": "packages/uniforms-bridge-simple-schema/tsconfig.esm.json" }, - { "path": "packages/uniforms-bridge-simple-schema/tsconfig.cjs.json" }, { "path": "packages/uniforms-bridge-simple-schema-2/tsconfig.esm.json" }, { "path": "packages/uniforms-bridge-simple-schema-2/tsconfig.cjs.json" }, { "path": "packages/uniforms-bridge-zod/tsconfig.esm.json" }, diff --git a/website/package.json b/website/package.json index 08696f8f2..ba75438ee 100644 --- a/website/package.json +++ b/website/package.json @@ -30,7 +30,6 @@ "uniforms-bootstrap4": "^4.0.0-alpha.0", "uniforms-bootstrap5": "^4.0.0-alpha.0", "uniforms-bridge-json-schema": "^4.0.0-alpha.0", - "uniforms-bridge-simple-schema": "^4.0.0-alpha.0", "uniforms-bridge-simple-schema-2": "^4.0.0-alpha.0", "uniforms-bridge-zod": "^4.0.0-alpha.0", "uniforms-material": "^4.0.0-alpha.0", diff --git a/website/types/meteor_aldeed_simple-schema.d.ts b/website/types/meteor_aldeed_simple-schema.d.ts deleted file mode 100644 index 7fc02368e..000000000 --- a/website/types/meteor_aldeed_simple-schema.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module 'meteor/aldeed:simple-schema' { - import SimpleSchemaStatic from 'simpl-schema'; - export class SimpleSchema extends SimpleSchemaStatic { - static _makeGeneric(name?: string): string | undefined; - // This type has to use `any` to match the `simpl-schema` argument type. - static extendOptions(options: Record): void; - objectKeys(name?: string): string[]; - } -}