@niledatabase/server 1.0.0-alpha.195

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 The Nile Platform
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @niledatabase/server
2
+
3
+ Consolidates the API and DB for working with Nile.
4
+
5
+ ### Adding an endpoint:
6
+
7
+ #### Add the openapi spec
8
+
9
+ 1. Find or add to `src` the name of the base property eg `src/tenants`
10
+ 1. Add a new folder with new method eg `src/tenants/createTenantUser`
11
+ 1. Add an `openapi/paths` folder under the method folder and insert a JSON openapi spec. [This helps with conversion](https://onlineyamltools.com/convert-yaml-to-json)
12
+ 1. If there are common schemas or responses, add them to `src/openapi` and reference them accordingly
13
+ 1. Update `/openapi/index.json` with any modifications, including the file you added/changed
14
+ 1. `yarn build` to be sure it works.
15
+
16
+ #### Add new function to the sdk
17
+
18
+ 1. Add the method (using the method name) and a function for obtaining URL to the base index file with types eg`src/tenants/index` (this should be a lot of copy paste)
19
+ 1. Add a test under the method folder to be sure it goes to the correct url.
@@ -0,0 +1,24 @@
1
+ import { Knex } from 'knex';
2
+ import { ServerConfig } from './types';
3
+ import { Config } from './utils/Config';
4
+ import Auth from './auth';
5
+ import Users from './users';
6
+ import Tenants from './tenants';
7
+ declare type Api = {
8
+ auth: Auth;
9
+ users: Users;
10
+ tenants: Tenants;
11
+ };
12
+ declare class Server {
13
+ config: Config;
14
+ api: Api;
15
+ db: Knex;
16
+ constructor(config?: ServerConfig);
17
+ setConfig(cfg: Config): void;
18
+ get tenantId(): string | undefined | null;
19
+ set tenantId(tenantId: string | undefined | null);
20
+ get token(): string | undefined;
21
+ set token(token: string | undefined);
22
+ }
23
+ export default function Nile(config: ServerConfig): Server;
24
+ export {};
@@ -0,0 +1,20 @@
1
+ import { RestModels } from '@niledatabase/js';
2
+ import { Config } from '../utils/Config';
3
+ import { NileRequest, NileResponse } from '../utils/Requester';
4
+ export default class Auth extends Config {
5
+ constructor(config: Config);
6
+ get loginUrl(): string;
7
+ login: (req: NileRequest<RestModels.CreateBasicUserRequest>, init?: RequestInit | undefined) => NileResponse<RestModels.LoginUserResponse>;
8
+ loginSSO: (redirectUrl: string) => (req: NileRequest<unknown>) => NileResponse<RestModels.TenantSSORegistration[]>;
9
+ loginSSOUrl: (provider: string) => string;
10
+ get signUpUrl(): string;
11
+ signUp: (req: NileRequest<RestModels.CreateBasicUserRequest>, init?: RequestInit | undefined) => NileResponse<RestModels.LoginUserResponse>;
12
+ updateProviderUrl(providerName: string): string;
13
+ get listTenantProvidersUrl(): string;
14
+ listTenantProviders: (req: NileRequest<void | Headers>, init?: RequestInit | undefined) => NileResponse<RestModels.TenantSSORegistration[]>;
15
+ createProvider: (req: NileRequest<RestModels.RegisterTenantSSORequest>, init?: RequestInit | undefined) => NileResponse<RestModels.TenantSSORegistration>;
16
+ updateProvider: (req: NileRequest<RestModels.RegisterTenantSSORequest>, init?: RequestInit | undefined) => NileResponse<RestModels.TenantSSORegistration>;
17
+ providerUrl(email?: undefined | string): string;
18
+ listProviders: (req: NileRequest<void | RestModels.CreateBasicUserRequest>, init?: RequestInit | undefined) => NileResponse<RestModels.TenantSSORegistration[]>;
19
+ getSSOCallbackUrl: (param: Headers | string) => string;
20
+ }
@@ -0,0 +1,9 @@
1
+ import knex, { Knex } from 'knex';
2
+ declare type IdParam = null | void | string | {
3
+ [key: string]: any;
4
+ id: string;
5
+ };
6
+ export declare function handleWithTenant(context: Knex.QueryBuilder, tenantId: IdParam): Promise<Knex.QueryBuilder>;
7
+ export declare function handleWithUser(context: Knex.QueryBuilder, userId: IdParam): Promise<Knex.QueryBuilder>;
8
+ export declare function extendKnex(): void;
9
+ export default knex;
@@ -0,0 +1,2 @@
1
+ import { default as Server } from './Server';
2
+ export default Server;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./server.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./server.cjs.development.js')
8
+ }