Browse Source

cd-schemas as library - minor fixes

Leszek Wiesner 4 years ago
parent
commit
3fb286f433

+ 3 - 0
content-directory-schemas/.gitignore

@@ -5,3 +5,6 @@ schemas/entities
 schemas/entityBatches
 schemas/entityReferences
 types/entities
+
+# Build
+lib

+ 3 - 1
content-directory-schemas/package.json

@@ -3,8 +3,10 @@
   "version": "0.1.0",
   "description": "JSON schemas, inputs and related tooling for Joystream content directory 2.0",
   "author": "Joystream contributors",
+  "main": "lib/index.js",
   "scripts": {
-    "lint": "eslint ./ --ext .ts",
+    "build": "tsc --build tsconfig.lib.json",
+    "lint": "eslint ./ --ext .ts --ignore-path .gitignore",
     "ts-check": "tsc --noEmit --pretty",
     "pretty": "prettier ./ --write --ignore-path .gitignore",
     "validate": "ts-node ./scripts/validate.ts",

+ 1 - 1
content-directory-schemas/scripts/devInitAliceLead.ts

@@ -1,7 +1,7 @@
 import { types } from '@joystream/types'
 import { ApiPromise, WsProvider } from '@polkadot/api'
 import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { ExtrinsicsHelper, getAlicePair } from './helpers/extrinsics'
+import { ExtrinsicsHelper, getAlicePair } from '../src/helpers/extrinsics'
 
 async function main() {
   // Init api

+ 4 - 4
content-directory-schemas/scripts/initializeContentDir.ts

@@ -2,12 +2,12 @@ import { CreateClass } from '../types/extrinsics/CreateClass'
 import { AddClassSchema } from '../types/extrinsics/AddClassSchema'
 import { types } from '@joystream/types'
 import { ApiPromise, WsProvider } from '@polkadot/api'
-import { getInputs } from './helpers/inputs'
+import { getInputs } from '../src/helpers/inputs'
 import fs from 'fs'
 import path from 'path'
-import { EntityBatch } from 'types/EntityBatch'
-import { InputParser } from './helpers/InputParser'
-import { ExtrinsicsHelper, getAlicePair } from './helpers/extrinsics'
+import { EntityBatch } from '../types/EntityBatch'
+import { InputParser } from '../src/helpers/InputParser'
+import { ExtrinsicsHelper, getAlicePair } from '../src/helpers/extrinsics'
 
 // Save entity operations output here for easier debugging
 const ENTITY_OPERATIONS_OUTPUT_PATH = path.join(__dirname, '../operations.json')

+ 1 - 1
content-directory-schemas/scripts/inputSchemasToEntitySchemas.ts

@@ -10,7 +10,7 @@ import {
   VecPropertyVariant,
 } from '../types/extrinsics/AddClassSchema'
 import PRIMITIVE_PROPERTY_DEFS from '../schemas/propertyValidationDefs.schema.json'
-import { getInputs } from './helpers/inputs'
+import { getInputs } from '../src/helpers/inputs'
 import { JSONSchema7 } from 'json-schema'
 
 const SINGLE_ENTITY_SCHEMAS_LOCATION = path.join(__dirname, '../schemas/entities')

+ 1 - 1
content-directory-schemas/scripts/validate.ts

@@ -1,6 +1,6 @@
 // TODO: Add entity batches validation
 import Ajv from 'ajv'
-import { FetchedInput, getInputs, InputType, INPUT_TYPES } from './helpers/inputs'
+import { FetchedInput, getInputs, InputType, INPUT_TYPES } from '../src/helpers/inputs'
 import path from 'path'
 import fs from 'fs'
 import $RefParser from '@apidevtools/json-schema-ref-parser'

+ 2 - 2
content-directory-schemas/scripts/helpers/InputParser.ts → content-directory-schemas/src/helpers/InputParser.ts

@@ -12,8 +12,8 @@ import {
 import { isSingle, isReference } from './propertyType'
 import { ApiPromise } from '@polkadot/api'
 import { JoyBTreeSet } from '@joystream/types/common'
-import { CreateClass } from 'types/extrinsics/CreateClass'
-import { EntityBatch } from 'types/EntityBatch'
+import { CreateClass } from '../../types/extrinsics/CreateClass'
+import { EntityBatch } from '../../types/EntityBatch'
 
 export class InputParser {
   private api: ApiPromise

+ 0 - 0
content-directory-schemas/scripts/helpers/extrinsics.ts → content-directory-schemas/src/helpers/extrinsics.ts


+ 4 - 0
content-directory-schemas/src/helpers/index.ts

@@ -0,0 +1,4 @@
+export { ExtrinsicsHelper, getAlicePair } from './extrinsics'
+export { InputParser } from './InputParser'
+export { getInputs, getInputsLocation } from './inputs'
+export { isReference, isSingle } from './propertyType'

+ 0 - 0
content-directory-schemas/scripts/helpers/inputs.ts → content-directory-schemas/src/helpers/inputs.ts


+ 6 - 1
content-directory-schemas/scripts/helpers/propertyType.ts → content-directory-schemas/src/helpers/propertyType.ts

@@ -1,4 +1,9 @@
-import { Property, ReferenceProperty, SinglePropertyType, SinglePropertyVariant } from 'types/extrinsics/AddClassSchema'
+import {
+  Property,
+  ReferenceProperty,
+  SinglePropertyType,
+  SinglePropertyVariant,
+} from '../../types/extrinsics/AddClassSchema'
 
 type PropertyType = Property['property_type']
 

+ 1 - 1
content-directory-schemas/tsconfig.json

@@ -23,5 +23,5 @@
       "@polkadot/api/augment": ["../types/augment-codec/augment-api.ts"]
     }
   },
-  "include": [ "scripts/**/*", "typings/**/*" ]
+  "include": [ "src/**/*", "scripts/**/*", "typings/**/*" ]
 }

+ 7 - 0
content-directory-schemas/tsconfig.lib.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "include": ["src/**/*"],
+  "compilerOptions": {
+    "outDir": "lib"
+  }
+}