Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/paris

Package Overview
Dependencies
Maintainers
9
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/paris - npm Package Compare versions

Comparing version 1.10.3 to 1.11.0

test/mock/comment-status.entity.ts

0

.vscode/settings.json

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ # [1.3.6] (2018-11-25)

@@ -0,0 +0,0 @@ # Contributor Covenant Code of Conduct

17

dist/lib/api/repository/readonly-repository.js

@@ -1,8 +0,11 @@

var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};

@@ -9,0 +12,0 @@ import { cloneDeep } from "lodash-es";

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -6,0 +9,0 @@ extendStatics(d, b);

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -6,0 +9,0 @@ extendStatics(d, b);

@@ -10,4 +10,4 @@ import { entityFieldsService } from "../services/entity-fields.service";

return function (entityPrototype, propertyKey) {
var propertyConstructor = Reflect.getMetadata("design:type", entityPrototype, propertyKey);
fieldConfig = fieldConfig || {};
var propertyConstructor = fieldConfig.type || Reflect.getMetadata("design:type", entityPrototype, propertyKey);
var field = Object.assign({}, fieldConfig);

@@ -14,0 +14,0 @@ if (!field.id)

@@ -17,2 +17,6 @@ import { DataEntityType } from "../api/entity/data-entity.base";

/**
* Optional type constructor to override the type Paris gets from decoratorMetadata. Useful for using Paris without emitDecoratorMetadata
*/
type?: any;
/**
* Specifies which property in the raw data should be assigned to the model's property.

@@ -19,0 +23,0 @@ * By default, Paris looks for a property of the same name as the property in the model. i.e:

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -27,6 +30,5 @@ extendStatics(d, b);

}
var _a;
__decorate([
EntityField(),
__metadata("design:type", typeof (_a = typeof TId !== "undefined" && TId) === "function" && _a || Object)
__metadata("design:type", Object)
], EntityModelBase.prototype, "id", void 0);

@@ -33,0 +35,0 @@ return EntityModelBase;

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -6,0 +9,0 @@ extendStatics(d, b);

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -6,0 +9,0 @@ extendStatics(d, b);

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -6,0 +9,0 @@ extendStatics(d, b);

@@ -11,2 +11,11 @@ import { DataAvailability } from "./data-availability.enum";

/**
* If true, the entity fields parsing will be case insensitive.
* e.g, a value for a field named "ProviderName" will be parsed into fields: "providerName", "providername", "ProviderName", "PROVIDERNAME",
* and any other class field that satisfies field.toLowerCase() === "ProviderName".toLowerCase().
* This logic is applied recursively to all sub-entities as well (fields of the entity that are objects themselves, and their sub-entities, and so on).
* Notice that casing of fields on the raw "fieldData" object passed to the entity's "parse" function, will remain as is.
* @default false
*/
ignoreFieldsCasing?: boolean;
/**
* The {DataAvailability} mode for fetching data.

@@ -13,0 +22,0 @@ */

@@ -1,8 +0,11 @@

var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};

@@ -9,0 +12,0 @@ import { of } from "rxjs";

@@ -35,5 +35,10 @@ import { ModelBase } from "../config/model.base";

