1.0.0 • Published 2 years ago

ep-node-lib v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Lista componenti (Aggiornata al 24 Marzo 2021)

ComponenteVersioneDescrizioneApp di TestFrontendZero ConfReferenteDipende da
node-fs-store1.0.12 (Stabile)File System StoreFVilli
node-arango-store1.0.0Store persistito in arango dbDMignini
node-socketio1.0.19 (Stabile)Semplificazione Socketiongx-socketioFVilli
node-p2p1.0.32 (Stabile)Semplificazione Peer to Peerngx-p2pFVilli
node-mqtt1.0.5 (Stabile)Semplificazione Mqttngx-mqttFVilli
node-scheduler1.0.2 (Stabile)SchedulazioneDMignini
node-queue1.0.2 (Stabile)Implementazione CodaFVillinode-fs-store
node-mailer1.0.0 (Stabile)Semplificazione invio emailFVilli
node-xls-parser1.0.0 (Non Stabile)Parsing XLS e CSVFVilli
node-xls-creator1.0.1 (Stabile)Create XLS fileFVilli
node-language1.0.0 (stabile)tiny wrapper di NLP.jsNo (Ava tests)FVilli
pg-ingestor2.2.4 (stabile)crea,importa,modifica dati in postgresFVilli

EP-NODE-LIB

è una libreria di moduli node.

Come faccio a modificare o aggiungere pacchetti a questa libreria ?

Configurare l'ambiente di lavoro

Ogni modulo è contenuto nella propria cartella, ed avrà il proprio package.json. Installare le dipendenze dei vari moduli con npm i nomepacchetto a livello di progetto (sulla root del progetto) e referenziare i pacchetti come peerDependencies nel package.json del modulo che intendiamo sviluppare.

Configurare npmrc

è il file di configurazione di npm e si trova di solito nella home dell'utente - %userprofile% su windows. col comando npm config ls potrete scoprire dove è il vostro file .npmrc, e con npm config ls -l avrete una lista di tutte le configurazioni di npm.

Per poter usare il repository, aggiungere al file le seguenti righe:

@ep-framework:registry=https://gitlab.com/api/v4/packages/npm/

per poter scaricare i pacchetti dal repository aggiungere:

//gitlab.com/api/v4/packages/npm/:_authToken=5M2XXh1XY7HefdQPHdKV

infine per poter pubblicare i pacchetti nel repository aggiungere:

//gitlab.com/api/v4/projects/21569962/packages/npm/:_authToken=5M2XXh1XY7HefdQPHdKV

Se non siete in possesso di un token per aggiungere/scaricare pacchetti dovrete richiederne uno.

Configurare il package.json e il tsconfig.json

partire dal seguente modello:

package.json

{
  "name": "@ep-framework/node-socket.io",
  "version": "1.0.4",
  "main": "./build/index.js",
  "types": "./build/index.d.ts",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "prestart": "tsc",
    "start": "node ./build/index.js",
    "prepublish": "tsc"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/cors": "^2.8.7",
    "@types/express": "^4.17.8",
    "@types/node": "^14.11.2",
    "@types/socket.io": "^2.1.11",
    "typescript": "^4.0.3"
  },
  "peerDependencies": {
    "chalk": "^4.1.0",
    "cors": "^2.8.5",
    "delay": "^4.4.0",
    "express": "^4.17.1",
    "guid-typescript": "^1.0.9",
    "rxjs": "^6.6.3",
    "socket.io": "^2.3.0"
  },
  "publishConfig": {
    "@ep-framework:registry": "https://gitlab.com/api/v4/projects/21569962/packages/npm/"
  },
  "description": ""
}

tsconfig.json

{
    "compilerOptions": {
        "target": "es2019",
        "module": "commonjs",
        "moduleResolution": "node",
        "allowJs": false,
        "declaration": true,
        "sourceMap": false,
        "outDir": "./build",
        "noImplicitAny": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "lib": [
            "es2020"
        ]
    },
    "compileOnSave": true,
    "include": [
        "./src/**/*"
    ]
}

