New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tpluscode/rdfine

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tpluscode/rdfine - npm Package Compare versions

Comparing version 0.2.11 to 0.2.12

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

### [0.2.12](https://github.com/tpluscode/rdfine/compare/v0.2.11...v0.2.12) (2020-01-30)
### Features
* ability to add multiple mixins at once ([9cb5595](https://github.com/tpluscode/rdfine/commit/9cb5595a045e5354115d7ac5e0153ae6ac84b116))
* allow setting initial value as clownface node ([82ca518](https://github.com/tpluscode/rdfine/commit/82ca518892fa4a290b36c7cd7ca14845167bdfd2))
### [0.2.11](https://github.com/tpluscode/rdfine/compare/v0.2.10...v0.2.11) (2020-01-27)

@@ -7,0 +15,0 @@

3

dist/es/lib/decorators/property.js

@@ -76,2 +76,5 @@ import { getPath } from '../path';

}
if (value && typeof value === 'object' && 'term' in value) {
return value.term;
}
return toTerm(value);

@@ -78,0 +81,0 @@ });

@@ -28,5 +28,9 @@ import { fromLiteral } from '../../conversion';

assertSetValue: (value) => {
return typeof value !== 'object' || value.termType === 'Literal';
if (typeof value === 'object') {
const term = 'term' in value ? value.term : value;
return term.termType === 'Literal';
}
return true;
},
});
}

@@ -13,5 +13,12 @@ import { propertyDecorator } from '../property';

assertSetValue: (value) => {
let term = null;
if ('termType' in value) {
return value.termType === 'NamedNode' || value.termType === 'BlankNode';
term = value;
}
else if ('term' in value) {
term = value.term;
}
if (term) {
return term.termType === 'NamedNode' || term.termType === 'BlankNode';
}
return true;

@@ -18,0 +25,0 @@ },

6

dist/es/lib/ResourceFactory.js

@@ -7,4 +7,6 @@ import { createProxy } from './proxy';

}
addMixin(mixin) {
this.__mixins.add(mixin);
addMixin(...mixins) {
mixins.forEach(mixin => {
this.__mixins.add(mixin);
});
}

@@ -11,0 +13,0 @@ createEntity(term, typeAndMixins = []) {

@@ -81,2 +81,5 @@ "use strict";

}
if (value && typeof value === 'object' && 'term' in value) {
return value.term;
}
return toTerm(value);

@@ -83,0 +86,0 @@ });

@@ -29,5 +29,9 @@ "use strict";

}, valueTypeName: type.name, assertSetValue: (value) => {
return typeof value !== 'object' || value.termType === 'Literal';
if (typeof value === 'object') {
const term = 'term' in value ? value.term : value;
return term.termType === 'Literal';
}
return true;
} }));
}
exports.default = default_1;

@@ -11,5 +11,12 @@ "use strict";

}, valueTypeName: 'RdfResource instance', assertSetValue: (value) => {
let term = null;
if ('termType' in value) {
return value.termType === 'NamedNode' || value.termType === 'BlankNode';
term = value;
}
else if ('term' in value) {
term = value.term;
}
if (term) {
return term.termType === 'NamedNode' || term.termType === 'BlankNode';
}
return true;

@@ -16,0 +23,0 @@ } }));

