componentsjs

🧩 A semantic dependency injection framework

https://github.com/linkedsoftwaredependencies/components.js

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    1 of 11 committers (9.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.2%) to scientific vocabulary

Keywords

dependency-injection inversion-of-control javascript linked-data typescript

Keywords from Contributors

decentralization federation heterogeneity query-engine rdf sparql triple-pattern-fragments
Last synced: 4 months ago · JSON representation ·

Repository

🧩 A semantic dependency injection framework

Basic Info
Statistics
  • Stars: 42
  • Watchers: 5
  • Forks: 6
  • Open Issues: 42
  • Releases: 3
Topics
dependency-injection inversion-of-control javascript linked-data typescript
Created over 8 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Citation

README.md

Components.js

A semantic dependency injection framework

Build status Coverage Status npm version DOI

This repository contains the source code of Components.js. Full documentation on its usage can be found at http://componentsjs.readthedocs.io/.

Interested in contributing to this project? Have a look at this contribution guide.

Introduction

Components.js is a dependency injection framework for TypeScript and JavaScript projects using JSON(-LD) files.

Instead of hard-wiring software components together, Components.js allows these components to be instantiated and wired together declaratively using semantic configuration files. The advantage of these semantic configuration files is that software components can be uniquely and globally identified using URIs.

Configurations can be written in any RDF serialization, such as JSON-LD.

This software is aimed for developers who want to build modular and easily configurable and rewireable JavaScript applications.

Get started with the TypeScript or JavaScript quick start guide below!

Quick Start (TypeScript)

1. Install dependencies

Components.js can be installed using npm: bash $ npm install componentsjs

Component and module files can be automatically generated using Components-Generator.js: bash $ npm install -D componentsjs-generator

2. Mark your package as a Components.js module

package.json: json { "name": "my-package", "version": "2.3.4", "lsd:module": true, "main": "index.js", "types": "index.d.ts", ... "scripts": { ... "build": "npm run build:ts && npm run build:components", "build:ts": "tsc", "build:components": "componentsjs-generator", "prepare": "npm run build", ... } }

"lsd:module" will allow Components.js to find your module(s) when they are included from other packages.

The "scripts" entry will make sure that all required component files will be generated when building your package.

The componentsjs-generator will look for your compiled TypeScript files (.d.ts) in the lib/ directory. If you use a different output directory for TypeScript (e.g. dist/), you must pass this to the generator using -s flag (e.g. componentsjs-generator -s dist).

3. Create a configuration file to instantiate our class

Assuming a TypeScript class that is exported from the package: typescript export class MyClass { public readonly name: string; constructor(name: string) { this.name = name; } }

