From 059836f4bcd066a4f4ef0723f71672378b8e505d Mon Sep 17 00:00:00 2001 From: sealday Date: Wed, 12 Jun 2024 11:39:09 +0800 Subject: [PATCH] refactor: core-libs (#1158) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1158 --- package.json | 12 +- packages/core/acl/src/__tests__/acl.test.ts | 4 +- .../acl/src/__tests__/allow-manager.test.ts | 1 + packages/core/acl/src/__tests__/allow.test.ts | 1 + packages/core/acl/src/acl-available-action.ts | 5 +- .../core/acl/src/acl-available-strategy.ts | 1 + packages/core/acl/src/acl-resource.ts | 5 +- packages/core/acl/src/acl-role.ts | 5 +- packages/core/acl/src/acl.ts | 4 +- .../actions/src/__tests__/add-action.test.ts | 3 +- .../src/__tests__/create-action.test.ts | 3 +- .../src/__tests__/destroy-action.test.ts | 1 + .../src/__tests__/first-or-create.test.ts | 3 +- .../actions/src/__tests__/get-action.test.ts | 1 + packages/core/actions/src/__tests__/index.ts | 2 + .../actions/src/__tests__/list-action.test.ts | 3 +- .../actions/src/__tests__/move-action.test.ts | 3 +- .../src/__tests__/remove-action.test.ts | 3 +- .../actions/src/__tests__/set-action.test.ts | 3 +- .../src/__tests__/sort-collection.test.ts | 5 +- .../src/__tests__/toggle-action.test.ts | 3 +- .../src/__tests__/update-action.test.ts | 3 +- .../src/__tests__/update-or-create.test.ts | 3 +- packages/core/actions/src/actions/add.ts | 1 + packages/core/actions/src/actions/destroy.ts | 2 +- packages/core/actions/src/actions/list.ts | 12 +- packages/core/actions/src/actions/move.ts | 7 +- .../src/actions/proxy-to-repository.ts | 1 + packages/core/actions/src/actions/remove.ts | 1 + packages/core/actions/src/actions/set.ts | 1 + packages/core/actions/src/actions/toggle.ts | 1 + packages/core/actions/src/utils.ts | 1 + packages/core/auth/package.json | 5 +- .../auth/src/__tests__/auth-manager.test.ts | 3 +- packages/core/auth/src/auth-manager.ts | 1 + packages/core/auth/src/auth.ts | 1 + packages/core/auth/src/base/auth.ts | 4 +- packages/core/auth/src/base/jwt-service.ts | 1 + packages/core/cache/package.json | 10 +- .../cache/src/__tests__/cache-manager.test.ts | 1 + .../core/cache/src/__tests__/cache.test.ts | 3 +- .../src/bloom-filter/memory-bloom-filter.ts | 3 +- .../src/bloom-filter/redis-bloom-filter.ts | 2 +- .../core/data-source-manager/package.json | 9 + .../src/__tests__/data-source-factory.test.ts | 1 + .../src/__tests__/data-source-manager.test.ts | 1 + .../src/__tests__/koa.test.ts | 2 + .../data-source-manager/src/collection.ts | 5 +- .../data-source-manager/src/data-source.ts | 4 +- .../src/default-actions/list.ts | 5 +- .../default-actions/proxy-to-repository.ts | 1 + .../src/default-actions/utils.ts | 1 + .../src/load-default-actions.ts | 2 +- .../data-source-manager/src/repository.ts | 3 +- .../src/sequelize-collection-manager.ts | 1 + packages/core/database/package.json | 3 +- .../adjacency-list-repository.test.ts | 2 +- .../__tests__/associations/references.test.ts | 1 + .../src/__tests__/collection-factory.test.ts | 3 +- .../src/__tests__/collection-importer.test.ts | 3 +- .../src/__tests__/collection.sortable.test.ts | 2 +- .../database/src/__tests__/collection.test.ts | 2 +- .../src/__tests__/database.import.test.ts | 3 +- .../database/src/__tests__/database.test.ts | 4 +- .../eager-loading/eager-loading-tree.test.ts | 1 + .../__tests__/field-options/sort-by.test.ts | 1 + .../array-field-repository.test.ts | 2 +- .../__tests__/fields/belongs-to-field.test.ts | 2 +- .../__tests__/fields/context-field.test.ts | 1 + .../__tests__/fields/has-many-field.test.ts | 2 +- .../__tests__/fields/has-one-field.test.ts | 2 +- .../src/__tests__/fields/sort-field.test.ts | 2 +- .../src/__tests__/fields/string-field.test.ts | 2 +- .../src/__tests__/filter-parser.test.ts | 1 + .../core/database/src/__tests__/group.test.ts | 1 + .../inhertits/collection-inherits.test.ts | 3 +- .../database/src/__tests__/migrator.test.ts | 5 +- .../database/src/__tests__/model-hook.test.ts | 2 +- .../operator/association-operator.test.ts | 3 +- .../__tests__/operator/empty-operator.test.ts | 3 +- .../src/__tests__/operator/notIn.test.ts | 2 +- .../src/__tests__/postgres/schema.test.ts | 5 +- .../belongs-to-many-repository.test.ts | 3 +- .../has-many-repository.test.ts | 7 +- .../database/src/__tests__/repository.test.ts | 2 + .../__tests__/repository/aggregation.test.ts | 4 +- .../src/__tests__/repository/count.test.ts | 4 +- .../src/__tests__/repository/create.test.ts | 4 +- .../src/__tests__/repository/destroy.test.ts | 5 +- .../src/__tests__/repository/find.test.ts | 6 +- .../src/__tests__/sequelize-hooks.test.ts | 1 + .../sql-collection/select-query.test.ts | 3 +- .../core/database/src/__tests__/sync.test.ts | 3 +- .../src/__tests__/sync/empty-table.test.ts | 2 +- .../src/__tests__/sync/primary-key.test.ts | 3 +- .../update-associations-through.test.ts | 1 + .../src/__tests__/update-guard.test.ts | 7 +- .../src/__tests__/value-parsers/date.test.ts | 1 + .../__tests__/view/view-collection.test.ts | 4 +- .../src/__tests__/view/view-inference.test.ts | 1 + .../view/view-with-association.test.ts | 5 +- .../core/database/src/collection-importer.ts | 5 +- packages/core/database/src/collection.ts | 4 +- .../core/database/src/database-utils/index.ts | 3 +- packages/core/database/src/database.ts | 6 +- .../src/decorators/transaction-decorator.ts | 17 +- .../src/eager-loading/eager-loading-tree.ts | 1 + .../database/src/features/references-map.ts | 12 +- .../features/referential-integrity-check.ts | 1 + .../array-field-repository.ts | 1 + .../core/database/src/fields/array-field.ts | 1 + .../database/src/fields/belongs-to-field.ts | 1 + .../src/fields/belongs-to-many-field.ts | 1 + .../core/database/src/fields/boolean-field.ts | 1 + .../core/database/src/fields/context-field.ts | 1 + .../core/database/src/fields/date-field.ts | 1 + packages/core/database/src/fields/field.ts | 1 + .../database/src/fields/has-many-field.ts | 1 + .../core/database/src/fields/has-one-field.ts | 1 + packages/core/database/src/fields/index.ts | 2 +- .../core/database/src/fields/json-field.ts | 1 + .../core/database/src/fields/nanoid-field.ts | 5 +- .../core/database/src/fields/number-field.ts | 1 + .../database/src/fields/password-field.ts | 2 + .../core/database/src/fields/radio-field.ts | 1 + .../core/database/src/fields/sort-field.ts | 1 + .../core/database/src/fields/string-field.ts | 1 + .../core/database/src/fields/text-field.ts | 1 + .../core/database/src/fields/time-field.ts | 1 + .../core/database/src/fields/uid-field.ts | 2 + .../core/database/src/fields/uuid-field.ts | 1 + .../core/database/src/fields/virtual-field.ts | 1 + packages/core/database/src/filter-parser.ts | 16 +- packages/core/database/src/helpers.ts | 4 +- .../core/database/src/inherited-collection.ts | 1 + packages/core/database/src/inherited-map.ts | 1 + .../database/src/inherited-sync-runner.ts | 3 +- .../database/src/magic-attribute-model.ts | 3 + packages/core/database/src/migration.ts | 2 + packages/core/database/src/model.ts | 3 +- packages/core/database/src/operators/array.ts | 1 + packages/core/database/src/operators/date.ts | 1 + packages/core/database/src/operators/empty.ts | 3 +- packages/core/database/src/operators/index.ts | 10 +- packages/core/database/src/operators/notIn.ts | 1 - .../core/database/src/operators/string.ts | 1 + packages/core/database/src/options-parser.ts | 3 +- .../query-interface/mysql-query-interface.ts | 1 + .../postgres-query-interface.ts | 3 +- .../src/query-interface/query-interface.ts | 1 + .../query-interface/sqlite-query-interface.ts | 3 +- .../belongs-to-many-repository.ts | 1 + .../belongs-to-repository.ts | 1 + .../relation-repository/hasmany-repository.ts | 4 +- .../relation-repository/hasone-repository.ts | 1 + .../multiple-relation-repository.ts | 3 +- .../relation-repository.ts | 1 + .../single-relation-repository.ts | 1 + .../database/src/relation-repository/types.ts | 3 +- .../adjacency-list-repository.ts | 5 +- packages/core/database/src/repository.ts | 13 +- .../src/sql-collection/query-generator.ts | 6 +- .../core/database/src/sql-parser/index.js | 2918 ++++++++++------- packages/core/database/src/types.ts | 5 +- .../core/database/src/update-associations.ts | 1 + packages/core/database/src/update-guard.ts | 1 + packages/core/database/src/utils.ts | 4 +- .../src/value-parsers/date-value-parser.ts | 2 + .../src/value-parsers/to-many-value-parser.ts | 1 + .../core/database/src/view/view-inference.ts | 1 + pnpm-lock.yaml | 307 +- 171 files changed, 2358 insertions(+), 1363 deletions(-) diff --git a/package.json b/package.json index 81f4a7a97..693873793 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "license": "Apache-2.0", "scripts": { - "build": "tachybase build", + "build": "tachybase build --no-dts", + "build:full": "tachybase build", "build:p": "tachybase build --no-dts", "changelog": "auto-changelog -p -t keepachangelog", "clean": "tachybase clean", @@ -19,19 +20,17 @@ "pm2": "tachybase pm2", "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 '\"')", - "run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts", "start": "tachybase start", "tachybase": "tachybase", - "tag": "changeset", "tar": "tachybase tar", "tb": "tachybase", "tbi": "tachybase install", + "tbu": "tachybase upgrade", "tc": "tachybase test:client", "test": "tachybase test", "test:client": "tachybase test:client", "test:server": "tachybase test:server", - "ts": "tachybase test:server", - "ver": "changeset version" + "ts": "tachybase test:server" }, "lint-staged": { "*.{js,json,sql}": [ @@ -76,7 +75,8 @@ "react-dom": "^18.2.0", "tsx": "^4.7.2", "typescript": "5.4.5", - "umi": "^4.1.10" + "umi": "^4.1.10", + "vitest": "^1.6.0" }, "packageManager": "pnpm@8.15.5", "engines": { diff --git a/packages/core/acl/src/__tests__/acl.test.ts b/packages/core/acl/src/__tests__/acl.test.ts index 16c305961..8469b7e49 100644 --- a/packages/core/acl/src/__tests__/acl.test.ts +++ b/packages/core/acl/src/__tests__/acl.test.ts @@ -1,5 +1,7 @@ -import { vi } from 'vitest'; import { Context } from '@tachybase/actions'; + +import { vi } from 'vitest'; + import { ACL } from '..'; describe('acl', () => { diff --git a/packages/core/acl/src/__tests__/allow-manager.test.ts b/packages/core/acl/src/__tests__/allow-manager.test.ts index e26b0c85b..f9c3fe5f6 100644 --- a/packages/core/acl/src/__tests__/allow-manager.test.ts +++ b/packages/core/acl/src/__tests__/allow-manager.test.ts @@ -1,5 +1,6 @@ import { ACL } from '..'; import { AllowManager } from '../allow-manager'; + describe('allow manager', () => { let acl: ACL; diff --git a/packages/core/acl/src/__tests__/allow.test.ts b/packages/core/acl/src/__tests__/allow.test.ts index e9f20e577..ebe3b4cbd 100644 --- a/packages/core/acl/src/__tests__/allow.test.ts +++ b/packages/core/acl/src/__tests__/allow.test.ts @@ -1,4 +1,5 @@ import { vi } from 'vitest'; + import { ACL } from '..'; describe('skip', () => { diff --git a/packages/core/acl/src/acl-available-action.ts b/packages/core/acl/src/acl-available-action.ts index 3f0e9ac3e..ecf5d6213 100644 --- a/packages/core/acl/src/acl-available-action.ts +++ b/packages/core/acl/src/acl-available-action.ts @@ -13,5 +13,8 @@ export interface AvailableActionOptions { } export class ACLAvailableAction { - constructor(public name: string, public options: AvailableActionOptions) {} + constructor( + public name: string, + public options: AvailableActionOptions, + ) {} } diff --git a/packages/core/acl/src/acl-available-strategy.ts b/packages/core/acl/src/acl-available-strategy.ts index f6ba69597..acdbf92f2 100644 --- a/packages/core/acl/src/acl-available-strategy.ts +++ b/packages/core/acl/src/acl-available-strategy.ts @@ -1,4 +1,5 @@ import lodash from 'lodash'; + import { ACL } from './acl'; type StrategyValue = false | '*' | string | string[]; diff --git a/packages/core/acl/src/acl-resource.ts b/packages/core/acl/src/acl-resource.ts index f16e94ba8..f92965035 100644 --- a/packages/core/acl/src/acl-resource.ts +++ b/packages/core/acl/src/acl-resource.ts @@ -1,7 +1,8 @@ -import { ACLRole, RoleActionParams } from './acl-role'; -import { ACL, ListenerContext } from './acl'; import lodash from 'lodash'; +import { ACL, ListenerContext } from './acl'; +import { ACLRole, RoleActionParams } from './acl-role'; + export type ResourceActions = { [key: string]: RoleActionParams }; interface AclResourceOptions { diff --git a/packages/core/acl/src/acl-role.ts b/packages/core/acl/src/acl-role.ts index 7413e8760..86e70795c 100644 --- a/packages/core/acl/src/acl-role.ts +++ b/packages/core/acl/src/acl-role.ts @@ -1,8 +1,9 @@ +import lodash from 'lodash'; +import minimatch from 'minimatch'; + import { ACL, DefineOptions } from './acl'; import { ACLAvailableStrategy, AvailableStrategyOptions } from './acl-available-strategy'; import { ACLResource } from './acl-resource'; -import lodash from 'lodash'; -import minimatch from 'minimatch'; export interface RoleActionParams { fields?: string[]; diff --git a/packages/core/acl/src/acl.ts b/packages/core/acl/src/acl.ts index 46c4775e6..d03c78ca5 100644 --- a/packages/core/acl/src/acl.ts +++ b/packages/core/acl/src/acl.ts @@ -1,8 +1,10 @@ +import EventEmitter from 'events'; import { Action } from '@tachybase/resourcer'; import { assign, parseFilter, Toposort, ToposortOptions } from '@tachybase/utils'; -import EventEmitter from 'events'; + import compose from 'koa-compose'; import lodash from 'lodash'; + import { ACLAvailableAction, AvailableActionOptions } from './acl-available-action'; import { ACLAvailableStrategy, AvailableStrategyOptions, predicate } from './acl-available-strategy'; import { ACLRole, ResourceActionsOptions, RoleActionParams } from './acl-role'; diff --git a/packages/core/actions/src/__tests__/add-action.test.ts b/packages/core/actions/src/__tests__/add-action.test.ts index 3845dffc4..4bea4dc63 100644 --- a/packages/core/actions/src/__tests__/add-action.test.ts +++ b/packages/core/actions/src/__tests__/add-action.test.ts @@ -1,6 +1,7 @@ -import { mockServer, MockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { mockServer, MockServer } from './index'; + describe('add action', () => { let app: MockServer; let Post; diff --git a/packages/core/actions/src/__tests__/create-action.test.ts b/packages/core/actions/src/__tests__/create-action.test.ts index 74563a317..dc25ce4c1 100644 --- a/packages/core/actions/src/__tests__/create-action.test.ts +++ b/packages/core/actions/src/__tests__/create-action.test.ts @@ -1,6 +1,7 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { mockServer } from './index'; + describe('create action', () => { let app; let Post; diff --git a/packages/core/actions/src/__tests__/destroy-action.test.ts b/packages/core/actions/src/__tests__/destroy-action.test.ts index f581c4644..cabfe0364 100644 --- a/packages/core/actions/src/__tests__/destroy-action.test.ts +++ b/packages/core/actions/src/__tests__/destroy-action.test.ts @@ -1,4 +1,5 @@ import { registerActions } from '@tachybase/actions'; + import { mockServer } from './index'; describe('destroy action', () => { diff --git a/packages/core/actions/src/__tests__/first-or-create.test.ts b/packages/core/actions/src/__tests__/first-or-create.test.ts index c83638037..1448e268c 100644 --- a/packages/core/actions/src/__tests__/first-or-create.test.ts +++ b/packages/core/actions/src/__tests__/first-or-create.test.ts @@ -1,7 +1,8 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; import { Collection } from '@tachybase/database'; +import { mockServer } from './index'; + describe('first or create', () => { let app; diff --git a/packages/core/actions/src/__tests__/get-action.test.ts b/packages/core/actions/src/__tests__/get-action.test.ts index 7064032b5..2ed012ee4 100644 --- a/packages/core/actions/src/__tests__/get-action.test.ts +++ b/packages/core/actions/src/__tests__/get-action.test.ts @@ -1,4 +1,5 @@ import { registerActions } from '@tachybase/actions'; + import { MockServer, mockServer } from './'; describe('get action', () => { diff --git a/packages/core/actions/src/__tests__/index.ts b/packages/core/actions/src/__tests__/index.ts index cb775325d..06ee955a0 100644 --- a/packages/core/actions/src/__tests__/index.ts +++ b/packages/core/actions/src/__tests__/index.ts @@ -1,9 +1,11 @@ import Database, { CollectionOptions, mockDatabase } from '@tachybase/database'; import { Handlers, ResourceOptions, Resourcer } from '@tachybase/resourcer'; + import Koa from 'koa'; import bodyParser from 'koa-bodyparser'; import qs from 'qs'; import supertest, { SuperAgentTest } from 'supertest'; + import db2resource from '../../../server/src/middlewares/db2resource'; interface ActionParams { diff --git a/packages/core/actions/src/__tests__/list-action.test.ts b/packages/core/actions/src/__tests__/list-action.test.ts index 14af102d4..db751f0d6 100644 --- a/packages/core/actions/src/__tests__/list-action.test.ts +++ b/packages/core/actions/src/__tests__/list-action.test.ts @@ -1,5 +1,6 @@ import { registerActions } from '@tachybase/actions'; -import { MockServer, mockServer as actionMockServer } from './index'; + +import { mockServer as actionMockServer, MockServer } from './index'; describe('list action', () => { let app: MockServer; diff --git a/packages/core/actions/src/__tests__/move-action.test.ts b/packages/core/actions/src/__tests__/move-action.test.ts index beceea6c3..033efd4c0 100644 --- a/packages/core/actions/src/__tests__/move-action.test.ts +++ b/packages/core/actions/src/__tests__/move-action.test.ts @@ -1,8 +1,9 @@ -import { mockServer, MockServer } from './index'; import { registerActions } from '@tachybase/actions'; import { Collection, Database } from '@tachybase/database'; import { waitSecond } from '@tachybase/test'; +import { mockServer, MockServer } from './index'; + describe('sort action', () => { describe('associations', () => { let api: MockServer; diff --git a/packages/core/actions/src/__tests__/remove-action.test.ts b/packages/core/actions/src/__tests__/remove-action.test.ts index 86cd4f0a5..f34561e6b 100644 --- a/packages/core/actions/src/__tests__/remove-action.test.ts +++ b/packages/core/actions/src/__tests__/remove-action.test.ts @@ -1,6 +1,7 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { mockServer } from './index'; + describe('remove action', () => { let app; let Post; diff --git a/packages/core/actions/src/__tests__/set-action.test.ts b/packages/core/actions/src/__tests__/set-action.test.ts index 57fdb3efd..508a141e4 100644 --- a/packages/core/actions/src/__tests__/set-action.test.ts +++ b/packages/core/actions/src/__tests__/set-action.test.ts @@ -1,6 +1,7 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { mockServer } from './index'; + describe('set action', () => { let app; let Post; diff --git a/packages/core/actions/src/__tests__/sort-collection.test.ts b/packages/core/actions/src/__tests__/sort-collection.test.ts index 28e5c6567..b7c13778d 100644 --- a/packages/core/actions/src/__tests__/sort-collection.test.ts +++ b/packages/core/actions/src/__tests__/sort-collection.test.ts @@ -1,7 +1,8 @@ -import { mockServer } from './index'; -import { SortAbleCollection } from '../actions'; import lodash from 'lodash'; +import { SortAbleCollection } from '../actions'; +import { mockServer } from './index'; + describe('sort collections', () => { let app; let Post; diff --git a/packages/core/actions/src/__tests__/toggle-action.test.ts b/packages/core/actions/src/__tests__/toggle-action.test.ts index 7d3e2a772..c527efbb6 100644 --- a/packages/core/actions/src/__tests__/toggle-action.test.ts +++ b/packages/core/actions/src/__tests__/toggle-action.test.ts @@ -1,6 +1,7 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { mockServer } from './index'; + describe('toggle action', () => { let app; let Post; diff --git a/packages/core/actions/src/__tests__/update-action.test.ts b/packages/core/actions/src/__tests__/update-action.test.ts index 1b638fad9..e65faf1b7 100644 --- a/packages/core/actions/src/__tests__/update-action.test.ts +++ b/packages/core/actions/src/__tests__/update-action.test.ts @@ -1,6 +1,7 @@ -import { MockServer, mockServer } from './index'; import { registerActions } from '@tachybase/actions'; +import { MockServer, mockServer } from './index'; + describe('update action', () => { let app: MockServer; let Post; diff --git a/packages/core/actions/src/__tests__/update-or-create.test.ts b/packages/core/actions/src/__tests__/update-or-create.test.ts index f99f31708..1aced30e8 100644 --- a/packages/core/actions/src/__tests__/update-or-create.test.ts +++ b/packages/core/actions/src/__tests__/update-or-create.test.ts @@ -1,7 +1,8 @@ -import { mockServer } from './index'; import { registerActions } from '@tachybase/actions'; import { Collection } from '@tachybase/database'; +import { mockServer } from './index'; + describe('update or create', () => { let app; diff --git a/packages/core/actions/src/actions/add.ts b/packages/core/actions/src/actions/add.ts index cd2aa8d7b..b7a28d906 100644 --- a/packages/core/actions/src/actions/add.ts +++ b/packages/core/actions/src/actions/add.ts @@ -4,6 +4,7 @@ import { HasManyRepository, MultipleRelationRepository, } from '@tachybase/database'; + import { Context } from '..'; import { getRepositoryFromParams } from '../utils'; diff --git a/packages/core/actions/src/actions/destroy.ts b/packages/core/actions/src/actions/destroy.ts index cbeae5c1f..eaabe9e4d 100644 --- a/packages/core/actions/src/actions/destroy.ts +++ b/packages/core/actions/src/actions/destroy.ts @@ -1,5 +1,5 @@ -import { getRepositoryFromParams } from '../utils'; import { Context } from '../index'; +import { getRepositoryFromParams } from '../utils'; export async function destroy(ctx: Context, next) { const repository = getRepositoryFromParams(ctx); diff --git a/packages/core/actions/src/actions/list.ts b/packages/core/actions/src/actions/list.ts index e9d8c52e8..b49a31cf7 100644 --- a/packages/core/actions/src/actions/list.ts +++ b/packages/core/actions/src/actions/list.ts @@ -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 { 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 { return Math.ceil(total / pageSize); diff --git a/packages/core/actions/src/actions/move.ts b/packages/core/actions/src/actions/move.ts index 52b028c4b..96f9f86eb 100644 --- a/packages/core/actions/src/actions/move.ts +++ b/packages/core/actions/src/actions/move.ts @@ -1,6 +1,3 @@ -import { Model, Op } from 'sequelize'; - -import { Context } from '..'; import { BelongsToManyRepository, Collection, @@ -9,6 +6,10 @@ import { SortField, TargetKey, } from '@tachybase/database'; + +import { Model, Op } from 'sequelize'; + +import { Context } from '..'; import { getRepositoryFromParams } from '../utils'; export async function move(ctx: Context, next) { diff --git a/packages/core/actions/src/actions/proxy-to-repository.ts b/packages/core/actions/src/actions/proxy-to-repository.ts index f126c53ae..0fc85459a 100644 --- a/packages/core/actions/src/actions/proxy-to-repository.ts +++ b/packages/core/actions/src/actions/proxy-to-repository.ts @@ -1,4 +1,5 @@ import lodash from 'lodash'; + import { Context } from '../index'; import { getRepositoryFromParams } from '../utils'; diff --git a/packages/core/actions/src/actions/remove.ts b/packages/core/actions/src/actions/remove.ts index 8faadc843..5f8bc4f06 100644 --- a/packages/core/actions/src/actions/remove.ts +++ b/packages/core/actions/src/actions/remove.ts @@ -1,2 +1,3 @@ import { RelationRepositoryActionBuilder } from '../utils'; + export const remove = RelationRepositoryActionBuilder('remove'); diff --git a/packages/core/actions/src/actions/set.ts b/packages/core/actions/src/actions/set.ts index 3fcab6813..9a854b48c 100644 --- a/packages/core/actions/src/actions/set.ts +++ b/packages/core/actions/src/actions/set.ts @@ -1,2 +1,3 @@ import { RelationRepositoryActionBuilder } from '../utils'; + export const set = RelationRepositoryActionBuilder('set'); diff --git a/packages/core/actions/src/actions/toggle.ts b/packages/core/actions/src/actions/toggle.ts index 8399341a9..e6c1b0e88 100644 --- a/packages/core/actions/src/actions/toggle.ts +++ b/packages/core/actions/src/actions/toggle.ts @@ -1,4 +1,5 @@ import { BelongsToManyRepository } from '@tachybase/database'; + import { Context } from '..'; import { getRepositoryFromParams } from '../utils'; diff --git a/packages/core/actions/src/utils.ts b/packages/core/actions/src/utils.ts index 06f464bc9..47788ea84 100644 --- a/packages/core/actions/src/utils.ts +++ b/packages/core/actions/src/utils.ts @@ -1,4 +1,5 @@ import { MultipleRelationRepository, Repository } from '@tachybase/database'; + import { Context } from '.'; export function pageArgsToLimitArgs( diff --git a/packages/core/auth/package.json b/packages/core/auth/package.json index 6f5a9768e..cebf64176 100644 --- a/packages/core/auth/package.json +++ b/packages/core/auth/package.json @@ -11,7 +11,10 @@ "@tachybase/database": "workspace:*", "@tachybase/resourcer": "workspace:*", "@tachybase/utils": "workspace:*", - "@types/jsonwebtoken": "^8.5.8", "jsonwebtoken": "^8.5.1" + }, + "devDependencies": { + "@types/jsonwebtoken": "^8.5.8", + "vitest": "^1.6.0" } } diff --git a/packages/core/auth/src/__tests__/auth-manager.test.ts b/packages/core/auth/src/__tests__/auth-manager.test.ts index c3b8054b0..2f843a05a 100644 --- a/packages/core/auth/src/__tests__/auth-manager.test.ts +++ b/packages/core/auth/src/__tests__/auth-manager.test.ts @@ -1,9 +1,10 @@ -import { vi } from 'vitest'; import { Context } from '@tachybase/actions'; import { Auth, AuthManager } from '@tachybase/auth'; import Database, { Model } from '@tachybase/database'; import { MockServer, mockServer } from '@tachybase/test'; +import { vi } from 'vitest'; + class MockStorer { elements: Map = new Map(); async set(name: string, value: any) { diff --git a/packages/core/auth/src/auth-manager.ts b/packages/core/auth/src/auth-manager.ts index 71ff9bac7..b0262c136 100644 --- a/packages/core/auth/src/auth-manager.ts +++ b/packages/core/auth/src/auth-manager.ts @@ -1,5 +1,6 @@ import { Context, Next } from '@tachybase/actions'; import { Registry } from '@tachybase/utils'; + import { Auth, AuthExtend } from './auth'; import { JwtOptions, JwtService } from './base/jwt-service'; import { ITokenBlacklistService } from './base/token-blacklist-service'; diff --git a/packages/core/auth/src/auth.ts b/packages/core/auth/src/auth.ts index 59dad9a94..44284b2cc 100644 --- a/packages/core/auth/src/auth.ts +++ b/packages/core/auth/src/auth.ts @@ -1,5 +1,6 @@ import { Context } from '@tachybase/actions'; import { Model } from '@tachybase/database'; + import { Authenticator } from './auth-manager'; export type AuthConfig = { diff --git a/packages/core/auth/src/base/auth.ts b/packages/core/auth/src/base/auth.ts index 12561033f..8aa0ec974 100644 --- a/packages/core/auth/src/base/auth.ts +++ b/packages/core/auth/src/base/auth.ts @@ -1,7 +1,7 @@ import { Collection, Model } from '@tachybase/database'; + import { Auth, AuthConfig } from '../auth'; import { JwtService } from './jwt-service'; -import { Cache } from '@tachybase/cache'; /** * BaseAuth @@ -56,7 +56,7 @@ export class BaseAuth extends Auth { 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), () => this.userRepository.findOne({ filter: { diff --git a/packages/core/auth/src/base/jwt-service.ts b/packages/core/auth/src/base/jwt-service.ts index 244be1281..7de1fd82f 100644 --- a/packages/core/auth/src/base/jwt-service.ts +++ b/packages/core/auth/src/base/jwt-service.ts @@ -1,4 +1,5 @@ import jwt, { SignOptions } from 'jsonwebtoken'; + import { ITokenBlacklistService } from './token-blacklist-service'; export interface JwtOptions { diff --git a/packages/core/cache/package.json b/packages/core/cache/package.json index bd96df8da..c4aa4b565 100644 --- a/packages/core/cache/package.json +++ b/packages/core/cache/package.json @@ -8,11 +8,13 @@ "dependencies": { "bloom-filters": "^3.0.1", "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": { - "deepmerge": "^4.2.2", - "lodash": "4.17.21", - "redis": "^4.6.10" + "@types/lodash": "^4.17.5", + "redis": "^4.6.10", + "vitest": "^1.6.0" } } diff --git a/packages/core/cache/src/__tests__/cache-manager.test.ts b/packages/core/cache/src/__tests__/cache-manager.test.ts index 4fceba96c..60de108dc 100644 --- a/packages/core/cache/src/__tests__/cache-manager.test.ts +++ b/packages/core/cache/src/__tests__/cache-manager.test.ts @@ -1,4 +1,5 @@ import { vi } from 'vitest'; + import { Cache } from '../cache'; import { CacheManager } from '../cache-manager'; diff --git a/packages/core/cache/src/__tests__/cache.test.ts b/packages/core/cache/src/__tests__/cache.test.ts index fb20f6d8b..77db364bd 100644 --- a/packages/core/cache/src/__tests__/cache.test.ts +++ b/packages/core/cache/src/__tests__/cache.test.ts @@ -1,6 +1,7 @@ +import lodash from 'lodash'; + import { Cache } from '../cache'; import { CacheManager } from '../cache-manager'; -import lodash from 'lodash'; describe('cache', () => { let cache: Cache; diff --git a/packages/core/cache/src/bloom-filter/memory-bloom-filter.ts b/packages/core/cache/src/bloom-filter/memory-bloom-filter.ts index adda85005..fb6ce8e0c 100644 --- a/packages/core/cache/src/bloom-filter/memory-bloom-filter.ts +++ b/packages/core/cache/src/bloom-filter/memory-bloom-filter.ts @@ -1,6 +1,7 @@ +import { BloomFilter } from 'bloom-filters'; + import { BloomFilter as IBloomFilter } from '.'; import { Cache } from '../cache'; -import { BloomFilter } from 'bloom-filters'; export class MemoryBloomFilter implements IBloomFilter { cache: Cache; diff --git a/packages/core/cache/src/bloom-filter/redis-bloom-filter.ts b/packages/core/cache/src/bloom-filter/redis-bloom-filter.ts index 0cea1563e..533708917 100644 --- a/packages/core/cache/src/bloom-filter/redis-bloom-filter.ts +++ b/packages/core/cache/src/bloom-filter/redis-bloom-filter.ts @@ -1,5 +1,5 @@ import type { RedisStore } from 'cache-manager-redis-yet'; -import type { RedisClientType } from 'redis'; + import { BloomFilter } from '.'; import { Cache } from '../cache'; diff --git a/packages/core/data-source-manager/package.json b/packages/core/data-source-manager/package.json index 2d2c3431d..e3ac47c5b 100644 --- a/packages/core/data-source-manager/package.json +++ b/packages/core/data-source-manager/package.json @@ -17,5 +17,14 @@ "jsonwebtoken": "^8.5.1", "koa-compose": "^4.1.0", "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" } } diff --git a/packages/core/data-source-manager/src/__tests__/data-source-factory.test.ts b/packages/core/data-source-manager/src/__tests__/data-source-factory.test.ts index 2038ca40c..c40b02bdf 100644 --- a/packages/core/data-source-manager/src/__tests__/data-source-factory.test.ts +++ b/packages/core/data-source-manager/src/__tests__/data-source-factory.test.ts @@ -1,4 +1,5 @@ import { createMockServer } from '@tachybase/test'; + import { DataSource } from '../data-source'; import { ICollectionManager } from '../types'; diff --git a/packages/core/data-source-manager/src/__tests__/data-source-manager.test.ts b/packages/core/data-source-manager/src/__tests__/data-source-manager.test.ts index 136799f66..52ca858b9 100644 --- a/packages/core/data-source-manager/src/__tests__/data-source-manager.test.ts +++ b/packages/core/data-source-manager/src/__tests__/data-source-manager.test.ts @@ -1,4 +1,5 @@ import { createMockServer, mockDatabase, supertest } from '@tachybase/test'; + import { SequelizeDataSource } from '../sequelize-data-source'; describe('example', () => { diff --git a/packages/core/data-source-manager/src/__tests__/koa.test.ts b/packages/core/data-source-manager/src/__tests__/koa.test.ts index d972ba6ba..9ad611a5f 100644 --- a/packages/core/data-source-manager/src/__tests__/koa.test.ts +++ b/packages/core/data-source-manager/src/__tests__/koa.test.ts @@ -1,7 +1,9 @@ import { mockDatabase } from '@tachybase/test'; + import Koa from 'koa'; import bodyParser from 'koa-bodyparser'; import supertest from 'supertest'; + import { DataSourceManager } from '../data-source-manager'; import { SequelizeDataSource } from '../sequelize-data-source'; diff --git a/packages/core/data-source-manager/src/collection.ts b/packages/core/data-source-manager/src/collection.ts index b496112ab..4aaa8c243 100644 --- a/packages/core/data-source-manager/src/collection.ts +++ b/packages/core/data-source-manager/src/collection.ts @@ -1,7 +1,8 @@ -import { CollectionOptions, ICollection, ICollectionManager, IField, IRepository } from './types'; -import { default as lodash } from 'lodash'; import merge from 'deepmerge'; +import { default as lodash } from 'lodash'; + import { CollectionField } from './collection-field'; +import { CollectionOptions, ICollection, ICollectionManager, IField, IRepository } from './types'; export class Collection implements ICollection { repository: IRepository; diff --git a/packages/core/data-source-manager/src/data-source.ts b/packages/core/data-source-manager/src/data-source.ts index b2183e743..1e6aaf571 100644 --- a/packages/core/data-source-manager/src/data-source.ts +++ b/packages/core/data-source-manager/src/data-source.ts @@ -1,7 +1,9 @@ +import EventEmitter from 'events'; import { ACL } from '@tachybase/acl'; import { getNameByParams, parseRequest } from '@tachybase/resourcer'; -import EventEmitter from 'events'; + import compose from 'koa-compose'; + import { loadDefaultActions } from './load-default-actions'; import { ResourceManager } from './resource-manager'; import { ICollectionManager } from './types'; diff --git a/packages/core/data-source-manager/src/default-actions/list.ts b/packages/core/data-source-manager/src/default-actions/list.ts index b69bc94bb..b5b72d391 100644 --- a/packages/core/data-source-manager/src/default-actions/list.ts +++ b/packages/core/data-source-manager/src/default-actions/list.ts @@ -1,6 +1,7 @@ -import { assign } from '@tachybase/utils'; -import { getRepositoryFromParams, pageArgsToLimitArgs } from './utils'; import { Context } from '@tachybase/actions'; +import { assign } from '@tachybase/utils'; + +import { getRepositoryFromParams, pageArgsToLimitArgs } from './utils'; function totalPage(total, pageSize): number { return Math.ceil(total / pageSize); diff --git a/packages/core/data-source-manager/src/default-actions/proxy-to-repository.ts b/packages/core/data-source-manager/src/default-actions/proxy-to-repository.ts index 5183a20fb..a3224c3bb 100644 --- a/packages/core/data-source-manager/src/default-actions/proxy-to-repository.ts +++ b/packages/core/data-source-manager/src/default-actions/proxy-to-repository.ts @@ -1,4 +1,5 @@ import lodash from 'lodash'; + import { DataSource } from '../data-source'; import { getRepositoryFromParams } from './utils'; diff --git a/packages/core/data-source-manager/src/default-actions/utils.ts b/packages/core/data-source-manager/src/default-actions/utils.ts index 6d88e52de..c9acddede 100644 --- a/packages/core/data-source-manager/src/default-actions/utils.ts +++ b/packages/core/data-source-manager/src/default-actions/utils.ts @@ -1,4 +1,5 @@ import { Context } from '@tachybase/actions'; + import { DataSource, IRepository } from '../'; export function pageArgsToLimitArgs( diff --git a/packages/core/data-source-manager/src/load-default-actions.ts b/packages/core/data-source-manager/src/load-default-actions.ts index e1ba576fc..d99c4eced 100644 --- a/packages/core/data-source-manager/src/load-default-actions.ts +++ b/packages/core/data-source-manager/src/load-default-actions.ts @@ -1,7 +1,7 @@ +import { DataSource } from './data-source'; import { list } from './default-actions/list'; import { move } from './default-actions/move'; import { proxyToRepository } from './default-actions/proxy-to-repository'; -import { DataSource } from './data-source'; type Actions = { [key: string]: { params: Array | ((ctx: any) => Array); method: string } }; diff --git a/packages/core/data-source-manager/src/repository.ts b/packages/core/data-source-manager/src/repository.ts index 95593e265..2e07abcfb 100644 --- a/packages/core/data-source-manager/src/repository.ts +++ b/packages/core/data-source-manager/src/repository.ts @@ -1,6 +1,7 @@ -import { IModel, IRepository } from './types'; import * as console from 'console'; +import { IModel, IRepository } from './types'; + export class Repository implements IRepository { async create(options) { console.log('Repository.create....'); diff --git a/packages/core/data-source-manager/src/sequelize-collection-manager.ts b/packages/core/data-source-manager/src/sequelize-collection-manager.ts index 3f75bd0b6..c32bc01b0 100644 --- a/packages/core/data-source-manager/src/sequelize-collection-manager.ts +++ b/packages/core/data-source-manager/src/sequelize-collection-manager.ts @@ -1,4 +1,5 @@ import Database from '@tachybase/database'; + import { CollectionOptions, ICollection, ICollectionManager, IRepository, MergeOptions } from './types'; export class SequelizeCollectionManager implements ICollectionManager { diff --git a/packages/core/database/package.json b/packages/core/database/package.json index 3b366994b..6190c46be 100644 --- a/packages/core/database/package.json +++ b/packages/core/database/package.json @@ -28,7 +28,8 @@ "umzug": "^3.1.1" }, "devDependencies": { + "@types/flat": "^5.0.5", "@types/glob": "^7.2.0", - "@types/lodash": "4.17.0" + "@types/lodash": "^4.17.5" } } diff --git a/packages/core/database/src/__tests__/adjacency-list-repository.test.ts b/packages/core/database/src/__tests__/adjacency-list-repository.test.ts index 4f9715f12..2ccbeb588 100644 --- a/packages/core/database/src/__tests__/adjacency-list-repository.test.ts +++ b/packages/core/database/src/__tests__/adjacency-list-repository.test.ts @@ -1,5 +1,5 @@ -import { mockDatabase } from './'; import Database from '../database'; +import { mockDatabase } from './'; describe('adjacency list repository', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/associations/references.test.ts b/packages/core/database/src/__tests__/associations/references.test.ts index 7fe4baabc..ce8c0dda8 100644 --- a/packages/core/database/src/__tests__/associations/references.test.ts +++ b/packages/core/database/src/__tests__/associations/references.test.ts @@ -1,5 +1,6 @@ import { Database } from '../../database'; import { mockDatabase } from '../index'; + describe('association references', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/collection-factory.test.ts b/packages/core/database/src/__tests__/collection-factory.test.ts index 97f0c04c9..35347af00 100644 --- a/packages/core/database/src/__tests__/collection-factory.test.ts +++ b/packages/core/database/src/__tests__/collection-factory.test.ts @@ -1,7 +1,8 @@ import { vi } from 'vitest'; + +import { Collection } from '../collection'; import Database from '../database'; import { mockDatabase } from './index'; -import { Collection } from '../collection'; describe('collection factory', function () { let db: Database; diff --git a/packages/core/database/src/__tests__/collection-importer.test.ts b/packages/core/database/src/__tests__/collection-importer.test.ts index e9d3c6399..1906ce9fa 100644 --- a/packages/core/database/src/__tests__/collection-importer.test.ts +++ b/packages/core/database/src/__tests__/collection-importer.test.ts @@ -1,5 +1,6 @@ -import { ImporterReader } from '../collection-importer'; import * as path from 'path'; + +import { ImporterReader } from '../collection-importer'; import { extend } from '../database'; describe('collection importer', () => { diff --git a/packages/core/database/src/__tests__/collection.sortable.test.ts b/packages/core/database/src/__tests__/collection.sortable.test.ts index 4ee1ad52b..1ddecfa7e 100644 --- a/packages/core/database/src/__tests__/collection.sortable.test.ts +++ b/packages/core/database/src/__tests__/collection.sortable.test.ts @@ -1,5 +1,5 @@ -import { mockDatabase } from './index'; import { Database } from '../database'; +import { mockDatabase } from './index'; describe('collection sortable options', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/collection.test.ts b/packages/core/database/src/__tests__/collection.test.ts index be4aa7ea6..81957d3e3 100644 --- a/packages/core/database/src/__tests__/collection.test.ts +++ b/packages/core/database/src/__tests__/collection.test.ts @@ -1,7 +1,7 @@ import { Collection } from '../collection'; import { Database } from '../database'; -import { mockDatabase } from './index'; import { IdentifierError } from '../errors/identifier-error'; +import { mockDatabase } from './index'; const pgOnly = () => (process.env.DB_DIALECT == 'postgres' ? it : it.skip); describe('collection', () => { diff --git a/packages/core/database/src/__tests__/database.import.test.ts b/packages/core/database/src/__tests__/database.import.test.ts index a51fc5e86..784d02414 100644 --- a/packages/core/database/src/__tests__/database.import.test.ts +++ b/packages/core/database/src/__tests__/database.import.test.ts @@ -1,6 +1,7 @@ -import { mockDatabase } from './index'; import path from 'path'; + import Database from '../database'; +import { mockDatabase } from './index'; describe('database', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/database.test.ts b/packages/core/database/src/__tests__/database.test.ts index e9d64feab..3ef72b719 100644 --- a/packages/core/database/src/__tests__/database.test.ts +++ b/packages/core/database/src/__tests__/database.test.ts @@ -1,5 +1,7 @@ -import { vi } from 'vitest'; import path from 'path'; + +import { vi } from 'vitest'; + import { Database, Model } from '..'; import { ArrayFieldRepository } from '../field-repository/array-field-repository'; import { mockDatabase } from './index'; diff --git a/packages/core/database/src/__tests__/eager-loading/eager-loading-tree.test.ts b/packages/core/database/src/__tests__/eager-loading/eager-loading-tree.test.ts index 62ac14cc3..febac5d41 100644 --- a/packages/core/database/src/__tests__/eager-loading/eager-loading-tree.test.ts +++ b/packages/core/database/src/__tests__/eager-loading/eager-loading-tree.test.ts @@ -1,4 +1,5 @@ import Database, { mockDatabase } from '@tachybase/database'; + import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree'; describe('Eager loading tree', () => { diff --git a/packages/core/database/src/__tests__/field-options/sort-by.test.ts b/packages/core/database/src/__tests__/field-options/sort-by.test.ts index 7d31028d9..6194c3b5b 100644 --- a/packages/core/database/src/__tests__/field-options/sort-by.test.ts +++ b/packages/core/database/src/__tests__/field-options/sort-by.test.ts @@ -1,4 +1,5 @@ import { mockDatabase } from '@tachybase/test'; + import { BelongsToManyRepository, Database } from '../../index'; describe('associated field order', () => { diff --git a/packages/core/database/src/__tests__/field-repository/array-field-repository.test.ts b/packages/core/database/src/__tests__/field-repository/array-field-repository.test.ts index 0acac517f..b9dcc2ca7 100644 --- a/packages/core/database/src/__tests__/field-repository/array-field-repository.test.ts +++ b/packages/core/database/src/__tests__/field-repository/array-field-repository.test.ts @@ -1,6 +1,6 @@ -import { mockDatabase } from '../index'; import Database from '../../database'; import { ArrayFieldRepository } from '../../field-repository/array-field-repository'; +import { mockDatabase } from '../index'; describe('Array field repository', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/fields/belongs-to-field.test.ts b/packages/core/database/src/__tests__/fields/belongs-to-field.test.ts index dedcce013..86cfa8787 100644 --- a/packages/core/database/src/__tests__/fields/belongs-to-field.test.ts +++ b/packages/core/database/src/__tests__/fields/belongs-to-field.test.ts @@ -1,5 +1,5 @@ -import { Database } from '../../database'; import { mockDatabase } from '../'; +import { Database } from '../../database'; import { IdentifierError } from '../../errors/identifier-error'; describe('belongs to field', () => { diff --git a/packages/core/database/src/__tests__/fields/context-field.test.ts b/packages/core/database/src/__tests__/fields/context-field.test.ts index c29d1b0ec..8925f42b5 100644 --- a/packages/core/database/src/__tests__/fields/context-field.test.ts +++ b/packages/core/database/src/__tests__/fields/context-field.test.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { mockDatabase } from '../'; import { Database } from '../../'; diff --git a/packages/core/database/src/__tests__/fields/has-many-field.test.ts b/packages/core/database/src/__tests__/fields/has-many-field.test.ts index ae20c69eb..7fd43b40a 100644 --- a/packages/core/database/src/__tests__/fields/has-many-field.test.ts +++ b/packages/core/database/src/__tests__/fields/has-many-field.test.ts @@ -1,5 +1,5 @@ -import { Database } from '../../database'; import { mockDatabase } from '../'; +import { Database } from '../../database'; import { IdentifierError } from '../../errors/identifier-error'; describe('has many field', () => { diff --git a/packages/core/database/src/__tests__/fields/has-one-field.test.ts b/packages/core/database/src/__tests__/fields/has-one-field.test.ts index e964ed1f4..18461c936 100644 --- a/packages/core/database/src/__tests__/fields/has-one-field.test.ts +++ b/packages/core/database/src/__tests__/fields/has-one-field.test.ts @@ -1,5 +1,5 @@ -import { Database } from '../../database'; import { mockDatabase } from '../'; +import { Database } from '../../database'; import { IdentifierError } from '../../errors/identifier-error'; describe('has many field', () => { diff --git a/packages/core/database/src/__tests__/fields/sort-field.test.ts b/packages/core/database/src/__tests__/fields/sort-field.test.ts index dbf0efffc..0bf9ae447 100644 --- a/packages/core/database/src/__tests__/fields/sort-field.test.ts +++ b/packages/core/database/src/__tests__/fields/sort-field.test.ts @@ -1,5 +1,5 @@ -import { Database } from '../../database'; import { mockDatabase } from '../'; +import { Database } from '../../database'; import { SortField } from '../../fields'; describe('string field', () => { diff --git a/packages/core/database/src/__tests__/fields/string-field.test.ts b/packages/core/database/src/__tests__/fields/string-field.test.ts index 3ea7a1524..60e0b857a 100644 --- a/packages/core/database/src/__tests__/fields/string-field.test.ts +++ b/packages/core/database/src/__tests__/fields/string-field.test.ts @@ -1,5 +1,5 @@ -import { Database } from '../../database'; import { mockDatabase } from '../'; +import { Database } from '../../database'; describe('string field', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/filter-parser.test.ts b/packages/core/database/src/__tests__/filter-parser.test.ts index 4db06404a..e838ac09d 100644 --- a/packages/core/database/src/__tests__/filter-parser.test.ts +++ b/packages/core/database/src/__tests__/filter-parser.test.ts @@ -1,4 +1,5 @@ import { Op } from 'sequelize'; + import { Database } from '../database'; import FilterParser from '../filter-parser'; import { mockDatabase } from './index'; diff --git a/packages/core/database/src/__tests__/group.test.ts b/packages/core/database/src/__tests__/group.test.ts index 297612ef0..ce2a3d88c 100644 --- a/packages/core/database/src/__tests__/group.test.ts +++ b/packages/core/database/src/__tests__/group.test.ts @@ -1,4 +1,5 @@ import { Database, mockDatabase } from '@tachybase/database'; + import sequelize from 'sequelize'; describe('migrator', () => { diff --git a/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts b/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts index 6045dd35f..4b2ffaaa6 100644 --- a/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts +++ b/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts @@ -1,8 +1,9 @@ import { BelongsToManyRepository } from '@tachybase/database'; +import { isPg } from '@tachybase/test'; + import Database from '../../database'; import { InheritedCollection } from '../../inherited-collection'; import { mockDatabase } from '../index'; -import { isPg } from '@tachybase/test'; describe.runIf(isPg())('collection inherits', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/migrator.test.ts b/packages/core/database/src/__tests__/migrator.test.ts index 9855a3834..5b7d41092 100644 --- a/packages/core/database/src/__tests__/migrator.test.ts +++ b/packages/core/database/src/__tests__/migrator.test.ts @@ -1,6 +1,7 @@ -import { vi } from 'vitest'; -import { Database, Migration, mockDatabase } from '@tachybase/database'; 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); diff --git a/packages/core/database/src/__tests__/model-hook.test.ts b/packages/core/database/src/__tests__/model-hook.test.ts index f643d36f2..4b231a7e5 100644 --- a/packages/core/database/src/__tests__/model-hook.test.ts +++ b/packages/core/database/src/__tests__/model-hook.test.ts @@ -1,5 +1,5 @@ -import { Database } from '..'; import { mockDatabase } from '.'; +import { Database } from '..'; describe('model hook', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/operator/association-operator.test.ts b/packages/core/database/src/__tests__/operator/association-operator.test.ts index 8c5d70298..88b225359 100644 --- a/packages/core/database/src/__tests__/operator/association-operator.test.ts +++ b/packages/core/database/src/__tests__/operator/association-operator.test.ts @@ -1,6 +1,5 @@ -import Database from '../../database'; import { Collection } from '../../collection'; - +import Database from '../../database'; import { mockDatabase } from '../index'; describe('association operator', () => { diff --git a/packages/core/database/src/__tests__/operator/empty-operator.test.ts b/packages/core/database/src/__tests__/operator/empty-operator.test.ts index e46b870fc..1a0ba6e0d 100644 --- a/packages/core/database/src/__tests__/operator/empty-operator.test.ts +++ b/packages/core/database/src/__tests__/operator/empty-operator.test.ts @@ -1,6 +1,5 @@ -import Database from '../../database'; import { Collection } from '../../collection'; - +import Database from '../../database'; import { mockDatabase } from '../index'; describe('empty operator', () => { diff --git a/packages/core/database/src/__tests__/operator/notIn.test.ts b/packages/core/database/src/__tests__/operator/notIn.test.ts index 04bdc6af4..39b44155e 100644 --- a/packages/core/database/src/__tests__/operator/notIn.test.ts +++ b/packages/core/database/src/__tests__/operator/notIn.test.ts @@ -1,5 +1,5 @@ -import { mockDatabase } from '../index'; import Database from '../../database'; +import { mockDatabase } from '../index'; describe('ne operator', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/postgres/schema.test.ts b/packages/core/database/src/__tests__/postgres/schema.test.ts index b40f411b3..25a0a0312 100644 --- a/packages/core/database/src/__tests__/postgres/schema.test.ts +++ b/packages/core/database/src/__tests__/postgres/schema.test.ts @@ -1,7 +1,8 @@ -import { mockDatabase } from '../index'; -import { Database } from '../../database'; import { randomStr } from '@tachybase/test'; +import { Database } from '../../database'; +import { mockDatabase } from '../index'; + describe('auth', () => { let db: Database; afterEach(async () => { diff --git a/packages/core/database/src/__tests__/relation-repository/belongs-to-many-repository.test.ts b/packages/core/database/src/__tests__/relation-repository/belongs-to-many-repository.test.ts index a3e300558..db3687c91 100644 --- a/packages/core/database/src/__tests__/relation-repository/belongs-to-many-repository.test.ts +++ b/packages/core/database/src/__tests__/relation-repository/belongs-to-many-repository.test.ts @@ -1,8 +1,9 @@ import { Collection } from '@tachybase/database'; +import { pgOnly } from '@tachybase/test'; + import Database from '../../database'; import { BelongsToManyRepository } from '../../relation-repository/belongs-to-many-repository'; import { mockDatabase } from '../index'; -import { pgOnly } from '@tachybase/test'; pgOnly()('belongs to many with targetCollection', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/relation-repository/has-many-repository.test.ts b/packages/core/database/src/__tests__/relation-repository/has-many-repository.test.ts index 82eeafd34..7a6ffa72c 100644 --- a/packages/core/database/src/__tests__/relation-repository/has-many-repository.test.ts +++ b/packages/core/database/src/__tests__/relation-repository/has-many-repository.test.ts @@ -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 { 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 () { let db: Database; afterEach(async () => { diff --git a/packages/core/database/src/__tests__/repository.test.ts b/packages/core/database/src/__tests__/repository.test.ts index 75ae2fcd8..da9662cd0 100644 --- a/packages/core/database/src/__tests__/repository.test.ts +++ b/packages/core/database/src/__tests__/repository.test.ts @@ -1,5 +1,7 @@ import { Repository } from '@tachybase/database'; + import { vi } from 'vitest'; + import { Collection } from '../collection'; import { Database } from '../database'; import { mockDatabase } from './'; diff --git a/packages/core/database/src/__tests__/repository/aggregation.test.ts b/packages/core/database/src/__tests__/repository/aggregation.test.ts index c25cdfb95..1f473f3c5 100644 --- a/packages/core/database/src/__tests__/repository/aggregation.test.ts +++ b/packages/core/database/src/__tests__/repository/aggregation.test.ts @@ -1,6 +1,6 @@ -import { BelongsToManyRepository, HasManyRepository, mockDatabase } from '../../index'; -import Database from '../../database'; import { Collection } from '../../collection'; +import Database from '../../database'; +import { BelongsToManyRepository, HasManyRepository, mockDatabase } from '../../index'; describe('association aggregation', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/repository/count.test.ts b/packages/core/database/src/__tests__/repository/count.test.ts index a9c0f9617..e98b8522b 100644 --- a/packages/core/database/src/__tests__/repository/count.test.ts +++ b/packages/core/database/src/__tests__/repository/count.test.ts @@ -1,6 +1,6 @@ -import { mockDatabase } from '../index'; -import { HasManyRepository } from '../../relation-repository/hasmany-repository'; import { Collection } from '../../collection'; +import { HasManyRepository } from '../../relation-repository/hasmany-repository'; +import { mockDatabase } from '../index'; describe('count', () => { let db; diff --git a/packages/core/database/src/__tests__/repository/create.test.ts b/packages/core/database/src/__tests__/repository/create.test.ts index b6500a6e7..3ff98f169 100644 --- a/packages/core/database/src/__tests__/repository/create.test.ts +++ b/packages/core/database/src/__tests__/repository/create.test.ts @@ -1,6 +1,6 @@ -import { mockDatabase } from '../index'; -import Database from '../../database'; import { Collection } from '../../collection'; +import Database from '../../database'; +import { mockDatabase } from '../index'; describe('create with hasMany', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/repository/destroy.test.ts b/packages/core/database/src/__tests__/repository/destroy.test.ts index d515e540d..661e0b1e7 100644 --- a/packages/core/database/src/__tests__/repository/destroy.test.ts +++ b/packages/core/database/src/__tests__/repository/destroy.test.ts @@ -1,7 +1,8 @@ -import { mockDatabase } from '../index'; -import { Collection } from '../../collection'; import { Database } from '@tachybase/database'; +import { Collection } from '../../collection'; +import { mockDatabase } from '../index'; + describe('destroy with targetKey', function () { let db: Database; let User: Collection; diff --git a/packages/core/database/src/__tests__/repository/find.test.ts b/packages/core/database/src/__tests__/repository/find.test.ts index a56f8f9b1..dea77c1d5 100644 --- a/packages/core/database/src/__tests__/repository/find.test.ts +++ b/packages/core/database/src/__tests__/repository/find.test.ts @@ -1,8 +1,10 @@ -import { mockDatabase } from '../index'; import Database from '@tachybase/database'; -import { Collection } from '../../collection'; + import qs from 'qs'; +import { Collection } from '../../collection'; +import { mockDatabase } from '../index'; + describe('find with associations', () => { let db: Database; beforeEach(async () => { diff --git a/packages/core/database/src/__tests__/sequelize-hooks.test.ts b/packages/core/database/src/__tests__/sequelize-hooks.test.ts index acefecbb9..4a360b26e 100644 --- a/packages/core/database/src/__tests__/sequelize-hooks.test.ts +++ b/packages/core/database/src/__tests__/sequelize-hooks.test.ts @@ -1,4 +1,5 @@ import { vi } from 'vitest'; + import { Database } from '../database'; import { mockDatabase } from './index'; diff --git a/packages/core/database/src/__tests__/sql-collection/select-query.test.ts b/packages/core/database/src/__tests__/sql-collection/select-query.test.ts index 4bac0122f..ab7e63d24 100644 --- a/packages/core/database/src/__tests__/sql-collection/select-query.test.ts +++ b/packages/core/database/src/__tests__/sql-collection/select-query.test.ts @@ -1,6 +1,7 @@ -import { SQLModel } from '../../sql-collection/sql-model'; import { Sequelize } from 'sequelize'; +import { SQLModel } from '../../sql-collection/sql-model'; + describe('select query', () => { const model = class extends SQLModel {}; model.init(null, { diff --git a/packages/core/database/src/__tests__/sync.test.ts b/packages/core/database/src/__tests__/sync.test.ts index 14d9439cc..4581ce060 100644 --- a/packages/core/database/src/__tests__/sync.test.ts +++ b/packages/core/database/src/__tests__/sync.test.ts @@ -1,6 +1,7 @@ -import { vi } from 'vitest'; import { Database, mockDatabase } from '@tachybase/database'; +import { vi } from 'vitest'; + describe('sync', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/sync/empty-table.test.ts b/packages/core/database/src/__tests__/sync/empty-table.test.ts index e06554820..bdceccc41 100644 --- a/packages/core/database/src/__tests__/sync/empty-table.test.ts +++ b/packages/core/database/src/__tests__/sync/empty-table.test.ts @@ -1,5 +1,5 @@ -import { Database, mockDatabase } from '@tachybase/database'; import * as process from 'process'; +import { Database, mockDatabase } from '@tachybase/database'; describe('empty table', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/sync/primary-key.test.ts b/packages/core/database/src/__tests__/sync/primary-key.test.ts index a43caae11..70f05ea48 100644 --- a/packages/core/database/src/__tests__/sync/primary-key.test.ts +++ b/packages/core/database/src/__tests__/sync/primary-key.test.ts @@ -1,6 +1,7 @@ -import { Database, mockDatabase } from '../../index'; import * as process from 'process'; +import { Database, mockDatabase } from '../../index'; + describe('primary key', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/update-associations-through.test.ts b/packages/core/database/src/__tests__/update-associations-through.test.ts index f118833cf..a00eceb1a 100644 --- a/packages/core/database/src/__tests__/update-associations-through.test.ts +++ b/packages/core/database/src/__tests__/update-associations-through.test.ts @@ -1,4 +1,5 @@ import { vi } from 'vitest'; + import { Database } from '../database'; import { mockDatabase } from './'; diff --git a/packages/core/database/src/__tests__/update-guard.test.ts b/packages/core/database/src/__tests__/update-guard.test.ts index 322b6f499..b209486d9 100644 --- a/packages/core/database/src/__tests__/update-guard.test.ts +++ b/packages/core/database/src/__tests__/update-guard.test.ts @@ -1,8 +1,9 @@ -import { Collection } from '../collection'; -import { mockDatabase } from './index'; -import { UpdateGuard } from '../update-guard'; import lodash from 'lodash'; + +import { Collection } from '../collection'; import { Database } from '../database'; +import { UpdateGuard } from '../update-guard'; +import { mockDatabase } from './index'; describe('update-guard', () => { let db: Database; diff --git a/packages/core/database/src/__tests__/value-parsers/date.test.ts b/packages/core/database/src/__tests__/value-parsers/date.test.ts index 6b83e0ea9..95a87d0b0 100644 --- a/packages/core/database/src/__tests__/value-parsers/date.test.ts +++ b/packages/core/database/src/__tests__/value-parsers/date.test.ts @@ -1,4 +1,5 @@ import dayjs from 'dayjs'; + import { Database, mockDatabase } from '../..'; import { DateValueParser } from '../../value-parsers'; diff --git a/packages/core/database/src/__tests__/view/view-collection.test.ts b/packages/core/database/src/__tests__/view/view-collection.test.ts index 90ec68714..7ccedf6fd 100644 --- a/packages/core/database/src/__tests__/view/view-collection.test.ts +++ b/packages/core/database/src/__tests__/view/view-collection.test.ts @@ -1,5 +1,7 @@ -import { vi } from 'vitest'; import { uid } from '@tachybase/utils'; + +import { vi } from 'vitest'; + import { Database, mockDatabase } from '../../index'; import { ViewCollection } from '../../view-collection'; import pgOnly from '../inhertits/helper'; diff --git a/packages/core/database/src/__tests__/view/view-inference.test.ts b/packages/core/database/src/__tests__/view/view-inference.test.ts index 949511492..58bc3c475 100644 --- a/packages/core/database/src/__tests__/view/view-inference.test.ts +++ b/packages/core/database/src/__tests__/view/view-inference.test.ts @@ -1,4 +1,5 @@ import { Database, mockDatabase } from '@tachybase/database'; + import { ViewFieldInference } from '../../view/view-inference'; describe('view inference', function () { diff --git a/packages/core/database/src/__tests__/view/view-with-association.test.ts b/packages/core/database/src/__tests__/view/view-with-association.test.ts index 9a6626d2b..897a6435e 100644 --- a/packages/core/database/src/__tests__/view/view-with-association.test.ts +++ b/packages/core/database/src/__tests__/view/view-with-association.test.ts @@ -1,6 +1,7 @@ -import { uid } from '@tachybase/utils'; -import { Database, mockDatabase, ViewFieldInference } from '../../index'; import { pgOnly } from '@tachybase/test'; +import { uid } from '@tachybase/utils'; + +import { Database, mockDatabase, ViewFieldInference } from '../../index'; pgOnly()('view with association', () => { let db: Database; diff --git a/packages/core/database/src/collection-importer.ts b/packages/core/database/src/collection-importer.ts index 314d721df..55bfc20c4 100644 --- a/packages/core/database/src/collection-importer.ts +++ b/packages/core/database/src/collection-importer.ts @@ -1,8 +1,9 @@ -import { importModule } from '@tachybase/utils'; import { existsSync } from 'fs'; import { readdir } from 'fs/promises'; -import { cloneDeep, isPlainObject } from 'lodash'; import path from 'path'; +import { importModule } from '@tachybase/utils'; + +import { cloneDeep, isPlainObject } from 'lodash'; export type ImportFileExtension = 'js' | 'ts' | 'json'; diff --git a/packages/core/database/src/collection.ts b/packages/core/database/src/collection.ts index 9d9506463..59430fac9 100644 --- a/packages/core/database/src/collection.ts +++ b/packages/core/database/src/collection.ts @@ -1,5 +1,6 @@ -import merge from 'deepmerge'; import { EventEmitter } from 'events'; + +import merge from 'deepmerge'; import { default as _, default as lodash } from 'lodash'; import { ModelOptions, @@ -10,6 +11,7 @@ import { Transactionable, Utils, } from 'sequelize'; + import { BuiltInGroup } from './collection-group-manager'; import { Database } from './database'; import { BelongsToField, Field, FieldOptions, HasManyField } from './fields'; diff --git a/packages/core/database/src/database-utils/index.ts b/packages/core/database/src/database-utils/index.ts index 46c3906b8..4790171ce 100644 --- a/packages/core/database/src/database-utils/index.ts +++ b/packages/core/database/src/database-utils/index.ts @@ -1,6 +1,7 @@ -import Database from '../database'; import lodash from 'lodash'; +import Database from '../database'; + export default class DatabaseUtils { constructor(public db: Database) {} diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index 0712a0763..55e23354d 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -1,13 +1,14 @@ +import { EventEmitter } from 'events'; +import { basename, isAbsolute, resolve } from 'path'; import { createConsoleLogger, createLogger, Logger, LoggerOptions } from '@tachybase/logger'; import { applyMixins, AsyncEmitter } from '@tachybase/utils'; + import chalk from 'chalk'; import merge from 'deepmerge'; -import { EventEmitter } from 'events'; import { backOff } from 'exponential-backoff'; import glob from 'glob'; import lodash from 'lodash'; import { nanoid } from 'nanoid'; -import { basename, isAbsolute, resolve } from 'path'; import semver from 'semver'; import { DataTypes, @@ -22,6 +23,7 @@ import { Utils, } from 'sequelize'; import { SequelizeStorage, Umzug } from 'umzug'; + import { Collection, CollectionOptions, RepositoryType } from './collection'; import { CollectionFactory } from './collection-factory'; import { CollectionGroupManager } from './collection-group-manager'; diff --git a/packages/core/database/src/decorators/transaction-decorator.ts b/packages/core/database/src/decorators/transaction-decorator.ts index 9419f7457..777a23a5d 100644 --- a/packages/core/database/src/decorators/transaction-decorator.ts +++ b/packages/core/database/src/decorators/transaction-decorator.ts @@ -5,12 +5,12 @@ export function transactionWrapperBuilder(transactionGenerator) { return (target, name, descriptor) => { const oldValue = descriptor.value; - descriptor.value = async function () { + descriptor.value = async function (...args: unknown[]) { let transaction; let newTransaction = false; - if (arguments.length > 0 && typeof arguments[0] === 'object') { - transaction = arguments[0]['transaction']; + if (args.length > 0 && typeof args[0] === 'object') { + transaction = args[0]['transaction']; } if (!transaction) { @@ -22,14 +22,15 @@ export function transactionWrapperBuilder(transactionGenerator) { if (newTransaction) { try { let callArguments; - if (lodash.isPlainObject(arguments[0])) { + if (lodash.isPlainObject(args[0])) { callArguments = { - ...arguments[0], + // @ts-ignore lodash type error + ...args[0], transaction, }; } else if (transactionInjector) { - callArguments = transactionInjector(arguments, transaction); - } else if (lodash.isNull(arguments[0]) || lodash.isUndefined(arguments[0])) { + callArguments = transactionInjector(args, transaction); + } else if (lodash.isNull(args[0]) || lodash.isUndefined(args[0])) { callArguments = { transaction, }; @@ -48,7 +49,7 @@ export function transactionWrapperBuilder(transactionGenerator) { throw err; } } else { - return oldValue.apply(this, arguments); + return oldValue.apply(this, args); } }; diff --git a/packages/core/database/src/eager-loading/eager-loading-tree.ts b/packages/core/database/src/eager-loading/eager-loading-tree.ts index 5ae9bcaa1..34e4b149b 100644 --- a/packages/core/database/src/eager-loading/eager-loading-tree.ts +++ b/packages/core/database/src/eager-loading/eager-loading-tree.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { Association, HasOne, HasOneOptions, Includeable, Model, ModelStatic, Op, Transaction } from 'sequelize'; + import Database from '../database'; import { appendChildCollectionNameAfterRepositoryFind } from '../listeners/append-child-collection-name-after-repository-find'; import { OptionsParser } from '../options-parser'; diff --git a/packages/core/database/src/features/references-map.ts b/packages/core/database/src/features/references-map.ts index e65bdd6bf..c2c6d7ea3 100644 --- a/packages/core/database/src/features/references-map.ts +++ b/packages/core/database/src/features/references-map.ts @@ -55,11 +55,13 @@ class ReferencesMap { if (existReference.onDelete === 'SET NULL' && reference.onDelete === 'CASCADE') { existReference.onDelete = reference.onDelete; } else { - console.error(new Error( - `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify( - reference, - )}`, - )); + console.error( + new Error( + `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify( + reference, + )}`, + ), + ); } } } diff --git a/packages/core/database/src/features/referential-integrity-check.ts b/packages/core/database/src/features/referential-integrity-check.ts index 57c94466f..9102a3f45 100644 --- a/packages/core/database/src/features/referential-integrity-check.ts +++ b/packages/core/database/src/features/referential-integrity-check.ts @@ -1,4 +1,5 @@ import { Model, Transactionable } from 'sequelize'; + import Database from '../database'; interface ReferentialIntegrityCheckOptions extends Transactionable { diff --git a/packages/core/database/src/field-repository/array-field-repository.ts b/packages/core/database/src/field-repository/array-field-repository.ts index 34cf59077..a2ffe418e 100644 --- a/packages/core/database/src/field-repository/array-field-repository.ts +++ b/packages/core/database/src/field-repository/array-field-repository.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { Transactionable } from 'sequelize/types'; + import { Collection } from '../collection'; import { transactionWrapperBuilder } from '../decorators/transaction-decorator'; import { ArrayField } from '../fields'; diff --git a/packages/core/database/src/fields/array-field.ts b/packages/core/database/src/fields/array-field.ts index 153904f62..9118a0999 100644 --- a/packages/core/database/src/fields/array-field.ts +++ b/packages/core/database/src/fields/array-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class ArrayField extends Field { diff --git a/packages/core/database/src/fields/belongs-to-field.ts b/packages/core/database/src/fields/belongs-to-field.ts index 586607340..19fc5b4f1 100644 --- a/packages/core/database/src/fields/belongs-to-field.ts +++ b/packages/core/database/src/fields/belongs-to-field.ts @@ -1,5 +1,6 @@ import lodash, { omit } from 'lodash'; import { BelongsToOptions as SequelizeBelongsToOptions, Utils } from 'sequelize'; + import { buildReference, Reference, ReferencePriority } from '../features/references-map'; import { checkIdentifier } from '../utils'; import { BaseRelationFieldOptions, RelationField } from './relation-field'; diff --git a/packages/core/database/src/fields/belongs-to-many-field.ts b/packages/core/database/src/fields/belongs-to-many-field.ts index f82d50520..522ca26dd 100644 --- a/packages/core/database/src/fields/belongs-to-many-field.ts +++ b/packages/core/database/src/fields/belongs-to-many-field.ts @@ -1,5 +1,6 @@ import { omit } from 'lodash'; import { AssociationScope, BelongsToManyOptions as SequelizeBelongsToManyOptions, Utils } from 'sequelize'; + import { Collection } from '../collection'; import { Reference } from '../features/references-map'; import { checkIdentifier } from '../utils'; diff --git a/packages/core/database/src/fields/boolean-field.ts b/packages/core/database/src/fields/boolean-field.ts index ee97a43b6..eafd5c6f9 100644 --- a/packages/core/database/src/fields/boolean-field.ts +++ b/packages/core/database/src/fields/boolean-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class BooleanField extends Field { diff --git a/packages/core/database/src/fields/context-field.ts b/packages/core/database/src/fields/context-field.ts index 8146ae8b2..a20bed5df 100644 --- a/packages/core/database/src/fields/context-field.ts +++ b/packages/core/database/src/fields/context-field.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { DataTypes } from 'sequelize'; + import { Model } from '../model'; import { BaseColumnFieldOptions, Field } from './field'; diff --git a/packages/core/database/src/fields/date-field.ts b/packages/core/database/src/fields/date-field.ts index e740129f9..69966cb52 100644 --- a/packages/core/database/src/fields/date-field.ts +++ b/packages/core/database/src/fields/date-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class DateField extends Field { diff --git a/packages/core/database/src/fields/field.ts b/packages/core/database/src/fields/field.ts index 2e8a423c2..2c1d04ca7 100644 --- a/packages/core/database/src/fields/field.ts +++ b/packages/core/database/src/fields/field.ts @@ -1,5 +1,6 @@ import _ from 'lodash'; import { DataType, ModelAttributeColumnOptions, ModelIndexesOptions, SyncOptions, Transactionable } from 'sequelize'; + import { Collection } from '../collection'; import { Database } from '../database'; import { ModelEventTypes } from '../types'; diff --git a/packages/core/database/src/fields/has-many-field.ts b/packages/core/database/src/fields/has-many-field.ts index 28a3f038b..515846e66 100644 --- a/packages/core/database/src/fields/has-many-field.ts +++ b/packages/core/database/src/fields/has-many-field.ts @@ -7,6 +7,7 @@ import { HasManyOptions as SequelizeHasManyOptions, Utils, } from 'sequelize'; + import { Collection } from '../collection'; import { buildReference, Reference } from '../features/references-map'; import { checkIdentifier } from '../utils'; diff --git a/packages/core/database/src/fields/has-one-field.ts b/packages/core/database/src/fields/has-one-field.ts index f2673daca..727b3985d 100644 --- a/packages/core/database/src/fields/has-one-field.ts +++ b/packages/core/database/src/fields/has-one-field.ts @@ -7,6 +7,7 @@ import { HasOneOptions as SequelizeHasOneOptions, Utils, } from 'sequelize'; + import { Collection } from '../collection'; import { buildReference, Reference } from '../features/references-map'; import { checkIdentifier } from '../utils'; diff --git a/packages/core/database/src/fields/index.ts b/packages/core/database/src/fields/index.ts index eb630051d..07763b27d 100644 --- a/packages/core/database/src/fields/index.ts +++ b/packages/core/database/src/fields/index.ts @@ -8,6 +8,7 @@ import { BaseFieldOptions } from './field'; import { HasManyFieldOptions } from './has-many-field'; import { HasOneFieldOptions } from './has-one-field'; import { JsonbFieldOptions, JsonFieldOptions } from './json-field'; +import { NanoidFieldOptions } from './nanoid-field'; import { DecimalFieldOptions, DoubleFieldOptions, @@ -25,7 +26,6 @@ import { TimeFieldOptions } from './time-field'; import { UidFieldOptions } from './uid-field'; import { UUIDFieldOptions } from './uuid-field'; import { VirtualFieldOptions } from './virtual-field'; -import { NanoidFieldOptions } from './nanoid-field'; export * from './array-field'; export * from './belongs-to-field'; diff --git a/packages/core/database/src/fields/json-field.ts b/packages/core/database/src/fields/json-field.ts index fbe424b26..1ce607ce0 100644 --- a/packages/core/database/src/fields/json-field.ts +++ b/packages/core/database/src/fields/json-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class JsonField extends Field { diff --git a/packages/core/database/src/fields/nanoid-field.ts b/packages/core/database/src/fields/nanoid-field.ts index 78e5a0aa8..30cb04a26 100644 --- a/packages/core/database/src/fields/nanoid-field.ts +++ b/packages/core/database/src/fields/nanoid-field.ts @@ -1,6 +1,7 @@ -import { DataTypes } from 'sequelize'; -import { BaseColumnFieldOptions, Field } from './field'; import { customAlphabet, nanoid } from 'nanoid'; +import { DataTypes } from 'sequelize'; + +import { BaseColumnFieldOptions, Field } from './field'; const DEFAULT_SIZE = 12; export class NanoidField extends Field { diff --git a/packages/core/database/src/fields/number-field.ts b/packages/core/database/src/fields/number-field.ts index 9fde4c9fb..c3d52a06e 100644 --- a/packages/core/database/src/fields/number-field.ts +++ b/packages/core/database/src/fields/number-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; abstract class NumberField extends Field {} diff --git a/packages/core/database/src/fields/password-field.ts b/packages/core/database/src/fields/password-field.ts index 32848b135..daa27d8d0 100644 --- a/packages/core/database/src/fields/password-field.ts +++ b/packages/core/database/src/fields/password-field.ts @@ -1,5 +1,7 @@ import crypto from 'crypto'; + import { DataTypes } from 'sequelize'; + import { Model } from '../model'; import { BaseColumnFieldOptions, Field } from './field'; diff --git a/packages/core/database/src/fields/radio-field.ts b/packages/core/database/src/fields/radio-field.ts index e6408c386..8d7799855 100644 --- a/packages/core/database/src/fields/radio-field.ts +++ b/packages/core/database/src/fields/radio-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export interface RadioFieldOptions extends BaseColumnFieldOptions { diff --git a/packages/core/database/src/fields/sort-field.ts b/packages/core/database/src/fields/sort-field.ts index 30d9adae6..d96f07544 100644 --- a/packages/core/database/src/fields/sort-field.ts +++ b/packages/core/database/src/fields/sort-field.ts @@ -1,6 +1,7 @@ import { Mutex } from 'async-mutex'; import { isNumber } from 'lodash'; import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; const sortFieldMutex = new Mutex(); diff --git a/packages/core/database/src/fields/string-field.ts b/packages/core/database/src/fields/string-field.ts index db7e60617..1d847c2f6 100644 --- a/packages/core/database/src/fields/string-field.ts +++ b/packages/core/database/src/fields/string-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class StringField extends Field { diff --git a/packages/core/database/src/fields/text-field.ts b/packages/core/database/src/fields/text-field.ts index c1d15e4e4..11cbf2080 100644 --- a/packages/core/database/src/fields/text-field.ts +++ b/packages/core/database/src/fields/text-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class TextField extends Field { diff --git a/packages/core/database/src/fields/time-field.ts b/packages/core/database/src/fields/time-field.ts index f9a487b9b..cce81b696 100644 --- a/packages/core/database/src/fields/time-field.ts +++ b/packages/core/database/src/fields/time-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class TimeField extends Field { diff --git a/packages/core/database/src/fields/uid-field.ts b/packages/core/database/src/fields/uid-field.ts index 9a09af092..dba176bc1 100644 --- a/packages/core/database/src/fields/uid-field.ts +++ b/packages/core/database/src/fields/uid-field.ts @@ -1,5 +1,7 @@ import { uid } from '@tachybase/utils'; + import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class UidField extends Field { diff --git a/packages/core/database/src/fields/uuid-field.ts b/packages/core/database/src/fields/uuid-field.ts index 53705c6b8..45919caf4 100644 --- a/packages/core/database/src/fields/uuid-field.ts +++ b/packages/core/database/src/fields/uuid-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field, FieldContext } from './field'; export class UuidField extends Field { diff --git a/packages/core/database/src/fields/virtual-field.ts b/packages/core/database/src/fields/virtual-field.ts index 7d03b1fe5..f4eee77aa 100644 --- a/packages/core/database/src/fields/virtual-field.ts +++ b/packages/core/database/src/fields/virtual-field.ts @@ -1,4 +1,5 @@ import { DataTypes } from 'sequelize'; + import { BaseColumnFieldOptions, Field } from './field'; export class VirtualField extends Field { diff --git a/packages/core/database/src/filter-parser.ts b/packages/core/database/src/filter-parser.ts index e72880e06..8af11f95d 100644 --- a/packages/core/database/src/filter-parser.ts +++ b/packages/core/database/src/filter-parser.ts @@ -1,6 +1,7 @@ import { flatten, unflatten } from 'flat'; -import { default as lodash, default as _ } from 'lodash'; +import _ from 'lodash'; import { ModelStatic } from 'sequelize'; + import { Collection } from './collection'; import { Database } from './database'; import { Model } from './model'; @@ -31,7 +32,7 @@ export default class FilterParser { } prepareFilter(filter: FilterType) { - if (lodash.isPlainObject(filter)) { + if (_.isPlainObject(filter)) { const renamedKey = {}; for (const key of Object.keys(filter)) { @@ -70,7 +71,7 @@ export default class FilterParser { // supported operators const operators = this.database.operators; - const originalFiler = lodash.cloneDeep(filter || {}); + const originalFiler = _.cloneDeep(filter || {}); const flattenedFilter = flatten(filter || {}); @@ -84,7 +85,8 @@ export default class FilterParser { debug('associations %O', associations); - for (let [key, value] of Object.entries(flattenedFilter)) { + for (const [key, _value] of Object.entries(flattenedFilter)) { + let value = _value; // 处理 filter 条件 if (skipPrefix && key.startsWith(skipPrefix)) { continue; @@ -127,7 +129,7 @@ export default class FilterParser { } else if (typeof opKey === 'function') { skipPrefix = origins.join('.'); - const queryValue = lodash.get(unflatten(originalFiler), skipPrefix); + const queryValue = _.get(unflatten(originalFiler), skipPrefix); const [fieldName, fullName] = this.getFieldNameFromQueryPath(skipPrefix); value = opKey(queryValue, { app: this.context.app, @@ -147,7 +149,7 @@ export default class FilterParser { } // firstKey is number - if (!lodash.isNaN(parseInt(firstKey))) { + if (!_.isNaN(parseInt(firstKey))) { paths.push(firstKey); continue; } @@ -261,7 +263,7 @@ export default class FilterParser { let fieldName; const fullPaths = []; for (const path of paths) { - if (path.startsWith('$') || !lodash.isNaN(parseInt(path))) { + if (path.startsWith('$') || !_.isNaN(parseInt(path))) { continue; } fullPaths.push(path); diff --git a/packages/core/database/src/helpers.ts b/packages/core/database/src/helpers.ts index 184bf8138..ff61dbc6f 100644 --- a/packages/core/database/src/helpers.ts +++ b/packages/core/database/src/helpers.ts @@ -1,7 +1,9 @@ -import { Database, IDatabaseOptions } from './database'; import fs from 'fs'; + import semver from 'semver'; +import { Database, IDatabaseOptions } from './database'; + function getEnvValue(key, defaultValue?) { return process.env[key] || defaultValue; } diff --git a/packages/core/database/src/inherited-collection.ts b/packages/core/database/src/inherited-collection.ts index 0615fd974..73676fe4e 100644 --- a/packages/core/database/src/inherited-collection.ts +++ b/packages/core/database/src/inherited-collection.ts @@ -1,4 +1,5 @@ import { default as lodash } from 'lodash'; + import { Field } from '.'; import { Collection, CollectionContext, CollectionOptions } from './collection'; diff --git a/packages/core/database/src/inherited-map.ts b/packages/core/database/src/inherited-map.ts index 1963fd16c..172b58221 100644 --- a/packages/core/database/src/inherited-map.ts +++ b/packages/core/database/src/inherited-map.ts @@ -1,4 +1,5 @@ import lodash from 'lodash'; + import Database from './database'; class TableNode { diff --git a/packages/core/database/src/inherited-sync-runner.ts b/packages/core/database/src/inherited-sync-runner.ts index 7fed9ead0..414df315c 100644 --- a/packages/core/database/src/inherited-sync-runner.ts +++ b/packages/core/database/src/inherited-sync-runner.ts @@ -1,6 +1,7 @@ -import { InheritedCollection } from './inherited-collection'; import lodash from 'lodash'; +import { InheritedCollection } from './inherited-collection'; + export class InheritedSyncRunner { static async syncInheritModel(model: any, options: any) { const { transaction } = options; diff --git a/packages/core/database/src/magic-attribute-model.ts b/packages/core/database/src/magic-attribute-model.ts index f6a49c656..238e8df6f 100644 --- a/packages/core/database/src/magic-attribute-model.ts +++ b/packages/core/database/src/magic-attribute-model.ts @@ -1,8 +1,11 @@ import { merge } from '@tachybase/utils'; + import _ from 'lodash'; import { Utils } from 'sequelize'; + import Database from './database'; import { Model } from './model'; + const Dottie = require('dottie'); export class MagicAttributeModel extends Model { diff --git a/packages/core/database/src/migration.ts b/packages/core/database/src/migration.ts index 01a752733..5dca8491c 100644 --- a/packages/core/database/src/migration.ts +++ b/packages/core/database/src/migration.ts @@ -1,6 +1,8 @@ import { importModule } from '@tachybase/utils'; + import _ from 'lodash'; import { QueryInterface, Sequelize } from 'sequelize'; + import Database from './database'; export interface MigrationContext { diff --git a/packages/core/database/src/model.ts b/packages/core/database/src/model.ts index 7642cbafe..aff08d614 100644 --- a/packages/core/database/src/model.ts +++ b/packages/core/database/src/model.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; -import { Model as SequelizeModel, ModelStatic } from 'sequelize'; +import { ModelStatic, Model as SequelizeModel } from 'sequelize'; + import { Collection } from './collection'; import { Database } from './database'; import { Field } from './fields'; diff --git a/packages/core/database/src/operators/array.ts b/packages/core/database/src/operators/array.ts index fc4d2703c..b433aa0e1 100644 --- a/packages/core/database/src/operators/array.ts +++ b/packages/core/database/src/operators/array.ts @@ -1,5 +1,6 @@ import _ from 'lodash'; import { Op, Sequelize } from 'sequelize'; + import { isMySQL, isPg } from './utils'; const getFieldName = (ctx) => { diff --git a/packages/core/database/src/operators/date.ts b/packages/core/database/src/operators/date.ts index 892da665e..9a4de31cf 100644 --- a/packages/core/database/src/operators/date.ts +++ b/packages/core/database/src/operators/date.ts @@ -1,4 +1,5 @@ import { parseDate } from '@tachybase/utils'; + import { Op } from 'sequelize'; function isDate(input) { diff --git a/packages/core/database/src/operators/empty.ts b/packages/core/database/src/operators/empty.ts index 6ad772d18..3ba68a601 100644 --- a/packages/core/database/src/operators/empty.ts +++ b/packages/core/database/src/operators/empty.ts @@ -1,7 +1,8 @@ +import lodash, { parseInt } from 'lodash'; import { Op } from 'sequelize'; + import { ArrayField, StringField } from '../fields'; import arrayOperators from './array'; -import lodash, { parseInt } from 'lodash'; const findFilterFieldType = (ctx) => { const db = ctx.db; diff --git a/packages/core/database/src/operators/index.ts b/packages/core/database/src/operators/index.ts index 7ad5fdc30..b39f71bb1 100644 --- a/packages/core/database/src/operators/index.ts +++ b/packages/core/database/src/operators/index.ts @@ -1,13 +1,13 @@ -import association from './association'; -import date from './date'; import array from './array'; +import association from './association'; +import boolean from './boolean'; +import childCollection from './child-collection'; +import date from './date'; import empty from './empty'; -import string from './string'; import eq from './eq'; import ne from './ne'; import notIn from './notIn'; -import boolean from './boolean'; -import childCollection from './child-collection'; +import string from './string'; export default { ...association, diff --git a/packages/core/database/src/operators/notIn.ts b/packages/core/database/src/operators/notIn.ts index e2be83122..fc1262b6c 100644 --- a/packages/core/database/src/operators/notIn.ts +++ b/packages/core/database/src/operators/notIn.ts @@ -10,4 +10,3 @@ export default { }; }, } as Record; - diff --git a/packages/core/database/src/operators/string.ts b/packages/core/database/src/operators/string.ts index 4c688ebd6..dec025bc4 100644 --- a/packages/core/database/src/operators/string.ts +++ b/packages/core/database/src/operators/string.ts @@ -1,4 +1,5 @@ import { Op } from 'sequelize'; + import { isPg } from './utils'; function escapeLike(value: string) { diff --git a/packages/core/database/src/options-parser.ts b/packages/core/database/src/options-parser.ts index 12a66418d..88cb95c4f 100644 --- a/packages/core/database/src/options-parser.ts +++ b/packages/core/database/src/options-parser.ts @@ -1,10 +1,11 @@ import lodash from 'lodash'; +import qs from 'qs'; import { FindAttributeOptions, ModelStatic, Op, Sequelize } from 'sequelize'; + import { Collection } from './collection'; import { Database } from './database'; import FilterParser from './filter-parser'; import { Appends, Except, FindOptions } from './repository'; -import qs from 'qs'; const debug = require('debug')('noco-database'); diff --git a/packages/core/database/src/query-interface/mysql-query-interface.ts b/packages/core/database/src/query-interface/mysql-query-interface.ts index ef49653eb..c60d009bd 100644 --- a/packages/core/database/src/query-interface/mysql-query-interface.ts +++ b/packages/core/database/src/query-interface/mysql-query-interface.ts @@ -1,4 +1,5 @@ import { Transaction, Transactionable } from 'sequelize'; + import { Collection } from '../collection'; import sqlParser from '../sql-parser'; import QueryInterface, { TableInfo } from './query-interface'; diff --git a/packages/core/database/src/query-interface/postgres-query-interface.ts b/packages/core/database/src/query-interface/postgres-query-interface.ts index 183c4465c..eda0173ba 100644 --- a/packages/core/database/src/query-interface/postgres-query-interface.ts +++ b/packages/core/database/src/query-interface/postgres-query-interface.ts @@ -1,8 +1,9 @@ import lodash from 'lodash'; +import { Transaction } from 'sequelize'; + import { Collection } from '../collection'; import sqlParser from '../sql-parser/postgres'; import QueryInterface, { TableInfo } from './query-interface'; -import { Transaction } from 'sequelize'; export default class PostgresQueryInterface extends QueryInterface { constructor(db) { diff --git a/packages/core/database/src/query-interface/query-interface.ts b/packages/core/database/src/query-interface/query-interface.ts index 2aa07a278..67ca95c3f 100644 --- a/packages/core/database/src/query-interface/query-interface.ts +++ b/packages/core/database/src/query-interface/query-interface.ts @@ -1,4 +1,5 @@ import { QueryInterface as SequelizeQueryInterface, Transaction, Transactionable } from 'sequelize'; + import { Collection } from '../collection'; import Database from '../database'; diff --git a/packages/core/database/src/query-interface/sqlite-query-interface.ts b/packages/core/database/src/query-interface/sqlite-query-interface.ts index 113a5d0a8..e15ac9ee1 100644 --- a/packages/core/database/src/query-interface/sqlite-query-interface.ts +++ b/packages/core/database/src/query-interface/sqlite-query-interface.ts @@ -1,7 +1,8 @@ +import { Transaction } from 'sequelize'; + import { Collection } from '../collection'; import sqlParser from '../sql-parser'; import QueryInterface, { TableInfo } from './query-interface'; -import { Transaction } from 'sequelize'; export default class SqliteQueryInterface extends QueryInterface { constructor(db) { diff --git a/packages/core/database/src/relation-repository/belongs-to-many-repository.ts b/packages/core/database/src/relation-repository/belongs-to-many-repository.ts index 1b0c894fe..ddf9b4390 100644 --- a/packages/core/database/src/relation-repository/belongs-to-many-repository.ts +++ b/packages/core/database/src/relation-repository/belongs-to-many-repository.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { BelongsToMany, Op, Transaction } from 'sequelize'; + import { AggregateOptions, CreateOptions, DestroyOptions, TargetKey } from '../repository'; import { updateAssociations, updateThroughTableValue } from '../update-associations'; import { MultipleRelationRepository } from './multiple-relation-repository'; diff --git a/packages/core/database/src/relation-repository/belongs-to-repository.ts b/packages/core/database/src/relation-repository/belongs-to-repository.ts index 1675c20d0..491d1c291 100644 --- a/packages/core/database/src/relation-repository/belongs-to-repository.ts +++ b/packages/core/database/src/relation-repository/belongs-to-repository.ts @@ -1,4 +1,5 @@ import { BelongsTo } from 'sequelize'; + import { SingleRelationFindOption, SingleRelationRepository } from './single-relation-repository'; type BelongsToFindOptions = SingleRelationFindOption; diff --git a/packages/core/database/src/relation-repository/hasmany-repository.ts b/packages/core/database/src/relation-repository/hasmany-repository.ts index cde1cc83b..54ca020a1 100644 --- a/packages/core/database/src/relation-repository/hasmany-repository.ts +++ b/packages/core/database/src/relation-repository/hasmany-repository.ts @@ -1,8 +1,10 @@ import { omit } from 'lodash'; import { HasMany, Op } from 'sequelize'; -import { AggregateOptions, DestroyOptions, FindOptions, TK, TargetKey } from '../repository'; + +import { AggregateOptions, DestroyOptions, FindOptions, TargetKey, TK } from '../repository'; import { AssociatedOptions, MultipleRelationRepository } from './multiple-relation-repository'; import { transaction } from './relation-repository'; + export class HasManyRepository extends MultipleRelationRepository { async find(options?: FindOptions): Promise { const targetRepository = this.targetCollection.repository; diff --git a/packages/core/database/src/relation-repository/hasone-repository.ts b/packages/core/database/src/relation-repository/hasone-repository.ts index 4547a2043..1904b18d5 100644 --- a/packages/core/database/src/relation-repository/hasone-repository.ts +++ b/packages/core/database/src/relation-repository/hasone-repository.ts @@ -1,4 +1,5 @@ import { HasOne } from 'sequelize'; + import { SingleRelationRepository } from './single-relation-repository'; export class HasOneRepository extends SingleRelationRepository { diff --git a/packages/core/database/src/relation-repository/multiple-relation-repository.ts b/packages/core/database/src/relation-repository/multiple-relation-repository.ts index fc5e374b7..fa594f81a 100644 --- a/packages/core/database/src/relation-repository/multiple-relation-repository.ts +++ b/packages/core/database/src/relation-repository/multiple-relation-repository.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { HasOne, MultiAssociationAccessors, Sequelize, Transaction, Transactionable } from 'sequelize'; + import injectTargetCollection from '../decorators/target-collection-decorator'; import { CommonFindOptions, @@ -8,8 +9,8 @@ import { Filter, FindOneOptions, FindOptions, - TK, TargetKey, + TK, UpdateOptions, } from '../repository'; import { updateModelByValues } from '../update-associations'; diff --git a/packages/core/database/src/relation-repository/relation-repository.ts b/packages/core/database/src/relation-repository/relation-repository.ts index a5e5f72ba..4e066fd66 100644 --- a/packages/core/database/src/relation-repository/relation-repository.ts +++ b/packages/core/database/src/relation-repository/relation-repository.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { Association, BelongsTo, BelongsToMany, HasMany, HasOne, ModelStatic, Transaction } from 'sequelize'; + import { Collection } from '../collection'; import Database from '../database'; import { transactionWrapperBuilder } from '../decorators/transaction-decorator'; diff --git a/packages/core/database/src/relation-repository/single-relation-repository.ts b/packages/core/database/src/relation-repository/single-relation-repository.ts index 37ed99869..7ee50f4d5 100644 --- a/packages/core/database/src/relation-repository/single-relation-repository.ts +++ b/packages/core/database/src/relation-repository/single-relation-repository.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { SingleAssociationAccessors, Transactionable } from 'sequelize'; + import injectTargetCollection from '../decorators/target-collection-decorator'; import { Model } from '../model'; import { Appends, Except, Fields, Filter, TargetKey, UpdateOptions } from '../repository'; diff --git a/packages/core/database/src/relation-repository/types.ts b/packages/core/database/src/relation-repository/types.ts index dd8c7f2c1..a114a0e60 100644 --- a/packages/core/database/src/relation-repository/types.ts +++ b/packages/core/database/src/relation-repository/types.ts @@ -1,6 +1,7 @@ -import { TargetKey, Values } from '../repository'; import { Transactionable } from 'sequelize'; +import { TargetKey, Values } from '../repository'; + export type PrimaryKeyWithThroughValues = [TargetKey, Values]; export interface AssociatedOptions extends Transactionable { diff --git a/packages/core/database/src/repositories/tree-repository/adjacency-list-repository.ts b/packages/core/database/src/repositories/tree-repository/adjacency-list-repository.ts index c26a77a8c..e17430481 100644 --- a/packages/core/database/src/repositories/tree-repository/adjacency-list-repository.ts +++ b/packages/core/database/src/repositories/tree-repository/adjacency-list-repository.ts @@ -1,7 +1,8 @@ import lodash from 'lodash'; -import { FindOptions, Repository } from '../../repository'; -import Database from '../../database'; + import { Collection } from '../../collection'; +import Database from '../../database'; +import { FindOptions, Repository } from '../../repository'; export class AdjacencyListRepository extends Repository { static queryParentSQL(options: { diff --git a/packages/core/database/src/repository.ts b/packages/core/database/src/repository.ts index 8e2ac2527..6cb4fa4ee 100644 --- a/packages/core/database/src/repository.ts +++ b/packages/core/database/src/repository.ts @@ -3,18 +3,19 @@ import lodash from 'lodash'; import { Association, BulkCreateOptions, - CountOptions as SequelizeCountOptions, - CreateOptions as SequelizeCreateOptions, - DestroyOptions as SequelizeDestroyOptions, - FindAndCountOptions as SequelizeAndCountOptions, - FindOptions as SequelizeFindOptions, ModelStatic, Op, Sequelize, - Transactionable, + FindAndCountOptions as SequelizeAndCountOptions, + CountOptions as SequelizeCountOptions, + CreateOptions as SequelizeCreateOptions, + DestroyOptions as SequelizeDestroyOptions, + FindOptions as SequelizeFindOptions, UpdateOptions as SequelizeUpdateOptions, + Transactionable, WhereOperators, } from 'sequelize'; + import { Collection } from './collection'; import { Database } from './database'; import mustHaveFilter from './decorators/must-have-filter-decorator'; diff --git a/packages/core/database/src/sql-collection/query-generator.ts b/packages/core/database/src/sql-collection/query-generator.ts index a0abe0def..5f070f4da 100644 --- a/packages/core/database/src/sql-collection/query-generator.ts +++ b/packages/core/database/src/sql-collection/query-generator.ts @@ -1,7 +1,9 @@ -import { GroupOption, Order, ProjectionAlias, WhereOptions } from 'sequelize'; -import { SQLModel } from './sql-model'; import { lodash } from '@tachybase/utils'; + +import { GroupOption, Order, ProjectionAlias, WhereOptions } from 'sequelize'; + import { Collection } from '../collection'; +import { SQLModel } from './sql-model'; export function selectQuery( tableName: string, diff --git a/packages/core/database/src/sql-parser/index.js b/packages/core/database/src/sql-parser/index.js index eab4bd585..f12783ec6 100644 --- a/packages/core/database/src/sql-parser/index.js +++ b/packages/core/database/src/sql-parser/index.js @@ -2,10 +2,12 @@ // // https://peggyjs.org/ -"use strict"; +'use strict'; function peg$subclass(child, parent) { - function C() { this.constructor = child; } + function C() { + this.constructor = child; + } C.prototype = parent.prototype; child.prototype = new C(); } @@ -19,22 +21,24 @@ function peg$SyntaxError(message, expected, found, location) { self.expected = expected; self.found = found; self.location = location; - self.name = "SyntaxError"; + self.name = 'SyntaxError'; return self; } peg$subclass(peg$SyntaxError, Error); function peg$padEnd(str, targetLength, padString) { - padString = padString || " "; - if (str.length > targetLength) { return str; } + padString = padString || ' '; + if (str.length > targetLength) { + return str; + } targetLength -= str.length; padString += padString.repeat(targetLength); return str + padString.slice(0, targetLength); } -peg$SyntaxError.prototype.format = function(sources) { - var str = "Error: " + this.message; +peg$SyntaxError.prototype.format = function (sources) { + var str = 'Error: ' + this.message; if (this.location) { var src = null; var k; @@ -45,55 +49,61 @@ peg$SyntaxError.prototype.format = function(sources) { } } var s = this.location.start; - var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) - ? this.location.source.offset(s) - : s; - var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + var offset_s = + this.location.source && typeof this.location.source.offset === 'function' ? this.location.source.offset(s) : s; + var loc = this.location.source + ':' + offset_s.line + ':' + offset_s.column; if (src) { var e = this.location.end; - var filler = peg$padEnd("", offset_s.line.toString().length, ' '); + var filler = peg$padEnd('', offset_s.line.toString().length, ' '); var line = src[s.line - 1]; var last = s.line === e.line ? e.column : line.length + 1; - var hatLen = (last - s.column) || 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + offset_s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1, ' ') - + peg$padEnd("", hatLen, "^"); + var hatLen = last - s.column || 1; + str += + '\n --> ' + + loc + + '\n' + + filler + + ' |\n' + + offset_s.line + + ' | ' + + line + + '\n' + + filler + + ' | ' + + peg$padEnd('', s.column - 1, ' ') + + peg$padEnd('', hatLen, '^'); } else { - str += "\n at " + loc; + str += '\n at ' + loc; } } return str; }; -peg$SyntaxError.buildMessage = function(expected, found) { +peg$SyntaxError.buildMessage = function (expected, found) { var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; + literal: function (expectation) { + return '"' + literalEscape(expectation.text) + '"'; }, - class: function(expectation) { - var escapedParts = expectation.parts.map(function(part) { - return Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part); + class: function (expectation) { + var escapedParts = expectation.parts.map(function (part) { + return Array.isArray(part) ? classEscape(part[0]) + '-' + classEscape(part[1]) : classEscape(part); }); - return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; + return '[' + (expectation.inverted ? '^' : '') + escapedParts.join('') + ']'; }, - any: function() { - return "any character"; + any: function () { + return 'any character'; }, - end: function() { - return "end of input"; + end: function () { + return 'end of input'; }, - other: function(expectation) { + other: function (expectation) { return expectation.description; - } + }, }; function hex(ch) { @@ -102,28 +112,36 @@ peg$SyntaxError.buildMessage = function(expected, found) { function literalEscape(s) { return s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); } function classEscape(s) { return s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + .replace(/\\/g, '\\\\') + .replace(/\]/g, '\\]') + .replace(/\^/g, '\\^') + .replace(/-/g, '\\-') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); } function describeExpectation(expectation) { @@ -151,20 +169,18 @@ peg$SyntaxError.buildMessage = function(expected, found) { return descriptions[0]; case 2: - return descriptions[0] + " or " + descriptions[1]; + return descriptions[0] + ' or ' + descriptions[1]; default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; + return descriptions.slice(0, -1).join(', ') + ', or ' + descriptions[descriptions.length - 1]; } } function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + return found ? '"' + literalEscape(found) + '"' : 'end of input'; } - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.'; }; function peg$parse(input, options) { @@ -176,139 +192,139 @@ function peg$parse(input, options) { var peg$startRuleFunctions = { start: peg$parsestart }; var peg$startRuleFunction = peg$parsestart; - var peg$c0 = "("; - var peg$c1 = ")"; - var peg$c2 = "="; - var peg$c3 = "!"; - var peg$c4 = ">="; - var peg$c5 = ">"; - var peg$c6 = "<="; - var peg$c7 = "<>"; - var peg$c8 = "<"; - var peg$c9 = "!="; - var peg$c10 = "+"; - var peg$c11 = "-"; - var peg$c12 = "*"; - var peg$c13 = "/"; - var peg$c14 = "%"; - var peg$c15 = "\""; + var peg$c0 = '('; + var peg$c1 = ')'; + var peg$c2 = '='; + var peg$c3 = '!'; + var peg$c4 = '>='; + var peg$c5 = '>'; + var peg$c6 = '<='; + var peg$c7 = '<>'; + var peg$c8 = '<'; + var peg$c9 = '!='; + var peg$c10 = '+'; + var peg$c11 = '-'; + var peg$c12 = '*'; + var peg$c13 = '/'; + var peg$c14 = '%'; + var peg$c15 = '"'; var peg$c16 = "'"; - var peg$c17 = "`"; - var peg$c18 = ":"; + var peg$c17 = '`'; + var peg$c18 = ':'; var peg$c19 = "\\'"; - var peg$c20 = "\\\""; - var peg$c21 = "\\\\"; - var peg$c22 = "\\/"; - var peg$c23 = "\\b"; - var peg$c24 = "\\f"; - var peg$c25 = "\\n"; - var peg$c26 = "\\r"; - var peg$c27 = "\\t"; - var peg$c28 = "\\u"; - var peg$c29 = "."; - var peg$c30 = "null"; - var peg$c31 = "true"; - var peg$c32 = "false"; - var peg$c33 = "show"; - var peg$c34 = "drop"; - var peg$c35 = "select"; - var peg$c36 = "update"; - var peg$c37 = "create"; - var peg$c38 = "delete"; - var peg$c39 = "insert"; - var peg$c40 = "RECURSIVE"; - var peg$c41 = "replace"; - var peg$c42 = "explain"; - var peg$c43 = "into"; - var peg$c44 = "from"; - var peg$c45 = "set"; - var peg$c46 = "as"; - var peg$c47 = "table"; - var peg$c48 = "on"; - var peg$c49 = "left"; - var peg$c50 = "right"; - var peg$c51 = "full"; - var peg$c52 = "inner"; - var peg$c53 = "join"; - var peg$c54 = "outer"; - var peg$c55 = "union"; - var peg$c56 = "values"; - var peg$c57 = "using"; - var peg$c58 = "where"; - var peg$c59 = "with"; - var peg$c60 = "group"; - var peg$c61 = "by"; - var peg$c62 = "order"; - var peg$c63 = "having"; - var peg$c64 = "limit"; - var peg$c65 = "asc"; - var peg$c66 = "desc"; - var peg$c67 = "all"; - var peg$c68 = "distinct"; - var peg$c69 = "between"; - var peg$c70 = "in"; - var peg$c71 = "is"; - var peg$c72 = "like"; - var peg$c73 = "exists"; - var peg$c74 = "not"; - var peg$c75 = "and"; - var peg$c76 = "or"; - var peg$c77 = "count"; - var peg$c78 = "max"; - var peg$c79 = "min"; - var peg$c80 = "sum"; - var peg$c81 = "avg"; - var peg$c82 = "case"; - var peg$c83 = "when"; - var peg$c84 = "then"; - var peg$c85 = "else"; - var peg$c86 = "end"; - var peg$c87 = "cast"; - var peg$c88 = "char"; - var peg$c89 = "varchar"; - var peg$c90 = "numeric"; - var peg$c91 = "decimal"; - var peg$c92 = "signed"; - var peg$c93 = "unsigned"; - var peg$c94 = "int"; - var peg$c95 = "integer"; - var peg$c96 = "json"; - var peg$c97 = "smallint"; - var peg$c98 = "date"; - var peg$c99 = "time"; - var peg$c100 = "timestamp"; - var peg$c101 = "user"; - var peg$c102 = "current_date"; - var peg$c103 = "adddate"; - var peg$c104 = "interval"; - var peg$c105 = "year"; - var peg$c106 = "month"; - var peg$c107 = "day"; - var peg$c108 = "hour"; - var peg$c109 = "minute"; - var peg$c110 = "second"; - var peg$c111 = "current_time"; - var peg$c112 = "current_timestamp"; - var peg$c113 = "current_user"; - var peg$c114 = "session_user"; - var peg$c115 = "system_user"; - var peg$c116 = "$"; - var peg$c117 = "return"; - var peg$c118 = ":="; - var peg$c119 = "dual"; - var peg$c120 = "sql_calc_found_rows"; - var peg$c121 = "sql_cache"; - var peg$c122 = "sql_no_cache"; - var peg$c123 = "sql_small_result"; - var peg$c124 = "sql_big_result"; - var peg$c125 = "sql_buffer_result"; - var peg$c126 = ","; - var peg$c127 = "["; - var peg$c128 = "]"; - var peg$c129 = ";"; - var peg$c130 = "/*"; - var peg$c131 = "*/"; - var peg$c132 = "--"; + var peg$c20 = '\\"'; + var peg$c21 = '\\\\'; + var peg$c22 = '\\/'; + var peg$c23 = '\\b'; + var peg$c24 = '\\f'; + var peg$c25 = '\\n'; + var peg$c26 = '\\r'; + var peg$c27 = '\\t'; + var peg$c28 = '\\u'; + var peg$c29 = '.'; + var peg$c30 = 'null'; + var peg$c31 = 'true'; + var peg$c32 = 'false'; + var peg$c33 = 'show'; + var peg$c34 = 'drop'; + var peg$c35 = 'select'; + var peg$c36 = 'update'; + var peg$c37 = 'create'; + var peg$c38 = 'delete'; + var peg$c39 = 'insert'; + var peg$c40 = 'RECURSIVE'; + var peg$c41 = 'replace'; + var peg$c42 = 'explain'; + var peg$c43 = 'into'; + var peg$c44 = 'from'; + var peg$c45 = 'set'; + var peg$c46 = 'as'; + var peg$c47 = 'table'; + var peg$c48 = 'on'; + var peg$c49 = 'left'; + var peg$c50 = 'right'; + var peg$c51 = 'full'; + var peg$c52 = 'inner'; + var peg$c53 = 'join'; + var peg$c54 = 'outer'; + var peg$c55 = 'union'; + var peg$c56 = 'values'; + var peg$c57 = 'using'; + var peg$c58 = 'where'; + var peg$c59 = 'with'; + var peg$c60 = 'group'; + var peg$c61 = 'by'; + var peg$c62 = 'order'; + var peg$c63 = 'having'; + var peg$c64 = 'limit'; + var peg$c65 = 'asc'; + var peg$c66 = 'desc'; + var peg$c67 = 'all'; + var peg$c68 = 'distinct'; + var peg$c69 = 'between'; + var peg$c70 = 'in'; + var peg$c71 = 'is'; + var peg$c72 = 'like'; + var peg$c73 = 'exists'; + var peg$c74 = 'not'; + var peg$c75 = 'and'; + var peg$c76 = 'or'; + var peg$c77 = 'count'; + var peg$c78 = 'max'; + var peg$c79 = 'min'; + var peg$c80 = 'sum'; + var peg$c81 = 'avg'; + var peg$c82 = 'case'; + var peg$c83 = 'when'; + var peg$c84 = 'then'; + var peg$c85 = 'else'; + var peg$c86 = 'end'; + var peg$c87 = 'cast'; + var peg$c88 = 'char'; + var peg$c89 = 'varchar'; + var peg$c90 = 'numeric'; + var peg$c91 = 'decimal'; + var peg$c92 = 'signed'; + var peg$c93 = 'unsigned'; + var peg$c94 = 'int'; + var peg$c95 = 'integer'; + var peg$c96 = 'json'; + var peg$c97 = 'smallint'; + var peg$c98 = 'date'; + var peg$c99 = 'time'; + var peg$c100 = 'timestamp'; + var peg$c101 = 'user'; + var peg$c102 = 'current_date'; + var peg$c103 = 'adddate'; + var peg$c104 = 'interval'; + var peg$c105 = 'year'; + var peg$c106 = 'month'; + var peg$c107 = 'day'; + var peg$c108 = 'hour'; + var peg$c109 = 'minute'; + var peg$c110 = 'second'; + var peg$c111 = 'current_time'; + var peg$c112 = 'current_timestamp'; + var peg$c113 = 'current_user'; + var peg$c114 = 'session_user'; + var peg$c115 = 'system_user'; + var peg$c116 = '$'; + var peg$c117 = 'return'; + var peg$c118 = ':='; + var peg$c119 = 'dual'; + var peg$c120 = 'sql_calc_found_rows'; + var peg$c121 = 'sql_cache'; + var peg$c122 = 'sql_no_cache'; + var peg$c123 = 'sql_small_result'; + var peg$c124 = 'sql_big_result'; + var peg$c125 = 'sql_buffer_result'; + var peg$c126 = ','; + var peg$c127 = '['; + var peg$c128 = ']'; + var peg$c129 = ';'; + var peg$c130 = '/*'; + var peg$c131 = '*/'; + var peg$c132 = '--'; var peg$r0 = /^[^"]/; var peg$r1 = /^[^']/; @@ -326,788 +342,1008 @@ function peg$parse(input, options) { var peg$r13 = /^[+\-]/; var peg$r14 = /^[ \t\n\r]/; - var peg$e0 = peg$literalExpectation("(", false); - var peg$e1 = peg$literalExpectation(")", false); - var peg$e2 = peg$literalExpectation("=", false); - var peg$e3 = peg$literalExpectation("!", false); - var peg$e4 = peg$literalExpectation(">=", false); - var peg$e5 = peg$literalExpectation(">", false); - var peg$e6 = peg$literalExpectation("<=", false); - var peg$e7 = peg$literalExpectation("<>", false); - var peg$e8 = peg$literalExpectation("<", false); - var peg$e9 = peg$literalExpectation("!=", false); - var peg$e10 = peg$literalExpectation("+", false); - var peg$e11 = peg$literalExpectation("-", false); - var peg$e12 = peg$literalExpectation("*", false); - var peg$e13 = peg$literalExpectation("/", false); - var peg$e14 = peg$literalExpectation("%", false); - var peg$e15 = peg$literalExpectation("\"", false); - var peg$e16 = peg$classExpectation(["\""], true, false); + var peg$e0 = peg$literalExpectation('(', false); + var peg$e1 = peg$literalExpectation(')', false); + var peg$e2 = peg$literalExpectation('=', false); + var peg$e3 = peg$literalExpectation('!', false); + var peg$e4 = peg$literalExpectation('>=', false); + var peg$e5 = peg$literalExpectation('>', false); + var peg$e6 = peg$literalExpectation('<=', false); + var peg$e7 = peg$literalExpectation('<>', false); + var peg$e8 = peg$literalExpectation('<', false); + var peg$e9 = peg$literalExpectation('!=', false); + var peg$e10 = peg$literalExpectation('+', false); + var peg$e11 = peg$literalExpectation('-', false); + var peg$e12 = peg$literalExpectation('*', false); + var peg$e13 = peg$literalExpectation('/', false); + var peg$e14 = peg$literalExpectation('%', false); + var peg$e15 = peg$literalExpectation('"', false); + var peg$e16 = peg$classExpectation(['"'], true, false); var peg$e17 = peg$literalExpectation("'", false); var peg$e18 = peg$classExpectation(["'"], true, false); - var peg$e19 = peg$literalExpectation("`", false); - var peg$e20 = peg$classExpectation(["`"], true, false); - var peg$e21 = peg$classExpectation([["A", "Z"], ["a", "z"], "_"], false, false); - var peg$e22 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false); - var peg$e23 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", ":"], false, false); - var peg$e24 = peg$literalExpectation(":", false); - var peg$e25 = peg$classExpectation(["\"", "\\", ["\0", "\x1F"], "\x7F"], true, false); - var peg$e26 = peg$classExpectation(["'", "\\", ["\0", "\x1F"], "\x7F"], true, false); + var peg$e19 = peg$literalExpectation('`', false); + var peg$e20 = peg$classExpectation(['`'], true, false); + var peg$e21 = peg$classExpectation([['A', 'Z'], ['a', 'z'], '_'], false, false); + var peg$e22 = peg$classExpectation([['A', 'Z'], ['a', 'z'], ['0', '9'], '_'], false, false); + var peg$e23 = peg$classExpectation([['A', 'Z'], ['a', 'z'], ['0', '9'], '_', ':'], false, false); + var peg$e24 = peg$literalExpectation(':', false); + var peg$e25 = peg$classExpectation(['"', '\\', ['\0', '\x1F'], '\x7F'], true, false); + var peg$e26 = peg$classExpectation(["'", '\\', ['\0', '\x1F'], '\x7F'], true, false); var peg$e27 = peg$literalExpectation("\\'", false); - var peg$e28 = peg$literalExpectation("\\\"", false); - var peg$e29 = peg$literalExpectation("\\\\", false); - var peg$e30 = peg$literalExpectation("\\/", false); - var peg$e31 = peg$literalExpectation("\\b", false); - var peg$e32 = peg$literalExpectation("\\f", false); - var peg$e33 = peg$literalExpectation("\\n", false); - var peg$e34 = peg$literalExpectation("\\r", false); - var peg$e35 = peg$literalExpectation("\\t", false); - var peg$e36 = peg$literalExpectation("\\u", false); - var peg$e37 = peg$classExpectation(["\n", "\r"], false, false); - var peg$e38 = peg$literalExpectation(".", false); - var peg$e39 = peg$classExpectation([["0", "9"]], false, false); - var peg$e40 = peg$classExpectation([["1", "9"]], false, false); - var peg$e41 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false); - var peg$e42 = peg$classExpectation(["e", "E"], false, false); - var peg$e43 = peg$classExpectation(["+", "-"], false, false); - var peg$e44 = peg$literalExpectation("NULL", true); - var peg$e45 = peg$literalExpectation("TRUE", true); - var peg$e46 = peg$literalExpectation("FALSE", true); - var peg$e47 = peg$literalExpectation("SHOW", true); - var peg$e48 = peg$literalExpectation("DROP", true); - var peg$e49 = peg$literalExpectation("SELECT", true); - var peg$e50 = peg$literalExpectation("UPDATE", true); - var peg$e51 = peg$literalExpectation("CREATE", true); - var peg$e52 = peg$literalExpectation("DELETE", true); - var peg$e53 = peg$literalExpectation("INSERT", true); - var peg$e54 = peg$literalExpectation("RECURSIVE", false); - var peg$e55 = peg$literalExpectation("REPLACE", true); - var peg$e56 = peg$literalExpectation("EXPLAIN", true); - var peg$e57 = peg$literalExpectation("INTO", true); - var peg$e58 = peg$literalExpectation("FROM", true); - var peg$e59 = peg$literalExpectation("SET", true); - var peg$e60 = peg$literalExpectation("AS", true); - var peg$e61 = peg$literalExpectation("TABLE", true); - var peg$e62 = peg$literalExpectation("ON", true); - var peg$e63 = peg$literalExpectation("LEFT", true); - var peg$e64 = peg$literalExpectation("RIGHT", true); - var peg$e65 = peg$literalExpectation("FULL", true); - var peg$e66 = peg$literalExpectation("INNER", true); - var peg$e67 = peg$literalExpectation("JOIN", true); - var peg$e68 = peg$literalExpectation("OUTER", true); - var peg$e69 = peg$literalExpectation("UNION", true); - var peg$e70 = peg$literalExpectation("VALUES", true); - var peg$e71 = peg$literalExpectation("USING", true); - var peg$e72 = peg$literalExpectation("WHERE", true); - var peg$e73 = peg$literalExpectation("WITH", true); - var peg$e74 = peg$literalExpectation("GROUP", true); - var peg$e75 = peg$literalExpectation("BY", true); - var peg$e76 = peg$literalExpectation("ORDER", true); - var peg$e77 = peg$literalExpectation("HAVING", true); - var peg$e78 = peg$literalExpectation("LIMIT", true); - var peg$e79 = peg$literalExpectation("ASC", true); - var peg$e80 = peg$literalExpectation("DESC", true); - var peg$e81 = peg$literalExpectation("ALL", true); - var peg$e82 = peg$literalExpectation("DISTINCT", true); - var peg$e83 = peg$literalExpectation("BETWEEN", true); - var peg$e84 = peg$literalExpectation("IN", true); - var peg$e85 = peg$literalExpectation("IS", true); - var peg$e86 = peg$literalExpectation("LIKE", true); - var peg$e87 = peg$literalExpectation("EXISTS", true); - var peg$e88 = peg$literalExpectation("NOT", true); - var peg$e89 = peg$literalExpectation("AND", true); - var peg$e90 = peg$literalExpectation("OR", true); - var peg$e91 = peg$literalExpectation("COUNT", true); - var peg$e92 = peg$literalExpectation("MAX", true); - var peg$e93 = peg$literalExpectation("MIN", true); - var peg$e94 = peg$literalExpectation("SUM", true); - var peg$e95 = peg$literalExpectation("AVG", true); - var peg$e96 = peg$literalExpectation("CASE", true); - var peg$e97 = peg$literalExpectation("WHEN", true); - var peg$e98 = peg$literalExpectation("THEN", true); - var peg$e99 = peg$literalExpectation("ELSE", true); - var peg$e100 = peg$literalExpectation("END", true); - var peg$e101 = peg$literalExpectation("CAST", true); - var peg$e102 = peg$literalExpectation("CHAR", true); - var peg$e103 = peg$literalExpectation("VARCHAR", true); - var peg$e104 = peg$literalExpectation("NUMERIC", true); - var peg$e105 = peg$literalExpectation("DECIMAL", true); - var peg$e106 = peg$literalExpectation("SIGNED", true); - var peg$e107 = peg$literalExpectation("UNSIGNED", true); - var peg$e108 = peg$literalExpectation("INT", true); - var peg$e109 = peg$literalExpectation("INTEGER", true); - var peg$e110 = peg$literalExpectation("JSON", true); - var peg$e111 = peg$literalExpectation("SMALLINT", true); - var peg$e112 = peg$literalExpectation("DATE", true); - var peg$e113 = peg$literalExpectation("TIME", true); - var peg$e114 = peg$literalExpectation("TIMESTAMP", true); - var peg$e115 = peg$literalExpectation("USER", true); - var peg$e116 = peg$literalExpectation("CURRENT_DATE", true); - var peg$e117 = peg$literalExpectation("ADDDATE", true); - var peg$e118 = peg$literalExpectation("INTERVAL", true); - var peg$e119 = peg$literalExpectation("YEAR", true); - var peg$e120 = peg$literalExpectation("MONTH", true); - var peg$e121 = peg$literalExpectation("DAY", true); - var peg$e122 = peg$literalExpectation("HOUR", true); - var peg$e123 = peg$literalExpectation("MINUTE", true); - var peg$e124 = peg$literalExpectation("SECOND", true); - var peg$e125 = peg$literalExpectation("CURRENT_TIME", true); - var peg$e126 = peg$literalExpectation("CURRENT_TIMESTAMP", true); - var peg$e127 = peg$literalExpectation("CURRENT_USER", true); - var peg$e128 = peg$literalExpectation("SESSION_USER", true); - var peg$e129 = peg$literalExpectation("SYSTEM_USER", true); - var peg$e130 = peg$literalExpectation("$", false); - var peg$e131 = peg$literalExpectation("return", true); - var peg$e132 = peg$literalExpectation(":=", false); - var peg$e133 = peg$literalExpectation("DUAL", true); - var peg$e134 = peg$literalExpectation("SQL_CALC_FOUND_ROWS", true); - var peg$e135 = peg$literalExpectation("SQL_CACHE", true); - var peg$e136 = peg$literalExpectation("SQL_NO_CACHE", true); - var peg$e137 = peg$literalExpectation("SQL_SMALL_RESULT", true); - var peg$e138 = peg$literalExpectation("SQL_BIG_RESULT", true); - var peg$e139 = peg$literalExpectation("SQL_BUFFER_RESULT", true); - var peg$e140 = peg$literalExpectation(",", false); - var peg$e141 = peg$literalExpectation("[", false); - var peg$e142 = peg$literalExpectation("]", false); - var peg$e143 = peg$literalExpectation(";", false); - var peg$e144 = peg$literalExpectation("/*", false); - var peg$e145 = peg$literalExpectation("*/", false); - var peg$e146 = peg$literalExpectation("--", false); + var peg$e28 = peg$literalExpectation('\\"', false); + var peg$e29 = peg$literalExpectation('\\\\', false); + var peg$e30 = peg$literalExpectation('\\/', false); + var peg$e31 = peg$literalExpectation('\\b', false); + var peg$e32 = peg$literalExpectation('\\f', false); + var peg$e33 = peg$literalExpectation('\\n', false); + var peg$e34 = peg$literalExpectation('\\r', false); + var peg$e35 = peg$literalExpectation('\\t', false); + var peg$e36 = peg$literalExpectation('\\u', false); + var peg$e37 = peg$classExpectation(['\n', '\r'], false, false); + var peg$e38 = peg$literalExpectation('.', false); + var peg$e39 = peg$classExpectation([['0', '9']], false, false); + var peg$e40 = peg$classExpectation([['1', '9']], false, false); + var peg$e41 = peg$classExpectation( + [ + ['0', '9'], + ['a', 'f'], + ['A', 'F'], + ], + false, + false, + ); + var peg$e42 = peg$classExpectation(['e', 'E'], false, false); + var peg$e43 = peg$classExpectation(['+', '-'], false, false); + var peg$e44 = peg$literalExpectation('NULL', true); + var peg$e45 = peg$literalExpectation('TRUE', true); + var peg$e46 = peg$literalExpectation('FALSE', true); + var peg$e47 = peg$literalExpectation('SHOW', true); + var peg$e48 = peg$literalExpectation('DROP', true); + var peg$e49 = peg$literalExpectation('SELECT', true); + var peg$e50 = peg$literalExpectation('UPDATE', true); + var peg$e51 = peg$literalExpectation('CREATE', true); + var peg$e52 = peg$literalExpectation('DELETE', true); + var peg$e53 = peg$literalExpectation('INSERT', true); + var peg$e54 = peg$literalExpectation('RECURSIVE', false); + var peg$e55 = peg$literalExpectation('REPLACE', true); + var peg$e56 = peg$literalExpectation('EXPLAIN', true); + var peg$e57 = peg$literalExpectation('INTO', true); + var peg$e58 = peg$literalExpectation('FROM', true); + var peg$e59 = peg$literalExpectation('SET', true); + var peg$e60 = peg$literalExpectation('AS', true); + var peg$e61 = peg$literalExpectation('TABLE', true); + var peg$e62 = peg$literalExpectation('ON', true); + var peg$e63 = peg$literalExpectation('LEFT', true); + var peg$e64 = peg$literalExpectation('RIGHT', true); + var peg$e65 = peg$literalExpectation('FULL', true); + var peg$e66 = peg$literalExpectation('INNER', true); + var peg$e67 = peg$literalExpectation('JOIN', true); + var peg$e68 = peg$literalExpectation('OUTER', true); + var peg$e69 = peg$literalExpectation('UNION', true); + var peg$e70 = peg$literalExpectation('VALUES', true); + var peg$e71 = peg$literalExpectation('USING', true); + var peg$e72 = peg$literalExpectation('WHERE', true); + var peg$e73 = peg$literalExpectation('WITH', true); + var peg$e74 = peg$literalExpectation('GROUP', true); + var peg$e75 = peg$literalExpectation('BY', true); + var peg$e76 = peg$literalExpectation('ORDER', true); + var peg$e77 = peg$literalExpectation('HAVING', true); + var peg$e78 = peg$literalExpectation('LIMIT', true); + var peg$e79 = peg$literalExpectation('ASC', true); + var peg$e80 = peg$literalExpectation('DESC', true); + var peg$e81 = peg$literalExpectation('ALL', true); + var peg$e82 = peg$literalExpectation('DISTINCT', true); + var peg$e83 = peg$literalExpectation('BETWEEN', true); + var peg$e84 = peg$literalExpectation('IN', true); + var peg$e85 = peg$literalExpectation('IS', true); + var peg$e86 = peg$literalExpectation('LIKE', true); + var peg$e87 = peg$literalExpectation('EXISTS', true); + var peg$e88 = peg$literalExpectation('NOT', true); + var peg$e89 = peg$literalExpectation('AND', true); + var peg$e90 = peg$literalExpectation('OR', true); + var peg$e91 = peg$literalExpectation('COUNT', true); + var peg$e92 = peg$literalExpectation('MAX', true); + var peg$e93 = peg$literalExpectation('MIN', true); + var peg$e94 = peg$literalExpectation('SUM', true); + var peg$e95 = peg$literalExpectation('AVG', true); + var peg$e96 = peg$literalExpectation('CASE', true); + var peg$e97 = peg$literalExpectation('WHEN', true); + var peg$e98 = peg$literalExpectation('THEN', true); + var peg$e99 = peg$literalExpectation('ELSE', true); + var peg$e100 = peg$literalExpectation('END', true); + var peg$e101 = peg$literalExpectation('CAST', true); + var peg$e102 = peg$literalExpectation('CHAR', true); + var peg$e103 = peg$literalExpectation('VARCHAR', true); + var peg$e104 = peg$literalExpectation('NUMERIC', true); + var peg$e105 = peg$literalExpectation('DECIMAL', true); + var peg$e106 = peg$literalExpectation('SIGNED', true); + var peg$e107 = peg$literalExpectation('UNSIGNED', true); + var peg$e108 = peg$literalExpectation('INT', true); + var peg$e109 = peg$literalExpectation('INTEGER', true); + var peg$e110 = peg$literalExpectation('JSON', true); + var peg$e111 = peg$literalExpectation('SMALLINT', true); + var peg$e112 = peg$literalExpectation('DATE', true); + var peg$e113 = peg$literalExpectation('TIME', true); + var peg$e114 = peg$literalExpectation('TIMESTAMP', true); + var peg$e115 = peg$literalExpectation('USER', true); + var peg$e116 = peg$literalExpectation('CURRENT_DATE', true); + var peg$e117 = peg$literalExpectation('ADDDATE', true); + var peg$e118 = peg$literalExpectation('INTERVAL', true); + var peg$e119 = peg$literalExpectation('YEAR', true); + var peg$e120 = peg$literalExpectation('MONTH', true); + var peg$e121 = peg$literalExpectation('DAY', true); + var peg$e122 = peg$literalExpectation('HOUR', true); + var peg$e123 = peg$literalExpectation('MINUTE', true); + var peg$e124 = peg$literalExpectation('SECOND', true); + var peg$e125 = peg$literalExpectation('CURRENT_TIME', true); + var peg$e126 = peg$literalExpectation('CURRENT_TIMESTAMP', true); + var peg$e127 = peg$literalExpectation('CURRENT_USER', true); + var peg$e128 = peg$literalExpectation('SESSION_USER', true); + var peg$e129 = peg$literalExpectation('SYSTEM_USER', true); + var peg$e130 = peg$literalExpectation('$', false); + var peg$e131 = peg$literalExpectation('return', true); + var peg$e132 = peg$literalExpectation(':=', false); + var peg$e133 = peg$literalExpectation('DUAL', true); + var peg$e134 = peg$literalExpectation('SQL_CALC_FOUND_ROWS', true); + var peg$e135 = peg$literalExpectation('SQL_CACHE', true); + var peg$e136 = peg$literalExpectation('SQL_NO_CACHE', true); + var peg$e137 = peg$literalExpectation('SQL_SMALL_RESULT', true); + var peg$e138 = peg$literalExpectation('SQL_BIG_RESULT', true); + var peg$e139 = peg$literalExpectation('SQL_BUFFER_RESULT', true); + var peg$e140 = peg$literalExpectation(',', false); + var peg$e141 = peg$literalExpectation('[', false); + var peg$e142 = peg$literalExpectation(']', false); + var peg$e143 = peg$literalExpectation(';', false); + var peg$e144 = peg$literalExpectation('/*', false); + var peg$e145 = peg$literalExpectation('*/', false); + var peg$e146 = peg$literalExpectation('--', false); var peg$e147 = peg$anyExpectation(); - var peg$e148 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); + var peg$e148 = peg$classExpectation([' ', '\t', '\n', '\r'], false, false); - var peg$f0 = function(head, tail) { - const cur = [head && head.ast || head]; - for (let i = 0; i < tail.length; i++) { - if(!tail[i][3] || tail[i][3].length === 0) continue; - cur.push(tail[i][3] && tail[i][3].ast || tail[i][3]); - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: cur - } + var peg$f0 = function (head, tail) { + const cur = [(head && head.ast) || head]; + for (let i = 0; i < tail.length; i++) { + if (!tail[i][3] || tail[i][3].length === 0) continue; + cur.push((tail[i][3] && tail[i][3].ast) || tail[i][3]); + } + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: cur, }; - var peg$f1 = function(head, tail) { - let cur = head; - for (let i = 0; i < tail.length; i++) { - cur._next = tail[i][3]; - cur = cur._next - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: head - } - }; - var peg$f2 = function(s) { - return s[2]; - }; - var peg$f3 = function(head, tail) { - return createList(head, tail); - }; - var peg$f4 = function(cte) { - cte.recursive = true; - return [cte] - }; - var peg$f5 = function(name, columns, stmt) { - return { name, stmt, columns }; - }; - var peg$f6 = function(head, tail) { - return createList(head, tail); - }; - var peg$f7 = function(cte, opts, d, c, f, w, g, h, o, l) { - if(f) f.forEach(info => info.table && tableList.add(`select::${info.db}::${info.table}`)); - return { - with: cte, - type: 'select', - options: opts, - distinct: d, - columns: c, - from: f, - where: w, - groupby: g, - having: h, - orderby: o, - limit: l - }; }; - var peg$f8 = function(head, tail) { + var peg$f1 = function (head, tail) { + let cur = head; + for (let i = 0; i < tail.length; i++) { + cur._next = tail[i][3]; + cur = cur._next; + } + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: head, + }; + }; + var peg$f2 = function (s) { + return s[2]; + }; + var peg$f3 = function (head, tail) { + return createList(head, tail); + }; + var peg$f4 = function (cte) { + cte.recursive = true; + return [cte]; + }; + var peg$f5 = function (name, columns, stmt) { + return { name, stmt, columns }; + }; + var peg$f6 = function (head, tail) { + return createList(head, tail); + }; + var peg$f7 = function (cte, opts, d, c, f, w, g, h, o, l) { + if (f) f.forEach((info) => info.table && tableList.add(`select::${info.db}::${info.table}`)); + return { + with: cte, + type: 'select', + options: opts, + distinct: d, + columns: c, + from: f, + where: w, + groupby: g, + having: h, + orderby: o, + limit: l, + }; + }; + var peg$f8 = function (head, tail) { const opts = [head]; for (let i = 0, l = tail.length; i < l; ++i) { opts.push(tail[i][1]); } return opts; }; - var peg$f9 = function(option) { return option; }; - var peg$f10 = function() { - columnList.add('select::null::(.*)'); - return '*'; + var peg$f9 = function (option) { + return option; + }; + var peg$f10 = function () { + columnList.add('select::null::(.*)'); + return '*'; + }; + var peg$f11 = function (head, tail) { + return createList(head, tail); + }; + var peg$f12 = function (tbl) { + columnList.add(`select::${tbl}::(.*)`); + return { + expr: { + type: 'column_ref', + table: tbl, + column: '*', + }, + as: null, }; - var peg$f11 = function(head, tail) { - return createList(head, tail); - }; - var peg$f12 = function(tbl) { - columnList.add(`select::${tbl}::(.*)`); - return { - expr: { - type: 'column_ref', - table: tbl, - column: '*' - }, - as: null - }; - }; - var peg$f13 = function(e, alias) { - return { expr: e, as: alias }; - }; - var peg$f14 = function(i) { return i; }; - var peg$f15 = function(i) { return i; }; - var peg$f16 = function(l) { return l; }; - var peg$f17 = function(head, tail) { - tail.unshift(head); - return tail; - }; - var peg$f18 = function(t) { return t; }; - var peg$f19 = function(t) { return t; }; - var peg$f20 = function(op, t, head, tail) { - t.join = op; - t.using = createList(head, tail); - return t; - }; - var peg$f21 = function(op, t, expr) { - t.join = op; - t.on = expr; - return t; - }; - var peg$f22 = function(op, stmt, alias, expr) { + }; + var peg$f13 = function (e, alias) { + return { expr: e, as: alias }; + }; + var peg$f14 = function (i) { + return i; + }; + var peg$f15 = function (i) { + return i; + }; + var peg$f16 = function (l) { + return l; + }; + var peg$f17 = function (head, tail) { + tail.unshift(head); + return tail; + }; + var peg$f18 = function (t) { + return t; + }; + var peg$f19 = function (t) { + return t; + }; + var peg$f20 = function (op, t, head, tail) { + t.join = op; + t.using = createList(head, tail); + return t; + }; + var peg$f21 = function (op, t, expr) { + t.join = op; + t.on = expr; + return t; + }; + var peg$f22 = function (op, stmt, alias, expr) { stmt.parentheses = true; return { expr: stmt, as: alias, join: op, - on: expr + on: expr, }; }; - var peg$f23 = function() { - return { - type: 'dual' - }; + var peg$f23 = function () { + return { + type: 'dual', + }; }; - var peg$f24 = function(t, alias) { - if (t.type === 'var') { - t.as = alias; - return t; - } else { - return { - db: t.db, - table: t.table, - as: alias - }; - } - }; - var peg$f25 = function(stmt, alias) { - stmt.parentheses = true; + var peg$f24 = function (t, alias) { + if (t.type === 'var') { + t.as = alias; + return t; + } else { return { - expr: stmt, - as: alias + db: t.db, + table: t.table, + as: alias, }; + } + }; + var peg$f25 = function (stmt, alias) { + stmt.parentheses = true; + return { + expr: stmt, + as: alias, }; - var peg$f26 = function() { return 'LEFT JOIN'; }; - var peg$f27 = function() { return 'RIGHT JOIN'; }; - var peg$f28 = function() { return 'FULL JOIN'; }; - var peg$f29 = function() { return 'INNER JOIN'; }; - var peg$f30 = function(dt, tail) { - const obj = { db: null, table: dt }; - if (tail !== null) { - obj.db = dt; - obj.table = tail[3]; - } - return obj; - }; - var peg$f31 = function(v) { - v.db = null; - v.table = v.name; - return v; - }; - var peg$f32 = function(e) { return e; }; - var peg$f33 = function(e) { return e; }; - var peg$f34 = function(l) { return l; }; - var peg$f35 = function(head, tail) { - return createList(head, tail); - }; - var peg$f36 = function(e) { return e; }; - var peg$f37 = function(l) { return l; }; - var peg$f38 = function(head, tail) { - return createList(head, tail); - }; - var peg$f39 = function(e, d) { + }; + var peg$f26 = function () { + return 'LEFT JOIN'; + }; + var peg$f27 = function () { + return 'RIGHT JOIN'; + }; + var peg$f28 = function () { + return 'FULL JOIN'; + }; + var peg$f29 = function () { + return 'INNER JOIN'; + }; + var peg$f30 = function (dt, tail) { + const obj = { db: null, table: dt }; + if (tail !== null) { + obj.db = dt; + obj.table = tail[3]; + } + return obj; + }; + var peg$f31 = function (v) { + v.db = null; + v.table = v.name; + return v; + }; + var peg$f32 = function (e) { + return e; + }; + var peg$f33 = function (e) { + return e; + }; + var peg$f34 = function (l) { + return l; + }; + var peg$f35 = function (head, tail) { + return createList(head, tail); + }; + var peg$f36 = function (e) { + return e; + }; + var peg$f37 = function (l) { + return l; + }; + var peg$f38 = function (head, tail) { + return createList(head, tail); + }; + var peg$f39 = function (e, d) { const obj = { expr: e, type: 'ASC' }; if (d === 'DESC') obj.type = 'DESC'; return obj; }; - var peg$f40 = function(i1, tail) { - const res = [i1]; - if (tail === null) res.unshift({ type: 'number', value: 0 }); - else res.push(tail[2]); - return res; + var peg$f40 = function (i1, tail) { + const res = [i1]; + if (tail === null) res.unshift({ type: 'number', value: 0 }); + else res.push(tail[2]); + return res; + }; + var peg$f41 = function (t, l, w) { + if (t.table) tableList.add(`update::${t.db}::${t.table}`); + if (l) l.forEach((col) => columnList.add(`update::${t.table}::${col.column}`)); + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: { + type: 'update', + db: t.db, + table: t.table, + set: l, + where: w, + }, }; - var peg$f41 = function(t, l, w) { - if(t.table) tableList.add(`update::${t.db}::${t.table}`); - if(l) l.forEach(col => columnList.add(`update::${t.table}::${col.column}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'update', - db: t.db, - table: t.table, - set: l, - where: w - } - }; - }; - var peg$f42 = function(t, f, w) { - if(f) f.forEach(info => { + }; + var peg$f42 = function (t, f, w) { + if (f) + f.forEach((info) => { info.table && tableList.add(`delete::${info.db}::${info.table}`); columnList.add(`delete::${info.table}::(.*)`); }); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'delete', - tables: t, - from: f, - where: w - } - }; + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: { + type: 'delete', + tables: t, + from: f, + where: w, + }, }; - var peg$f43 = function(head, tail) { - return createList(head, tail); + }; + var peg$f43 = function (head, tail) { + return createList(head, tail); + }; + var peg$f44 = function (tbl, c, v) { + return { column: c, value: v, table: tbl && tbl[0] }; + }; + var peg$f45 = function (ri, t, c, v) { + if (t.table) tableList.add(`insert::${t.db}::${t.table}`); + if (c) c.forEach((c) => columnList.add(`insert::${t.table}::${c}`)); + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: { + type: ri, + db: t.db, + table: t.table, + columns: c, + values: v, + }, }; - var peg$f44 = function(tbl, c, v) { - return { column: c, value: v, table: tbl && tbl[0] }; + }; + var peg$f46 = function (ri, t, v) { + if (t.table) tableList.add(`insert::${t.db}::${t.table}`); + columnList.add(`insert::${t.table}::(.*)`); + return { + tableList: Array.from(tableList), + columnList: Array.from(columnList), + ast: { + type: ri, + db: t.db, + table: t.table, + columns: null, + values: v, + }, }; - var peg$f45 = function(ri, t, c, v) { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - if (c) c.forEach(c => columnList.add(`insert::${t.table}::${c}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: c, - values: v - } - }; + }; + var peg$f47 = function () { + return 'insert'; + }; + var peg$f48 = function () { + return 'replace'; + }; + var peg$f49 = function (l) { + return l; + }; + var peg$f50 = function (head, tail) { + return createList(head, tail); + }; + var peg$f51 = function (l) { + return l; + }; + var peg$f52 = function (head, tail) { + const el = { type: 'expr_list' }; + el.value = createList(head, tail); + return el; + }; + var peg$f53 = function (n, u) { + return { + type: 'interval', + value: [n, u], }; - var peg$f46 = function(ri, t, v) { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - columnList.add(`insert::${t.table}::(.*)`); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: null, - values: v - } - }; + }; + var peg$f54 = function (expr, condition_list, otherwise) { + if (otherwise) condition_list.push(otherwise); + return { + type: 'case', + expr: expr || null, + args: condition_list, }; - var peg$f47 = function() { return 'insert'; }; - var peg$f48 = function() { return 'replace'; }; - var peg$f49 = function(l) { return l; }; - var peg$f50 = function(head, tail) { - return createList(head, tail); - }; - var peg$f51 = function(l) { - return l; - }; - var peg$f52 = function(head, tail) { - const el = { type: 'expr_list' }; - el.value = createList(head, tail); - return el; - }; - var peg$f53 = function(n, u) { - return { - type: 'interval', - value: [n, u] - } - }; - var peg$f54 = function(expr, condition_list, otherwise) { - if (otherwise) condition_list.push(otherwise); - return { - type: 'case', - expr: expr || null, - args: condition_list - }; - }; - var peg$f55 = function(condition, result) { + }; + var peg$f55 = function (condition, result) { return { type: 'when', cond: condition, - result: result + result: result, }; }; - var peg$f56 = function(result) { + var peg$f56 = function (result) { return { type: 'else', result: result }; }; - var peg$f57 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f58 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f59 = function(expr) { - return createUnaryExpr('NOT', expr); - }; - var peg$f60 = function(left, rh) { - if (rh === null) return left; - else if (rh.type === 'arithmetic') return createBinaryExprChain(left, rh.tail); - else return createBinaryExpr(rh.op, left, rh.right); - }; - var peg$f61 = function(op, stmt) { + var peg$f57 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f58 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f59 = function (expr) { + return createUnaryExpr('NOT', expr); + }; + var peg$f60 = function (left, rh) { + if (rh === null) return left; + else if (rh.type === 'arithmetic') return createBinaryExprChain(left, rh.tail); + else return createBinaryExpr(rh.op, left, rh.right); + }; + var peg$f61 = function (op, stmt) { stmt.parentheses = true; return createUnaryExpr(op, stmt); }; - var peg$f62 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f63 = function(l) { - return { type: 'arithmetic', tail: l }; - }; - var peg$f64 = function(right) { - return { op: 'IS', right: right }; - }; - var peg$f65 = function(right) { - return { op: 'IS NOT', right: right }; + var peg$f62 = function (nk) { + return nk[0] + ' ' + nk[2]; }; - var peg$f66 = function(op, begin, end) { - return { - op: op, - right: { - type: 'expr_list', - value: [begin, end] - } - }; - }; - var peg$f67 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f68 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f69 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f70 = function(op, right) { - return { op: op, right: right }; - }; - var peg$f71 = function(op, l) { - return { op: op, right: l }; - }; - var peg$f72 = function(op, e) { - return { op: op, right: e }; - }; - var peg$f73 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f74 = function(head, tail) { - return createBinaryExprChain(head, tail) - }; - var peg$f75 = function(e) { - e.parentheses = true; - return e; - }; - var peg$f76 = function(list) { - list.parentheses = true; - return list; - }; - var peg$f77 = function(tbl, col) { - columnList.add(`select::${tbl}::${col}`); - return { - type: 'column_ref', - table: tbl, - column: col - }; - }; - var peg$f78 = function(col) { - columnList.add(`select::null::${col}`); - return { - type: 'column_ref', - table: null, - column: col - }; - }; - var peg$f79 = function(head, tail) { - return createList(head, tail); - }; - var peg$f80 = function(name) { return reservedMap[name.toUpperCase()] === true; }; - var peg$f81 = function(name) { - return name; - }; - var peg$f82 = function(name) { - return name; - }; - var peg$f83 = function(name) { - if (reservedMap[name.toUpperCase()] === true) throw new Error("Error: "+ JSON.stringify(name)+" is a reserved word, can not as alias clause"); - return false - }; - var peg$f84 = function(name) { - return name; - }; - var peg$f85 = function(name) { - return name; - }; - var peg$f86 = function(chars) { return chars.join(''); }; - var peg$f87 = function(chars) { return chars.join(''); }; - var peg$f88 = function(chars) { return chars.join(''); }; - var peg$f89 = function(name) { return reservedMap[name.toUpperCase()] === true; }; - var peg$f90 = function(name) { return name; }; - var peg$f91 = function(start, parts) { return start + parts.join(''); }; - var peg$f92 = function(start, parts) { return start + parts.join(''); }; - var peg$f93 = function(l) { - return { type: 'param', value: l[1] }; - }; - var peg$f94 = function(name, e) { - return { - type: 'aggr_func', - name: name, - args: { - expr: e - } - }; - }; - var peg$f95 = function(name, arg) { - return { - type: 'aggr_func', - name: name, - args: arg - }; - }; - var peg$f96 = function(e) { return { expr: e }; }; - var peg$f97 = function(d, c) { return { distinct: d, expr: c }; }; - var peg$f98 = function() { return { type: 'star', value: '*' }; }; - var peg$f99 = function(name, l) { - return { - type: 'function', - name: name, - args: l ? l: { type: 'expr_list', value: [] } - }; - }; - var peg$f100 = function(name) { - return { - type: 'function', - name: name, - args: { type: 'expr_list', value: [] } - }; - }; - var peg$f101 = function(e, t) { + var peg$f63 = function (l) { + return { type: 'arithmetic', tail: l }; + }; + var peg$f64 = function (right) { + return { op: 'IS', right: right }; + }; + var peg$f65 = function (right) { + return { op: 'IS NOT', right: right }; + }; + var peg$f66 = function (op, begin, end) { return { - type: 'cast', - expr: e, - target: t + op: op, + right: { + type: 'expr_list', + value: [begin, end], + }, }; }; - var peg$f102 = function(e, precision) { + var peg$f67 = function (nk) { + return nk[0] + ' ' + nk[2]; + }; + var peg$f68 = function (nk) { + return nk[0] + ' ' + nk[2]; + }; + var peg$f69 = function (nk) { + return nk[0] + ' ' + nk[2]; + }; + var peg$f70 = function (op, right) { + return { op: op, right: right }; + }; + var peg$f71 = function (op, l) { + return { op: op, right: l }; + }; + var peg$f72 = function (op, e) { + return { op: op, right: e }; + }; + var peg$f73 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f74 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f75 = function (e) { + e.parentheses = true; + return e; + }; + var peg$f76 = function (list) { + list.parentheses = true; + return list; + }; + var peg$f77 = function (tbl, col) { + columnList.add(`select::${tbl}::${col}`); return { - type: 'cast', - expr: e, - target: { - dataType: 'DECIMAL(' + precision + ')' - } + type: 'column_ref', + table: tbl, + column: col, }; }; - var peg$f103 = function(e, precision, scale) { - return { - type: 'cast', + var peg$f78 = function (col) { + columnList.add(`select::null::${col}`); + return { + type: 'column_ref', + table: null, + column: col, + }; + }; + var peg$f79 = function (head, tail) { + return createList(head, tail); + }; + var peg$f80 = function (name) { + return reservedMap[name.toUpperCase()] === true; + }; + var peg$f81 = function (name) { + return name; + }; + var peg$f82 = function (name) { + return name; + }; + var peg$f83 = function (name) { + if (reservedMap[name.toUpperCase()] === true) + throw new Error('Error: ' + JSON.stringify(name) + ' is a reserved word, can not as alias clause'); + return false; + }; + var peg$f84 = function (name) { + return name; + }; + var peg$f85 = function (name) { + return name; + }; + var peg$f86 = function (chars) { + return chars.join(''); + }; + var peg$f87 = function (chars) { + return chars.join(''); + }; + var peg$f88 = function (chars) { + return chars.join(''); + }; + var peg$f89 = function (name) { + return reservedMap[name.toUpperCase()] === true; + }; + var peg$f90 = function (name) { + return name; + }; + var peg$f91 = function (start, parts) { + return start + parts.join(''); + }; + var peg$f92 = function (start, parts) { + return start + parts.join(''); + }; + var peg$f93 = function (l) { + return { type: 'param', value: l[1] }; + }; + var peg$f94 = function (name, e) { + return { + type: 'aggr_func', + name: name, + args: { expr: e, - target: { - dataType: 'DECIMAL(' + precision + ', ' + scale + ')' - } - }; + }, }; - var peg$f104 = function(e, s, t) { /* MySQL cast to un-/signed integer */ + }; + var peg$f95 = function (name, arg) { + return { + type: 'aggr_func', + name: name, + args: arg, + }; + }; + var peg$f96 = function (e) { + return { expr: e }; + }; + var peg$f97 = function (d, c) { + return { distinct: d, expr: c }; + }; + var peg$f98 = function () { + return { type: 'star', value: '*' }; + }; + var peg$f99 = function (name, l) { + return { + type: 'function', + name: name, + args: l ? l : { type: 'expr_list', value: [] }, + }; + }; + var peg$f100 = function (name) { + return { + type: 'function', + name: name, + args: { type: 'expr_list', value: [] }, + }; + }; + var peg$f101 = function (e, t) { + return { + type: 'cast', + expr: e, + target: t, + }; + }; + var peg$f102 = function (e, precision) { return { type: 'cast', expr: e, target: { - dataType: s + (t ? ' ' + t: '') - } + dataType: 'DECIMAL(' + precision + ')', + }, }; }; - var peg$f105 = function(head, tail) { - return createList(head, tail); + var peg$f103 = function (e, precision, scale) { + return { + type: 'cast', + expr: e, + target: { + dataType: 'DECIMAL(' + precision + ', ' + scale + ')', + }, }; - var peg$f106 = function() { - return { type: 'null', value: null }; + }; + var peg$f104 = function (e, s, t) { + /* MySQL cast to un-/signed integer */ + return { + type: 'cast', + expr: e, + target: { + dataType: s + (t ? ' ' + t : ''), + }, }; - var peg$f107 = function() { - return { type: 'bool', value: true }; + }; + var peg$f105 = function (head, tail) { + return createList(head, tail); + }; + var peg$f106 = function () { + return { type: 'null', value: null }; + }; + var peg$f107 = function () { + return { type: 'bool', value: true }; + }; + var peg$f108 = function () { + return { type: 'bool', value: false }; + }; + var peg$f109 = function (ca) { + return { + type: 'string', + value: ca[1].join(''), }; - var peg$f108 = function() { - return { type: 'bool', value: false }; + }; + var peg$f110 = function (ca) { + return { + type: 'string', + value: ca[1].join(''), }; - var peg$f109 = function(ca) { - return { - type: 'string', - value: ca[1].join('') - }; + }; + var peg$f111 = function (type, ca) { + return { + type: type.toLowerCase(), + value: ca[1].join(''), }; - var peg$f110 = function(ca) { - return { - type: 'string', - value: ca[1].join('') - }; - }; - var peg$f111 = function(type, ca) { - return { - type: type.toLowerCase(), - value: ca[1].join('') - }; - }; - var peg$f112 = function() { return "'"; }; - var peg$f113 = function() { return '"'; }; - var peg$f114 = function() { return "\\"; }; - var peg$f115 = function() { return "/"; }; - var peg$f116 = function() { return "\b"; }; - var peg$f117 = function() { return "\f"; }; - var peg$f118 = function() { return "\n"; }; - var peg$f119 = function() { return "\r"; }; - var peg$f120 = function() { return "\t"; }; - var peg$f121 = function(h1, h2, h3, h4) { - return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - }; - var peg$f122 = function(n) { - return { type: 'number', value: n }; - }; - var peg$f123 = function(int_, frac, exp) { return parseFloat(int_ + frac + exp); }; - var peg$f124 = function(int_, frac) { return parseFloat(int_ + frac); }; - var peg$f125 = function(int_, exp) { return parseFloat(int_ + exp); }; - var peg$f126 = function(int_) { return parseFloat(int_); }; - var peg$f127 = function(digit19, digits) { return digit19 + digits; }; - var peg$f128 = function(op, digit19, digits) { return "-" + digit19 + digits; }; - var peg$f129 = function(op, digit) { return "-" + digit; }; - var peg$f130 = function(digits) { return "." + digits; }; - var peg$f131 = function(e, digits) { return e + digits; }; - var peg$f132 = function(digits) { return digits.join(""); }; - var peg$f133 = function(e, sign) { return e + (sign !== null ? sign: ''); }; - var peg$f134 = function() { return 'ASC'; }; - var peg$f135 = function() { return 'DESC'; }; - var peg$f136 = function() { return 'ALL'; }; - var peg$f137 = function() { return 'DISTINCT';}; - var peg$f138 = function() { return 'BETWEEN'; }; - var peg$f139 = function() { return 'IN'; }; - var peg$f140 = function() { return 'IS'; }; - var peg$f141 = function() { return 'LIKE'; }; - var peg$f142 = function() { return 'EXISTS'; }; - var peg$f143 = function() { return 'NOT'; }; - var peg$f144 = function() { return 'AND'; }; - var peg$f145 = function() { return 'OR'; }; - var peg$f146 = function() { return 'COUNT'; }; - var peg$f147 = function() { return 'MAX'; }; - var peg$f148 = function() { return 'MIN'; }; - var peg$f149 = function() { return 'SUM'; }; - var peg$f150 = function() { return 'AVG'; }; - var peg$f151 = function() { return 'CHAR'; }; - var peg$f152 = function() { return 'VARCHAR';}; - var peg$f153 = function() { return 'NUMERIC'; }; - var peg$f154 = function() { return 'DECIMAL'; }; - var peg$f155 = function() { return 'SIGNED'; }; - var peg$f156 = function() { return 'UNSIGNED'; }; - var peg$f157 = function() { return 'INT'; }; - var peg$f158 = function() { return 'INTEGER'; }; - var peg$f159 = function() { return 'JSON'; }; - var peg$f160 = function() { return 'SMALLINT'; }; - var peg$f161 = function() { return 'DATE'; }; - var peg$f162 = function() { return 'TIME'; }; - var peg$f163 = function() { return 'TIMESTAMP'; }; - var peg$f164 = function() { return 'USER'; }; - var peg$f165 = function() { return 'CURRENT_DATE'; }; - var peg$f166 = function() { return 'ADDDATE'; }; - var peg$f167 = function() { return 'INTERVAL'; }; - var peg$f168 = function() { return 'YEAR'; }; - var peg$f169 = function() { return 'MONTH'; }; - var peg$f170 = function() { return 'DAY'; }; - var peg$f171 = function() { return 'HOUR'; }; - var peg$f172 = function() { return 'MINUTE'; }; - var peg$f173 = function() { return 'SECOND'; }; - var peg$f174 = function() { return 'CURRENT_TIME'; }; - var peg$f175 = function() { return 'CURRENT_TIMESTAMP'; }; - var peg$f176 = function() { return 'CURRENT_USER'; }; - var peg$f177 = function() { return 'SESSION_USER'; }; - var peg$f178 = function() { return 'SYSTEM_USER'; }; - var peg$f179 = function() { varList = []; return true; }; - var peg$f180 = function(s) { - return { stmt: s, vars: varList }; - }; - var peg$f181 = function(va, e) { + }; + var peg$f112 = function () { + return "'"; + }; + var peg$f113 = function () { + return '"'; + }; + var peg$f114 = function () { + return '\\'; + }; + var peg$f115 = function () { + return '/'; + }; + var peg$f116 = function () { + return '\b'; + }; + var peg$f117 = function () { + return '\f'; + }; + var peg$f118 = function () { + return '\n'; + }; + var peg$f119 = function () { + return '\r'; + }; + var peg$f120 = function () { + return '\t'; + }; + var peg$f121 = function (h1, h2, h3, h4) { + return String.fromCharCode(parseInt('0x' + h1 + h2 + h3 + h4)); + }; + var peg$f122 = function (n) { + return { type: 'number', value: n }; + }; + var peg$f123 = function (int_, frac, exp) { + return parseFloat(int_ + frac + exp); + }; + var peg$f124 = function (int_, frac) { + return parseFloat(int_ + frac); + }; + var peg$f125 = function (int_, exp) { + return parseFloat(int_ + exp); + }; + var peg$f126 = function (int_) { + return parseFloat(int_); + }; + var peg$f127 = function (digit19, digits) { + return digit19 + digits; + }; + var peg$f128 = function (op, digit19, digits) { + return '-' + digit19 + digits; + }; + var peg$f129 = function (op, digit) { + return '-' + digit; + }; + var peg$f130 = function (digits) { + return '.' + digits; + }; + var peg$f131 = function (e, digits) { + return e + digits; + }; + var peg$f132 = function (digits) { + return digits.join(''); + }; + var peg$f133 = function (e, sign) { + return e + (sign !== null ? sign : ''); + }; + var peg$f134 = function () { + return 'ASC'; + }; + var peg$f135 = function () { + return 'DESC'; + }; + var peg$f136 = function () { + return 'ALL'; + }; + var peg$f137 = function () { + return 'DISTINCT'; + }; + var peg$f138 = function () { + return 'BETWEEN'; + }; + var peg$f139 = function () { + return 'IN'; + }; + var peg$f140 = function () { + return 'IS'; + }; + var peg$f141 = function () { + return 'LIKE'; + }; + var peg$f142 = function () { + return 'EXISTS'; + }; + var peg$f143 = function () { + return 'NOT'; + }; + var peg$f144 = function () { + return 'AND'; + }; + var peg$f145 = function () { + return 'OR'; + }; + var peg$f146 = function () { + return 'COUNT'; + }; + var peg$f147 = function () { + return 'MAX'; + }; + var peg$f148 = function () { + return 'MIN'; + }; + var peg$f149 = function () { + return 'SUM'; + }; + var peg$f150 = function () { + return 'AVG'; + }; + var peg$f151 = function () { + return 'CHAR'; + }; + var peg$f152 = function () { + return 'VARCHAR'; + }; + var peg$f153 = function () { + return 'NUMERIC'; + }; + var peg$f154 = function () { + return 'DECIMAL'; + }; + var peg$f155 = function () { + return 'SIGNED'; + }; + var peg$f156 = function () { + return 'UNSIGNED'; + }; + var peg$f157 = function () { + return 'INT'; + }; + var peg$f158 = function () { + return 'INTEGER'; + }; + var peg$f159 = function () { + return 'JSON'; + }; + var peg$f160 = function () { + return 'SMALLINT'; + }; + var peg$f161 = function () { + return 'DATE'; + }; + var peg$f162 = function () { + return 'TIME'; + }; + var peg$f163 = function () { + return 'TIMESTAMP'; + }; + var peg$f164 = function () { + return 'USER'; + }; + var peg$f165 = function () { + return 'CURRENT_DATE'; + }; + var peg$f166 = function () { + return 'ADDDATE'; + }; + var peg$f167 = function () { + return 'INTERVAL'; + }; + var peg$f168 = function () { + return 'YEAR'; + }; + var peg$f169 = function () { + return 'MONTH'; + }; + var peg$f170 = function () { + return 'DAY'; + }; + var peg$f171 = function () { + return 'HOUR'; + }; + var peg$f172 = function () { + return 'MINUTE'; + }; + var peg$f173 = function () { + return 'SECOND'; + }; + var peg$f174 = function () { + return 'CURRENT_TIME'; + }; + var peg$f175 = function () { + return 'CURRENT_TIMESTAMP'; + }; + var peg$f176 = function () { + return 'CURRENT_USER'; + }; + var peg$f177 = function () { + return 'SESSION_USER'; + }; + var peg$f178 = function () { + return 'SYSTEM_USER'; + }; + var peg$f179 = function () { + varList = []; + return true; + }; + var peg$f180 = function (s) { + return { stmt: s, vars: varList }; + }; + var peg$f181 = function (va, e) { return { type: 'assign', left: va, - right: e + right: e, }; }; - var peg$f182 = function(e) { - return { type: 'return', expr: e }; + var peg$f182 = function (e) { + return { type: 'return', expr: e }; + }; + var peg$f183 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f184 = function (head, tail) { + return createBinaryExprChain(head, tail); + }; + var peg$f185 = function (lt, op, rt, expr) { + return { + type: 'join', + ltable: lt, + rtable: rt, + op: op, + on: expr, }; - var peg$f183 = function(head, tail) { - return createBinaryExprChain(head, tail); + }; + var peg$f186 = function (e) { + e.parentheses = true; + return e; + }; + var peg$f187 = function (name, l) { + //compatible with original func_call + return { + type: 'function', + name: name, + args: { + type: 'expr_list', + value: l, + }, }; - var peg$f184 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f185 = function(lt, op, rt, expr) { - return { - type: 'join', - ltable: lt, - rtable: rt, - op: op, - on: expr - }; - }; - var peg$f186 = function(e) { - e.parentheses = true; - return e; - }; - var peg$f187 = function(name, l) { - //compatible with original func_call - return { - type: 'function', - name: name, - args: { - type: 'expr_list', - value: l - } - }; - }; - var peg$f188 = function(head, tail) { - return createList(head, tail); - }; - var peg$f189 = function(l) { + }; + var peg$f188 = function (head, tail) { + return createList(head, tail); + }; + var peg$f189 = function (l) { return { type: 'array', value: l }; }; - var peg$f190 = function(name, m) { + var peg$f190 = function (name, m) { //push for analysis varList.push(name); return { type: 'var', name: name, - members: m + members: m, }; }; - var peg$f191 = function(l) { + var peg$f191 = function (l) { const s = []; for (let i = 0; i < l.length; i++) { s.push(l[i][1]); } return s; }; - var peg$f192 = function(t, l) { + var peg$f192 = function (t, l) { return { dataType: t, length: parseInt(l.join(''), 10) }; }; - var peg$f193 = function(t) { return { dataType: t }; }; - var peg$f194 = function(t) { return { dataType: t }; }; - var peg$f195 = function(t) { return { dataType: t }; }; - var peg$f196 = function(t) { return { dataType: t }; }; - var peg$f197 = function(t) { return { dataType: t }; }; + var peg$f193 = function (t) { + return { dataType: t }; + }; + var peg$f194 = function (t) { + return { dataType: t }; + }; + var peg$f195 = function (t) { + return { dataType: t }; + }; + var peg$f196 = function (t) { + return { dataType: t }; + }; + var peg$f197 = function (t) { + return { dataType: t }; + }; var peg$currPos = 0; var peg$savedPos = 0; var peg$posDetailsCache = [{ line: 1, column: 1 }]; @@ -1117,9 +1353,9 @@ function peg$parse(input, options) { var peg$result; - if ("startRule" in options) { + if ('startRule' in options) { if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + throw new Error('Can\'t start parsing from rule "' + options.startRule + '".'); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; @@ -1137,7 +1373,7 @@ function peg$parse(input, options) { return { source: peg$source, start: peg$savedPos, - end: peg$currPos + end: peg$currPos, }; } @@ -1146,43 +1382,39 @@ function peg$parse(input, options) { } function expected(description, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); + location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), - location + location, ); } function error(message, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); + location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; + return { type: 'literal', text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { - return { type: "any" }; + return { type: 'any' }; } function peg$endExpectation() { - return { type: "end" }; + return { type: 'end' }; } function peg$otherExpectation(description) { - return { type: "other", description: description }; + return { type: 'other', description: description }; } function peg$computePosDetails(pos) { @@ -1200,7 +1432,7 @@ function peg$parse(input, options) { details = peg$posDetailsCache[p]; details = { line: details.line, - column: details.column + column: details.column, }; while (p < pos) { @@ -1229,15 +1461,15 @@ function peg$parse(input, options) { start: { offset: startPos, line: startPosDetails.line, - column: startPosDetails.column + column: startPosDetails.column, }, end: { offset: endPos, line: endPosDetails.line, - column: endPosDetails.column - } + column: endPosDetails.column, + }, }; - if (offset && peg$source && (typeof peg$source.offset === "function")) { + if (offset && peg$source && typeof peg$source.offset === 'function') { res.start = peg$source.offset(res.start); res.end = peg$source.offset(res.end); } @@ -1245,7 +1477,9 @@ function peg$parse(input, options) { } function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } + if (peg$currPos < peg$maxFailPos) { + return; + } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; @@ -1260,12 +1494,7 @@ function peg$parse(input, options) { } function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError( - peg$SyntaxError.buildMessage(expected, found), - expected, - found, - location - ); + return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); } function peg$parsestart() { @@ -1431,7 +1660,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } + if (peg$silentFails === 0) { + peg$fail(peg$e0); + } } if (s2 !== peg$FAILED) { s3 = peg$parse__(); @@ -1443,7 +1674,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } + if (peg$silentFails === 0) { + peg$fail(peg$e1); + } } if (s6 !== peg$FAILED) { s2 = [s2, s3, s4, s5, s6]; @@ -2902,7 +3135,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } + if (peg$silentFails === 0) { + peg$fail(peg$e2); + } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); @@ -3485,7 +3720,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e3); } + if (peg$silentFails === 0) { + peg$fail(peg$e3); + } } if (s2 !== peg$FAILED) { s3 = peg$currPos; @@ -3495,7 +3732,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } + if (peg$silentFails === 0) { + peg$fail(peg$e2); + } } peg$silentFails--; if (s4 === peg$FAILED) { @@ -3709,7 +3948,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e4); } + if (peg$silentFails === 0) { + peg$fail(peg$e4); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 62) { @@ -3717,7 +3958,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } + if (peg$silentFails === 0) { + peg$fail(peg$e5); + } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c6) { @@ -3725,7 +3968,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e6); } + if (peg$silentFails === 0) { + peg$fail(peg$e6); + } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c7) { @@ -3733,7 +3978,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } + if (peg$silentFails === 0) { + peg$fail(peg$e7); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 60) { @@ -3741,7 +3988,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } + if (peg$silentFails === 0) { + peg$fail(peg$e8); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 61) { @@ -3749,7 +3998,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } + if (peg$silentFails === 0) { + peg$fail(peg$e2); + } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c9) { @@ -3757,7 +4008,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } + if (peg$silentFails === 0) { + peg$fail(peg$e9); + } } } } @@ -4098,7 +4351,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } + if (peg$silentFails === 0) { + peg$fail(peg$e10); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { @@ -4106,7 +4361,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } + if (peg$silentFails === 0) { + peg$fail(peg$e11); + } } } @@ -4175,7 +4432,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } + if (peg$silentFails === 0) { + peg$fail(peg$e12); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { @@ -4183,7 +4442,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e13); } + if (peg$silentFails === 0) { + peg$fail(peg$e13); + } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 37) { @@ -4191,7 +4452,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e14); } + if (peg$silentFails === 0) { + peg$fail(peg$e14); + } } } } @@ -4471,7 +4734,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } + if (peg$silentFails === 0) { + peg$fail(peg$e15); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -4480,7 +4745,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } + if (peg$silentFails === 0) { + peg$fail(peg$e16); + } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { @@ -4490,7 +4757,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } + if (peg$silentFails === 0) { + peg$fail(peg$e16); + } } } } else { @@ -4502,7 +4771,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } + if (peg$silentFails === 0) { + peg$fail(peg$e15); + } } if (s3 !== peg$FAILED) { peg$savedPos = s0; @@ -4532,7 +4803,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -4541,7 +4814,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } + if (peg$silentFails === 0) { + peg$fail(peg$e18); + } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { @@ -4551,7 +4826,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } + if (peg$silentFails === 0) { + peg$fail(peg$e18); + } } } } else { @@ -4563,7 +4840,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s3 !== peg$FAILED) { peg$savedPos = s0; @@ -4593,7 +4872,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } + if (peg$silentFails === 0) { + peg$fail(peg$e19); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -4602,7 +4883,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } + if (peg$silentFails === 0) { + peg$fail(peg$e20); + } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { @@ -4612,7 +4895,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } + if (peg$silentFails === 0) { + peg$fail(peg$e20); + } } } } else { @@ -4624,7 +4909,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } + if (peg$silentFails === 0) { + peg$fail(peg$e19); + } } if (s3 !== peg$FAILED) { peg$savedPos = s0; @@ -4728,7 +5015,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } + if (peg$silentFails === 0) { + peg$fail(peg$e21); + } } return s0; @@ -4742,7 +5031,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e22); } + if (peg$silentFails === 0) { + peg$fail(peg$e22); + } } return s0; @@ -4756,7 +5047,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e23); } + if (peg$silentFails === 0) { + peg$fail(peg$e23); + } } return s0; @@ -4772,7 +5065,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } + if (peg$silentFails === 0) { + peg$fail(peg$e24); + } } if (s2 !== peg$FAILED) { s3 = peg$parseident_name(); @@ -4937,7 +5232,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } + if (peg$silentFails === 0) { + peg$fail(peg$e12); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5422,7 +5719,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s2 !== peg$FAILED) { s3 = []; @@ -5436,7 +5735,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s4 !== peg$FAILED) { s2 = [s2, s3, s4]; @@ -5462,7 +5763,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } + if (peg$silentFails === 0) { + peg$fail(peg$e15); + } } if (s2 !== peg$FAILED) { s3 = []; @@ -5476,7 +5779,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } + if (peg$silentFails === 0) { + peg$fail(peg$e15); + } } if (s4 !== peg$FAILED) { s2 = [s2, s3, s4]; @@ -5518,7 +5823,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s4 !== peg$FAILED) { s5 = []; @@ -5532,7 +5839,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } + if (peg$silentFails === 0) { + peg$fail(peg$e17); + } } if (s6 !== peg$FAILED) { s4 = [s4, s5, s6]; @@ -5568,7 +5877,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e25); } + if (peg$silentFails === 0) { + peg$fail(peg$e25); + } } if (s0 === peg$FAILED) { s0 = peg$parseescape_char(); @@ -5585,7 +5896,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e26); } + if (peg$silentFails === 0) { + peg$fail(peg$e26); + } } if (s0 === peg$FAILED) { s0 = peg$parseescape_char(); @@ -5603,7 +5916,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e27); } + if (peg$silentFails === 0) { + peg$fail(peg$e27); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5617,7 +5932,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } + if (peg$silentFails === 0) { + peg$fail(peg$e28); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5631,7 +5948,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e29); } + if (peg$silentFails === 0) { + peg$fail(peg$e29); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5645,7 +5964,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } + if (peg$silentFails === 0) { + peg$fail(peg$e30); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5659,7 +5980,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } + if (peg$silentFails === 0) { + peg$fail(peg$e31); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5673,7 +5996,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } + if (peg$silentFails === 0) { + peg$fail(peg$e32); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5687,7 +6012,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e33); } + if (peg$silentFails === 0) { + peg$fail(peg$e33); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5701,7 +6028,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e34); } + if (peg$silentFails === 0) { + peg$fail(peg$e34); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5715,7 +6044,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e35); } + if (peg$silentFails === 0) { + peg$fail(peg$e35); + } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -5729,7 +6060,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e36); } + if (peg$silentFails === 0) { + peg$fail(peg$e36); + } } if (s1 !== peg$FAILED) { s2 = peg$parsehexDigit(); @@ -5783,7 +6116,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } + if (peg$silentFails === 0) { + peg$fail(peg$e37); + } } return s0; @@ -5907,7 +6242,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } + if (peg$silentFails === 0) { + peg$fail(peg$e11); + } } if (s1 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 43) { @@ -5915,7 +6252,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } + if (peg$silentFails === 0) { + peg$fail(peg$e10); + } } } if (s1 !== peg$FAILED) { @@ -5944,7 +6283,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } + if (peg$silentFails === 0) { + peg$fail(peg$e11); + } } if (s1 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 43) { @@ -5952,7 +6293,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } + if (peg$silentFails === 0) { + peg$fail(peg$e10); + } } } if (s1 !== peg$FAILED) { @@ -5984,7 +6327,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } + if (peg$silentFails === 0) { + peg$fail(peg$e38); + } } if (s1 !== peg$FAILED) { s2 = peg$parsedigits(); @@ -6056,7 +6401,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } + if (peg$silentFails === 0) { + peg$fail(peg$e39); + } } return s0; @@ -6070,7 +6417,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e40); } + if (peg$silentFails === 0) { + peg$fail(peg$e40); + } } return s0; @@ -6084,7 +6433,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e41); } + if (peg$silentFails === 0) { + peg$fail(peg$e41); + } } return s0; @@ -6099,7 +6450,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e42); } + if (peg$silentFails === 0) { + peg$fail(peg$e42); + } } if (s1 !== peg$FAILED) { if (peg$r13.test(input.charAt(peg$currPos))) { @@ -6107,7 +6460,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e43); } + if (peg$silentFails === 0) { + peg$fail(peg$e43); + } } if (s2 === peg$FAILED) { s2 = null; @@ -6131,7 +6486,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } + if (peg$silentFails === 0) { + peg$fail(peg$e44); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6168,7 +6525,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e45); } + if (peg$silentFails === 0) { + peg$fail(peg$e45); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6205,7 +6564,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } + if (peg$silentFails === 0) { + peg$fail(peg$e46); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6242,7 +6603,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } + if (peg$silentFails === 0) { + peg$fail(peg$e47); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6279,7 +6642,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } + if (peg$silentFails === 0) { + peg$fail(peg$e48); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6316,7 +6681,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } + if (peg$silentFails === 0) { + peg$fail(peg$e49); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6353,7 +6720,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } + if (peg$silentFails === 0) { + peg$fail(peg$e50); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6390,7 +6759,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } + if (peg$silentFails === 0) { + peg$fail(peg$e51); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6427,7 +6798,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { + peg$fail(peg$e52); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6464,7 +6837,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } + if (peg$silentFails === 0) { + peg$fail(peg$e53); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6501,7 +6876,9 @@ function peg$parse(input, options) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { + peg$fail(peg$e54); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6538,7 +6915,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } + if (peg$silentFails === 0) { + peg$fail(peg$e55); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6575,7 +6954,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } + if (peg$silentFails === 0) { + peg$fail(peg$e56); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6612,7 +6993,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } + if (peg$silentFails === 0) { + peg$fail(peg$e57); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6649,7 +7032,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } + if (peg$silentFails === 0) { + peg$fail(peg$e58); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6686,7 +7071,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } + if (peg$silentFails === 0) { + peg$fail(peg$e59); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6723,7 +7110,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } + if (peg$silentFails === 0) { + peg$fail(peg$e60); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6760,7 +7149,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } + if (peg$silentFails === 0) { + peg$fail(peg$e61); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6797,7 +7188,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } + if (peg$silentFails === 0) { + peg$fail(peg$e62); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6834,7 +7227,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } + if (peg$silentFails === 0) { + peg$fail(peg$e63); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6871,7 +7266,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } + if (peg$silentFails === 0) { + peg$fail(peg$e64); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6908,7 +7305,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } + if (peg$silentFails === 0) { + peg$fail(peg$e65); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6945,7 +7344,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } + if (peg$silentFails === 0) { + peg$fail(peg$e66); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6982,7 +7383,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } + if (peg$silentFails === 0) { + peg$fail(peg$e67); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7019,7 +7422,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e68); } + if (peg$silentFails === 0) { + peg$fail(peg$e68); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7056,7 +7461,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e69); } + if (peg$silentFails === 0) { + peg$fail(peg$e69); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7093,7 +7500,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e70); } + if (peg$silentFails === 0) { + peg$fail(peg$e70); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7130,7 +7539,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e71); } + if (peg$silentFails === 0) { + peg$fail(peg$e71); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7167,7 +7578,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e72); } + if (peg$silentFails === 0) { + peg$fail(peg$e72); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7204,7 +7617,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e73); } + if (peg$silentFails === 0) { + peg$fail(peg$e73); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7241,7 +7656,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e74); } + if (peg$silentFails === 0) { + peg$fail(peg$e74); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7278,7 +7695,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e75); } + if (peg$silentFails === 0) { + peg$fail(peg$e75); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7315,7 +7734,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e76); } + if (peg$silentFails === 0) { + peg$fail(peg$e76); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7352,7 +7773,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e77); } + if (peg$silentFails === 0) { + peg$fail(peg$e77); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7389,7 +7812,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e78); } + if (peg$silentFails === 0) { + peg$fail(peg$e78); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7426,7 +7851,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e79); } + if (peg$silentFails === 0) { + peg$fail(peg$e79); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7463,7 +7890,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e80); } + if (peg$silentFails === 0) { + peg$fail(peg$e80); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7500,7 +7929,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e81); } + if (peg$silentFails === 0) { + peg$fail(peg$e81); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7537,7 +7968,9 @@ function peg$parse(input, options) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e82); } + if (peg$silentFails === 0) { + peg$fail(peg$e82); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7574,7 +8007,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e83); } + if (peg$silentFails === 0) { + peg$fail(peg$e83); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7611,7 +8046,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e84); } + if (peg$silentFails === 0) { + peg$fail(peg$e84); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7648,7 +8085,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e85); } + if (peg$silentFails === 0) { + peg$fail(peg$e85); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7685,7 +8124,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e86); } + if (peg$silentFails === 0) { + peg$fail(peg$e86); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7722,7 +8163,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e87); } + if (peg$silentFails === 0) { + peg$fail(peg$e87); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7759,7 +8202,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e88); } + if (peg$silentFails === 0) { + peg$fail(peg$e88); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7796,7 +8241,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e89); } + if (peg$silentFails === 0) { + peg$fail(peg$e89); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7833,7 +8280,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e90); } + if (peg$silentFails === 0) { + peg$fail(peg$e90); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7870,7 +8319,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } + if (peg$silentFails === 0) { + peg$fail(peg$e91); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7907,7 +8358,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { + peg$fail(peg$e92); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7944,7 +8397,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { + peg$fail(peg$e93); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -7981,7 +8436,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { + peg$fail(peg$e94); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8018,7 +8475,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { + peg$fail(peg$e95); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8055,7 +8514,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { + peg$fail(peg$e96); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8092,7 +8553,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { + peg$fail(peg$e97); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8129,7 +8592,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { + peg$fail(peg$e98); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8166,7 +8631,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { + peg$fail(peg$e99); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8203,7 +8670,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { + peg$fail(peg$e100); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8240,7 +8709,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { + peg$fail(peg$e101); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8277,7 +8748,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { + peg$fail(peg$e102); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8314,7 +8787,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { + peg$fail(peg$e103); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8351,7 +8826,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { + peg$fail(peg$e104); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8388,7 +8865,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { + peg$fail(peg$e105); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8425,7 +8904,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { + peg$fail(peg$e106); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8462,7 +8943,9 @@ function peg$parse(input, options) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { + peg$fail(peg$e107); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8499,7 +8982,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { + peg$fail(peg$e108); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8536,7 +9021,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { + peg$fail(peg$e109); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8573,7 +9060,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { + peg$fail(peg$e110); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8610,7 +9099,9 @@ function peg$parse(input, options) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { + peg$fail(peg$e111); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8647,7 +9138,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { + peg$fail(peg$e112); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8684,7 +9177,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { + peg$fail(peg$e113); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8721,7 +9216,9 @@ function peg$parse(input, options) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { + peg$fail(peg$e114); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8758,7 +9255,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { + peg$fail(peg$e115); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8795,7 +9294,9 @@ function peg$parse(input, options) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { + peg$fail(peg$e116); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8832,7 +9333,9 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { + peg$fail(peg$e117); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8869,7 +9372,9 @@ function peg$parse(input, options) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e118); } + if (peg$silentFails === 0) { + peg$fail(peg$e118); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8906,7 +9411,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { + peg$fail(peg$e119); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8943,7 +9450,9 @@ function peg$parse(input, options) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e120); } + if (peg$silentFails === 0) { + peg$fail(peg$e120); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -8980,7 +9489,9 @@ function peg$parse(input, options) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { + peg$fail(peg$e121); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9017,7 +9528,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { + peg$fail(peg$e122); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9054,7 +9567,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { + peg$fail(peg$e123); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9091,7 +9606,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { + peg$fail(peg$e124); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9128,7 +9645,9 @@ function peg$parse(input, options) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { + peg$fail(peg$e125); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9165,7 +9684,9 @@ function peg$parse(input, options) { peg$currPos += 17; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { + peg$fail(peg$e126); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9202,7 +9723,9 @@ function peg$parse(input, options) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { + peg$fail(peg$e127); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9239,7 +9762,9 @@ function peg$parse(input, options) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { + peg$fail(peg$e128); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9276,7 +9801,9 @@ function peg$parse(input, options) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { + peg$fail(peg$e129); + } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -9312,7 +9839,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { + peg$fail(peg$e130); + } } return s0; @@ -9326,7 +9855,9 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { + peg$fail(peg$e131); + } } return s0; @@ -9340,7 +9871,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { + peg$fail(peg$e132); + } } return s0; @@ -9354,7 +9887,9 @@ function peg$parse(input, options) { peg$currPos += 4; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e133); } + if (peg$silentFails === 0) { + peg$fail(peg$e133); + } } return s0; @@ -9368,7 +9903,9 @@ function peg$parse(input, options) { peg$currPos += 19; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e134); } + if (peg$silentFails === 0) { + peg$fail(peg$e134); + } } return s0; @@ -9382,7 +9919,9 @@ function peg$parse(input, options) { peg$currPos += 9; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e135); } + if (peg$silentFails === 0) { + peg$fail(peg$e135); + } } return s0; @@ -9396,7 +9935,9 @@ function peg$parse(input, options) { peg$currPos += 12; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e136); } + if (peg$silentFails === 0) { + peg$fail(peg$e136); + } } return s0; @@ -9410,7 +9951,9 @@ function peg$parse(input, options) { peg$currPos += 16; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e137); } + if (peg$silentFails === 0) { + peg$fail(peg$e137); + } } return s0; @@ -9424,7 +9967,9 @@ function peg$parse(input, options) { peg$currPos += 14; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e138); } + if (peg$silentFails === 0) { + peg$fail(peg$e138); + } } return s0; @@ -9438,7 +9983,9 @@ function peg$parse(input, options) { peg$currPos += 17; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e139); } + if (peg$silentFails === 0) { + peg$fail(peg$e139); + } } return s0; @@ -9452,7 +9999,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } + if (peg$silentFails === 0) { + peg$fail(peg$e38); + } } return s0; @@ -9466,7 +10015,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e140); } + if (peg$silentFails === 0) { + peg$fail(peg$e140); + } } return s0; @@ -9480,7 +10031,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } + if (peg$silentFails === 0) { + peg$fail(peg$e12); + } } return s0; @@ -9494,7 +10047,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } + if (peg$silentFails === 0) { + peg$fail(peg$e0); + } } return s0; @@ -9508,7 +10063,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } + if (peg$silentFails === 0) { + peg$fail(peg$e1); + } } return s0; @@ -9522,7 +10079,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e141); } + if (peg$silentFails === 0) { + peg$fail(peg$e141); + } } return s0; @@ -9536,7 +10095,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e142); } + if (peg$silentFails === 0) { + peg$fail(peg$e142); + } } return s0; @@ -9550,7 +10111,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e143); } + if (peg$silentFails === 0) { + peg$fail(peg$e143); + } } return s0; @@ -9595,7 +10158,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e144); } + if (peg$silentFails === 0) { + peg$fail(peg$e144); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -9607,7 +10172,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } + if (peg$silentFails === 0) { + peg$fail(peg$e145); + } } peg$silentFails--; if (s5 === peg$FAILED) { @@ -9639,7 +10206,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } + if (peg$silentFails === 0) { + peg$fail(peg$e145); + } } peg$silentFails--; if (s5 === peg$FAILED) { @@ -9667,7 +10236,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } + if (peg$silentFails === 0) { + peg$fail(peg$e145); + } } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; @@ -9693,7 +10264,9 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e146); } + if (peg$silentFails === 0) { + peg$fail(peg$e146); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -9766,7 +10339,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } + if (peg$silentFails === 0) { + peg$fail(peg$e147); + } } return s0; @@ -9803,7 +10378,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e148); } + if (peg$silentFails === 0) { + peg$fail(peg$e148); + } } return s0; @@ -9820,7 +10397,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } + if (peg$silentFails === 0) { + peg$fail(peg$e37); + } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { @@ -9830,7 +10409,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } + if (peg$silentFails === 0) { + peg$fail(peg$e37); + } } } } else { @@ -9851,7 +10432,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } + if (peg$silentFails === 0) { + peg$fail(peg$e147); + } } peg$silentFails--; if (s1 === peg$FAILED) { @@ -10321,7 +10904,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } + if (peg$silentFails === 0) { + peg$fail(peg$e38); + } } if (s3 !== peg$FAILED) { s4 = peg$parseident_name(); @@ -10344,7 +10929,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } + if (peg$silentFails === 0) { + peg$fail(peg$e38); + } } if (s3 !== peg$FAILED) { s4 = peg$parseident_name(); @@ -10403,7 +10990,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } + if (peg$silentFails === 0) { + peg$fail(peg$e39); + } } if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { @@ -10413,7 +11002,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } + if (peg$silentFails === 0) { + peg$fail(peg$e39); + } } } } else { @@ -10524,97 +11115,96 @@ function peg$parse(input, options) { return s0; } - const reservedMap = { - 'ALL': true, - 'AND': true, - 'AS': true, - 'ASC': true, + ALL: true, + AND: true, + AS: true, + ASC: true, - 'BETWEEN': true, - 'BY': true, + BETWEEN: true, + BY: true, - 'CASE': true, - 'CREATE': true, - 'CONTAINS': true, - 'CURRENT_DATE': true, - 'CURRENT_TIME': true, - 'CURRENT_TIMESTAMP': true, - 'CURRENT_USER': true, + CASE: true, + CREATE: true, + CONTAINS: true, + CURRENT_DATE: true, + CURRENT_TIME: true, + CURRENT_TIMESTAMP: true, + CURRENT_USER: true, - 'DELETE': true, - 'DESC': true, - 'DISTINCT': true, - 'DROP': true, + DELETE: true, + DESC: true, + DISTINCT: true, + DROP: true, - 'ELSE': true, - 'END': true, - 'EXISTS': true, - 'EXPLAIN': true, + ELSE: true, + END: true, + EXISTS: true, + EXPLAIN: true, - 'FALSE': true, - 'FROM': true, - 'FULL': true, + FALSE: true, + FROM: true, + FULL: true, - 'GROUP': true, + GROUP: true, - 'HAVING': true, + HAVING: true, - 'IN': true, - 'INDEX': true, - 'INNER': true, - 'INSERT': true, - 'INTO': true, - 'IS': true, + IN: true, + INDEX: true, + INNER: true, + INSERT: true, + INTO: true, + IS: true, - 'JOIN': true, - 'JSON': true, + JOIN: true, + JSON: true, - 'LEFT': true, - 'LIKE': true, - 'LIMIT': true, + LEFT: true, + LIKE: true, + LIMIT: true, - 'NOT': true, - 'NULL': true, + NOT: true, + NULL: true, - 'ON': true, - 'OR': true, - 'ORDER': true, - 'OUTER': true, + ON: true, + OR: true, + ORDER: true, + OUTER: true, - 'RECURSIVE': true, - 'REPLACE': true, - 'RIGHT': true, + RECURSIVE: true, + REPLACE: true, + RIGHT: true, - 'SELECT': true, - 'SESSION_USER': true, - 'SET': true, - 'SHOW': true, - 'STATUS': true, // reserved (MySQL) - 'SYSTEM_USER': true, + SELECT: true, + SESSION_USER: true, + SET: true, + SHOW: true, + STATUS: true, // reserved (MySQL) + SYSTEM_USER: true, - 'TABLE': true, - 'THEN': true, - 'TRUE': true, - 'TYPE': true, // reserved (MySQL) + TABLE: true, + THEN: true, + TRUE: true, + TYPE: true, // reserved (MySQL) - 'UNION': true, - 'UPDATE': true, - 'USER': true, - 'USING': true, + UNION: true, + UPDATE: true, + USER: true, + USING: true, - 'VALUES': true, + VALUES: true, - 'WITH': true, - 'WHEN': true, - 'WHERE': true + WITH: true, + WHEN: true, + WHERE: true, }; function createUnaryExpr(op, e) { return { type: 'unary_expr', operator: op, - expr: e + expr: e, }; } @@ -10623,7 +11213,7 @@ function peg$parse(input, options) { type: 'binary_expr', operator: op, left: left, - right: right + right: right, }; } @@ -10654,17 +11244,17 @@ function peg$parse(input, options) { '=': true, //between - 'B': true, - 'b': true, + B: true, + b: true, //for is or in - 'I': true, - 'i': true, + I: true, + i: true, //for like - 'L': true, - 'l': true, + L: true, + l: true, //for not - 'N': true, - 'n': true + N: true, + n: true, }; // used for dependency analysis @@ -10687,12 +11277,12 @@ function peg$parse(input, options) { peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos), ); } } module.exports = { SyntaxError: peg$SyntaxError, - parse: peg$parse + parse: peg$parse, }; diff --git a/packages/core/database/src/types.ts b/packages/core/database/src/types.ts index 99ba47777..e294dc372 100644 --- a/packages/core/database/src/types.ts +++ b/packages/core/database/src/types.ts @@ -1,9 +1,10 @@ -import type { Model } from './model'; import type { CreateOptions, DestroyOptions, SaveOptions, SyncOptions, UpdateOptions } from 'sequelize/types'; -import { Collection, CollectionOptions } from './collection'; import { HookReturn } from 'sequelize/types/hooks'; import { ValidationOptions } from 'sequelize/types/instance-validator'; +import { Collection, CollectionOptions } from './collection'; +import type { Model } from './model'; + export type CollectionNameType = string; export type ModelSyncEventType = 'beforeSync' | 'afterSync'; diff --git a/packages/core/database/src/update-associations.ts b/packages/core/database/src/update-associations.ts index 3076bc9ce..11778a67b 100644 --- a/packages/core/database/src/update-associations.ts +++ b/packages/core/database/src/update-associations.ts @@ -9,6 +9,7 @@ import { ModelStatic, Transactionable, } from 'sequelize'; + import Database from './database'; import { Model } from './model'; import { UpdateGuard } from './update-guard'; diff --git a/packages/core/database/src/update-guard.ts b/packages/core/database/src/update-guard.ts index a8603758e..8e86536fe 100644 --- a/packages/core/database/src/update-guard.ts +++ b/packages/core/database/src/update-guard.ts @@ -1,5 +1,6 @@ import lodash from 'lodash'; import { ModelStatic } from 'sequelize'; + import { Model } from './model'; import { AssociationKeysToBeUpdate, BlackList, WhiteList } from './repository'; diff --git a/packages/core/database/src/utils.ts b/packages/core/database/src/utils.ts index 6c2c464ab..aba178ab3 100644 --- a/packages/core/database/src/utils.ts +++ b/packages/core/database/src/utils.ts @@ -1,7 +1,9 @@ import crypto from 'crypto'; + +import lodash from 'lodash'; + import Database from './database'; import { IdentifierError } from './errors/identifier-error'; -import lodash from 'lodash'; export function md5(value: string) { return crypto.createHash('md5').update(value).digest('hex'); diff --git a/packages/core/database/src/value-parsers/date-value-parser.ts b/packages/core/database/src/value-parsers/date-value-parser.ts index faccaf416..e9cf09172 100644 --- a/packages/core/database/src/value-parsers/date-value-parser.ts +++ b/packages/core/database/src/value-parsers/date-value-parser.ts @@ -1,6 +1,8 @@ import { moment2str } from '@tachybase/utils'; + import dayjs from 'dayjs'; import { getJsDateFromExcel } from 'excel-date-to-js'; + import { BaseValueParser } from './base-value-parser'; function isNumeric(str: any) { diff --git a/packages/core/database/src/value-parsers/to-many-value-parser.ts b/packages/core/database/src/value-parsers/to-many-value-parser.ts index af8f78fb9..2e43e930f 100644 --- a/packages/core/database/src/value-parsers/to-many-value-parser.ts +++ b/packages/core/database/src/value-parsers/to-many-value-parser.ts @@ -1,4 +1,5 @@ import { basename, extname } from 'path'; + import { Repository } from '../repository'; import { BaseValueParser } from './base-value-parser'; diff --git a/packages/core/database/src/view/view-inference.ts b/packages/core/database/src/view/view-inference.ts index 596697b2c..69e219c39 100644 --- a/packages/core/database/src/view/view-inference.ts +++ b/packages/core/database/src/view/view-inference.ts @@ -1,4 +1,5 @@ import { isArray } from 'mathjs'; + import Database from '../database'; import FieldTypeMap from './field-type-map'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c121c9f11..5568d03c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,6 +124,9 @@ importers: umi: specifier: ^4.1.10 version: 4.1.10(@babel/core@7.22.10)(@types/node@20.12.8)(@types/react@18.2.79)(eslint@8.57.0)(prettier@3.2.5)(react-dom@18.2.0)(react@18.2.0)(stylelint@14.16.1)(typescript@5.4.5)(webpack@5.91.0) + vitest: + specifier: ^1.6.0 + version: 1.6.0(@types/node@20.12.8) packages/core/acl: dependencies: @@ -229,12 +232,16 @@ importers: '@tachybase/utils': specifier: workspace:* version: link:../utils - '@types/jsonwebtoken': - specifier: ^8.5.8 - version: 8.5.9 jsonwebtoken: specifier: ^8.5.1 version: 8.5.1 + devDependencies: + '@types/jsonwebtoken': + specifier: ^8.5.8 + version: 8.5.9 + vitest: + specifier: ^1.6.0 + version: 1.6.0(@types/node@20.12.8) packages/core/build: dependencies: @@ -322,16 +329,22 @@ importers: cache-manager-redis-yet: specifier: ^4.1.2 version: 4.1.2 - devDependencies: deepmerge: specifier: ^4.2.2 version: 4.3.1 lodash: specifier: 4.17.21 version: 4.17.21 + devDependencies: + '@types/lodash': + specifier: ^4.17.5 + version: 4.17.5 redis: specifier: ^4.6.10 version: 4.6.13 + vitest: + specifier: ^1.6.0 + version: 1.6.0(@types/node@20.12.8) packages/core/cli: dependencies: @@ -752,6 +765,28 @@ importers: lodash: specifier: 4.17.21 version: 4.17.21 + devDependencies: + '@types/koa': + specifier: ^2.15.0 + version: 2.15.0 + '@types/koa-bodyparser': + specifier: ^4.3.12 + version: 4.3.12 + '@types/lodash': + specifier: ^4.17.5 + version: 4.17.5 + '@types/supertest': + specifier: ^6.0.2 + version: 6.0.2 + koa: + specifier: ^2.15.3 + version: 2.15.3 + koa-bodyparser: + specifier: 4.4.1 + version: 4.4.1 + supertest: + specifier: ^7.0.0 + version: 7.0.0 packages/core/database: dependencies: @@ -816,12 +851,15 @@ importers: specifier: ^3.1.1 version: 3.5.0 devDependencies: + '@types/flat': + specifier: ^5.0.5 + version: 5.0.5 '@types/glob': specifier: ^7.2.0 version: 7.2.0 '@types/lodash': - specifier: 4.17.0 - version: 4.17.0 + specifier: ^4.17.5 + version: 4.17.5 packages/core/devtools: dependencies: @@ -12004,7 +12042,6 @@ packages: /@types/cookiejar@2.1.5: resolution: {integrity: sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==} - dev: false /@types/cookies@0.7.10: resolution: {integrity: sha512-hmUCjAk2fwZVPPkkPBcI7jGLIR5mg4OVoNMBwU6aVsMm/iNPY7z9/R+x2fSwLt/ZXoGua6C5Zy2k5xOo9jUyhQ==} @@ -12085,6 +12122,10 @@ packages: resolution: {integrity: sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==} dev: true + /@types/flat@5.0.5: + resolution: {integrity: sha512-nPLljZQKSnac53KDUDzuzdRfGI0TDb5qPrb+SrQyN3MtdQrOnGsKniHN1iYZsJEBIVQve94Y6gNz22sgISZq+Q==} + dev: true + /@types/fs-extra@11.0.4: resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} dependencies: @@ -12284,6 +12325,10 @@ packages: resolution: {integrity: sha512-6L6VymKTzYSrEf4Nev4Xa1LCHKrlTlYCBMTlQKFuddo1CvQcE52I0mwfOJayueUC7MJuXOeHTcIU683lzd0cUA==} dev: true + /@types/methods@1.1.4: + resolution: {integrity: sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==} + dev: true + /@types/mime@1.3.5: resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} @@ -12471,12 +12516,27 @@ packages: '@types/node': 20.12.8 dev: false + /@types/superagent@8.1.7: + resolution: {integrity: sha512-NmIsd0Yj4DDhftfWvvAku482PZum4DBW7U51OvS8gvOkDDY0WT1jsVyDV3hK+vplrsYw8oDwi9QxOM7U68iwww==} + dependencies: + '@types/cookiejar': 2.1.5 + '@types/methods': 1.1.4 + '@types/node': 20.12.8 + dev: true + /@types/supertest@2.0.16: resolution: {integrity: sha512-6c2ogktZ06tr2ENoZivgm7YnprnhYE4ZoXGMY+oA7IuAf17M8FWvujXZGmxLv8y0PTyts4x5A+erSwVUFA8XSg==} dependencies: '@types/superagent': 4.1.24 dev: false + /@types/supertest@6.0.2: + resolution: {integrity: sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==} + dependencies: + '@types/methods': 1.1.4 + '@types/superagent': 8.1.7 + dev: true + /@types/tar-fs@2.0.2: resolution: {integrity: sha512-XuZRAvdo7FbDfgQCNkc8NOdSae5XtG+of2mTSgJ85G4OG0miN4E8BTGT+JBTLO87RQ7iCwsIDCqCsHnf2IaSXA==} dependencies: @@ -13732,6 +13792,14 @@ packages: '@vitest/utils': 1.4.0 chai: 4.3.10 + /@vitest/expect@1.6.0: + resolution: {integrity: sha512-ixEvFVQjycy/oNgHjqsL6AZCDduC+tflRluaHIzKIsdbzkLn2U/iBnVeJwB6HsIjQBdfMR8Z0tRxKUsvFJEeWQ==} + dependencies: + '@vitest/spy': 1.6.0 + '@vitest/utils': 1.6.0 + chai: 4.3.10 + dev: true + /@vitest/runner@1.4.0: resolution: {integrity: sha512-EDYVSmesqlQ4RD2VvWo3hQgTJ7ZrFQ2VSJdfiJiArkCerDAGeyF1i6dHkmySqk573jLp6d/cfqCN+7wUB5tLgg==} dependencies: @@ -13739,6 +13807,14 @@ packages: p-limit: 5.0.0 pathe: 1.1.2 + /@vitest/runner@1.6.0: + resolution: {integrity: sha512-P4xgwPjwesuBiHisAVz/LSSZtDjOTPYZVmNAnpHHSR6ONrf8eCJOFRvUwdHn30F5M1fxhqtl7QZQUk2dprIXAg==} + dependencies: + '@vitest/utils': 1.6.0 + p-limit: 5.0.0 + pathe: 1.1.2 + dev: true + /@vitest/snapshot@1.4.0: resolution: {integrity: sha512-saAFnt5pPIA5qDGxOHxJ/XxhMFKkUSBJmVt5VgDsAqPTX6JP326r5C/c9UuCMPoXNzuudTPsYDZCoJ5ilpqG2A==} dependencies: @@ -13746,11 +13822,25 @@ packages: pathe: 1.1.2 pretty-format: 29.7.0 + /@vitest/snapshot@1.6.0: + resolution: {integrity: sha512-+Hx43f8Chus+DCmygqqfetcAZrDJwvTj0ymqjQq4CvmpKFSTVteEOBzCusu1x2tt4OJcvBflyHUE0DZSLgEMtQ==} + dependencies: + magic-string: 0.30.8 + pathe: 1.1.2 + pretty-format: 29.7.0 + dev: true + /@vitest/spy@1.4.0: resolution: {integrity: sha512-Ywau/Qs1DzM/8Uc+yA77CwSegizMlcgTJuYGAi0jujOteJOUf1ujunHThYo243KG9nAyWT3L9ifPYZ5+As/+6Q==} dependencies: tinyspy: 2.2.1 + /@vitest/spy@1.6.0: + resolution: {integrity: sha512-leUTap6B/cqi/bQkXUu6bQV5TZPx7pmMBKBQiI0rJA8c3pB56ZsaTbREnF7CJfmvAS4V2cXIBAh/3rVwrrCYgw==} + dependencies: + tinyspy: 2.2.1 + dev: true + /@vitest/utils@1.4.0: resolution: {integrity: sha512-mx3Yd1/6e2Vt/PUC98DcqTirtfxUyAZ32uK82r8rZzbtBeBo+nqgnjx/LvqQdWsrvNtm14VmurNgcf4nqY5gJg==} dependencies: @@ -13759,6 +13849,15 @@ packages: loupe: 2.3.7 pretty-format: 29.7.0 + /@vitest/utils@1.6.0: + resolution: {integrity: sha512-21cPiuGMoMZwiOHa2i4LXkMkMkCGzA+MVFV70jRwHo95dL4x/ts5GZhML1QWuy7yfp3WzK3lRvZi3JnXTYqrBw==} + dependencies: + diff-sequences: 29.6.3 + estree-walker: 3.0.3 + loupe: 2.3.7 + pretty-format: 29.7.0 + dev: true + /@webassemblyjs/ast@1.12.1: resolution: {integrity: sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg==} dependencies: @@ -13899,7 +13998,6 @@ packages: dependencies: mime-types: 2.1.35 negotiator: 0.6.3 - dev: false /acorn-globals@6.0.0: resolution: {integrity: sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==} @@ -15284,7 +15382,6 @@ packages: /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - dev: false /cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} @@ -15324,7 +15421,6 @@ packages: dependencies: mime-types: 2.1.35 ylru: 1.3.2 - dev: false /cache-manager-redis-yet@4.1.2: resolution: {integrity: sha512-pM2K1ZlOv8gQpE1Z5mcDrfLj5CsNKVRiYua/SZ12j7LEDgfDeFVntI6JSgIw0siFSR/9P/FpG30scI3frHwibA==} @@ -15802,12 +15898,10 @@ packages: qs: 6.12.1 raw-body: 2.5.2 type-is: 1.6.18 - dev: false /co@4.6.0: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - dev: false /codepage@1.15.0: resolution: {integrity: sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==} @@ -16107,6 +16201,14 @@ packages: keygrip: 1.1.0 dev: false + /cookies@0.9.1: + resolution: {integrity: sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==} + engines: {node: '>= 0.8'} + dependencies: + depd: 2.0.0 + keygrip: 1.1.0 + dev: true + /copy-anything@2.0.6: resolution: {integrity: sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==} dependencies: @@ -17011,7 +17113,6 @@ packages: /deep-equal@1.0.1: resolution: {integrity: sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==} - dev: false /deep-equal@1.1.2: resolution: {integrity: sha512-5tdhKF6DbU7iIzrIOa1AOUt39ZRm13cmL1cGEh//aqR8x9+tNfbywRf0n5FD/18OKMdo7DNEtrX2t22ZAkI+eg==} @@ -17152,7 +17253,6 @@ packages: /depd@2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} - dev: false /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} @@ -17492,7 +17592,6 @@ packages: /encodeurl@1.0.2: resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} engines: {node: '>= 0.8'} - dev: false /encoding@0.1.13: resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} @@ -17744,7 +17843,7 @@ packages: engines: {node: '>= 0.4'} dependencies: get-intrinsic: 1.2.4 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 hasown: 2.0.2 /es-set-tostringtag@2.0.3: @@ -18990,6 +19089,14 @@ packages: once: 1.4.0 qs: 6.12.1 + /formidable@3.5.1: + resolution: {integrity: sha512-WJWKelbRHN41m5dumb0/k8TeAx7Id/y3a+Z7QfhxP/htI9Js5zYaEDtG8uMgG0vM0lOlqnmjE99/kfpOYi/0Og==} + dependencies: + dezalgo: 1.0.4 + hexoid: 1.0.0 + once: 1.4.0 + dev: true + /formstream@1.3.1: resolution: {integrity: sha512-FkW++ub+VbE5dpwukJVDizNWhSgp8FhmhI65pF7BZSVStBqe6Wgxe2Z9/Vhsn7l7nXCPwP+G1cyYlX8VwWOf0g==} dependencies: @@ -19009,7 +19116,6 @@ packages: /fresh@0.5.2: resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} engines: {node: '>= 0.6'} - dev: false /fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} @@ -19744,7 +19850,6 @@ packages: dependencies: deep-equal: 1.0.1 http-errors: 1.8.1 - dev: false /http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} @@ -19781,7 +19886,6 @@ packages: setprototypeof: 1.2.0 statuses: 2.0.1 toidentifier: 1.0.1 - dev: false /http-proxy-agent@4.0.1: resolution: {integrity: sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==} @@ -19991,7 +20095,6 @@ packages: /inflation@2.1.0: resolution: {integrity: sha512-t54PPJHG1Pp7VQvxyVCJ9mBbjG3Hqryges9bXoOO6GExCPa+//i/d5GSuFtpx3ALLd7lgIAur6zrIlBQyJuMlQ==} engines: {node: '>= 0.8.0'} - dev: false /inflection@1.13.4: resolution: {integrity: sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==} @@ -20124,7 +20227,7 @@ packages: engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-array-buffer@3.0.2: resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==} @@ -20156,7 +20259,7 @@ packages: resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==} engines: {node: '>= 0.4'} dependencies: - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-bigint@1.0.4: resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} @@ -20174,7 +20277,7 @@ packages: engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-buffer@1.1.6: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} @@ -20220,7 +20323,7 @@ packages: resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} engines: {node: '>= 0.4'} dependencies: - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-decimal@1.0.4: resolution: {integrity: sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==} @@ -20363,7 +20466,7 @@ packages: resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} engines: {node: '>= 0.4'} dependencies: - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} @@ -20424,7 +20527,7 @@ packages: engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-set@2.0.2: resolution: {integrity: sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==} @@ -20460,7 +20563,7 @@ packages: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} dependencies: - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /is-subdir@1.2.0: resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} @@ -20974,7 +21077,6 @@ packages: engines: {node: '>= 0.6'} dependencies: tsscmp: 1.0.6 - dev: false /keyv@3.1.0: resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==} @@ -21022,7 +21124,6 @@ packages: co-body: 6.1.0 copy-to: 2.0.1 type-is: 1.6.18 - dev: false /koa-compose@4.1.0: resolution: {integrity: sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==} @@ -21033,7 +21134,6 @@ packages: dependencies: co: 4.6.0 koa-compose: 4.1.0 - dev: false /koa-send@5.0.1: resolution: {integrity: sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==} @@ -21085,6 +21185,37 @@ packages: - supports-color dev: false + /koa@2.15.3: + resolution: {integrity: sha512-j/8tY9j5t+GVMLeioLaxweJiKUayFhlGqNTzf2ZGwL0ZCQijd2RLHK0SLW5Tsko8YyyqCZC2cojIb0/s62qTAg==} + engines: {node: ^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4} + dependencies: + accepts: 1.3.8 + cache-content-type: 1.0.1 + content-disposition: 0.5.4 + content-type: 1.0.5 + cookies: 0.9.1 + debug: 4.3.4(supports-color@5.5.0) + delegates: 1.0.0 + depd: 2.0.0 + destroy: 1.2.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + fresh: 0.5.2 + http-assert: 1.5.0 + http-errors: 1.8.1 + is-generator-function: 1.0.10 + koa-compose: 4.1.0 + koa-convert: 2.0.0 + on-finished: 2.4.1 + only: 0.0.2 + parseurl: 1.3.3 + statuses: 1.5.0 + type-is: 1.6.18 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + dev: true + /kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} @@ -22395,7 +22526,6 @@ packages: /negotiator@0.6.3: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} - dev: false /neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} @@ -22814,7 +22944,6 @@ packages: /only@0.0.2: resolution: {integrity: sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==} - dev: false /open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} @@ -23109,7 +23238,6 @@ packages: /parseurl@1.3.3: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} - dev: false /pascal-case@3.1.2: resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} @@ -24500,7 +24628,6 @@ packages: http-errors: 2.0.0 iconv-lite: 0.4.24 unpipe: 1.0.0 - dev: false /rbush@3.0.1: resolution: {integrity: sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==} @@ -27075,7 +27202,6 @@ packages: /statuses@2.0.1: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} - dev: false /std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} @@ -27492,6 +27618,23 @@ packages: transitivePeerDependencies: - supports-color + /superagent@9.0.2: + resolution: {integrity: sha512-xuW7dzkUpcJq7QnhOsnNUgtYp3xRwpt2F7abdRYIpCsAt0hhUqia0EdxyXZQQpNmGtsCzYHryaKSV3q3GJnq7w==} + engines: {node: '>=14.18.0'} + dependencies: + component-emitter: 1.3.1 + cookiejar: 2.1.4 + debug: 4.3.4(supports-color@5.5.0) + fast-safe-stringify: 2.1.1 + form-data: 4.0.0 + formidable: 3.5.1 + methods: 1.1.2 + mime: 2.6.0 + qs: 6.12.1 + transitivePeerDependencies: + - supports-color + dev: true + /supertest@6.3.3: resolution: {integrity: sha512-EMCG6G8gDu5qEqRQ3JjjPs6+FYT1a7Hv5ApHvtSghmOFJYtsU5S+pSb6Y2EUeCEY3CmEL3mmQ8YWlPOzQomabA==} engines: {node: '>=6.4.0'} @@ -27501,6 +27644,16 @@ packages: transitivePeerDependencies: - supports-color + /supertest@7.0.0: + resolution: {integrity: sha512-qlsr7fIC0lSddmA3tzojvzubYxvlGtzumcdHgPwbFWMISQwL22MhM2Y3LNt+6w9Yyx7559VW5ab70dgphm8qQA==} + engines: {node: '>=14.18.0'} + dependencies: + methods: 1.1.2 + superagent: 9.0.2 + transitivePeerDependencies: + - supports-color + dev: true + /supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} engines: {node: '>=0.8.0'} @@ -28126,7 +28279,6 @@ packages: /tsscmp@1.0.6: resolution: {integrity: sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==} engines: {node: '>=0.6.x'} - dev: false /tsup@7.2.0(postcss@8.4.38)(typescript@5.4.4): resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} @@ -28688,7 +28840,6 @@ packages: /unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - dev: false /untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} @@ -29003,6 +29154,27 @@ packages: - supports-color - terser + /vite-node@1.6.0(@types/node@20.12.8): + resolution: {integrity: sha512-de6HJgzC+TFzOu0NTC4RAIsyf/DY/ibWDYQUcuEA84EMHhcefTUGkjFHKKEJhQN4A+6I0u++kr3l36ZF2d7XRw==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4(supports-color@5.5.0) + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.2.8(@types/node@20.12.8) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /vite-plugin-css-injected-by-js@3.3.0(vite@5.1.5): resolution: {integrity: sha512-xG+jyHNCmUqi/TXp6q88wTJGeAOrNLSyUUTp4qEQ9QZLGcHWQQsCsSSKa59rPMQr8sOzfzmWDd8enGqfH/dBew==} peerDependencies: @@ -29258,6 +29430,62 @@ packages: - supports-color - terser + /vitest@1.6.0(@types/node@20.12.8): + resolution: {integrity: sha512-H5r/dN06swuFnzNFhq/dnz37bPXnq8xB2xB5JOVk8K09rUtoeNN+LHWkoQ0A/i3hvbUKKcCei9KpbxqHMLhLLA==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^20.12.2 + '@vitest/browser': 1.6.0 + '@vitest/ui': 1.6.0 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/node': 20.12.8 + '@vitest/expect': 1.6.0 + '@vitest/runner': 1.6.0 + '@vitest/snapshot': 1.6.0 + '@vitest/spy': 1.6.0 + '@vitest/utils': 1.6.0 + acorn-walk: 8.3.2 + chai: 4.3.10 + debug: 4.3.4(supports-color@5.5.0) + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.8 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 2.0.0 + tinybench: 2.6.0 + tinypool: 0.8.3 + vite: 5.2.8(@types/node@20.12.8) + vite-node: 1.6.0(@types/node@20.12.8) + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /vizion@2.2.1: resolution: {integrity: sha512-sfAcO2yeSU0CSPFI/DmZp3FsFE9T+8913nv1xWBOyzODv13fwkn6Vl7HqxGpkr9F608M+8SuFId3s+BlZqfXww==} engines: {node: '>=4.0'} @@ -29425,7 +29653,7 @@ packages: engines: {node: '>= 0.4'} dependencies: function.prototype.name: 1.1.6 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 is-async-function: 2.0.0 is-date-object: 1.0.5 is-finalizationregistry: 1.0.2 @@ -29474,7 +29702,7 @@ packages: call-bind: 1.0.7 for-each: 0.3.3 gopd: 1.0.1 - has-tostringtag: 1.0.0 + has-tostringtag: 1.0.2 /which-typed-array@1.1.15: resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==} @@ -29928,7 +30156,6 @@ packages: /ylru@1.3.2: resolution: {integrity: sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==} engines: {node: '>= 4.0.0'} - dev: false /yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}