@platformatic/sql-mapper 0.26.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mapper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FastifyPluginAsync } from 'fastify'
1
+ import { FastifyPluginAsync, FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
2
2
  import { SQL, SQLQuery } from '@databases/sql'
3
3
 
4
4
  interface ILogger {
@@ -306,10 +306,19 @@ export interface SQLMapperPluginInterface {
306
306
  addEntityHooks(entityName: string, hooks: EntityHooks): any
307
307
  }
308
308
 
309
+ export interface PlatformaticContext {
310
+ app: FastifyInstance,
311
+ reply: FastifyReply
312
+ }
313
+
309
314
  declare module 'fastify' {
310
315
  interface FastifyInstance {
311
316
  platformatic: SQLMapperPluginInterface
312
317
  }
318
+
319
+ interface FastifyRequest {
320
+ platformaticContext: PlatformaticContext
321
+ }
313
322
  }
314
323
 
315
324
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/sql-mapper",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "description": "A data mapper utility for SQL databases",
5
5
  "main": "mapper.js",
6
6
  "repository": {
@@ -14,10 +14,10 @@
14
14
  },
15
15
  "homepage": "https://github.com/platformatic/platformatic#readme",
16
16
  "devDependencies": {
17
- "fastify": "^4.17.0",
17
+ "fastify": "^4.18.0",
18
18
  "snazzy": "^9.0.0",
19
- "standard": "^17.0.0",
20
- "tap": "^16.3.4",
19
+ "standard": "^17.1.0",
20
+ "tap": "^16.3.6",
21
21
  "tsd": "^0.28.1"
22
22
  },
23
23
  "dependencies": {
@@ -1,3 +1,4 @@
1
+ 'use strict'
1
2
 
2
3
  const { test } = require('tap')
3
4
  const { connect, plugin } = require('..')
@@ -1,6 +1,6 @@
1
1
  import { expectType } from 'tsd'
2
2
  import { SQL, SQLQuery } from '@databases/sql'
3
- import { fastify, FastifyInstance } from 'fastify'
3
+ import { fastify, FastifyInstance, FastifyReply } from 'fastify'
4
4
  import {
5
5
  connect,
6
6
  plugin,
@@ -72,6 +72,13 @@ expectType<SQLMapperPluginInterface>(await connect({
72
72
 
73
73
  const instance: FastifyInstance = fastify()
74
74
  instance.register(plugin, { connectionString: '', autoTimestamp: true })
75
- instance.register((instance) => { expectType<SQLMapperPluginInterface>(instance.platformatic) })
75
+ instance.register((instance) => {
76
+ expectType<SQLMapperPluginInterface>(instance.platformatic)
77
+ instance.get('/', async (request, reply) => {
78
+ const ctx = request.platformaticContext
79
+ expectType<FastifyInstance>(ctx.app)
80
+ expectType<FastifyReply>(ctx.reply)
81
+ })
82
+ })
76
83
 
77
84
  expectType<(str: string) => string>(utils.toSingular)