config.jsonld: json { "@context": [ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld", "https://linkedsoftwaredependencies.org/bundles/npm/my-package/^2.0.0/components/context.jsonld" ], "@id": "urn:my-package:myInstance", "@type": "MyClass", "name": "John" }

This configuration is a semantic representation of the instantiation of MyClass with name set to "John".

4. Instantiate from config file

```javascript ... import { ComponentsManager } from 'componentsjs';

const manager = await ComponentsManager.build({ mainModulePath: __dirname, // Path to your npm package's root }); await manager.configRegistry.register('config.jsonld'); const myInstance = await manager.instantiate('urn:my-package:myInstance'); ... ```

myInstance is an instance of type MyClass, as defined in the config file.

After running npm run build, you can now execute your program.

Quick Start (JavaScript)

1. Install dependencies

Components.js can be installed using npm: bash $ npm install componentsjs

2. Define your module and its components

Assuming a JavaScript class that is exported from the package: typescript export class MyClass { public readonly name; constructor(name) { this.name = name; } }

module.jsonld: json { "@context": [ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld", { "ex": "http://example.org/" } ], "@id": "ex:MyPackage", "@type": "Module", "requireName": "my-package", "components": [ { "@id": "ex:MyPackage/MyClass", "@type": "Class", "requireElement": "MyClass", "parameters": [ { "@id": "ex:MyPackage/MyClass#name", "unique": true } ], "constructorArguments": [ { "@id": "ex:MyPackage/MyClass#name" } ] } ] }

The npm module my-package exports a class with the name MyClass.

The constructor of MyClass takes a single name argument.

3. Create a configuration file to instantiate our class

config.jsonld: json { "@context": [ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld", { "ex": "http://example.org/", "name": "ex:MyPackage/MyClass#name" } ], "@id": "http://example.org/myInstance", "@type": "ex:MyPackage/MyClass", "name": "John" }

This configuration is a semantic representation of the instantiation of MyClass with name set to "John".

4. Instantiate from config file

```javascript ... import { ComponentsManager } from 'componentsjs';

const manager = await ComponentsManager.build({ mainModulePath: __dirname, // Path to your npm package's root }); await manager.configRegistry.register('config.jsonld'); const myInstance = await manager.instantiate('http://example.org/myInstance'); ... ```

myInstance is an instance of type MyClass, as defined in the config file.

Advanced usage

The ComponentsManager can be customized with the following options:

javascript const manager = await ComponentsManager.build({ // Absolute path to the package root from which module resolution should start. mainModulePath: __dirname, // Callback for registering components and modules // Defaults to an invocation of {@link ComponentRegistry.registerAvailableModules}. moduleLoader: (registry) => {}, // Callback for registering configurations. // Defaults to no config registrations. configLoader: (registry) => {}, // A strategy for constructing instances. // Defaults to {@link ConstructionStrategyCommonJs}. constructionStrategy: new ConstructionStrategyCommonJs(), // If the error state should be dumped into `componentsjs-error-state.json` after failed instantiations. // Defaults to `true`. dumpErrorState: true, // The logging level. // Defaults to `'warn'`. logLevel: 'warn', // The module state. // Defaults to a newly created instance on the {@link mainModulePath}. moduleState: {}, // If JSON-LD context validation should be skipped. // Defaults to `true`. skipContextValidation: true, // If values for parameters should be type-checked. // Defaults to `true`. typeChecking: true, });

Cite

If you are using or extending Components.js as part of a scientific publication, we would appreciate a citation of our article.

bibtex @article{taelman_swj_componentsjs_2022, author = {Taelman, Ruben and Van Herwegen, Joachim and Vander Sande, Miel and Verborgh, Ruben}, title = {Components.js: Semantic Dependency Injection}, journal = {Semantic Web Journal}, year = {2022}, month = jan, url = {https://linkedsoftwaredependencies.github.io/Article-System-Components/} }

License

Components.js is written by Ruben Taelman.

This code is copyrighted by Ghent University – imec and released under the MIT license.

Owner

  • Name: Linked Software Dependencies
  • Login: LinkedSoftwareDependencies
  • Kind: organization
  • Location: Belgium

Improving the reproducibility of software experiments

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite the article."
authors:
- family-names: "Taelman"
  given-names: "Ruben"
title: "Components.js"
version: 1.0.0
doi: 10.5281/zenodo.1243988
date-released: 2021-08-30
url: "https://github.com/LinkedSoftwareDependencies/Components.js"
preferred-citation:
  type: article
  authors:
  - family-names: "Taelman"
    given-names: "Ruben"
  - family-names: "Van Herwegen"
    given-names: "Joachim"
  - family-names: "Vander Sande"
    given-names: "Miel"
  - family-names: "Verborgh"
    given-names: "Ruben"
  doi: "TODO"
  journal: "Semantic Web Journal"
  month: 1
  title: "Components.js: Semantic Dependency Injection"
  year: 2022

GitHub Events

Total
  • Issues event: 5
  • Delete event: 3
  • Issue comment event: 20
  • Push event: 33
  • Pull request event: 8
  • Create event: 9
Last Year
  • Issues event: 5
  • Delete event: 3
  • Issue comment event: 20
  • Push event: 33
  • Pull request event: 8
  • Create event: 9

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 451
  • Total Committers: 11
  • Avg Commits per committer: 41.0
  • Development Distribution Score (DDS): 0.075
Past Year
  • Commits: 15
  • Committers: 7
  • Avg Commits per committer: 2.143
  • Development Distribution Score (DDS): 0.6
Top Committers
Name Email Commits
Ruben Taelman r****n@u****e 417
Joachim Van Herwegen j****h@g****m 12
Renovate Bot b****t@r****m 8
Ruben Verborgh r****n@v****g 5
renovate[bot] 2****]@u****m 3
Jesse Wright 6****r@u****m 1
Jesse Wright j****t@a****u 1
Ruben Taelman r****s@u****m 1
wkerckho w****e@g****m 1
Thomas Dupont t****t@u****e 1
Lander Noterman l****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 79
  • Total pull requests: 56
  • Average time to close issues: 7 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 24
  • Total pull request authors: 9
  • Average comments per issue: 3.35
  • Average comments per pull request: 2.07
  • Merged pull requests: 24
  • Bot issues: 1
  • Bot pull requests: 37
Past Year
  • Issues: 4
  • Pull requests: 11
  • Average time to close issues: about 15 hours
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 1.75
  • Average comments per pull request: 0.36
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 10
Top Authors
Issue Authors
  • rubensworks (22)
  • RubenVerborgh (16)
  • joachimvh (9)
  • woutermont (3)
  • pheyvaer (2)
  • jaxoncreed (2)
  • surilindur (2)
  • jeswr (2)
  • phochste (2)
  • adlerfaulkner (2)
  • angelaraya (2)
  • thhck (2)
  • LanderN (1)
  • renovate[bot] (1)
  • joeitu (1)
Pull Request Authors
  • renovate[bot] (43)
  • joachimvh (10)
  • jeswr (4)
  • termontwouter (2)
  • LanderN (1)
  • Falx (1)
  • RubenVerborgh (1)
  • wkerckho (1)
  • dependabot[bot] (1)
Top Labels
Issue Labels
feature ➕ (23) bug 🐛 (23) feature (14) enhancement (12) recheck-in-latest-version (4) question (1)
Pull Request Labels
bug 🐛 (1) dependencies (1)

Packages

  • Total packages: 2
  • Total downloads:
    • npm 68,334 last-month
  • Total docker downloads: 49,732
  • Total dependent packages: 37
    (may contain duplicates)
  • Total dependent repositories: 399
    (may contain duplicates)
  • Total versions: 61
  • Total maintainers: 1
npmjs.org: componentsjs

A semantic dependency injection framework

  • Versions: 60
  • Dependent Packages: 36
  • Dependent Repositories: 399
  • Downloads: 68,334 Last month
  • Docker Downloads: 49,732
Rankings
Docker downloads count: 0.7%
Dependent packages count: 0.8%
Dependent repos count: 0.8%
Downloads: 1.5%
Average: 2.9%
Stargazers count: 6.6%
Forks count: 7.3%
Maintainers (1)
Last synced: 4 months ago
repo1.maven.org: org.webjars.npm:componentsjs

WebJar for componentsjs

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Stargazers count: 25.5%
Average: 30.3%
Forks count: 31.6%
Dependent repos count: 32.0%
Dependent packages count: 32.0%
Last synced: 4 months ago

Dependencies

package.json npm
  • @rubensworks/eslint-config ^1.0.1 development
  • @types/jest ^27.0.0 development
  • @typescript-eslint/eslint-plugin ^5.0.0 development
  • @typescript-eslint/parser ^5.0.0 development
  • eslint ^7.12.1 development
  • eslint-config-es 3.25.3 development
  • eslint-import-resolver-typescript ^2.3.0 development
  • eslint-plugin-import ^2.22.1 development
  • eslint-plugin-jest ^26.0.0 development
  • eslint-plugin-tsdoc ^0.2.7 development
  • eslint-plugin-unused-imports ^2.0.0 development
  • jest ^27.0.1 development
  • jest-rdf ^1.7.0 development
  • jshint ^2.1.10 development
  • manual-git-changelog ^1.0.1 development
  • n3 ^1.11.1 development
  • pre-commit ^1.2.2 development
  • streamify-string ^1.0.1 development
  • ts-jest ^27.0.1 development
  • typescript ^4.3.5 development
  • @rdfjs/types *
  • @types/minimist ^1.2.0
  • @types/node ^14.14.7
  • @types/semver ^7.3.4
  • jsonld-context-parser ^2.1.1
  • minimist ^1.2.0
  • rdf-data-factory ^1.1.0
  • rdf-object ^1.13.1
  • rdf-parse ^2.0.0
  • rdf-quad ^1.5.0
  • rdf-string ^1.6.0
  • rdf-terms ^1.7.0
  • semver ^7.3.2
  • winston ^3.3.3
yarn.lock npm
  • 720 dependencies
.github/workflows/ci.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-node v2 composite
  • coverallsapp/github-action master composite
.github/workflows/close-issues-no-response.yml actions
  • actions/stale v3 composite
.github/workflows/issue-label-commenter.yml actions
  • actions/checkout v2 composite
  • peaceiris/actions-label-commenter v1 composite
.github/workflows/new-issue-label.yml actions
  • github/issue-labeler v2.5 composite