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

@wix/motion-edm-autogen-common

Package Overview
Dependencies
Maintainers
33
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/motion-edm-autogen-common - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

138

dist/cjs/__tests__/unit.spec.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _motionEdmAutogenTestContext = require("@wix/motion-edm-autogen-test-context");
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
var _dedentJs = _interopRequireDefault(require("dedent-js"));
var _lodash = require("lodash");

@@ -16,6 +10,2 @@

describe('generators commons', () => {
const object = {
a: (0, _motionRuntimeTestContext.aNumber)(),
b: (0, _motionRuntimeTestContext.aString)()
};
describe('constants', () => {

@@ -38,54 +28,2 @@ test('exposes a constant for the default query property name', () => {

});
describe('prettyJsonStringify', () => {
test('returns a pretty formatted json string', () => {
expect((0, _.prettyJsonStringify)(object)).toStrictEqual((0, _dedentJs.default)`
{
"a": ${object.a},
"b": "${object.b}"
}
`);
});
});
describe('edmCodeRootRelativePathInRepo', () => {
test('returns the relative code path of the given edm', () => {
const edmName = (0, _motionEdmAutogenTestContext.anEdmName)();
expect((0, _.edmCodeRootRelativePathInRepo)(edmName)).toStrictEqual(`autogenerated-code/${edmName}`);
});
});
describe('toExportedObjectSnippet', () => {
test('returns the given module with a module.exports prefix', () => {
expect((0, _.toExportedObjectSnippet)(object)).toStrictEqual((0, _dedentJs.default)`
module.exports = {
a: ${object.a},
b: "${object.b}"
};
`);
});
test('removes wrapping quotes from expressions when removeValueQuotes is passed', () => {
expect((0, _.toExportedObjectSnippet)(object, {
removeValueQuotes: true
})).toStrictEqual((0, _dedentJs.default)`
module.exports = {
a: ${object.a},
b: ${object.b}
};
`);
});
test('prettifies the given object', () => {
const objectWithMultiLineString = {
a: `() => {\n\n }`
};
expect((0, _.toExportedObjectSnippet)(objectWithMultiLineString, {
removeValueQuotes: true
})).toStrictEqual((0, _dedentJs.default)`
module.exports = {
a: () => {}
};
`);
});
});
describe('segmentCount', () => {

@@ -101,78 +39,2 @@ test('return the count of segments in a dot-separated path', () => {

});
describe('prettifyCode', () => {
test('return the prettified code', () => {
const code = `
const x = 'aaa'
const z = x * 42;
`;
expect((0, _.prettifyCode)(code)).toStrictEqual((0, _dedentJs.default)`
const x = "aaa";
const z = x * 42;
`);
});
});
describe('stringifiedObject', () => {
test("removes wrapping quotes from the value when the 'removeValueQuotes' flag is passed", () => {
expect((0, _.stringifiedObject)({
a: 'b'
}, {
removeValueQuotes: true
})).toStrictEqual((0, _dedentJs.default)`{
a: b
}
`);
});
test("preserves wrapping quotes on the value when the 'removeValueQuotes' flag not passed", () => {
expect((0, _.stringifiedObject)({
a: 'b'
})).toStrictEqual((0, _dedentJs.default)`{
a: 'b'
}
`);
});
test('preserves new lines in the stringified object', () => {
const objectWithMultiLineString = {
x: 'a\nb'
};
expect((0, _.stringifiedObject)(objectWithMultiLineString)).toStrictEqual((0, _dedentJs.default)`{
x: 'a
b'
}
`);
});
});
describe('stringifiedArray', () => {
test('returns a single line string with array items', () => {
const array = (0, _lodash.times)(5, () => (0, _motionRuntimeTestContext.aString)());
const expectedArrayString = `[${array.map(item => `'${item}'`).join(',')}]`;
expect((0, _.stringifiedArray)(array)).toStrictEqual(expectedArrayString);
});
});
describe('packageNameToImportedVariable', () => {
test('creates a JS-safe variable name corresponding to a package name', () => {
expect((0, _.packageNameToImportedVariable)(`@wix/some-package-name`)).toStrictEqual('wixSomePackageName');
});
});
describe('calculateMethodFullExportPath', () => {
test('returns the method name when exported path is not passed', () => {
const edmMethodName = (0, _motionRuntimeTestContext.aString)();
expect((0, _.calculateMethodFullExportPath)({
edmMethodName
})).toStrictEqual(edmMethodName);
});
test('concatenates exported path and edm method name when both are passed', () => {
const _times = (0, _lodash.times)(2, () => (0, _motionRuntimeTestContext.aString)()),
edmMethodName = _times[0],
exportedPath = _times[1];
expect((0, _.calculateMethodFullExportPath)({
edmMethodName,
exportedPath
})).toStrictEqual(`${exportedPath}.${edmMethodName}`);
});
});
describe('parentPathOf', () => {

@@ -179,0 +41,0 @@ test('returns the path without the last segment', () => {

63

dist/cjs/index.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.toExportedObjectSnippet = exports.stringifiedObject = exports.stringifiedArray = exports.segmentCount = exports.prettyJsonStringify = exports.prettifyCode = exports.parentPathOf = exports.packageNameToImportedVariable = exports.lastPathSegmentOf = exports.edmCodeRootRelativePathInRepo = exports.constants = exports.calculateMethodFullExportPath = void 0;
exports.segmentCount = exports.parentPathOf = exports.lastPathSegmentOf = exports.constants = void 0;
var _lodash = require("lodash");
var _prettier = _interopRequireDefault(require("prettier"));
var _stringifyObject = _interopRequireDefault(require("stringify-object"));
var _constants = require("./lib/constants");

@@ -20,3 +14,2 @@

const SPACES_INDENTATION = ' '.repeat(2);
const constants = {

@@ -31,45 +24,2 @@ ARTIFACT_GROUP_ID: _constants.ARTIFACT_GROUP_ID,

const removeWrappingQuotesFromJavascriptExpression = expression => expression.replace(/[']/g, '');
const fixMultiLineStringsInStringifiedObject = stringifiedObject => stringifiedObject.split('\\n').join('\n');
const prettifyCode = code => _prettier.default.format(code, {
trailingComma: 'none',
parser: 'babel',
printWidth: 120
});
exports.prettifyCode = prettifyCode;
const stringifiedObject = (exportsObject, {
removeValueQuotes = false
} = {}) => fixMultiLineStringsInStringifiedObject((0, _stringifyObject.default)(exportsObject, {
transform: removeValueQuotes ? (_obj, _key, value) => removeWrappingQuotesFromJavascriptExpression(value) : undefined,
indent: SPACES_INDENTATION
}));
exports.stringifiedObject = stringifiedObject;
const stringifiedArray = arr => (0, _stringifyObject.default)(arr, {
indent: ''
}).replace(/[\n\t]/g, '');
exports.stringifiedArray = stringifiedArray;
const toExportedObjectSnippet = (exportsObj, {
removeValueQuotes = false
} = {}) => prettifyCode(`module.exports = ${stringifiedObject(exportsObj, {
removeValueQuotes
})};`);
exports.toExportedObjectSnippet = toExportedObjectSnippet;
const prettyJsonStringify = json => `${JSON.stringify(json, null, 2)}\n`;
exports.prettyJsonStringify = prettyJsonStringify;
const edmCodeRootRelativePathInRepo = edmName => `${_constants.EDM_AUTO_GENERATED_CODE_ROOT}/${edmName}`;
exports.edmCodeRootRelativePathInRepo = edmCodeRootRelativePathInRepo;
const segmentCount = path => path.split('.').length;

@@ -79,13 +29,2 @@

const packageNameToImportedVariable = packageName => (0, _lodash.camelCase)(packageName);
exports.packageNameToImportedVariable = packageNameToImportedVariable;
const calculateMethodFullExportPath = ({
edmMethodName,
exportedPath
}) => exportedPath ? `${exportedPath}.${edmMethodName}` : edmMethodName;
exports.calculateMethodFullExportPath = calculateMethodFullExportPath;
const parentPathOf = path => (0, _lodash.initial)(path.split('.')).join('.');

@@ -92,0 +31,0 @@

4

dist/cjs/lib/constants.js
"use strict";
exports.__esModule = true;
exports.EDM_AUTO_GENERATED_CODE_ROOT = exports.AS_ADMIN_NAMESPACE_NAME = exports.ARTIFACT_GROUP_ID = void 0;
exports.AS_ADMIN_NAMESPACE_NAME = exports.ARTIFACT_GROUP_ID = void 0;
const ARTIFACT_GROUP_ID = 'com.wixpress.cloud.auto-generated-edms';

@@ -9,4 +9,2 @@ exports.ARTIFACT_GROUP_ID = ARTIFACT_GROUP_ID;

exports.AS_ADMIN_NAMESPACE_NAME = AS_ADMIN_NAMESPACE_NAME;
const EDM_AUTO_GENERATED_CODE_ROOT = 'autogenerated-code';
exports.EDM_AUTO_GENERATED_CODE_ROOT = EDM_AUTO_GENERATED_CODE_ROOT;
//# sourceMappingURL=constants.js.map

@@ -1,9 +0,5 @@

import { __makeTemplateObject } from "tslib";
import { anEdmName } from '@wix/motion-edm-autogen-test-context';
import { aNumber, aString } from '@wix/motion-runtime-test-context';
import dedent from 'dedent-js';
import { times } from 'lodash';
import { constants, edmCodeRootRelativePathInRepo, prettyJsonStringify, toExportedObjectSnippet, segmentCount, prettifyCode, stringifiedObject, stringifiedArray, packageNameToImportedVariable, calculateMethodFullExportPath, parentPathOf, lastPathSegmentOf, } from '..';
import { constants, segmentCount, parentPathOf, lastPathSegmentOf } from '..';
describe('generators commons', function () {
var object = { a: aNumber(), b: aString() };
describe('constants', function () {

@@ -26,30 +22,2 @@ test('exposes a constant for the default query property name', function () {

});
describe('prettyJsonStringify', function () {
test('returns a pretty formatted json string', function () {
expect(prettyJsonStringify(object)).toStrictEqual(dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {\n \"a\": ", ",\n \"b\": \"", "\"\n }\n\n "], ["\n {\n \"a\": ", ",\n \"b\": \"", "\"\n }\n\n "])), object.a, object.b));
});
});
describe('edmCodeRootRelativePathInRepo', function () {
test('returns the relative code path of the given edm', function () {
var edmName = anEdmName();
expect(edmCodeRootRelativePathInRepo(edmName)).toStrictEqual("autogenerated-code/".concat(edmName));
});
});
describe('toExportedObjectSnippet', function () {
test('returns the given module with a module.exports prefix', function () {
expect(toExportedObjectSnippet(object)).toStrictEqual(dedent(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n module.exports = {\n a: ", ",\n b: \"", "\"\n };\n\n "], ["\n module.exports = {\n a: ", ",\n b: \"", "\"\n };\n\n "])), object.a, object.b));
});
test('removes wrapping quotes from expressions when removeValueQuotes is passed', function () {
expect(toExportedObjectSnippet(object, { removeValueQuotes: true }))
.toStrictEqual(dedent(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n module.exports = {\n a: ", ",\n b: ", "\n };\n\n "], ["\n module.exports = {\n a: ", ",\n b: ", "\n };\n\n "])), object.a, object.b));
});
test('prettifies the given object', function () {
var objectWithMultiLineString = {
a: "() => {\n\n }",
};
expect(toExportedObjectSnippet(objectWithMultiLineString, {
removeValueQuotes: true,
})).toStrictEqual(dedent(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n module.exports = {\n a: () => {}\n };\n\n "], ["\n module.exports = {\n a: () => {}\n };\n\n "]))));
});
});
describe('segmentCount', function () {

@@ -62,46 +30,2 @@ test('return the count of segments in a dot-separated path', function () {

});
describe('prettifyCode', function () {
test('return the prettified code', function () {
var code = "\n const x = 'aaa'\n\n const z = x * 42;\n\n ";
expect(prettifyCode(code)).toStrictEqual(dedent(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n const x = \"aaa\";\n\n const z = x * 42;\n\n "], ["\n const x = \"aaa\";\n\n const z = x * 42;\n\n "]))));
});
});
describe('stringifiedObject', function () {
test("removes wrapping quotes from the value when the 'removeValueQuotes' flag is passed", function () {
expect(stringifiedObject({ a: 'b' }, { removeValueQuotes: true }))
.toStrictEqual(dedent(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{\n a: b\n }\n "], ["{\n a: b\n }\n "]))));
});
test("preserves wrapping quotes on the value when the 'removeValueQuotes' flag not passed", function () {
expect(stringifiedObject({ a: 'b' })).toStrictEqual(dedent(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{\n a: 'b'\n }\n "], ["{\n a: 'b'\n }\n "]))));
});
test('preserves new lines in the stringified object', function () {
var objectWithMultiLineString = { x: 'a\nb' };
expect(stringifiedObject(objectWithMultiLineString))
.toStrictEqual(dedent(templateObject_8 || (templateObject_8 = __makeTemplateObject(["{\n x: 'a\n b'\n }\n "], ["{\n x: 'a\n b'\n }\n "]))));
});
});
describe('stringifiedArray', function () {
test('returns a single line string with array items', function () {
var array = times(5, function () { return aString(); });
var expectedArrayString = "[".concat(array
.map(function (item) { return "'".concat(item, "'"); })
.join(','), "]");
expect(stringifiedArray(array)).toStrictEqual(expectedArrayString);
});
});
describe('packageNameToImportedVariable', function () {
test('creates a JS-safe variable name corresponding to a package name', function () {
expect(packageNameToImportedVariable("@wix/some-package-name")).toStrictEqual('wixSomePackageName');
});
});
describe('calculateMethodFullExportPath', function () {
test('returns the method name when exported path is not passed', function () {
var edmMethodName = aString();
expect(calculateMethodFullExportPath({ edmMethodName: edmMethodName })).toStrictEqual(edmMethodName);
});
test('concatenates exported path and edm method name when both are passed', function () {
var _a = times(2, function () { return aString(); }), edmMethodName = _a[0], exportedPath = _a[1];
expect(calculateMethodFullExportPath({ edmMethodName: edmMethodName, exportedPath: exportedPath })).toStrictEqual("".concat(exportedPath, ".").concat(edmMethodName));
});
});
describe('parentPathOf', function () {

@@ -123,3 +47,2 @@ test('returns the path without the last segment', function () {

});
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
//# sourceMappingURL=unit.spec.js.map

@@ -1,8 +0,5 @@

import { camelCase, initial } from 'lodash';
import prettier from 'prettier';
import stringifyObject from 'stringify-object';
import { ARTIFACT_GROUP_ID, EDM_AUTO_GENERATED_CODE_ROOT, AS_ADMIN_NAMESPACE_NAME, } from './lib/constants';
import { initial } from 'lodash';
import { ARTIFACT_GROUP_ID, AS_ADMIN_NAMESPACE_NAME } from './lib/constants';
import { Elevations } from './lib/Elevations';
import { PagingMethods } from './lib/PagingMethods';
var SPACES_INDENTATION = ' '.repeat(2);
var constants = {

@@ -15,43 +12,3 @@ ARTIFACT_GROUP_ID: ARTIFACT_GROUP_ID,

};
var removeWrappingQuotesFromJavascriptExpression = function (expression) { return expression.replace(/[']/g, ''); };
var fixMultiLineStringsInStringifiedObject = function (stringifiedObject) { return stringifiedObject.split('\\n').join('\n'); };
var prettifyCode = function (code) {
return prettier.format(code, {
trailingComma: 'none',
parser: 'babel',
printWidth: 120,
});
};
var stringifiedObject = function (exportsObject, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.removeValueQuotes, removeValueQuotes = _c === void 0 ? false : _c;
return fixMultiLineStringsInStringifiedObject(stringifyObject(exportsObject, {
transform: removeValueQuotes
? function (_obj, _key, value) {
return removeWrappingQuotesFromJavascriptExpression(value);
}
: undefined,
indent: SPACES_INDENTATION,
}));
};
var stringifiedArray = function (arr) {
return stringifyObject(arr, { indent: '' }).replace(/[\n\t]/g, '');
};
var toExportedObjectSnippet = function (exportsObj, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.removeValueQuotes, removeValueQuotes = _c === void 0 ? false : _c;
return prettifyCode("module.exports = ".concat(stringifiedObject(exportsObj, { removeValueQuotes: removeValueQuotes }), ";"));
};
var prettyJsonStringify = function (json) {
return "".concat(JSON.stringify(json, null, 2), "\n");
};
var edmCodeRootRelativePathInRepo = function (edmName) {
return "".concat(EDM_AUTO_GENERATED_CODE_ROOT, "/").concat(edmName);
};
var segmentCount = function (path) { return path.split('.').length; };
var packageNameToImportedVariable = function (packageName) {
return camelCase(packageName);
};
var calculateMethodFullExportPath = function (_a) {
var edmMethodName = _a.edmMethodName, exportedPath = _a.exportedPath;
return exportedPath ? "".concat(exportedPath, ".").concat(edmMethodName) : edmMethodName;
};
var parentPathOf = function (path) {

@@ -63,3 +20,3 @@ return initial(path.split('.')).join('.');

};
export { constants, stringifiedObject, prettifyCode, toExportedObjectSnippet, prettyJsonStringify, edmCodeRootRelativePathInRepo, segmentCount, stringifiedArray, packageNameToImportedVariable, calculateMethodFullExportPath, parentPathOf, lastPathSegmentOf, };
export { constants, segmentCount, parentPathOf, lastPathSegmentOf };
//# sourceMappingURL=index.js.map
var ARTIFACT_GROUP_ID = 'com.wixpress.cloud.auto-generated-edms';
var AS_ADMIN_NAMESPACE_NAME = 'withPermissions';
var EDM_AUTO_GENERATED_CODE_ROOT = 'autogenerated-code';
export { ARTIFACT_GROUP_ID, AS_ADMIN_NAMESPACE_NAME, EDM_AUTO_GENERATED_CODE_ROOT, };
export { ARTIFACT_GROUP_ID, AS_ADMIN_NAMESPACE_NAME };
//# sourceMappingURL=constants.js.map
import { Elevations } from './lib/Elevations';
import { PagingMethods } from './lib/PagingMethods';
import type { EdmMethodInfo } from '@wix/motion-edm-autogen-types';
declare const constants: {

@@ -11,18 +10,6 @@ ARTIFACT_GROUP_ID: string;

};
declare const prettifyCode: (code: string) => string;
declare const stringifiedObject: (exportsObject: unknown, { removeValueQuotes }?: {
removeValueQuotes?: boolean | undefined;
}) => string;
declare const stringifiedArray: (arr: unknown[]) => string;
declare const toExportedObjectSnippet: (exportsObj: Record<string, unknown>, { removeValueQuotes }?: {
removeValueQuotes?: boolean | undefined;
}) => string;
declare const prettyJsonStringify: (json: unknown) => string;
declare const edmCodeRootRelativePathInRepo: (edmName: string) => string;
declare const segmentCount: (path: string) => number;
declare const packageNameToImportedVariable: (packageName: string) => string;
declare const calculateMethodFullExportPath: ({ edmMethodName, exportedPath, }: EdmMethodInfo) => string;
declare const parentPathOf: (path: string) => string;
declare const lastPathSegmentOf: (path: string) => string | undefined;
export { constants, stringifiedObject, prettifyCode, toExportedObjectSnippet, prettyJsonStringify, edmCodeRootRelativePathInRepo, segmentCount, stringifiedArray, packageNameToImportedVariable, calculateMethodFullExportPath, parentPathOf, lastPathSegmentOf, };
export { constants, segmentCount, parentPathOf, lastPathSegmentOf };
//# sourceMappingURL=index.d.ts.map
declare const ARTIFACT_GROUP_ID = "com.wixpress.cloud.auto-generated-edms";
declare const AS_ADMIN_NAMESPACE_NAME = "withPermissions";
declare const EDM_AUTO_GENERATED_CODE_ROOT = "autogenerated-code";
export { ARTIFACT_GROUP_ID, AS_ADMIN_NAMESPACE_NAME, EDM_AUTO_GENERATED_CODE_ROOT, };
export { ARTIFACT_GROUP_ID, AS_ADMIN_NAMESPACE_NAME };
//# sourceMappingURL=constants.d.ts.map
{
"name": "@wix/motion-edm-autogen-common",
"version": "1.4.0",
"version": "1.5.0",
"license": "UNLICENSED",

@@ -38,14 +38,10 @@ "author": {

"@babel/runtime": "^7.0.0",
"@rushstack/eslint-patch": "^1.1.0",
"jsonpath-plus": "~5.1.0",
"lodash": "~4.17.0",
"prettier": "~2.6.0",
"stringify-object": "~3.3.0",
"tslib": "^2.0.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.1.0",
"@types/jest": "^26.0.15",
"@types/js-yaml": "^4.0.5",
"@types/node": "^14.0.0",
"@wix/motion-edm-autogen-test-context": "~1.0.0",
"@wix/motion-runtime-test-context": "~1.0.0",

@@ -55,3 +51,2 @@ "@wix/jest-yoshi-preset": "^5.162.7",

"@wix/yoshi-flow-library": "^5.162.7",
"dedent-js": "~1.0.0",
"husky": "~4.2.1",

@@ -73,3 +68,4 @@ "lint-staged": "^10.0.7",

"autoDetect": true
}
},
"falconPackageHash": "1e55b0b2e56987263259b3884496f09b1846770c2a5114fae6e17277"
}

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

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

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