@@ -9,4 +9,6 @@ "use strict";

}
addMixin(mixin) {
this.__mixins.add(mixin);
addMixin(...mixins) {
mixins.forEach(mixin => {
this.__mixins.add(mixin);
});
}

@@ -13,0 +15,0 @@ createEntity(term, typeAndMixins = []) {

@@ -17,3 +17,3 @@ import { Term } from 'rdf-js';

toTerm: (value: T) => Term;
assertSetValue: (value: T | Term) => boolean;
assertSetValue: (value: T | Term | SingleContextClownface) => boolean;
valueTypeName: string;

@@ -20,0 +20,0 @@ initial?: ObjectOrFactory<any, T | N>;

@@ -0,10 +1,13 @@

import { DatasetCore } from 'rdf-js';
import { SingleContextClownface } from 'clownface';
import { RdfResource, ResourceIdentifier } from '../../RdfResource';
import { AccessorOptions, ObjectOrFactory } from '../property';
import { Constructor, Mixin } from '../../ResourceFactory';
declare type InitialValue = SingleContextClownface<DatasetCore, ResourceIdentifier> | RdfResource;
interface ResourceOptions<R extends RdfResource> {
as?: Mixin<any>[] | [Constructor, ...Mixin<any>[]];
initial?: ObjectOrFactory<R, ResourceIdentifier | RdfResource>;
initial?: ObjectOrFactory<R, InitialValue | RdfResource>;
}
declare function resourcePropertyDecorator<R extends RdfResource>(options?: AccessorOptions & ResourceOptions<R>): (protoOrDescriptor: RdfResource<import("rdf-js").DatasetCore<import("rdf-js").Quad>> | import("..").ClassElement, name?: string | number | symbol | undefined) => any;
declare function resourcePropertyDecorator<R extends RdfResource>(options?: AccessorOptions & ResourceOptions<R>): (protoOrDescriptor: RdfResource<DatasetCore<import("rdf-js").Quad>> | import("..").ClassElement, name?: string | number | symbol | undefined) => any;
export default resourcePropertyDecorator;
//# sourceMappingURL=resource.d.ts.map

@@ -21,6 +21,6 @@ import { Clownface } from 'clownface';

constructor(baseClass: Constructor);
addMixin(mixin: Mixin<T> & ShouldApply): void;
createEntity<S>(term: Clownface, typeAndMixins?: Mixin<any>[] | [Constructor, ...Mixin<any>[]]): R & S & ResourceIndexer<R>;
addMixin(...mixins: (Mixin<T> & ShouldApply)[]): void;
createEntity<S>(term: Clownface, typeAndMixins?: Mixin<T>[] | [Constructor, ...Mixin<T>[]]): R & S & ResourceIndexer<R>;
}
export {};
//# sourceMappingURL=ResourceFactory.d.ts.map
{
"name": "@tpluscode/rdfine",
"version": "0.2.11",
"description": "RDF/JS idiomatic, native, enjoyable",
"version": "0.2.12",
"description": "RDF/JS idiomatic, native, effective",
"main": "dist/node/index.js",

@@ -6,0 +6,0 @@ "module": "dist/es/index.js",

@@ -5,6 +5,72 @@ ## RDFine _/rɪdɪˈfaɪn/_

## About
### Idiomatic
RDFine greatly simplifies the manipulation of data in RDF graph ([RDF/JS datasets][dataset])
by wrapping low-level node handling of triples in plain JavaScript objects.
It is also possible to share the JS-RDF bindings between projects as npm packages.
### Native
While plain JS objects are the preferred way to access the graphs, they do not completely
replace the underlying [RDF/JS dataset][dataset]. Both RDFine objects and the dataset can
be modified simultaneously, with changes to one immediately reflected in the other.
### Effective
RDFine makes it super easy to bootstrap a triple-backed project without the need
to drink up the RDF Kool-Aid. Novices will use the idiomatic JS interface to get
the job done quickly, while power users still can take advantage of seamless
integration with [@rdfjs][rdfjs] libraries.
[dataset]: https://rdf.js.org/dataset-spec/
[rdfjs]: https://www.npmjs.com/search?q=rdfjs
## TL;DR; overview
You have RDF triples in an RDF/JS Dataset object
```turtle
@prefix ex: <http://rdfine.ggg/> .
@prefix schema: <http://schema.org/> .
ex:john a schema:Person ;
schema:name "John Doe" ;
schema:spouse ex:jane ;
schema:nationality [
schema:name "USA"
] .
```
You want to create a JS object model to access that data
```typescript
import { namedNode } from '@rdfjs/data-model'
import { RdfResourceImpl } from '@tpluscode/rdfine'
import { loadData } from './data/person'
import { Person, PersonMixin } from './model/Person'
// make rdfine "aware" of object model for schema:Person
RdfResourceImpl.factory.addMixin(PersonMixin)
// create entity through the factory
const john = RdfResourceImpl.factory.createEntity<Person>({
dataset: await loadData(),
term: namedNode('http://rdfine.ggg/john'),
})
// modify the dataset through JS objects
john.nationality = "United States of America"
john.spouse.name = "Jane Doe"
// get the modified dataset, always in sync
const dataset = john._node.dataset
```
## Installation
```shell script
npm i @tplusode/rdfine
npm i @tpluscode/rdfine
```

@@ -11,0 +77,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc