From dddd238113b20b55f72b631f2e784333aba168bc Mon Sep 17 00:00:00 2001 From: Aschen Date: Fri, 13 Nov 2020 16:47:01 +0100 Subject: [PATCH] Export more interfaces --- index.ts | 8 ++++- package-lock.json | 4 +-- package.json | 1 + src/controllers/Realtime.ts | 4 +-- src/utils/interfaces.ts | 62 +++++++++++++++++++++---------------- 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/index.ts b/index.ts index e2b112903..633ecbe28 100644 --- a/index.ts +++ b/index.ts @@ -10,7 +10,6 @@ if (typeof window !== 'undefined' && typeof BUILT === 'undefined') { export * from './src/Kuzzle'; export * from './src/protocols'; -export * from './src/controllers/Base'; export * from './src/protocols/abstract/Base'; export * from './src/core/KuzzleEventEmitter'; @@ -22,3 +21,10 @@ export * from './src/core/searchResult/Specifications'; export * from './src/core/searchResult/User'; export * from './src/utils/interfaces'; + +export * from './src/controllers/Auth'; +export * from './src/controllers/Base'; +export * from './src/controllers/Collection'; +export * from './src/controllers/Document'; +export * from './src/controllers/Index'; +export * from './src/controllers/Realtime'; diff --git a/package-lock.json b/package-lock.json index c5ed57e1e..009556c45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4170,7 +4170,7 @@ }, "inherits": { "version": "2.0.3", - "resolved": "", + "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, @@ -6709,7 +6709,7 @@ }, "should-util": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", "dev": true }, diff --git a/package.json b/package.json index 5255c62cb..3f065dc8e 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "test:lint:ts:fix": "eslint ./src --ext .ts --config .eslintrc-ts.json --fix", "build": "npm run build-ts && node build.js", "build-ts": "tsc --build tsconfig.json", + "clean": "npm run build | grep TSFILE | cut -d' ' -f 2 | xargs rm", "doc": "docker-compose -f doc/docker-compose.yml up", "doc-testing": "bash .ci/test-docs.sh", "doc-prepare": "kuzdoc framework:install", diff --git a/src/controllers/Realtime.ts b/src/controllers/Realtime.ts index 1d8c272fb..202a30eba 100644 --- a/src/controllers/Realtime.ts +++ b/src/controllers/Realtime.ts @@ -1,6 +1,6 @@ import { BaseController } from './Base'; import Room from '../core/Room'; -import { JSONObject } from '../utils/interfaces'; +import { Notification, JSONObject } from '../utils/interfaces'; /** * Enum for `scope` option of realtime.subscribe method @@ -253,5 +253,3 @@ export class RealtimeController extends BaseController { this._subscriptionsOff = new Map(); } } - -module.exports = { RealtimeController }; diff --git a/src/utils/interfaces.ts b/src/utils/interfaces.ts index cfb3d9ae3..4f2c532c5 100644 --- a/src/utils/interfaces.ts +++ b/src/utils/interfaces.ts @@ -161,6 +161,38 @@ export interface ApiKey { } } +/** + * Kuzzle metadata + * @see https://docs.kuzzle.io/core/2/guides/essentials/document-metadata/ + */ +export interface KuzzleMetadata { + _kuzzle_info: { + /** + * Kuid of the user who created the document + */ + author: string, + /** + * Creation date in micro-timestamp + */ + createdAt: number, + /** + * Kuid of the user who last updated the document + */ + updater: string | null, + /** + * Update date in micro-timestamp + */ + updatedAt: number | null + } +} + +/** + * Represents the `_source` property of the document + */ +export interface DocumentContent extends KuzzleMetadata { + [key: string]: JSONObject | any, +} + /** * Kuzzle document * @@ -168,11 +200,11 @@ export interface ApiKey { * @property _version * @property _source */ -export interface Document { +export class Document { /** * Document unique ID */ - _id?: string; + _id: string; /** * Document Version (generated by Elasticsearch) */ @@ -180,31 +212,7 @@ export interface Document { /** * Document Content */ - _source?: { - [key: string]: JSONObject | any, - /** - * Kuzzle metadata - * @see https://docs.kuzzle.io/core/2/guides/essentials/document-metadata/ - */ - _kuzzle_info?: { - /** - * Kuid of the user who created the document - */ - author: string, - /** - * Creation date in micro-timestamp - */ - createdAt: number, - /** - * Kuid of the user who last updated the document - */ - updater: string | null, - /** - * Update date in micro-timestamp - */ - updatedAt: number | null - } - }; + _source: DocumentContent; } /**