5htp-core 0.6.2-93 → 0.6.2-95

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.
@@ -1,6 +1,7 @@
1
1
  .table {
2
2
 
3
3
  overflow: auto;
4
+ display: block!important;
4
5
 
5
6
  &.scrollable {
6
7
  max-height: 90vh;
@@ -81,6 +81,8 @@ import ToolbarPlugin from './ToolbarPlugin';
81
81
 
82
82
  export const EMPTY_STATE = '{"root":{"children":[{"children":[],"direction":null,"format":"","indent":0,"type":"paragraph","version":1}],"direction":null,"format":"","indent":0,"type":"root","version":1}}';
83
83
 
84
+ import './style.less';
85
+
84
86
  /*----------------------------------
85
87
  - TYPES
86
88
  ----------------------------------*/
@@ -11,7 +11,6 @@ import type { TToolbarDisplay } from './ToolbarPlugin';
11
11
 
12
12
  // Special componets
13
13
  import type TEditor from './Editor';
14
- import './style.less';
15
14
 
16
15
  /*----------------------------------
17
16
  - TYPES
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.6.2-93",
4
+ "version": "0.6.2-95",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -46,7 +46,7 @@ export type StartedServicesIndex = {
46
46
 
47
47
  export type TServiceArgs<TService extends AnyService> = [
48
48
  parent: AnyService | 'self',
49
- getConfig: null | undefined | ((instance: TService) => {}),
49
+ config: null | undefined | TService['config'],
50
50
  app: TService['app'] | 'self'
51
51
  ]
52
52
 
@@ -122,7 +122,7 @@ export default abstract class Service<
122
122
  TConfig extends {},
123
123
  THooks extends THooksList,
124
124
  TApplication extends Application,
125
- TParent extends AnyService | Application = Application
125
+ TParent extends AnyService
126
126
  > {
127
127
 
128
128
  public started?: Promise<void>;
@@ -136,18 +136,17 @@ export default abstract class Service<
136
136
  public app: TApplication;
137
137
  public config: TConfig = {} as TConfig;
138
138
 
139
- public constructor(...[parent, getConfig, app]: TServiceArgs<AnyService>) {
139
+ public constructor(...[parent, config, app]: TServiceArgs<AnyService>) {
140
140
 
141
141
  this.parent = parent;
142
142
  if (this.parent === 'self')
143
- this.parent = this;
143
+ this.parent = this as unknown as TParent;
144
144
 
145
145
  this.app = app === 'self'
146
146
  ? this as unknown as TApplication
147
147
  : app
148
148
 
149
- if (typeof getConfig === 'function')
150
- this.config = getConfig(this);
149
+ this.config = config || {};
151
150
 
152
151
  }
153
152
 
@@ -7,9 +7,11 @@
7
7
  // Core
8
8
  import {
9
9
  default as Router, Request as ServerRequest, Response as ServerResponse, TAnyRoute,
10
- RouterService, TRouterServiceArgs
10
+ RouterService
11
11
  } from '@server/services/router';
12
12
 
13
+ import type { TRouterServiceArgs } from '@server/services/router/service';
14
+
13
15
  // Specific
14
16
  import type { default as UsersService, TUserRole } from '..';
15
17
  import UsersRequestService from './request';
@@ -58,6 +58,10 @@ export default abstract class FsDriver<
58
58
  TBucketName = keyof Config["buckets"]
59
59
  > extends Service<Config, {}, Application> {
60
60
 
61
+ public constructor( config: Config, app: Application ) {
62
+ super(app, config, app);
63
+ }
64
+
61
65
  public abstract mount(): Promise<void>;
62
66
 
63
67
  public abstract getFileUrl(
@@ -50,9 +50,9 @@ export default class S3Driver<
50
50
 
51
51
  public s3: AWS.S3;
52
52
 
53
- public constructor(...args: TServiceArgs) {
53
+ public constructor( config: TConfig, app: Application ) {
54
54
 
55
- super(...args);
55
+ super(app, config, app);
56
56
 
57
57
  AWS.config.update({
58
58
  accessKeyId: this.config.accessKeyId,
@@ -37,7 +37,7 @@ export default class DisksManager<
37
37
  MountpointList extends Services,
38
38
  TConfig extends Config,
39
39
  TApplication extends Application
40
- > extends Service<TConfig, Hooks, TApplication> {
40
+ > extends Service<TConfig, Hooks, TApplication, TApplication> {
41
41
 
42
42
  public default!: Driver;
43
43
 
@@ -50,10 +50,17 @@ export default class DisksManager<
50
50
  super(...args);
51
51
 
52
52
  const drivers = this.config.drivers;
53
+
54
+ console.log('drivers', args);
53
55
 
54
56
  if (Object.keys( drivers ).length === 0)
55
57
  throw new Error("At least one disk driver should be mounted.");
56
58
 
59
+ // Bind current instance of the service as parent
60
+ /*for (const driverId in drivers) {
61
+ drivers[driverId].parent = this;
62
+ }*/
63
+
57
64
  const defaultDisk = drivers[ this.config.default ];
58
65
  if (defaultDisk === undefined)
59
66
  console.log(`Default disk "${this.config.default as string}" not mounted.`);
@@ -104,7 +104,7 @@ export type Config<
104
104
 
105
105
  // Set it as a function, so when we instanciate the services, we can callthis.router to pass the router instance in roiuter services
106
106
  type TRouterServicesList = {
107
- [serviceName: string]: RouterService<TServerRouter>
107
+ [serviceName: string]: RouterService
108
108
  }
109
109
 
110
110
  export type Hooks = {
@@ -127,7 +127,7 @@ export default class ServerRouter<
127
127
  TServices extends TRouterServicesList,
128
128
  TConfig extends Config<TServices>,
129
129
  >
130
- extends Service<TConfig, Hooks, TApplication> implements BaseRouter {
130
+ extends Service<TConfig, Hooks, TApplication, TApplication> implements BaseRouter {
131
131
 
132
132
  public disks = this.use<DisksManager>('Core/Disks', { optional: true });
133
133
 
@@ -175,7 +175,9 @@ export default class ServerRouter<
175
175
 
176
176
  // Detect router services
177
177
  for (const serviceName in this.config.plugins) {
178
- this.app.register( this.config.plugins[serviceName] )
178
+ const service = this.config.plugins[serviceName];
179
+ service.parent = this;
180
+ this.app.register( service )
179
181
  }
180
182
 
181
183
  // Use require to avoid circular references
@@ -373,10 +375,10 @@ export default class ServerRouter<
373
375
  req: Request,
374
376
  res: Response,
375
377
  next: NextFunction,
376
- requestContext: TRouterContext
378
+ requestContext: TRouterContext<this>
377
379
  ) => void
378
380
  ) {
379
- return (context: TRouterContext) => new Promise((resolve) => {
381
+ return (context: TRouterContext<this>) => new Promise((resolve) => {
380
382
 
381
383
  context.request.res.on('finish', function() {
382
384
  //console.log('the response has been sent', request.res.statusCode);
@@ -12,7 +12,7 @@ import express from 'express';
12
12
 
13
13
  // Core
14
14
  import { Application } from '@server/app';
15
- import type { default as ServerRouter, TServerRouter } from '@server/services/router';
15
+ import type { RouterService, default as ServerRouter, TServerRouter } from '@server/services/router';
16
16
  import ServerRequest from '@server/services/router/request';
17
17
  import { TRoute, TAnyRoute, TDomainsList } from '@common/router';
18
18
  import { NotFound, Forbidden, Anomaly } from '@common/errors';
@@ -62,7 +62,9 @@ export type TRouterContextServices<
62
62
  // Custom context via servuces
63
63
  // For each roiuter service, return the request service (returned by roiuterService.requestService() )
64
64
  {
65
- [serviceName in keyof TPlugins]: TRouter["config"]["plugins"]//TPlugins[serviceName]
65
+ [serviceName in keyof TPlugins]: TPlugins[serviceName] extends RouterService
66
+ ? ReturnType<TPlugins[serviceName]["requestService"]>
67
+ : TPlugins[serviceName]
66
68
  }
67
69
  )
68
70
 
@@ -215,7 +217,7 @@ export default class ServerResponse<
215
217
  return this;
216
218
  }
217
219
 
218
- public async render( page: Page, context: TRouterContext, additionnalData: {} ) {
220
+ public async render( page: Page, context: TRouterContext<TRouter>, additionnalData: {} ) {
219
221
 
220
222
  // Set page in context for the client side
221
223
  context.page = page;
@@ -11,7 +11,10 @@ import type { default as Router } from '.';
11
11
  import type ServerRequest from './request';
12
12
  import type RequestService from './request/service';
13
13
 
14
- export type TRouterServiceArgs = TServiceArgs<RouterService>;
14
+ export type TRouterServiceArgs = [
15
+ getConfig: TServiceArgs<RouterService>[1],
16
+ app: Application,
17
+ ];
15
18
 
16
19
  /*----------------------------------
17
20
  - SERVICE
@@ -20,10 +23,10 @@ export default abstract class RouterService<
20
23
  TConfig extends {} = {}
21
24
  > extends Service<TConfig, {}, Application> {
22
25
 
23
- public constructor( ...args: TRouterServiceArgs) {
24
- super(...args);
26
+ public constructor( ...[config, app]: TRouterServiceArgs) {
27
+ super(app, config, app);
25
28
  }
26
29
 
27
- public abstract requestService( request: ServerRequest<Router> ): RequestService | null;
30
+ public abstract requestService( request: ServerRequest<RouterService> ): RequestService | {} | null;
28
31
 
29
32
  }
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"rocket"|"user-circle"|"plane-departure"|"plus-circle"|"comments-alt"|"chart-bar"|"crosshairs"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"at"|"phone"|"brands/linkedin"|"search"|"lightbulb"|"magnet"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"brands/whatsapp"|"plus"|"minus"|"trash"|"check"|"clock"|"cog"|"ellipsis-h"|"play"|"stop"|"regular/shield-check"|"angle-down"|"angle-up"|"solid/crown"|"eye"|"pen"|"file"|"envelope"|"coins"|"download"|"exclamation-circle"|"times-circle"|"bars"|"arrow-left"|"meh-rolling-eyes"|"minus-circle"|"chevron-left"|"bolt"|"key"|"power-off"|"comment-alt"|"external-link"|"question-circle"|"wind"|"broom"|"brands/google"|"copy"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"users"|"bug"|"binoculars"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"coin"|"plug"|"angle-left"|"angle-right"|"arrow-to-bottom"|"magic"|"solid/magic"|"map-marker"|"fire"|"globe"|"industry"|"calendar"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "solid/spinner-third"|"rocket"|"user-circle"|"plane-departure"|"long-arrow-right"|"plus-circle"|"comments-alt"|"crosshairs"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"magnet"|"search"|"times"|"at"|"plus"|"minus"|"trash"|"brands/linkedin"|"play"|"stop"|"paper-plane"|"regular/shield-check"|"angle-down"|"check"|"clock"|"cog"|"ellipsis-h"|"lightbulb"|"phone"|"angle-up"|"envelope"|"solid/crown"|"eye"|"pen"|"file"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"download"|"brands/google"|"brands/whatsapp"|"crown"|"check-circle"|"exclamation-circle"|"times-circle"|"key"|"arrow-left"|"minus-circle"|"external-link"|"wind"|"broom"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"angle-left"|"angle-right"|"coins"|"plug"|"coin"|"question-circle"|"arrow-to-bottom"|"magic"|"user"|"meh-rolling-eyes"|"unlink"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"