Skip to content

Commit

Permalink
Merge cd1a365 into 8c34fb1
Browse files Browse the repository at this point in the history
  • Loading branch information
smouillour authored Apr 12, 2024
2 parents 8c34fb1 + cd1a365 commit fed44e6
Show file tree
Hide file tree
Showing 37 changed files with 321 additions and 5,711 deletions.
8 changes: 8 additions & 0 deletions .changeset/seven-bananas-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@talend/json-schema-form-core": patch
---

- JSFC is a fork of https://github.com/json-schema-form/json-schema-form-core : its place is in the Fork folder
- Remove local copy of json-refs and use package instead
- add missing type to fix ts compilation error
- add a polyfill for json-refs: path-browserify
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 14 additions & 7 deletions packages/jsfc/README.md → fork/json-schema-form-core/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# JSON Schema Form Core

[![Gitter](https://img.shields.io/badge/GITTER-JOIN%20CHAT%20%E2%86%92-ff69b4.svg?style=flat-square)](https://gitter.im/json-schema-form/angular-schema-form?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/json-schema-form/json-schema-form-core.svg?branch=development)](https://travis-ci.org/json-schema-form/json-schema-form-core)

Expand All @@ -11,11 +12,13 @@ You **DO NOT** use this file in addition to Angular Schema Form, it is embedded
build into any frameworks using it.

## Work-In-Progress!

There is [test output](docs/test.md) that forms some super basic documentation
and I intend to expand them much further to the point of almost being
useful before I create a proper API and document that.

## Keeping Track

After changing to Webpack 2, this library now includes a detailed version
header which is passed through into `Angular Schema Form` and also the `Bootstrap` decorator bundle

Expand All @@ -31,6 +34,7 @@ header which is passed through into `Angular Schema Form` and also the `Bootstra
```

## Contributing / Plans

The main contributions we need to the core at the moment are related to both the migration
of `Angular Schema Form` features to the core (like templates/builders) and the addition
of an API for use by ASF (Angular) and RSF (React) libraries.
Expand All @@ -40,21 +44,24 @@ Please contact @Anthropic via our [Gitter](https://gitter.im/json-schema-form/an
## Testing it

### With Angular Schema Form

There is a branch in angular-schema-form called `feature/webpack-babel` that integrates the core.
To use it roughly follow these steps:

* Clone angular-schema-form to a **sibling** directory and switch to branch `feature/webpack-babel`
* `npm install` to install dependencies
* `npm run build` to build with the core.
* Use dist/angular-schema-form.js, now with the core from this folder. *No need to also load ObjectPath since it is already included*
- Clone angular-schema-form to a **sibling** directory and switch to branch `feature/webpack-babel`
- `npm install` to install dependencies
- `npm run build` to build with the core.
- Use dist/angular-schema-form.js, now with the core from this folder. _No need to also load ObjectPath since it is already included_

### With Mocha tests

Tests are written in mocha + chai and run trough `npm test`.

When the command `npm run testdoc` is run instead, the tests will also generate a readable
`markdown` file [test.md](docs/test.md) to document elements of the library.

## Notes
* ObjectPath is bundled with json-schema-form-core
* angular-schema-form bundles json-schema-form-core so the user doesn't have to include it as an dependency.
* The code for not using ObjectPath on Angular 1.2 is removed. Could maybe be fixed but I (davidlgj) strongly believe its time to drop Angular 1.2 support since it complicates validation code as well.

- ObjectPath is bundled with json-schema-form-core
- angular-schema-form bundles json-schema-form-core so the user doesn't have to include it as an dependency.
- The code for not using ObjectPath on Angular 1.2 is removed. Could maybe be fixed but I (davidlgj) strongly believe its time to drop Angular 1.2 support since it complicates validation code as well.
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@
"json-schema"
],
"devDependencies": {
"@talend/babel-plugin-assets-api": "^1.3.1",
"@talend/babel-plugin-import-from-index": "^1.7.1",
"@talend/eslint-config": "^13.0.3",
"@talend/eslint-plugin": "^1.1.1",
"@talend/scripts-core": "^16.3.6",
"@talend/scripts-config-react-webpack": "^16.5.1",
"@talend/scripts-config-typescript": "^11.2.1",
"@talend/babel-plugin-import-from-index": "^1.7.1",
"@talend/babel-plugin-assets-api": "^1.3.1",
"@talend/scripts-core": "^16.3.6",
"@types/chai": "^3.5.2",
"@types/node": "^6.14.13",
"json-refs": "^3.0.15",
"rimraf": "^5.0.5",
"webpack": "^5.90.3"
},
"dependencies": {
"json-refs": "3.0.15",
"objectpath": "^1.2.2",
"path-browserify": "^1.0.1",
"tv4": "^1.3.0"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// in the list format.
export default function (titleMap: Array<any>, originalEnum?: any) {
if (!Array.isArray(titleMap)) {
const canonical = [];
const canonical: any = [];
if (originalEnum) {
originalEnum.forEach(value => {
canonical.push({ name: titleMap[value], value });
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import chai from 'chai';
import { describe, it } from 'mocha';

import {
canonicalTitleMap,
jsonref,
merge,
schemaDefaults,
select,
traverseSchema,
sfPath,
traverseForm,
traverseSchema,
validate,
sfPath,
schemaDefaults,
canonicalTitleMap,
jsonref,
} from '.';

chai.should();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as JsonRefs from './../lib/json-refs-standalone';
import * as JsonRefs from 'json-refs';

export function jsonref(schema, callBack) {
let promise = new Promise(function (resolve, reject) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const stripNullType = type => {

// Creates an default titleMap list from an enum, i.e. a list of strings.
const enumToTitleMap = enm => {
const titleMap = []; // canonical titleMap format is a list.
const titleMap: any = []; // canonical titleMap format is a list.
enm.forEach(name => {
titleMap.push({ name, value: name });
});
Expand Down Expand Up @@ -94,7 +94,7 @@ export function stdFormObj(name, schema, options) {
f.validationMessage = schema.validationMessage;
}
if (schema.enumNames) {
f.titleMap = canonicalTitleMap(schema.enumNames, schema['enum']);
f.titleMap = canonicalTitleMap(schema.enumNames, schema.enum);
}
f.schema = schema;

Expand All @@ -107,7 +107,7 @@ export function stdFormObj(name, schema, options) {

/*** Schema types to form type mappings, with defaults ***/
export function text(name, schema, options) {
if (stripNullType(schema.type) === 'string' && !schema['enum']) {
if (stripNullType(schema.type) === 'string' && !schema.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'text';
Expand Down Expand Up @@ -149,25 +149,25 @@ export function checkbox(name, schema, options) {
}

export function select(name, schema, options) {
if (stripNullType(schema.type) === 'string' && schema['enum']) {
if (stripNullType(schema.type) === 'string' && schema.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'select';
if (!f.titleMap) {
f.titleMap = enumToTitleMap(schema['enum']);
f.titleMap = enumToTitleMap(schema.enum);
}
options.lookup[stringify(options.path)] = f;
return f;
}
}

export function checkboxes(name, schema, options) {
if (stripNullType(schema.type) === 'array' && schema.items && schema.items['enum']) {
if (stripNullType(schema.type) === 'array' && schema.items && schema.items.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'checkboxes';
if (!f.titleMap) {
f.titleMap = enumToTitleMap(schema.items['enum']);
f.titleMap = enumToTitleMap(schema.items.enum);
}
options.lookup[stringify(options.path)] = f;
return f;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fed44e6

Please sign in to comment.