From e5a7f0ec2e62e83ad6136fcc401f5fb1e3565044 Mon Sep 17 00:00:00 2001 From: Aschen Date: Sun, 23 Jan 2022 16:20:47 +0100 Subject: [PATCH] fix(crud): property scope --- lib/crud/CRUDController.d.ts | 8 +++++--- lib/crud/CRUDController.js.map | 2 +- lib/crud/CRUDController.ts | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/crud/CRUDController.d.ts b/lib/crud/CRUDController.d.ts index 29fc220..d5ba266 100644 --- a/lib/crud/CRUDController.d.ts +++ b/lib/crud/CRUDController.d.ts @@ -1,11 +1,13 @@ -import { KuzzleRequest, PluginContext, JSONObject, ControllerDefinition, Plugin } from 'kuzzle'; +import { KuzzleRequest, PluginContext, JSONObject, ControllerDefinition, Plugin, EmbeddedSDK } from 'kuzzle'; export declare class CRUDController { protected context: PluginContext; protected config: JSONObject; - private collection; + protected collection: string; definition: ControllerDefinition; constructor(plugin: Plugin, collection: string); - get as(): (user: any) => import("kuzzle").EmbeddedSDK; + protected get as(): (user: { + _id: string; + }) => EmbeddedSDK; /** * Create an asset or a device depending on the collection. * diff --git a/lib/crud/CRUDController.js.map b/lib/crud/CRUDController.js.map index 6f1b2f4..ce39041 100644 --- a/lib/crud/CRUDController.js.map +++ b/lib/crud/CRUDController.js.map @@ -1 +1 @@ -{"version":3,"file":"CRUDController.js","sourceRoot":"","sources":["CRUDController.ts"],"names":[],"mappings":";;;AAQA,MAAa,cAAc;IAMzB,YAAa,MAAc,EAAE,UAAkB;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC3B,CAAC;IAEL,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,WA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;IACnB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAE,OAAsB;QAClC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAClD,KAAK,EACL,IAAI,CAAC,UAAU,EACf,EAAE,EACF,IAAI,EACJ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/B,CAAC;CACF;AA3FD,wCA2FC"} \ No newline at end of file diff --git a/lib/crud/CRUDController.ts b/lib/crud/CRUDController.ts index 79e6db3..d2a90d2 100644 --- a/lib/crud/CRUDController.ts +++ b/lib/crud/CRUDController.ts @@ -4,12 +4,14 @@ import { JSONObject, ControllerDefinition, Plugin, + EmbeddedSDK, } from 'kuzzle'; export class CRUDController { protected context: PluginContext; protected config: JSONObject; - private collection: string; + protected collection: string; + public definition: ControllerDefinition; constructor (plugin: Plugin, collection: string) { @@ -18,7 +20,7 @@ export class CRUDController { this.collection = collection; } - get as () { + protected get as (): (user: { _id: string }) => EmbeddedSDK { return user => this.context.accessors.sdk.as(user, { checkRights: true }); }