/**
* If @rawData is an object, this method will return the same object, with all its keys lowercased.
* The function is not recursive, since it's anyway called on each sub-model.
*/
static lowercaseKeysOfRawData<TRawData extends any = any>(rawData: TRawData): any;
/**
* Given an EntityField configuration and the raw data provided to the entity's modeler, returns the raw data to use for that field.
*/
static getFieldRawData<TRawData extends any = any>(entityField: Field, rawData: TRawData): any;
static getFieldRawData<TRawData extends any = any>(entityField: Field, rawData: TRawData, ignoreCase: boolean): any;
/**

@@ -40,0 +45,0 @@ * Gets the data to be assigned in a model to the specified field.

@@ -35,4 +35,6 @@ import { ModelBase } from "../config/model.base";

var entityIdProperty = entity.idProperty || this.paris.config.entityIdProperty, modelData = {}, subModels = [];
if (entity instanceof ModelEntity)
modelData.id = rawData[entityIdProperty];
if (options.ignoreFieldsCasing) {
rawData = Modeler.lowercaseKeysOfRawData(rawData);
entityIdProperty = typeof (entityIdProperty) === "string" ? entityIdProperty.toLowerCase() : entityIdProperty;
}
var getModelDataError = new Error("Failed to create " + entity.singularName + ".");

@@ -58,3 +60,3 @@ if (typeof entity.modelWith === 'function') {

}
var entityFieldRawData = Modeler.getFieldRawData(entityField, rawData);
var entityFieldRawData = Modeler.getFieldRawData(entityField, rawData, options.ignoreFieldsCasing);
if (entityField.parse) {

@@ -86,2 +88,4 @@ try {

});
if (entity instanceof ModelEntity)
modelData.id = rawData[entityIdProperty];
var model$;

@@ -151,5 +155,23 @@ if (subModels.length) {

/**
* If @rawData is an object, this method will return the same object, with all its keys lowercased.
* The function is not recursive, since it's anyway called on each sub-model.
*/
Modeler.lowercaseKeysOfRawData = function (rawData) {
if (rawData instanceof Object && !(rawData instanceof Array)) {
var newRawData = {};
for (var key in rawData) {
if (rawData.hasOwnProperty(key)) {
newRawData[key.toLowerCase()] = rawData[key];
}
}
return newRawData;
}
else {
return rawData;
}
};
/**
* Given an EntityField configuration and the raw data provided to the entity's modeler, returns the raw data to use for that field.
*/
Modeler.getFieldRawData = function (entityField, rawData) {
Modeler.getFieldRawData = function (entityField, rawData, ignoreCase) {
var fieldRawData;

@@ -159,3 +181,3 @@ if (entityField.data) {

for (var i = 0, path = void 0; i < entityField.data.length && fieldRawData === undefined; i++) {
path = entityField.data[i];
path = ignoreCase ? entityField.data[i].toLowerCase() : entityField.data[i];
var value = path === FIELD_DATA_SELF ? rawData : get(rawData, path);

@@ -167,6 +189,6 @@ if (value !== undefined && value !== null)

else
fieldRawData = entityField.data === FIELD_DATA_SELF ? rawData : get(rawData, entityField.data);
fieldRawData = entityField.data === FIELD_DATA_SELF ? rawData : get(rawData, ignoreCase ? entityField.data.toLowerCase() : entityField.data);
}
else
fieldRawData = rawData[entityField.id];
fieldRawData = rawData[ignoreCase ? entityField.id.toLowerCase() : entityField.id];
return fieldRawData;

@@ -173,0 +195,0 @@ };

@@ -1,8 +0,11 @@

var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};

@@ -9,0 +12,0 @@ import * as jsonStringify from 'json-stringify-safe';

@@ -0,0 +0,0 @@ # Paris

@@ -0,0 +0,0 @@ const gulp = require('gulp');

export * from "./lib/main";
{
"_args": [
[
"json-stringify-safe@5.0.1",
"/mnt/c/Users/aagreenw/code/paris"
]
],
"_development": true,
"_from": "json-stringify-safe@5.0.1",
"_id": "json-stringify-safe@5.0.1",
"_inBundle": false,
"_integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"_location": "/json-stringify-safe",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "json-stringify-safe@5.0.1",
"name": "json-stringify-safe",
"escapedName": "json-stringify-safe",
"rawSpec": "5.0.1",
"saveSpec": null,
"fetchSpec": "5.0.1"
},
"_requiredBy": [
"/",
"/conventional-changelog-writer",
"/request"
],
"_resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"_spec": "5.0.1",
"_where": "/mnt/c/Users/aagreenw/code/paris",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me"
},
"bugs": {
"url": "https://github.com/isaacs/json-stringify-safe/issues"
},
"contributors": [
{
"name": "Andri Möll",
"email": "andri@dot.ee",
"url": "http://themoll.com"
}
],
"name": "json-stringify-safe",
"version": "5.0.1",
"description": "Like JSON.stringify, but doesn't blow up on circular refs.",
"devDependencies": {
"mocha": ">= 2.1.0 < 3",
"must": ">= 0.12 < 0.13",
"sinon": ">= 1.12.2 < 2"
},
"homepage": "https://github.com/isaacs/json-stringify-safe",
"keywords": [

@@ -61,13 +11,22 @@ "json",

],
"homepage": "https://github.com/isaacs/json-stringify-safe",
"bugs": "https://github.com/isaacs/json-stringify-safe/issues",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"contributors": [
"Andri Möll <andri@dot.ee> (http://themoll.com)"
],
"license": "ISC",
"main": "stringify.js",
"name": "json-stringify-safe",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/json-stringify-safe.git"
"url": "git://github.com/isaacs/json-stringify-safe"
},
"main": "stringify.js",
"scripts": {
"test": "node test.js"
},
"version": "5.0.1"
"devDependencies": {
"mocha": ">= 2.1.0 < 3",
"must": ">= 0.12 < 0.13",
"sinon": ">= 1.12.2 < 2"
}
}
{
"name": "@microsoft/paris",
"version": "1.10.3",
"version": "1.11.0",
"description": "Library for the implementation of Domain Driven Design with TypeScript + RxJS",

@@ -83,3 +83,3 @@ "repository": {

"typedoc": "^0.11.1",
"typescript": "^2.7.2",
"typescript": "3.1.8",
"zone.js": ">=0.8.7"

@@ -86,0 +86,0 @@ },

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

**🚧🚧🚧Danger🚧🚧🚧:**
Paris is unmaintained. The new decorators proposal, the new RxJS syntax, `useDeclareForClassFields` in modern TypeScript and modern decorator metadata meant that in order to property maintain Paris it'd need an effective rewrite. We no longer use Angular for new code internally and our React/MobX code does not use RxJS.
We are gradually migrating our internal code from it to our new next-gen data modeling framework. It _may_ eventually be open source but honestly that's a lot of work so we'll see. It is inspired by Paris but does not share any code with it.
You are free to use this code and we _will_ take pull requests but we will not regularly fix bugs or draft new releases.
# Paris

@@ -7,4 +16,2 @@

Paris is a data management library for webapps, using TypeScript and RxJS to implement Domain-Driven Design.
*Paris, fashion capital of the world, where all the **models** want to be*.

@@ -96,2 +103,2 @@

## Testing
Unit tests are written using [Jest](https://jestjs.io/), and executed with [ts-jest](https://github.com/kulshekhar/ts-jest).
Unit tests are written using [Jest](https://jestjs.io/), and executed with [ts-jest](https://github.com/kulshekhar/ts-jest).

@@ -0,0 +0,0 @@ import resolve from 'rollup-plugin-node-resolve';

@@ -0,0 +0,0 @@ import { DataStoreService } from "../../lib/data_access/data-store.service";

@@ -0,0 +0,0 @@ import {ApiCall} from "../../lib/config/decorators/api-call.decorator";

@@ -0,0 +0,0 @@ import {of} from "rxjs";

interface MockConfigData {
version: number
}

@@ -0,0 +0,0 @@ import {ModelBase} from "../../lib/config/model.base";

@@ -0,0 +0,0 @@ import {ModelBase} from "../../lib/config/model.base";

@@ -0,0 +0,0 @@ import {EntityModelBase} from "../../lib/config/entity-model.base";

@@ -0,0 +0,0 @@ import {Entity} from "../../lib/config/decorators/entity.decorator";

@@ -0,0 +0,0 @@ import {Todo} from "./todo.entity";

@@ -0,0 +0,0 @@ import { EntityModelBase } from '../../lib/config/entity-model.base';

@@ -0,0 +0,0 @@ import { ApiCallModel } from "../../lib/api/api-calls/api-call.model";

@@ -0,0 +0,0 @@ import 'reflect-metadata';

@@ -6,2 +6,3 @@ import {forkJoin, Observable, of} from 'rxjs';

import {Todo} from "../mock/todo.entity";
import {Comment} from "../mock/comment.entity";
import {DataEntityType} from "../../lib/api/entity/data-entity.base";

@@ -23,2 +24,4 @@ import {Tag} from "../mock/tag.value-object";

import {Dog} from "../mock/dog.entity";
import {User, UserType} from "../mock/user.entity";
import {commentStatusValues} from "../mock/comment-status.entity";

@@ -140,3 +143,3 @@ describe('Modeler', () => {

it('uses the id of the field if no data was specified', () => {
expect(Modeler.getFieldRawData(baseField, rawData)).toEqual(rawData.name);
expect(Modeler.getFieldRawData(baseField, rawData, false)).toEqual(rawData.name);
});

@@ -146,3 +149,3 @@

const fieldConfig = Object.assign({ data: 'alias' }, baseField);
expect(Modeler.getFieldRawData(fieldConfig, rawData)).toEqual(rawData[fieldConfig.data]);
expect(Modeler.getFieldRawData(fieldConfig, rawData, false)).toEqual(rawData[fieldConfig.data]);
});

@@ -152,3 +155,3 @@

const fieldConfig = Object.assign({ data: 'fullName.firstName' }, baseField);
expect(Modeler.getFieldRawData(fieldConfig, rawData)).toEqual(rawData.fullName.firstName);
expect(Modeler.getFieldRawData(fieldConfig, rawData, false)).toEqual(rawData.fullName.firstName);
});

@@ -158,3 +161,3 @@

const fieldConfig = Object.assign({ data: ['exactName', 'alias', "name"] }, baseField);
expect(Modeler.getFieldRawData(fieldConfig, rawData)).toEqual(rawData.alias);
expect(Modeler.getFieldRawData(fieldConfig, rawData, false)).toEqual(rawData.alias);
});

