-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unsure what i did here. something about joining models in a query i g…
…uess
- Loading branch information
Showing
92 changed files
with
1,009 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {getUser} from "./lib.mjs"; | ||
|
||
|
||
/** | ||
* @returns {User} | ||
*/ | ||
function myUser() { | ||
const us = getUser("hej") | ||
return us | ||
} | ||
|
||
console.log(myUser.prototype.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @typedef {Object} User | ||
* @property {number} id | ||
* @property {string} name | ||
* @property {string} email | ||
*/ | ||
export class User { | ||
constructor(id, name, email) { | ||
} | ||
} | ||
|
||
/** | ||
* @param {number} id | ||
* @returns {User} | ||
*/ | ||
export function getUser(id) { | ||
return new User({ | ||
id | ||
}) | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function setAppBasedir(dir: any): void; | ||
export function getFwPackageDir(): string; | ||
export function getFwBasedir(): string; | ||
export function getRelativeImport(from: any): string; | ||
export function getAppBasedir(): string; | ||
export function getAppMigrationsDir(): string; | ||
export function isNonProd(): boolean; | ||
export function isNonTest(): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function registerAuthenticator(authenticator: any): void; | ||
export function getAuthenticator(name: any): any; | ||
export function getAuthenticatorForRoute(generatedRoute: any): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function initDevBundler(): Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default function get(path: any, _default: any): any; | ||
export function add(path: any, value: any): void; | ||
export function addDefault(path: any, value: any): void; | ||
export function envShortName(): "dev" | "test" | "prod"; | ||
export function addItemToObject(object: any, path: any, content: any): any; | ||
export function getLeaves(obj: any, path?: string, collector?: {}): {}; | ||
export function fullConf(): {}; | ||
export function fullDefaults(): {}; | ||
export function setConf(_conf: any): void; | ||
export function setDefaults(_defaults: any): void; | ||
export function allWithResolution(): { | ||
conf: {}; | ||
defaults: {}; | ||
resolved: {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function applyDefaultConfig(): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export function registerController(controller: any): void; | ||
export function getControllers(): { | ||
name: string; | ||
propertyNames: string[]; | ||
}[]; | ||
export class ControllerSetupCollector { | ||
constructor(controller: any); | ||
controller: any; | ||
middlewares: any[]; | ||
before(actions: any, callback: any): void; | ||
getRelevantMiddleware(action: any): any[]; | ||
} | ||
export function runMiddleware(controllerInst: any, action: any, ctx: any): Promise<void>; | ||
export function getController(name: any): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export class DbAdapter { | ||
getModelTableMetadata(): void; | ||
} | ||
export class PostgresDbAdapter extends DbAdapter { | ||
typeIdToString(tableName: any, name: any, dataTypeId: any): "BOOL" | "BIGSERIAL" | "INTEGER" | "REAL" | "TEXT" | "VARCHAR" | "TIMESTAMP" | "TIMESTAMPTZ" | "DECIMAL"; | ||
} | ||
export class MockDbAdapter extends DbAdapter { | ||
metas: {}; | ||
allEmpty: boolean; | ||
addModelTableMetadata(modelName: any, metas: any): void; | ||
setAllEmpty(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export function instantiateFromDbRow(model: any, row: any): any; | ||
export function addARQueryThings(model: any): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getPool(env: any): any; | ||
export function query(text: any, params: any, env: any): Promise<any>; | ||
export function close(): Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ModelType } from './models'; | ||
import { Field } from './querying/fields'; | ||
export declare function findStartEnd(definingFile: string, model: ModelType): { | ||
start: number; | ||
end: number; | ||
}; | ||
export declare function lineForField(field: Field): [string, string, string, string]; | ||
export declare function generateComment(model: ModelType, newlineChar: string): Promise<string>; | ||
export declare function insertComment(original: string, start: number, end: number, content: string): string; | ||
export declare function generateNewContent(contentBefore: string, model: ModelType): Promise<string>; | ||
export declare const modelsToGenerateDescriptionsFor: () => ModelType[]; | ||
export declare const generateDescriptions: () => Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
interface FieldOptions { | ||
null?: boolean; | ||
default?: any; | ||
} | ||
interface TableObject { | ||
name: string; | ||
} | ||
declare abstract class MigrationField { | ||
protected name: string; | ||
protected options?: FieldOptions; | ||
type: string; | ||
constructor(name: any, options: any); | ||
nullableString(): "" | " NOT NULL"; | ||
abstract ddl(param: TableObject): any; | ||
} | ||
export declare class MigratorTable { | ||
private fields; | ||
name: string; | ||
constructor(name: string); | ||
integer(name: any, options?: FieldOptions): void; | ||
bigint(name: any, options?: FieldOptions): void; | ||
text(name: any, options?: FieldOptions): void; | ||
bool(name: any, options?: FieldOptions): void; | ||
boolean(name: any, options?: FieldOptions): void; | ||
timestamp(name: any, options?: FieldOptions): void; | ||
timestamptz(name: any, options?: FieldOptions): void; | ||
decimal(name: any, options?: FieldOptions): void; | ||
timestamps(): void; | ||
generateDDL(): string; | ||
} | ||
declare class FieldCollector { | ||
type: any; | ||
tableName: any; | ||
fields: MigrationField[]; | ||
constructor(type: any, tableName: any); | ||
bool(name: any, opts: FieldOptions): void; | ||
boolean(name: any, opts: FieldOptions): void; | ||
text(name: any, opts: FieldOptions): void; | ||
integer(name: any, opts: FieldOptions): void; | ||
timestamp(name: any, opts: FieldOptions): void; | ||
timestamptz(name: any, opts: FieldOptions): void; | ||
decimal(name: any, options?: FieldOptions): void; | ||
generateDDL(): string; | ||
} | ||
declare abstract class TableOperation { | ||
tableName: string; | ||
constructor(tableName: any); | ||
abstract ddl(): any; | ||
} | ||
export declare class AlterTable { | ||
private field; | ||
operations: TableOperation[]; | ||
add: FieldCollector; | ||
tableName: any; | ||
constructor(table: any); | ||
rename(from: any, to: any): void; | ||
dropColumn(name: any): void; | ||
generateOperationDDLs(): string; | ||
ddl(): string; | ||
} | ||
export declare class MigrationCollector { | ||
private rawQueries; | ||
private tables; | ||
private alterTables; | ||
constructor(); | ||
query(text: string): void; | ||
alterTable(name: string, cb: (t: AlterTable) => void): void; | ||
renameTable(nameBefore: string, nameAfter: string): void; | ||
addTable(name: string, cb: (t: MigratorTable) => void): void; | ||
generateStatements(): string[]; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function addMigrationFileDir(dir: any): void; | ||
export function getMigrations(env: any): Promise<MigrationFile[]>; | ||
export function forceRunMigrationClass(cls: any): Promise<any>; | ||
export function getStatements(cls: any): Promise<string[]>; | ||
export function runMigrations(env: any): Promise<{ | ||
success: boolean; | ||
message: string; | ||
numSuccessful: number; | ||
}>; | ||
declare class MigrationFile { | ||
fullpath: string; | ||
name: string; | ||
hasRun: boolean; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Field, Fields } from './querying/fields'; | ||
import { ValidationCollector } from './validation/collection'; | ||
import { ModelSetupCollector } from './models/collector'; | ||
export interface ModelType { | ||
id: Field; | ||
_fields: Fields; | ||
_relationFields: Field[]; | ||
_modelName: string; | ||
prototype: any; | ||
_routeParamName: string; | ||
_setup: ModelSetupCollector; | ||
_tableName: string; | ||
_validations: ValidationCollector; | ||
_loaded: boolean; | ||
_registeringPath: string; | ||
loaded(): boolean; | ||
findOne(any: any): any; | ||
find(any: any): any; | ||
} | ||
interface ModelsType { | ||
[s: string]: ModelType; | ||
} | ||
export interface ModelInstance { | ||
} | ||
export declare const assureBucket: (obj: any) => void; | ||
export declare function setDbAdapter(adapter: any): void; | ||
export declare const registerModelsAsQueryParams: (app: any) => Promise<void>; | ||
export declare const modelNameToTableName: (name: any) => any; | ||
export declare const getLowercasedModel: (name: any) => ModelType | undefined; | ||
export declare const collectSetup: (model: any) => void; | ||
export declare const prepareModels: () => Promise<void>; | ||
export declare const models: ModelsType; | ||
export declare function registerModel(model: any): void; | ||
export declare function clearModels(): void; | ||
export declare function getUserModels(): ModelsType; | ||
export declare function getLoadedUserModelList(): ModelType[]; | ||
export declare function getModels(): ModelsType; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ValidationCollector } from '../validation/collection'; | ||
import { ModelType } from '../models'; | ||
export interface CollectedRelation { | ||
type: 'belongsTo' | 'hasMany'; | ||
name: string; | ||
options: any; | ||
model: ModelType; | ||
} | ||
export interface BelongsToOptions { | ||
model?: string; | ||
} | ||
export interface HasManyOptions { | ||
model?: string; | ||
} | ||
export declare class ModelSetupCollector { | ||
relations: CollectedRelation[]; | ||
fillable_fields: string[]; | ||
model: ModelType; | ||
validationCollector: ValidationCollector; | ||
_getFromParamCallback: (id: any) => string; | ||
constructor(model: ModelType); | ||
belongsTo(name: any, options?: BelongsToOptions): void; | ||
fillable(fields: any): void; | ||
getFromParam(callback: any): void; | ||
hasMany(name: any, options?: HasManyOptions): void; | ||
validate(callback: (validations: ValidationCollector) => void): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ModelType } from '../models'; | ||
export declare const jsifyFieldName: (underscored_name: any) => string; | ||
export declare const dbIfyJsName: (jsName: any) => any; | ||
declare type FieldTypes = 'hasMany' | 'belongsTo'; | ||
export declare class Field { | ||
dbName: string; | ||
jsName: string; | ||
type: FieldTypes; | ||
relation: boolean; | ||
targetModel?: ModelType; | ||
model: ModelType; | ||
tsType: string; | ||
relationField?: Field; | ||
isLessThanComparable(): boolean; | ||
static typeStringToTsType(string: any): "Date" | "number" | "string" | "boolean"; | ||
static FromDb(dbName: any, type: any): Field; | ||
static FromRelation(relation: any): Field; | ||
jsIfy(dbName: any): string; | ||
isDateTime(): boolean; | ||
} | ||
export declare class Fields { | ||
private all; | ||
constructor(arr: any); | ||
getAll(): Field[]; | ||
dbFieldNames(): string[]; | ||
jsFieldNames(): string[]; | ||
addField(field: any): void; | ||
getByJsName(changedJsName: any): Field | undefined; | ||
getByDbName(column: any): Field | undefined; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ModelInstance, ModelType } from '../models'; | ||
import { Field } from './fields'; | ||
declare type SqlOperators = '=' | '!=' | '<' | '<=' | '>' | '>=' | 'ANY'; | ||
export declare class QueryField { | ||
private field; | ||
model: ModelType; | ||
private name; | ||
dbName: any; | ||
private operator; | ||
relation?: Field; | ||
constructor(model: ModelType, field: Field, operator: SqlOperators); | ||
setRelation(rel: any): void; | ||
needsIdx(value: any): boolean; | ||
sql(alias: any, value: any, paramId: any): string | undefined; | ||
} | ||
export declare class QueryBuilder { | ||
private conditions; | ||
private joinFields; | ||
private aliases; | ||
private orderings; | ||
private limitCount; | ||
private model; | ||
constructor(); | ||
joinedColumnNames(): string; | ||
leftJoin(...conditions: any[]): this; | ||
join(...conditions: any[]): this; | ||
isJoinedWith(relation: any): boolean; | ||
isAliasAvailable(str: any): boolean; | ||
setUpAliases(): void; | ||
getAlias(model: any): string; | ||
joinTablesString(): string; | ||
conditionsString(values: any): string; | ||
sql(): (string | never[])[]; | ||
limitStr(): string; | ||
orderingStr(): string; | ||
first(): Promise<ModelInstance>; | ||
one(): Promise<ModelInstance>; | ||
query(): Promise<ModelInstance[]>; | ||
all(): void; | ||
get(): Promise<ModelInstance[]>; | ||
targetModel(model: any): void; | ||
addConditions(conditions: any): void; | ||
addCondition(param: any): void; | ||
order(param: any, direction: any): this; | ||
limit(count: any): this; | ||
where(...args: any[]): this; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { ModelType } from '../models'; | ||
export declare const setupRelations: (model: ModelType) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function findOneSql(model: any, id: any): (string | never[])[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export declare const registerSerializer: (serializer: any) => void; | ||
export declare class SerializerCollector<T> { | ||
fieldsToResolve: string[]; | ||
objsGiven: {}; | ||
fieldsToStringify: string[]; | ||
constructor(); | ||
add(...args: object[] | (keyof T)[]): void; | ||
addString(obj: keyof T | (keyof T)[]): void; | ||
} | ||
export declare const serialize: (hej: any, desiredSerializer?: string | undefined) => Promise<any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function register(): void; | ||
export function getDbStore(expSess: any): any; | ||
export function hasSessionsTable(): Promise<boolean>; |
3 changes: 3 additions & 0 deletions
3
semla/decl/db/sessions/migrations/2020-03-26_21-22_AddSessionsTable.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default class Migration_20200326_2122_AddSessionsTable { | ||
change(m: any): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ModelType } from './models'; | ||
interface Attributes { | ||
settableName: string; | ||
settableContent: string; | ||
attributesName: string; | ||
attributesContent: string; | ||
joinableFieldsName: string; | ||
joinableFieldsType: string; | ||
queryFieldsName: string; | ||
queryFieldsContent: string; | ||
} | ||
export declare const generateAttributesForModel: (model: ModelType) => Attributes; | ||
export declare const generateBaseClassForModel: (model: ModelType, attributes: Attributes) => string; | ||
export declare const generateBodyForModel: (model: ModelType) => string; | ||
export declare const generateTypes: () => Promise<void>; | ||
export {}; |
Oops, something went wrong.