parent
365f472717
commit
059836f4bc
12
package.json
12
package.json
@ -4,7 +4,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tachybase build",
|
"build": "tachybase build --no-dts",
|
||||||
|
"build:full": "tachybase build",
|
||||||
"build:p": "tachybase build --no-dts",
|
"build:p": "tachybase build --no-dts",
|
||||||
"changelog": "auto-changelog -p -t keepachangelog",
|
"changelog": "auto-changelog -p -t keepachangelog",
|
||||||
"clean": "tachybase clean",
|
"clean": "tachybase clean",
|
||||||
@ -19,19 +20,17 @@
|
|||||||
"pm2": "tachybase pm2",
|
"pm2": "tachybase pm2",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"release": "pnpm -r exec -- npm version patch && npm version patch --no-git-tag-version && git commit -a -m 'chore(version): release '$(jq -r '.version | \"v\\(.)\"' package.json | tr -d '\"') && git tag $(jq -r '.version | \"v\\(.)\"' package.json | tr -d '\"')",
|
"release": "pnpm -r exec -- npm version patch && npm version patch --no-git-tag-version && git commit -a -m 'chore(version): release '$(jq -r '.version | \"v\\(.)\"' package.json | tr -d '\"') && git tag $(jq -r '.version | \"v\\(.)\"' package.json | tr -d '\"')",
|
||||||
"run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts",
|
|
||||||
"start": "tachybase start",
|
"start": "tachybase start",
|
||||||
"tachybase": "tachybase",
|
"tachybase": "tachybase",
|
||||||
"tag": "changeset",
|
|
||||||
"tar": "tachybase tar",
|
"tar": "tachybase tar",
|
||||||
"tb": "tachybase",
|
"tb": "tachybase",
|
||||||
"tbi": "tachybase install",
|
"tbi": "tachybase install",
|
||||||
|
"tbu": "tachybase upgrade",
|
||||||
"tc": "tachybase test:client",
|
"tc": "tachybase test:client",
|
||||||
"test": "tachybase test",
|
"test": "tachybase test",
|
||||||
"test:client": "tachybase test:client",
|
"test:client": "tachybase test:client",
|
||||||
"test:server": "tachybase test:server",
|
"test:server": "tachybase test:server",
|
||||||
"ts": "tachybase test:server",
|
"ts": "tachybase test:server"
|
||||||
"ver": "changeset version"
|
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,json,sql}": [
|
"*.{js,json,sql}": [
|
||||||
@ -76,7 +75,8 @@
|
|||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"tsx": "^4.7.2",
|
"tsx": "^4.7.2",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.4.5",
|
||||||
"umi": "^4.1.10"
|
"umi": "^4.1.10",
|
||||||
|
"vitest": "^1.6.0"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@8.15.5",
|
"packageManager": "pnpm@8.15.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import { Context } from '@tachybase/actions';
|
import { Context } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { ACL } from '..';
|
import { ACL } from '..';
|
||||||
|
|
||||||
describe('acl', () => {
|
describe('acl', () => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ACL } from '..';
|
import { ACL } from '..';
|
||||||
import { AllowManager } from '../allow-manager';
|
import { AllowManager } from '../allow-manager';
|
||||||
|
|
||||||
describe('allow manager', () => {
|
describe('allow manager', () => {
|
||||||
let acl: ACL;
|
let acl: ACL;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { ACL } from '..';
|
import { ACL } from '..';
|
||||||
|
|
||||||
describe('skip', () => {
|
describe('skip', () => {
|
||||||
|
@ -13,5 +13,8 @@ export interface AvailableActionOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ACLAvailableAction {
|
export class ACLAvailableAction {
|
||||||
constructor(public name: string, public options: AvailableActionOptions) {}
|
constructor(
|
||||||
|
public name: string,
|
||||||
|
public options: AvailableActionOptions,
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { ACL } from './acl';
|
import { ACL } from './acl';
|
||||||
|
|
||||||
type StrategyValue = false | '*' | string | string[];
|
type StrategyValue = false | '*' | string | string[];
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { ACLRole, RoleActionParams } from './acl-role';
|
|
||||||
import { ACL, ListenerContext } from './acl';
|
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
|
import { ACL, ListenerContext } from './acl';
|
||||||
|
import { ACLRole, RoleActionParams } from './acl-role';
|
||||||
|
|
||||||
export type ResourceActions = { [key: string]: RoleActionParams };
|
export type ResourceActions = { [key: string]: RoleActionParams };
|
||||||
|
|
||||||
interface AclResourceOptions {
|
interface AclResourceOptions {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import lodash from 'lodash';
|
||||||
|
import minimatch from 'minimatch';
|
||||||
|
|
||||||
import { ACL, DefineOptions } from './acl';
|
import { ACL, DefineOptions } from './acl';
|
||||||
import { ACLAvailableStrategy, AvailableStrategyOptions } from './acl-available-strategy';
|
import { ACLAvailableStrategy, AvailableStrategyOptions } from './acl-available-strategy';
|
||||||
import { ACLResource } from './acl-resource';
|
import { ACLResource } from './acl-resource';
|
||||||
import lodash from 'lodash';
|
|
||||||
import minimatch from 'minimatch';
|
|
||||||
|
|
||||||
export interface RoleActionParams {
|
export interface RoleActionParams {
|
||||||
fields?: string[];
|
fields?: string[];
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import EventEmitter from 'events';
|
||||||
import { Action } from '@tachybase/resourcer';
|
import { Action } from '@tachybase/resourcer';
|
||||||
import { assign, parseFilter, Toposort, ToposortOptions } from '@tachybase/utils';
|
import { assign, parseFilter, Toposort, ToposortOptions } from '@tachybase/utils';
|
||||||
import EventEmitter from 'events';
|
|
||||||
import compose from 'koa-compose';
|
import compose from 'koa-compose';
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { ACLAvailableAction, AvailableActionOptions } from './acl-available-action';
|
import { ACLAvailableAction, AvailableActionOptions } from './acl-available-action';
|
||||||
import { ACLAvailableStrategy, AvailableStrategyOptions, predicate } from './acl-available-strategy';
|
import { ACLAvailableStrategy, AvailableStrategyOptions, predicate } from './acl-available-strategy';
|
||||||
import { ACLRole, ResourceActionsOptions, RoleActionParams } from './acl-role';
|
import { ACLRole, ResourceActionsOptions, RoleActionParams } from './acl-role';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockServer, MockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { mockServer, MockServer } from './index';
|
||||||
|
|
||||||
describe('add action', () => {
|
describe('add action', () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('create action', () => {
|
describe('create action', () => {
|
||||||
let app;
|
let app;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
import { mockServer } from './index';
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('destroy action', () => {
|
describe('destroy action', () => {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
import { Collection } from '@tachybase/database';
|
import { Collection } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('first or create', () => {
|
describe('first or create', () => {
|
||||||
let app;
|
let app;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
import { MockServer, mockServer } from './';
|
import { MockServer, mockServer } from './';
|
||||||
|
|
||||||
describe('get action', () => {
|
describe('get action', () => {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import Database, { CollectionOptions, mockDatabase } from '@tachybase/database';
|
import Database, { CollectionOptions, mockDatabase } from '@tachybase/database';
|
||||||
import { Handlers, ResourceOptions, Resourcer } from '@tachybase/resourcer';
|
import { Handlers, ResourceOptions, Resourcer } from '@tachybase/resourcer';
|
||||||
|
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import bodyParser from 'koa-bodyparser';
|
import bodyParser from 'koa-bodyparser';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import supertest, { SuperAgentTest } from 'supertest';
|
import supertest, { SuperAgentTest } from 'supertest';
|
||||||
|
|
||||||
import db2resource from '../../../server/src/middlewares/db2resource';
|
import db2resource from '../../../server/src/middlewares/db2resource';
|
||||||
|
|
||||||
interface ActionParams {
|
interface ActionParams {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
import { MockServer, mockServer as actionMockServer } from './index';
|
|
||||||
|
import { mockServer as actionMockServer, MockServer } from './index';
|
||||||
|
|
||||||
describe('list action', () => {
|
describe('list action', () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { mockServer, MockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
import { Collection, Database } from '@tachybase/database';
|
import { Collection, Database } from '@tachybase/database';
|
||||||
import { waitSecond } from '@tachybase/test';
|
import { waitSecond } from '@tachybase/test';
|
||||||
|
|
||||||
|
import { mockServer, MockServer } from './index';
|
||||||
|
|
||||||
describe('sort action', () => {
|
describe('sort action', () => {
|
||||||
describe('associations', () => {
|
describe('associations', () => {
|
||||||
let api: MockServer;
|
let api: MockServer;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('remove action', () => {
|
describe('remove action', () => {
|
||||||
let app;
|
let app;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('set action', () => {
|
describe('set action', () => {
|
||||||
let app;
|
let app;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { SortAbleCollection } from '../actions';
|
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
|
import { SortAbleCollection } from '../actions';
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('sort collections', () => {
|
describe('sort collections', () => {
|
||||||
let app;
|
let app;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('toggle action', () => {
|
describe('toggle action', () => {
|
||||||
let app;
|
let app;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { MockServer, mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
|
|
||||||
|
import { MockServer, mockServer } from './index';
|
||||||
|
|
||||||
describe('update action', () => {
|
describe('update action', () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
let Post;
|
let Post;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { mockServer } from './index';
|
|
||||||
import { registerActions } from '@tachybase/actions';
|
import { registerActions } from '@tachybase/actions';
|
||||||
import { Collection } from '@tachybase/database';
|
import { Collection } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { mockServer } from './index';
|
||||||
|
|
||||||
describe('update or create', () => {
|
describe('update or create', () => {
|
||||||
let app;
|
let app;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
HasManyRepository,
|
HasManyRepository,
|
||||||
MultipleRelationRepository,
|
MultipleRelationRepository,
|
||||||
} from '@tachybase/database';
|
} from '@tachybase/database';
|
||||||
|
|
||||||
import { Context } from '..';
|
import { Context } from '..';
|
||||||
import { getRepositoryFromParams } from '../utils';
|
import { getRepositoryFromParams } from '../utils';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getRepositoryFromParams } from '../utils';
|
|
||||||
import { Context } from '../index';
|
import { Context } from '../index';
|
||||||
|
import { getRepositoryFromParams } from '../utils';
|
||||||
|
|
||||||
export async function destroy(ctx: Context, next) {
|
export async function destroy(ctx: Context, next) {
|
||||||
const repository = getRepositoryFromParams(ctx);
|
const repository = getRepositoryFromParams(ctx);
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { assign } from '@tachybase/utils';
|
|
||||||
import { Context } from '..';
|
|
||||||
import { getRepositoryFromParams, pageArgsToLimitArgs } from '../utils';
|
|
||||||
import { DEFAULT_PAGE, DEFAULT_PER_PAGE } from '../constants';
|
|
||||||
import { Op, QueryTypes } from 'sequelize';
|
|
||||||
import qs from 'querystring';
|
import qs from 'querystring';
|
||||||
|
import { assign } from '@tachybase/utils';
|
||||||
|
|
||||||
|
import { Op, QueryTypes } from 'sequelize';
|
||||||
|
|
||||||
|
import { Context } from '..';
|
||||||
|
import { DEFAULT_PAGE, DEFAULT_PER_PAGE } from '../constants';
|
||||||
|
import { getRepositoryFromParams, pageArgsToLimitArgs } from '../utils';
|
||||||
|
|
||||||
function totalPage(total, pageSize): number {
|
function totalPage(total, pageSize): number {
|
||||||
return Math.ceil(total / pageSize);
|
return Math.ceil(total / pageSize);
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { Model, Op } from 'sequelize';
|
|
||||||
|
|
||||||
import { Context } from '..';
|
|
||||||
import {
|
import {
|
||||||
BelongsToManyRepository,
|
BelongsToManyRepository,
|
||||||
Collection,
|
Collection,
|
||||||
@ -9,6 +6,10 @@ import {
|
|||||||
SortField,
|
SortField,
|
||||||
TargetKey,
|
TargetKey,
|
||||||
} from '@tachybase/database';
|
} from '@tachybase/database';
|
||||||
|
|
||||||
|
import { Model, Op } from 'sequelize';
|
||||||
|
|
||||||
|
import { Context } from '..';
|
||||||
import { getRepositoryFromParams } from '../utils';
|
import { getRepositoryFromParams } from '../utils';
|
||||||
|
|
||||||
export async function move(ctx: Context, next) {
|
export async function move(ctx: Context, next) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { Context } from '../index';
|
import { Context } from '../index';
|
||||||
import { getRepositoryFromParams } from '../utils';
|
import { getRepositoryFromParams } from '../utils';
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
import { RelationRepositoryActionBuilder } from '../utils';
|
import { RelationRepositoryActionBuilder } from '../utils';
|
||||||
|
|
||||||
export const remove = RelationRepositoryActionBuilder('remove');
|
export const remove = RelationRepositoryActionBuilder('remove');
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
import { RelationRepositoryActionBuilder } from '../utils';
|
import { RelationRepositoryActionBuilder } from '../utils';
|
||||||
|
|
||||||
export const set = RelationRepositoryActionBuilder('set');
|
export const set = RelationRepositoryActionBuilder('set');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { BelongsToManyRepository } from '@tachybase/database';
|
import { BelongsToManyRepository } from '@tachybase/database';
|
||||||
|
|
||||||
import { Context } from '..';
|
import { Context } from '..';
|
||||||
import { getRepositoryFromParams } from '../utils';
|
import { getRepositoryFromParams } from '../utils';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { MultipleRelationRepository, Repository } from '@tachybase/database';
|
import { MultipleRelationRepository, Repository } from '@tachybase/database';
|
||||||
|
|
||||||
import { Context } from '.';
|
import { Context } from '.';
|
||||||
|
|
||||||
export function pageArgsToLimitArgs(
|
export function pageArgsToLimitArgs(
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
"@tachybase/database": "workspace:*",
|
"@tachybase/database": "workspace:*",
|
||||||
"@tachybase/resourcer": "workspace:*",
|
"@tachybase/resourcer": "workspace:*",
|
||||||
"@tachybase/utils": "workspace:*",
|
"@tachybase/utils": "workspace:*",
|
||||||
"@types/jsonwebtoken": "^8.5.8",
|
|
||||||
"jsonwebtoken": "^8.5.1"
|
"jsonwebtoken": "^8.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jsonwebtoken": "^8.5.8",
|
||||||
|
"vitest": "^1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import { Context } from '@tachybase/actions';
|
import { Context } from '@tachybase/actions';
|
||||||
import { Auth, AuthManager } from '@tachybase/auth';
|
import { Auth, AuthManager } from '@tachybase/auth';
|
||||||
import Database, { Model } from '@tachybase/database';
|
import Database, { Model } from '@tachybase/database';
|
||||||
import { MockServer, mockServer } from '@tachybase/test';
|
import { MockServer, mockServer } from '@tachybase/test';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
class MockStorer {
|
class MockStorer {
|
||||||
elements: Map<string, any> = new Map();
|
elements: Map<string, any> = new Map();
|
||||||
async set(name: string, value: any) {
|
async set(name: string, value: any) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Context, Next } from '@tachybase/actions';
|
import { Context, Next } from '@tachybase/actions';
|
||||||
import { Registry } from '@tachybase/utils';
|
import { Registry } from '@tachybase/utils';
|
||||||
|
|
||||||
import { Auth, AuthExtend } from './auth';
|
import { Auth, AuthExtend } from './auth';
|
||||||
import { JwtOptions, JwtService } from './base/jwt-service';
|
import { JwtOptions, JwtService } from './base/jwt-service';
|
||||||
import { ITokenBlacklistService } from './base/token-blacklist-service';
|
import { ITokenBlacklistService } from './base/token-blacklist-service';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Context } from '@tachybase/actions';
|
import { Context } from '@tachybase/actions';
|
||||||
import { Model } from '@tachybase/database';
|
import { Model } from '@tachybase/database';
|
||||||
|
|
||||||
import { Authenticator } from './auth-manager';
|
import { Authenticator } from './auth-manager';
|
||||||
|
|
||||||
export type AuthConfig = {
|
export type AuthConfig = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Collection, Model } from '@tachybase/database';
|
import { Collection, Model } from '@tachybase/database';
|
||||||
|
|
||||||
import { Auth, AuthConfig } from '../auth';
|
import { Auth, AuthConfig } from '../auth';
|
||||||
import { JwtService } from './jwt-service';
|
import { JwtService } from './jwt-service';
|
||||||
import { Cache } from '@tachybase/cache';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BaseAuth
|
* BaseAuth
|
||||||
@ -56,7 +56,7 @@ export class BaseAuth extends Auth {
|
|||||||
this.ctx.headers['x-role'] = roleName;
|
this.ctx.headers['x-role'] = roleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cache = this.ctx.cache as Cache;
|
const cache = this.ctx.cache;
|
||||||
return await cache.wrap(this.getCacheKey(userId), () =>
|
return await cache.wrap(this.getCacheKey(userId), () =>
|
||||||
this.userRepository.findOne({
|
this.userRepository.findOne({
|
||||||
filter: {
|
filter: {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import jwt, { SignOptions } from 'jsonwebtoken';
|
import jwt, { SignOptions } from 'jsonwebtoken';
|
||||||
|
|
||||||
import { ITokenBlacklistService } from './token-blacklist-service';
|
import { ITokenBlacklistService } from './token-blacklist-service';
|
||||||
|
|
||||||
export interface JwtOptions {
|
export interface JwtOptions {
|
||||||
|
10
packages/core/cache/package.json
vendored
10
packages/core/cache/package.json
vendored
@ -8,11 +8,13 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bloom-filters": "^3.0.1",
|
"bloom-filters": "^3.0.1",
|
||||||
"cache-manager": "^5.2.4",
|
"cache-manager": "^5.2.4",
|
||||||
"cache-manager-redis-yet": "^4.1.2"
|
"cache-manager-redis-yet": "^4.1.2",
|
||||||
|
"deepmerge": "^4.2.2",
|
||||||
|
"lodash": "4.17.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"deepmerge": "^4.2.2",
|
"@types/lodash": "^4.17.5",
|
||||||
"lodash": "4.17.21",
|
"redis": "^4.6.10",
|
||||||
"redis": "^4.6.10"
|
"vitest": "^1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Cache } from '../cache';
|
import { Cache } from '../cache';
|
||||||
import { CacheManager } from '../cache-manager';
|
import { CacheManager } from '../cache-manager';
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { Cache } from '../cache';
|
import { Cache } from '../cache';
|
||||||
import { CacheManager } from '../cache-manager';
|
import { CacheManager } from '../cache-manager';
|
||||||
import lodash from 'lodash';
|
|
||||||
|
|
||||||
describe('cache', () => {
|
describe('cache', () => {
|
||||||
let cache: Cache;
|
let cache: Cache;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import { BloomFilter } from 'bloom-filters';
|
||||||
|
|
||||||
import { BloomFilter as IBloomFilter } from '.';
|
import { BloomFilter as IBloomFilter } from '.';
|
||||||
import { Cache } from '../cache';
|
import { Cache } from '../cache';
|
||||||
import { BloomFilter } from 'bloom-filters';
|
|
||||||
|
|
||||||
export class MemoryBloomFilter implements IBloomFilter {
|
export class MemoryBloomFilter implements IBloomFilter {
|
||||||
cache: Cache;
|
cache: Cache;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { RedisStore } from 'cache-manager-redis-yet';
|
import type { RedisStore } from 'cache-manager-redis-yet';
|
||||||
import type { RedisClientType } from 'redis';
|
|
||||||
import { BloomFilter } from '.';
|
import { BloomFilter } from '.';
|
||||||
import { Cache } from '../cache';
|
import { Cache } from '../cache';
|
||||||
|
|
||||||
|
@ -17,5 +17,14 @@
|
|||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"koa-compose": "^4.1.0",
|
"koa-compose": "^4.1.0",
|
||||||
"lodash": "4.17.21"
|
"lodash": "4.17.21"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/koa": "^2.15.0",
|
||||||
|
"@types/koa-bodyparser": "^4.3.12",
|
||||||
|
"@types/lodash": "^4.17.5",
|
||||||
|
"@types/supertest": "^6.0.2",
|
||||||
|
"koa": "^2.15.3",
|
||||||
|
"koa-bodyparser": "4.4.1",
|
||||||
|
"supertest": "^7.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { createMockServer } from '@tachybase/test';
|
import { createMockServer } from '@tachybase/test';
|
||||||
|
|
||||||
import { DataSource } from '../data-source';
|
import { DataSource } from '../data-source';
|
||||||
import { ICollectionManager } from '../types';
|
import { ICollectionManager } from '../types';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { createMockServer, mockDatabase, supertest } from '@tachybase/test';
|
import { createMockServer, mockDatabase, supertest } from '@tachybase/test';
|
||||||
|
|
||||||
import { SequelizeDataSource } from '../sequelize-data-source';
|
import { SequelizeDataSource } from '../sequelize-data-source';
|
||||||
|
|
||||||
describe('example', () => {
|
describe('example', () => {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { mockDatabase } from '@tachybase/test';
|
import { mockDatabase } from '@tachybase/test';
|
||||||
|
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import bodyParser from 'koa-bodyparser';
|
import bodyParser from 'koa-bodyparser';
|
||||||
import supertest from 'supertest';
|
import supertest from 'supertest';
|
||||||
|
|
||||||
import { DataSourceManager } from '../data-source-manager';
|
import { DataSourceManager } from '../data-source-manager';
|
||||||
import { SequelizeDataSource } from '../sequelize-data-source';
|
import { SequelizeDataSource } from '../sequelize-data-source';
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { CollectionOptions, ICollection, ICollectionManager, IField, IRepository } from './types';
|
|
||||||
import { default as lodash } from 'lodash';
|
|
||||||
import merge from 'deepmerge';
|
import merge from 'deepmerge';
|
||||||
|
import { default as lodash } from 'lodash';
|
||||||
|
|
||||||
import { CollectionField } from './collection-field';
|
import { CollectionField } from './collection-field';
|
||||||
|
import { CollectionOptions, ICollection, ICollectionManager, IField, IRepository } from './types';
|
||||||
|
|
||||||
export class Collection implements ICollection {
|
export class Collection implements ICollection {
|
||||||
repository: IRepository;
|
repository: IRepository;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import EventEmitter from 'events';
|
||||||
import { ACL } from '@tachybase/acl';
|
import { ACL } from '@tachybase/acl';
|
||||||
import { getNameByParams, parseRequest } from '@tachybase/resourcer';
|
import { getNameByParams, parseRequest } from '@tachybase/resourcer';
|
||||||
import EventEmitter from 'events';
|
|
||||||
import compose from 'koa-compose';
|
import compose from 'koa-compose';
|
||||||
|
|
||||||
import { loadDefaultActions } from './load-default-actions';
|
import { loadDefaultActions } from './load-default-actions';
|
||||||
import { ResourceManager } from './resource-manager';
|
import { ResourceManager } from './resource-manager';
|
||||||
import { ICollectionManager } from './types';
|
import { ICollectionManager } from './types';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { assign } from '@tachybase/utils';
|
|
||||||
import { getRepositoryFromParams, pageArgsToLimitArgs } from './utils';
|
|
||||||
import { Context } from '@tachybase/actions';
|
import { Context } from '@tachybase/actions';
|
||||||
|
import { assign } from '@tachybase/utils';
|
||||||
|
|
||||||
|
import { getRepositoryFromParams, pageArgsToLimitArgs } from './utils';
|
||||||
|
|
||||||
function totalPage(total, pageSize): number {
|
function totalPage(total, pageSize): number {
|
||||||
return Math.ceil(total / pageSize);
|
return Math.ceil(total / pageSize);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { DataSource } from '../data-source';
|
import { DataSource } from '../data-source';
|
||||||
import { getRepositoryFromParams } from './utils';
|
import { getRepositoryFromParams } from './utils';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Context } from '@tachybase/actions';
|
import { Context } from '@tachybase/actions';
|
||||||
|
|
||||||
import { DataSource, IRepository } from '../';
|
import { DataSource, IRepository } from '../';
|
||||||
|
|
||||||
export function pageArgsToLimitArgs(
|
export function pageArgsToLimitArgs(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { DataSource } from './data-source';
|
||||||
import { list } from './default-actions/list';
|
import { list } from './default-actions/list';
|
||||||
import { move } from './default-actions/move';
|
import { move } from './default-actions/move';
|
||||||
import { proxyToRepository } from './default-actions/proxy-to-repository';
|
import { proxyToRepository } from './default-actions/proxy-to-repository';
|
||||||
import { DataSource } from './data-source';
|
|
||||||
|
|
||||||
type Actions = { [key: string]: { params: Array<string> | ((ctx: any) => Array<string>); method: string } };
|
type Actions = { [key: string]: { params: Array<string> | ((ctx: any) => Array<string>); method: string } };
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { IModel, IRepository } from './types';
|
|
||||||
import * as console from 'console';
|
import * as console from 'console';
|
||||||
|
|
||||||
|
import { IModel, IRepository } from './types';
|
||||||
|
|
||||||
export class Repository implements IRepository {
|
export class Repository implements IRepository {
|
||||||
async create(options) {
|
async create(options) {
|
||||||
console.log('Repository.create....');
|
console.log('Repository.create....');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Database from '@tachybase/database';
|
import Database from '@tachybase/database';
|
||||||
|
|
||||||
import { CollectionOptions, ICollection, ICollectionManager, IRepository, MergeOptions } from './types';
|
import { CollectionOptions, ICollection, ICollectionManager, IRepository, MergeOptions } from './types';
|
||||||
|
|
||||||
export class SequelizeCollectionManager implements ICollectionManager {
|
export class SequelizeCollectionManager implements ICollectionManager {
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
"umzug": "^3.1.1"
|
"umzug": "^3.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/flat": "^5.0.5",
|
||||||
"@types/glob": "^7.2.0",
|
"@types/glob": "^7.2.0",
|
||||||
"@types/lodash": "4.17.0"
|
"@types/lodash": "^4.17.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { mockDatabase } from './';
|
|
||||||
import Database from '../database';
|
import Database from '../database';
|
||||||
|
import { mockDatabase } from './';
|
||||||
|
|
||||||
describe('adjacency list repository', () => {
|
describe('adjacency list repository', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Database } from '../../database';
|
import { Database } from '../../database';
|
||||||
import { mockDatabase } from '../index';
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('association references', () => {
|
describe('association references', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
|
import { Collection } from '../collection';
|
||||||
import Database from '../database';
|
import Database from '../database';
|
||||||
import { mockDatabase } from './index';
|
import { mockDatabase } from './index';
|
||||||
import { Collection } from '../collection';
|
|
||||||
|
|
||||||
describe('collection factory', function () {
|
describe('collection factory', function () {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ImporterReader } from '../collection-importer';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
import { ImporterReader } from '../collection-importer';
|
||||||
import { extend } from '../database';
|
import { extend } from '../database';
|
||||||
|
|
||||||
describe('collection importer', () => {
|
describe('collection importer', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { mockDatabase } from './index';
|
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
|
import { mockDatabase } from './index';
|
||||||
|
|
||||||
describe('collection sortable options', () => {
|
describe('collection sortable options', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Collection } from '../collection';
|
import { Collection } from '../collection';
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
import { mockDatabase } from './index';
|
|
||||||
import { IdentifierError } from '../errors/identifier-error';
|
import { IdentifierError } from '../errors/identifier-error';
|
||||||
|
import { mockDatabase } from './index';
|
||||||
|
|
||||||
const pgOnly = () => (process.env.DB_DIALECT == 'postgres' ? it : it.skip);
|
const pgOnly = () => (process.env.DB_DIALECT == 'postgres' ? it : it.skip);
|
||||||
describe('collection', () => {
|
describe('collection', () => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mockDatabase } from './index';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import Database from '../database';
|
import Database from '../database';
|
||||||
|
import { mockDatabase } from './index';
|
||||||
|
|
||||||
describe('database', () => {
|
describe('database', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Database, Model } from '..';
|
import { Database, Model } from '..';
|
||||||
import { ArrayFieldRepository } from '../field-repository/array-field-repository';
|
import { ArrayFieldRepository } from '../field-repository/array-field-repository';
|
||||||
import { mockDatabase } from './index';
|
import { mockDatabase } from './index';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Database, { mockDatabase } from '@tachybase/database';
|
import Database, { mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree';
|
import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree';
|
||||||
|
|
||||||
describe('Eager loading tree', () => {
|
describe('Eager loading tree', () => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { mockDatabase } from '@tachybase/test';
|
import { mockDatabase } from '@tachybase/test';
|
||||||
|
|
||||||
import { BelongsToManyRepository, Database } from '../../index';
|
import { BelongsToManyRepository, Database } from '../../index';
|
||||||
|
|
||||||
describe('associated field order', () => {
|
describe('associated field order', () => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import Database from '../../database';
|
import Database from '../../database';
|
||||||
import { ArrayFieldRepository } from '../../field-repository/array-field-repository';
|
import { ArrayFieldRepository } from '../../field-repository/array-field-repository';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('Array field repository', () => {
|
describe('Array field repository', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '../../database';
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
|
import { Database } from '../../database';
|
||||||
import { IdentifierError } from '../../errors/identifier-error';
|
import { IdentifierError } from '../../errors/identifier-error';
|
||||||
|
|
||||||
describe('belongs to field', () => {
|
describe('belongs to field', () => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { DataTypes } from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
import { Database } from '../../';
|
import { Database } from '../../';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '../../database';
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
|
import { Database } from '../../database';
|
||||||
import { IdentifierError } from '../../errors/identifier-error';
|
import { IdentifierError } from '../../errors/identifier-error';
|
||||||
|
|
||||||
describe('has many field', () => {
|
describe('has many field', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '../../database';
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
|
import { Database } from '../../database';
|
||||||
import { IdentifierError } from '../../errors/identifier-error';
|
import { IdentifierError } from '../../errors/identifier-error';
|
||||||
|
|
||||||
describe('has many field', () => {
|
describe('has many field', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '../../database';
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
|
import { Database } from '../../database';
|
||||||
import { SortField } from '../../fields';
|
import { SortField } from '../../fields';
|
||||||
|
|
||||||
describe('string field', () => {
|
describe('string field', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '../../database';
|
|
||||||
import { mockDatabase } from '../';
|
import { mockDatabase } from '../';
|
||||||
|
import { Database } from '../../database';
|
||||||
|
|
||||||
describe('string field', () => {
|
describe('string field', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Op } from 'sequelize';
|
import { Op } from 'sequelize';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
import FilterParser from '../filter-parser';
|
import FilterParser from '../filter-parser';
|
||||||
import { mockDatabase } from './index';
|
import { mockDatabase } from './index';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Database, mockDatabase } from '@tachybase/database';
|
import { Database, mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
import sequelize from 'sequelize';
|
import sequelize from 'sequelize';
|
||||||
|
|
||||||
describe('migrator', () => {
|
describe('migrator', () => {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { BelongsToManyRepository } from '@tachybase/database';
|
import { BelongsToManyRepository } from '@tachybase/database';
|
||||||
|
import { isPg } from '@tachybase/test';
|
||||||
|
|
||||||
import Database from '../../database';
|
import Database from '../../database';
|
||||||
import { InheritedCollection } from '../../inherited-collection';
|
import { InheritedCollection } from '../../inherited-collection';
|
||||||
import { mockDatabase } from '../index';
|
import { mockDatabase } from '../index';
|
||||||
import { isPg } from '@tachybase/test';
|
|
||||||
|
|
||||||
describe.runIf(isPg())('collection inherits', () => {
|
describe.runIf(isPg())('collection inherits', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import { Database, Migration, mockDatabase } from '@tachybase/database';
|
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
import { Database, Migration, mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
const names = (migrations: Array<{ name: string }>) => migrations.map((m) => m.name);
|
const names = (migrations: Array<{ name: string }>) => migrations.map((m) => m.name);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database } from '..';
|
|
||||||
import { mockDatabase } from '.';
|
import { mockDatabase } from '.';
|
||||||
|
import { Database } from '..';
|
||||||
|
|
||||||
describe('model hook', () => {
|
describe('model hook', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import Database from '../../database';
|
|
||||||
import { Collection } from '../../collection';
|
import { Collection } from '../../collection';
|
||||||
|
import Database from '../../database';
|
||||||
import { mockDatabase } from '../index';
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('association operator', () => {
|
describe('association operator', () => {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import Database from '../../database';
|
|
||||||
import { Collection } from '../../collection';
|
import { Collection } from '../../collection';
|
||||||
|
import Database from '../../database';
|
||||||
import { mockDatabase } from '../index';
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('empty operator', () => {
|
describe('empty operator', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import Database from '../../database';
|
import Database from '../../database';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('ne operator', () => {
|
describe('ne operator', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import { Database } from '../../database';
|
|
||||||
import { randomStr } from '@tachybase/test';
|
import { randomStr } from '@tachybase/test';
|
||||||
|
|
||||||
|
import { Database } from '../../database';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('auth', () => {
|
describe('auth', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Collection } from '@tachybase/database';
|
import { Collection } from '@tachybase/database';
|
||||||
|
import { pgOnly } from '@tachybase/test';
|
||||||
|
|
||||||
import Database from '../../database';
|
import Database from '../../database';
|
||||||
import { BelongsToManyRepository } from '../../relation-repository/belongs-to-many-repository';
|
import { BelongsToManyRepository } from '../../relation-repository/belongs-to-many-repository';
|
||||||
import { mockDatabase } from '../index';
|
import { mockDatabase } from '../index';
|
||||||
import { pgOnly } from '@tachybase/test';
|
|
||||||
|
|
||||||
pgOnly()('belongs to many with targetCollection', () => {
|
pgOnly()('belongs to many with targetCollection', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import { HasManyRepository } from '../../relation-repository/hasmany-repository';
|
|
||||||
import { BelongsToManyRepository } from '../../relation-repository/belongs-to-many-repository';
|
|
||||||
import Database, { Collection } from '@tachybase/database';
|
import Database, { Collection } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { BelongsToManyRepository } from '../../relation-repository/belongs-to-many-repository';
|
||||||
|
import { HasManyRepository } from '../../relation-repository/hasmany-repository';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('has many with target key', function () {
|
describe('has many with target key', function () {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { Repository } from '@tachybase/database';
|
import { Repository } from '@tachybase/database';
|
||||||
|
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Collection } from '../collection';
|
import { Collection } from '../collection';
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
import { mockDatabase } from './';
|
import { mockDatabase } from './';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BelongsToManyRepository, HasManyRepository, mockDatabase } from '../../index';
|
|
||||||
import Database from '../../database';
|
|
||||||
import { Collection } from '../../collection';
|
import { Collection } from '../../collection';
|
||||||
|
import Database from '../../database';
|
||||||
|
import { BelongsToManyRepository, HasManyRepository, mockDatabase } from '../../index';
|
||||||
|
|
||||||
describe('association aggregation', () => {
|
describe('association aggregation', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import { HasManyRepository } from '../../relation-repository/hasmany-repository';
|
|
||||||
import { Collection } from '../../collection';
|
import { Collection } from '../../collection';
|
||||||
|
import { HasManyRepository } from '../../relation-repository/hasmany-repository';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('count', () => {
|
describe('count', () => {
|
||||||
let db;
|
let db;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import Database from '../../database';
|
|
||||||
import { Collection } from '../../collection';
|
import { Collection } from '../../collection';
|
||||||
|
import Database from '../../database';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('create with hasMany', () => {
|
describe('create with hasMany', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import { Collection } from '../../collection';
|
|
||||||
import { Database } from '@tachybase/database';
|
import { Database } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { Collection } from '../../collection';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('destroy with targetKey', function () {
|
describe('destroy with targetKey', function () {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
let User: Collection;
|
let User: Collection;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import { mockDatabase } from '../index';
|
|
||||||
import Database from '@tachybase/database';
|
import Database from '@tachybase/database';
|
||||||
import { Collection } from '../../collection';
|
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
|
|
||||||
|
import { Collection } from '../../collection';
|
||||||
|
import { mockDatabase } from '../index';
|
||||||
|
|
||||||
describe('find with associations', () => {
|
describe('find with associations', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
import { mockDatabase } from './index';
|
import { mockDatabase } from './index';
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { SQLModel } from '../../sql-collection/sql-model';
|
|
||||||
import { Sequelize } from 'sequelize';
|
import { Sequelize } from 'sequelize';
|
||||||
|
|
||||||
|
import { SQLModel } from '../../sql-collection/sql-model';
|
||||||
|
|
||||||
describe('select query', () => {
|
describe('select query', () => {
|
||||||
const model = class extends SQLModel {};
|
const model = class extends SQLModel {};
|
||||||
model.init(null, {
|
model.init(null, {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import { Database, mockDatabase } from '@tachybase/database';
|
import { Database, mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
describe('sync', () => {
|
describe('sync', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Database, mockDatabase } from '@tachybase/database';
|
|
||||||
import * as process from 'process';
|
import * as process from 'process';
|
||||||
|
import { Database, mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
describe('empty table', () => {
|
describe('empty table', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Database, mockDatabase } from '../../index';
|
|
||||||
import * as process from 'process';
|
import * as process from 'process';
|
||||||
|
|
||||||
|
import { Database, mockDatabase } from '../../index';
|
||||||
|
|
||||||
describe('primary key', () => {
|
describe('primary key', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
import { mockDatabase } from './';
|
import { mockDatabase } from './';
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Collection } from '../collection';
|
|
||||||
import { mockDatabase } from './index';
|
|
||||||
import { UpdateGuard } from '../update-guard';
|
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
|
import { Collection } from '../collection';
|
||||||
import { Database } from '../database';
|
import { Database } from '../database';
|
||||||
|
import { UpdateGuard } from '../update-guard';
|
||||||
|
import { mockDatabase } from './index';
|
||||||
|
|
||||||
describe('update-guard', () => {
|
describe('update-guard', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { Database, mockDatabase } from '../..';
|
import { Database, mockDatabase } from '../..';
|
||||||
import { DateValueParser } from '../../value-parsers';
|
import { DateValueParser } from '../../value-parsers';
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { vi } from 'vitest';
|
|
||||||
import { uid } from '@tachybase/utils';
|
import { uid } from '@tachybase/utils';
|
||||||
|
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { Database, mockDatabase } from '../../index';
|
import { Database, mockDatabase } from '../../index';
|
||||||
import { ViewCollection } from '../../view-collection';
|
import { ViewCollection } from '../../view-collection';
|
||||||
import pgOnly from '../inhertits/helper';
|
import pgOnly from '../inhertits/helper';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Database, mockDatabase } from '@tachybase/database';
|
import { Database, mockDatabase } from '@tachybase/database';
|
||||||
|
|
||||||
import { ViewFieldInference } from '../../view/view-inference';
|
import { ViewFieldInference } from '../../view/view-inference';
|
||||||
|
|
||||||
describe('view inference', function () {
|
describe('view inference', function () {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user