I nomi dei pacchetti devono cominciare con node, trattandosi di moduli node. Referenziare nel pacchetto le dipendenze di sviluppo e le peerDependencies. se lo script è molto complesso aggiustare il file package.json e ts.lib di conseguenza, altrimenti si possono usare quelli d'esempio, modificando opportunamente nomi e dipendenze. L'ultima sezione del package.json serve per pubblicare il pacchetto sul progetto ep-node-lib (21569962)

Pubblicare un pacchetto

una volta che tutto l'ambiente è configurato a dovere, basterà lanciare il comando npm publish nella cartella del modulo che si vuole pubblicare.

Come faccio ad installare/utilizzare uno di questi pacchetti ?

consulta la sezione Configurare npmrc - quando npm è correttamente configurato basterà eseguire il seguente comando per instalalre i pacchetti:

npm i @ep-framework/nomepachetto

lista pacchetti (aggiornata al 27/10/2020)

1. socketio-svr
> npm i @ep-framework/socketio-svr
2. p2p
> npm i @ep-framework/p2p

XLS-PARSER

Ingestor options

ParserActivityOptions = {
  id?: number; // for readability of sheet models
  xlsSourceName?: string;
  modelFilePath?: string; // path for model; default is /chache
  createSchema?: boolean; // not implemented yet
  onlySchema?: boolean; // not implemented yet
  sheetIgnore?: string[]; // sheet to be ignored
  sheetDetail?: { [sheetName: string]: SheetOption }; // options for sheet or each sheet 
  onlyDetailedSheets?: boolean; // parse only sheets which is present on sheetDetail
};
SheetOption = {
  uniqueColumns?: boolean; // if we have two or more same columns, only one column will be parsed
  headerRow?: number; // on which row header is; default is 0
  rowStart?: number; // from which row data begin (example: you can skip first 10 rows, just make count headerRow + 10) default is 1
  collStart?: number; // from which coll to start
  rowEnd?: number; // on which row to stop parsing
  collEnd?: number; // on which coll to end parsing
  maxValueFreq?: number; // not implemented yet
  columnType?: { [id: string]: string }; // ex: string, number...
  keyFieldHash?: boolean; // in the end of parsing, it will add to final result a hash code of e each row to row
  validationFields?: string[]; // if value of any row of this column is empty the row will be skiped 
  removeSpaceFromHeaders?: boolean;
  fieldNameWithColumnNumber?: boolean;
  parseOnlyColumns?: Array<string>; // permit to choose columns which will be parsed
};
ParserActivityResult = { 
  error: any; 
  session: string; 
  sheetParsed: Array<SheetParsed>; // result of parsing
};
SheetParsed = {
  name: string;
  fields: Array<SheetField>; // is a result of headers parsing
  ignoredFields: Array<SheetField>;
  data?: Array<Array<any>>; // is a result of rows parsing
  file: FileInfo;
  xlsxNpmLibVersion: string;
  model: Array<SheetField>; // is a result of headers parsing, and is used to create model
};
SheetField = {
  name: string;
  column: number; // defacto index of column in sheet
  idx: number; // index of column in result
  dataType: string; // ex: string, number...
  format?: { [id: string]: number };
  symbol: string;
  cellHeader: string; // position of cell in sheet. Ex: D21
  analysis?: CellAnalysis;
};
 CellAnalysis = {
  samples: number;
  typeFrequencies: { [id: string]: number };
  valueFrequencies: { [id: string]: number }; // how often do we see value
};

Pubblicazione dei pacchetti nel Package Registry

npm config set '//gitlab.com/api/v4/projects/21569962/packages/npm/:_authToken' "HLxMscvzzysBELW6aLpQ"

perchè 21569962 è l'id di questo repository (vedere package.json)

invece HLxMscvzzysBELW6aLpQ è un token creato a livello di gruppo che permette la pubblicazione nel Package Registry