@@ -164,3 +167,3 @@

const fieldConfig = Object.assign({ data: ['exactName', 'fullName.firstName', 'alias', "name"] }, baseField);
expect(Modeler.getFieldRawData(fieldConfig, rawData)).toEqual(rawData.fullName.firstName);
expect(Modeler.getFieldRawData(fieldConfig, rawData, false)).toEqual(rawData.fullName.firstName);
});

@@ -170,6 +173,99 @@

const fieldConfig = Object.assign({ data: FIELD_DATA_SELF }, baseField);
expect(Modeler.getFieldRawData(fieldConfig, rawData)).toEqual(rawData);
expect(Modeler.getFieldRawData(fieldConfig, rawData, false)).toEqual(rawData);
})
});
describe('ignoreFieldsCasing', () => {
const commentRawData = {
CommentId: 'comment1',
COMMENT: 'Hello world!',
StatuS: 2,
createdBy: {
UserName: 'nitsanamit',
age: 26,
NickNames: ['nits', 'namit'],
address: {
city: 'Herzliya',
},
user_type: UserType.ADMIN
},
liked: [
{
username: 'billgates',
AGE: 56,
Address: {
city: 'California',
}
},
{
Name: 'Robert',
UserName: 'Spongbob',
age: 5,
NickNames: ['Squarepants'],
address: {
City: 'Bikini Bottom',
},
User_Type: UserType.USER
},
]
};
const commentEntityConfig = (<DataEntityType<Comment>>Comment).entityConfig;
let commentItem$:Observable<Comment>;
beforeEach(() => {
commentItem$ = paris.modeler.modelEntity(commentRawData, commentEntityConfig, {ignoreFieldsCasing: true});
});
afterEach(() => {
jest.restoreAllMocks();
});
it('ignores casing of simple entity fields', done => {
commentItem$.subscribe((comment: Comment) => {
expect(comment.id).toEqual(commentRawData.CommentId);
expect(comment.comment).toEqual(commentRawData.COMMENT);
expect(comment.status).toEqual(commentStatusValues[commentRawData.StatuS]);
done();
});
});
it('ignores casing of recursive entity models', done => {
commentItem$.subscribe((comment: Comment) => {
expect(comment.CreatedBy.name).toEqual(commentRawData.createdBy.UserName);
expect(comment.CreatedBy.Age).toEqual(commentRawData.createdBy.age);
expect(comment.CreatedBy.nickNames).toEqual(commentRawData.createdBy.NickNames);
expect(comment.CreatedBy.city).toEqual(commentRawData.createdBy.address.city);
expect(comment.CreatedBy.USER_TYPE).toEqual(commentRawData.createdBy.user_type);
done();
});
});
it('ignores casing of array properties', done => {
commentItem$.subscribe((comment: Comment) => {
expect(comment.Liked[0].name).toEqual(commentRawData.liked[0].username);
expect(comment.Liked[0].Age).toEqual(commentRawData.liked[0].AGE);
expect(comment.Liked[0].nickNames).toStrictEqual([]);
expect(comment.Liked[0].city).toEqual(commentRawData.liked[0].Address.city);
expect(comment.Liked[0].USER_TYPE).toEqual((<DataEntityType<User>>User).entityConfig.fields.get('USER_TYPE').defaultValue);
expect(comment.Liked[1].name).toEqual(commentRawData.liked[1].UserName);
expect(comment.Liked[1].Age).toEqual(commentRawData.liked[1].age);
expect(comment.Liked[1].nickNames).toEqual(commentRawData.liked[1].NickNames);
expect(comment.Liked[1].USER_TYPE).toEqual(commentRawData.liked[1].User_Type);
done();
});
});
it('keeps the fieldsData original casing for entity fields with a "parse" function', done => {
commentItem$.subscribe((comment: Comment) => {
expect(comment.Liked[1].city).toBeNull();
done();
});
});
});
describe('defaultValue', () => {

@@ -176,0 +272,0 @@ it("doesn't set default value to a field that has value", done => {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ module.exports = {

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