You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@strapi/typescript-utils

Package Overview
Dependencies
Maintainers
7
Versions
1807
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strapi/typescript-utils - npm Package Compare versions

Comparing version

to
0.0.0-43cfd27dff91c9ef27fa624c94a3a3d37669eec8

55

lib/__tests__/generators/schemas/attributes.test.js

@@ -441,2 +441,57 @@ 'use strict';

describe('Custom field', () => {
test('No custom field', () => {
const attribute = {};
const modifiers = getAttributeModifiers(attribute);
expect(modifiers).toHaveLength(0);
});
test('Basic custom field', () => {
const attribute = {
type: 'string',
customField: 'plugin::color-picker.color',
};
const modifiers = getAttributeModifiers(attribute);
expect(modifiers).toHaveLength(1);
expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
expect(modifiers[0].typeName.escapedText).toBe('CustomField');
expect(modifiers[0].typeArguments).toHaveLength(1);
expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
expect(modifiers[0].typeArguments[0].text).toBe('plugin::color-picker.color');
});
test('Advanced custom field', () => {
const attribute = {
type: 'string',
customField: 'plugin::color-picker.color',
options: {
format: 'hex',
},
};
const modifiers = getAttributeModifiers(attribute);
expect(modifiers).toHaveLength(1);
expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
expect(modifiers[0].typeName.escapedText).toBe('CustomField');
expect(modifiers[0].typeArguments).toHaveLength(2);
expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
expect(modifiers[0].typeArguments[0].text).toBe('plugin::color-picker.color');
expect(modifiers[0].typeArguments[1].kind).toBe(ts.SyntaxKind.TypeLiteral);
expect(modifiers[0].typeArguments[1].members).toHaveLength(1);
expect(modifiers[0].typeArguments[1].members[0].kind).toBe(
ts.SyntaxKind.PropertyDeclaration
);
expect(modifiers[0].typeArguments[1].members[0].name.escapedText).toBe('format');
expect(modifiers[0].typeArguments[1].members[0].kind).toBe(
ts.SyntaxKind.PropertyDeclaration
);
expect(modifiers[0].typeArguments[1].members[0].type.kind).toBe(
ts.SyntaxKind.StringLiteral
);
expect(modifiers[0].typeArguments[1].members[0].type.text).toBe('hex');
});
});
describe('Plugin Options', () => {

@@ -443,0 +498,0 @@ test('No plugin options', () => {

@@ -73,2 +73,18 @@ 'use strict';

// Custom field
if (attribute.customField) {
addImport('CustomField');
const customFieldUid = factory.createStringLiteral(attribute.customField);
const typeArguments = [customFieldUid];
if (attribute.options) {
typeArguments.push(toTypeLiteral(attribute.options));
}
modifiers.push(
factory.createTypeReferenceNode(factory.createIdentifier('CustomField'), typeArguments)
);
}
// Plugin Options

@@ -75,0 +91,0 @@ if (!_.isEmpty(attribute.pluginOptions)) {

4

lib/utils/get-config-path.js

@@ -20,4 +20,6 @@ 'use strict';

const dirAbsolutePath = path.resolve(dir);
const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
let configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
if (configFilePath) configFilePath = path.resolve(configFilePath);
if (!configFilePath || ancestorsLookup) {

@@ -24,0 +26,0 @@ return configFilePath;

{
"name": "@strapi/typescript-utils",
"version": "0.0.0-410c0cef7603996154e5c78e6e6282076a90b4ec",
"version": "0.0.0-43cfd27dff91c9ef27fa624c94a3a3d37669eec8",
"description": "Typescript support for Strapi",

@@ -38,3 +38,3 @@ "keywords": [

},
"gitHead": "410c0cef7603996154e5c78e6e6282076a90b4ec"
"gitHead": "43cfd27dff91c9ef27fa624c94a3a3d37669eec8"
}