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

@platformatic/sql-openapi

Package Overview
Dependencies
Maintainers
5
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platformatic/sql-openapi - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

test/schema.test.js

6

index.js

@@ -6,4 +6,2 @@ 'use strict'

const deepmerge = require('@fastify/deepmerge')({ all: true })
const camelcase = require('camelcase')
const { singularize } = require('inflected')
const { mapSQLEntityToJSONSchema } = require('@platformatic/sql-json-schema-mapper')

@@ -55,6 +53,6 @@ const entityPlugin = require('./lib/entity-to-routes')

for (const relation of Object.values(entity.relations)) {
const targetEntityName = singularize(camelcase(relation.foreign_table_name))
const targetEntityName = relation.foreignEntityName
const targetEntity = app.platformatic.entities[targetEntityName]
const reverseRelationship = {
sourceEntity: entity.name,
sourceEntity: relation.entityName,
relation

@@ -61,0 +59,0 @@ }

@@ -5,3 +5,2 @@ 'use strict'

const camelcase = require('camelcase')
const { singularize } = require('inflected')
const { generateArgs, rootEntityRoutes, capitalize, getFieldsForEntity } = require('./shared')

@@ -13,3 +12,3 @@

const ownField = camelcase(relation.column_name)
const relatedEntity = app.platformatic.entities[camelcase(singularize(relation.foreign_table_name))]
const relatedEntity = app.platformatic.entities[relation.foreignEntityName]
const relatedEntityPrimaryKeyCamelcase = camelcase(relatedEntity.primaryKeys.values().next().value)

@@ -30,3 +29,3 @@ const relatedEntityPrimaryKeyCamelcaseCapitalized = capitalize(relatedEntityPrimaryKeyCamelcase)

const ownField = camelcase(relation.foreign_column_name)
const relatedEntity = app.platformatic.entities[camelcase(singularize(relation.table_name))]
const relatedEntity = app.platformatic.entities[relation.entityName]
if (relatedEntity.primaryKeys.size !== 1) {

@@ -106,3 +105,3 @@ continue

for (const reverseRelationship of entity.reverseRelationships) {
const targetEntityName = singularize(camelcase(reverseRelationship.relation.table_name))
const targetEntityName = reverseRelationship.relation.entityName
const targetEntity = app.platformatic.entities[targetEntityName]

@@ -176,6 +175,8 @@ const targetForeignKeyCamelcase = camelcase(reverseRelationship.relation.column_name)

for (const relation of entity.relations) {
const targetEntityName = singularize(camelcase(relation.foreign_table_name))
const targetEntityName = relation.foreignEntityName
const targetEntity = app.platformatic.entities[targetEntityName]
const targetForeignKeyCamelcase = camelcase(relation.foreign_column_name)
const targetColumnCamelcase = camelcase(relation.column_name)
// In this case, we navigate the relationship so we MUST use the column_name otherwise we will fail in case of recursive relationships
// (or multiple relationships between the same entities). We might want to specify this in documentation, because can be confusing
const targetRelation = relation.column_name.replace(/_id$/, '')

@@ -182,0 +183,0 @@ const targetEntitySchema = {

@@ -5,3 +5,2 @@ 'use strict'

const camelcase = require('camelcase')
const { singularize } = require('inflected')
const { generateArgs, capitalize, getFieldsForEntity, rootEntityRoutes } = require('./shared')

@@ -31,3 +30,3 @@

if (relation) {
pathWithParams += `/${camelcase(singularize(relation.foreign_table_name))}/:${camelcaseKey}`
pathWithParams += `/${relation.foreignEntityName}/:${camelcaseKey}`
} else {

@@ -34,0 +33,0 @@ pathWithParams += `/${camelcaseKey}/:${camelcaseKey}`

{
"name": "@platformatic/sql-openapi",
"version": "0.11.0",
"version": "0.12.0",
"description": "Map a SQL database to OpenAPI, for Fastify",

@@ -17,19 +17,19 @@ "main": "index.js",

"devDependencies": {
"fastify": "^4.6.0",
"mercurius": "^11.0.0",
"openapi-types": "^12.0.2",
"fastify": "^4.10.2",
"mercurius": "^11.4.0",
"openapi-types": "^12.1.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tap": "^16.3.2",
"tsd": "^0.25.0",
"@platformatic/sql-mapper": "0.11.0"
"@platformatic/sql-mapper": "0.12.0"
},
"dependencies": {
"@fastify/deepmerge": "^1.1.0",
"@fastify/swagger": "^8.0.0",
"@fastify/swagger-ui": "^1.0.0",
"camelcase": "^6.0.0",
"fastify-plugin": "^4.1.0",
"@fastify/deepmerge": "^1.3.0",
"@fastify/swagger": "^8.2.1",
"@fastify/swagger-ui": "^1.3.0",
"camelcase": "^6.3.0",
"fastify-plugin": "^4.4.0",
"inflected": "^2.1.0",
"@platformatic/sql-json-schema-mapper": "0.11.0"
"@platformatic/sql-json-schema-mapper": "0.12.0"
},

@@ -36,0 +36,0 @@ "tsd": {

@@ -83,2 +83,29 @@ 'use strict'

}
try {
await db.query(sql`DROP TABLE generated_test`)
} catch (err) {
}
// Don't change the order of these drops below
try {
await db.query(sql`DROP TABLE test1.editors`)
} catch (err) {
}
try {
await db.query(sql`DROP TABLE test2.users`)
} catch (err) {
}
try {
await db.query(sql`DROP TABLE test1.pages`)
} catch (err) {
}
try {
await db.query(sql`DROP SCHEMA test2`)
} catch (err) {
}
try {
await db.query(sql`DROP SCHEMA test1`)
} catch (err) {
}
}

@@ -218,3 +218,3 @@

test('nested routes with recursive FK', async (t) => {
t.only('nested routes with recursive FK', async (t) => {
const { pass, teardown, same, equal, matchSnapshot } = t

@@ -221,0 +221,0 @@ t.snapshotFile = resolve(__dirname, 'tap-snapshots', 'nested-routes-openapi-recursive.cjs')

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