@uql/core 1.0.11 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +243 -0
- package/LICENSE.md +2 -2
- package/dist/CHANGELOG.md +186 -0
- package/dist/README.md +413 -0
- package/dist/browser/http/bus.d.ts +3 -0
- package/dist/browser/http/bus.js +14 -0
- package/dist/browser/http/http.d.ts +6 -0
- package/dist/browser/http/http.js +45 -0
- package/dist/browser/http/index.d.ts +2 -0
- package/dist/browser/http/index.js +3 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +5 -0
- package/dist/browser/options.d.ts +4 -0
- package/dist/browser/options.js +14 -0
- package/dist/browser/querier/genericClientRepository.d.ts +17 -0
- package/dist/browser/querier/genericClientRepository.js +39 -0
- package/dist/browser/querier/httpQuerier.d.ts +20 -0
- package/dist/browser/querier/httpQuerier.js +71 -0
- package/dist/browser/querier/index.d.ts +3 -0
- package/dist/browser/querier/index.js +4 -0
- package/dist/browser/querier/querier.util.d.ts +2 -0
- package/dist/browser/querier/querier.util.js +17 -0
- package/dist/browser/type/clientQuerier.d.ts +16 -0
- package/dist/browser/type/clientQuerier.js +2 -0
- package/dist/browser/type/clientQuerierPool.d.ts +4 -0
- package/dist/browser/type/clientQuerierPool.js +2 -0
- package/dist/browser/type/clientRepository.d.ts +13 -0
- package/dist/browser/type/clientRepository.js +2 -0
- package/dist/browser/type/index.d.ts +4 -0
- package/dist/browser/type/index.js +5 -0
- package/dist/browser/type/request.d.ts +28 -0
- package/dist/browser/type/request.js +2 -0
- package/dist/browser/uql-browser.min.js +2150 -0
- package/dist/browser/uql-browser.min.js.map +1 -0
- package/dist/dialect/abstractDialect.d.ts +16 -0
- package/dist/dialect/abstractDialect.js +28 -0
- package/dist/dialect/abstractSqlDialect.d.ts +47 -0
- package/dist/dialect/abstractSqlDialect.js +650 -0
- package/dist/dialect/index.d.ts +3 -0
- package/dist/dialect/index.js +4 -0
- package/dist/dialect/queryContext.d.ts +48 -0
- package/dist/dialect/queryContext.js +65 -0
- package/{entity → dist/entity}/decorator/definition.d.ts +3 -3
- package/dist/entity/decorator/definition.js +214 -0
- package/{entity → dist/entity}/decorator/entity.d.ts +1 -1
- package/dist/entity/decorator/entity.js +7 -0
- package/{entity → dist/entity}/decorator/field.d.ts +1 -1
- package/dist/entity/decorator/field.js +8 -0
- package/{entity → dist/entity}/decorator/id.d.ts +1 -1
- package/dist/entity/decorator/id.js +8 -0
- package/dist/entity/decorator/index.d.ts +5 -0
- package/dist/entity/decorator/index.js +6 -0
- package/{entity → dist/entity}/decorator/relation.d.ts +2 -2
- package/dist/entity/decorator/relation.js +20 -0
- package/dist/entity/index.d.ts +1 -0
- package/dist/entity/index.js +2 -0
- package/dist/express/index.d.ts +2 -0
- package/dist/express/index.js +3 -0
- package/dist/express/querierMiddleware.d.ts +26 -0
- package/dist/express/querierMiddleware.js +190 -0
- package/dist/express/query.util.d.ts +2 -0
- package/dist/express/query.util.js +19 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/maria/index.d.ts +3 -0
- package/dist/maria/index.js +4 -0
- package/dist/maria/mariaDialect.d.ts +8 -0
- package/dist/maria/mariaDialect.js +38 -0
- package/dist/maria/mariaQuerierPool.test.d.ts +5 -0
- package/dist/maria/mariaQuerierPool.test.js +19 -0
- package/dist/maria/mariadbQuerier.d.ts +17 -0
- package/dist/maria/mariadbQuerier.js +39 -0
- package/dist/maria/mariadbQuerier.test.d.ts +4 -0
- package/dist/maria/mariadbQuerier.test.js +19 -0
- package/dist/maria/mariadbQuerierPool.d.ts +10 -0
- package/dist/maria/mariadbQuerierPool.js +17 -0
- package/dist/migrate/cli.d.ts +2 -0
- package/dist/migrate/cli.js +254 -0
- package/dist/migrate/generator/index.d.ts +4 -0
- package/dist/migrate/generator/index.js +5 -0
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +12 -0
- package/dist/migrate/generator/mongoSchemaGenerator.js +100 -0
- package/dist/migrate/generator/mysqlSchemaGenerator.d.ts +14 -0
- package/dist/migrate/generator/mysqlSchemaGenerator.js +81 -0
- package/dist/migrate/generator/postgresSchemaGenerator.d.ts +18 -0
- package/dist/migrate/generator/postgresSchemaGenerator.js +111 -0
- package/dist/migrate/generator/sqliteSchemaGenerator.d.ts +14 -0
- package/dist/migrate/generator/sqliteSchemaGenerator.js +68 -0
- package/dist/migrate/index.d.ts +12 -0
- package/dist/migrate/index.js +17 -0
- package/dist/migrate/introspection/index.d.ts +4 -0
- package/dist/migrate/introspection/index.js +5 -0
- package/dist/migrate/introspection/mongoIntrospector.d.ts +8 -0
- package/dist/migrate/introspection/mongoIntrospector.js +46 -0
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +25 -0
- package/dist/migrate/introspection/mysqlIntrospector.js +220 -0
- package/dist/migrate/introspection/postgresIntrospector.d.ts +21 -0
- package/dist/migrate/introspection/postgresIntrospector.js +269 -0
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +23 -0
- package/dist/migrate/introspection/sqliteIntrospector.js +212 -0
- package/dist/migrate/migrator-mongo.test.d.ts +1 -0
- package/dist/migrate/migrator-mongo.test.js +54 -0
- package/dist/migrate/migrator.d.ts +133 -0
- package/dist/migrate/migrator.js +600 -0
- package/dist/migrate/migrator.test.d.ts +1 -0
- package/dist/migrate/migrator.test.js +106 -0
- package/dist/migrate/schemaGenerator.d.ts +78 -0
- package/dist/migrate/schemaGenerator.js +363 -0
- package/dist/migrate/storage/databaseStorage.d.ts +24 -0
- package/dist/migrate/storage/databaseStorage.js +77 -0
- package/dist/migrate/storage/index.d.ts +2 -0
- package/dist/migrate/storage/index.js +3 -0
- package/dist/migrate/storage/jsonStorage.d.ts +15 -0
- package/dist/migrate/storage/jsonStorage.js +51 -0
- package/dist/migrate/type.d.ts +1 -0
- package/dist/migrate/type.js +2 -0
- package/dist/mongo/index.d.ts +3 -0
- package/dist/mongo/index.js +4 -0
- package/dist/mongo/mongoDialect.d.ts +34 -0
- package/dist/mongo/mongoDialect.js +163 -0
- package/dist/mongo/mongodbQuerier.d.ts +28 -0
- package/dist/mongo/mongodbQuerier.js +204 -0
- package/dist/mongo/mongodbQuerier.test.d.ts +1 -0
- package/dist/mongo/mongodbQuerier.test.js +36 -0
- package/dist/mongo/mongodbQuerierPool.d.ts +10 -0
- package/dist/mongo/mongodbQuerierPool.js +20 -0
- package/dist/mongo/mongodbQuerierPool.test.d.ts +1 -0
- package/dist/mongo/mongodbQuerierPool.test.js +21 -0
- package/dist/mysql/index.d.ts +3 -0
- package/dist/mysql/index.js +4 -0
- package/dist/mysql/mysql2Querier.d.ts +17 -0
- package/dist/mysql/mysql2Querier.js +43 -0
- package/dist/mysql/mysql2Querier.test.d.ts +4 -0
- package/dist/mysql/mysql2Querier.test.js +16 -0
- package/dist/mysql/mysql2QuerierPool.d.ts +10 -0
- package/dist/mysql/mysql2QuerierPool.js +17 -0
- package/dist/mysql/mysql2QuerierPool.test.d.ts +5 -0
- package/dist/mysql/mysql2QuerierPool.test.js +16 -0
- package/dist/mysql/mysqlDialect.d.ts +5 -0
- package/dist/mysql/mysqlDialect.js +15 -0
- package/dist/namingStrategy/defaultNamingStrategy.d.ts +9 -0
- package/dist/namingStrategy/defaultNamingStrategy.js +15 -0
- package/dist/namingStrategy/index.d.ts +2 -0
- package/dist/namingStrategy/index.js +3 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +8 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.js +14 -0
- package/{options.d.ts → dist/options.d.ts} +1 -1
- package/dist/options.js +14 -0
- package/dist/package.json +131 -0
- package/dist/postgres/index.d.ts +3 -0
- package/dist/postgres/index.js +4 -0
- package/dist/postgres/pgQuerier.d.ts +17 -0
- package/dist/postgres/pgQuerier.js +39 -0
- package/dist/postgres/pgQuerier.test.d.ts +4 -0
- package/dist/postgres/pgQuerier.test.js +20 -0
- package/dist/postgres/pgQuerierPool.d.ts +10 -0
- package/dist/postgres/pgQuerierPool.js +17 -0
- package/dist/postgres/pgQuerierPool.test.d.ts +5 -0
- package/dist/postgres/pgQuerierPool.test.js +23 -0
- package/dist/postgres/postgresDialect.d.ts +13 -0
- package/dist/postgres/postgresDialect.js +110 -0
- package/dist/querier/abstractQuerier-test.d.ts +45 -0
- package/dist/querier/abstractQuerier-test.js +461 -0
- package/dist/querier/abstractQuerier.d.ts +50 -0
- package/dist/querier/abstractQuerier.js +278 -0
- package/dist/querier/abstractQuerierPool-test.d.ts +9 -0
- package/dist/querier/abstractQuerierPool-test.js +18 -0
- package/dist/querier/abstractQuerierPool.d.ts +14 -0
- package/dist/querier/abstractQuerierPool.js +9 -0
- package/dist/querier/abstractSqlQuerier-test.d.ts +9 -0
- package/dist/querier/abstractSqlQuerier-test.js +16 -0
- package/dist/querier/abstractSqlQuerier.d.ts +28 -0
- package/dist/querier/abstractSqlQuerier.js +133 -0
- package/dist/querier/decorator/index.d.ts +3 -0
- package/dist/querier/decorator/index.js +4 -0
- package/dist/querier/decorator/injectQuerier.d.ts +3 -0
- package/dist/querier/decorator/injectQuerier.js +33 -0
- package/dist/querier/decorator/serialized.d.ts +6 -0
- package/dist/querier/decorator/serialized.js +14 -0
- package/{querier → dist/querier}/decorator/transactional.d.ts +1 -1
- package/dist/querier/decorator/transactional.js +48 -0
- package/dist/querier/index.d.ts +4 -0
- package/dist/querier/index.js +5 -0
- package/dist/repository/genericRepository.d.ts +20 -0
- package/dist/repository/genericRepository.js +51 -0
- package/dist/repository/index.d.ts +1 -0
- package/dist/repository/index.js +2 -0
- package/dist/sqlite/index.d.ts +3 -0
- package/dist/sqlite/index.js +4 -0
- package/dist/sqlite/sqliteDialect.d.ts +10 -0
- package/dist/sqlite/sqliteDialect.js +48 -0
- package/dist/sqlite/sqliteQuerier.d.ts +15 -0
- package/dist/sqlite/sqliteQuerier.js +33 -0
- package/dist/sqlite/sqliteQuerier.test.d.ts +5 -0
- package/dist/sqlite/sqliteQuerier.test.js +19 -0
- package/dist/sqlite/sqliteQuerierPool.d.ts +14 -0
- package/dist/sqlite/sqliteQuerierPool.js +34 -0
- package/dist/sqlite/sqliteQuerierPool.test.d.ts +5 -0
- package/dist/sqlite/sqliteQuerierPool.test.js +10 -0
- package/dist/test/entityMock.d.ts +164 -0
- package/dist/test/entityMock.js +554 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +4 -0
- package/dist/test/it.util.d.ts +4 -0
- package/dist/test/it.util.js +55 -0
- package/dist/test/spec.util.d.ts +14 -0
- package/dist/test/spec.util.js +50 -0
- package/dist/type/entity.d.ts +169 -0
- package/dist/type/entity.js +5 -0
- package/dist/type/index.d.ts +9 -0
- package/dist/type/index.js +10 -0
- package/dist/type/migration.d.ts +213 -0
- package/dist/type/migration.js +2 -0
- package/dist/type/namingStrategy.d.ts +17 -0
- package/dist/type/namingStrategy.js +2 -0
- package/dist/type/querier.d.ts +96 -0
- package/dist/type/querier.js +11 -0
- package/dist/type/querierPool.d.ts +22 -0
- package/dist/type/querierPool.js +2 -0
- package/dist/type/query.d.ts +456 -0
- package/dist/type/query.js +9 -0
- package/{type → dist/type}/repository.d.ts +43 -36
- package/dist/type/repository.js +2 -0
- package/{type → dist/type}/universalQuerier.d.ts +50 -28
- package/dist/type/universalQuerier.js +2 -0
- package/dist/type/utility.d.ts +13 -0
- package/dist/type/utility.js +2 -0
- package/dist/util/dialect.util.d.ts +12 -0
- package/dist/util/dialect.util.js +93 -0
- package/dist/util/index.d.ts +5 -0
- package/dist/util/index.js +6 -0
- package/dist/util/object.util.d.ts +7 -0
- package/dist/util/object.util.js +19 -0
- package/dist/util/raw.d.ts +8 -0
- package/dist/util/raw.js +11 -0
- package/dist/util/sql.util.d.ts +13 -0
- package/dist/util/sql.util.js +78 -0
- package/{util → dist/util}/string.util.d.ts +1 -0
- package/dist/util/string.util.js +34 -0
- package/package.json +83 -15
- package/src/@types/index.d.ts +1 -0
- package/src/@types/jest.d.ts +6 -0
- package/src/browser/http/bus.spec.ts +22 -0
- package/src/browser/http/bus.ts +17 -0
- package/src/browser/http/http.spec.ts +70 -0
- package/src/browser/http/http.ts +55 -0
- package/src/browser/http/index.ts +2 -0
- package/src/browser/index.ts +4 -0
- package/src/browser/options.spec.ts +37 -0
- package/src/browser/options.ts +18 -0
- package/src/browser/querier/genericClientRepository.spec.ts +105 -0
- package/src/browser/querier/genericClientRepository.ts +49 -0
- package/src/browser/querier/httpQuerier.ts +82 -0
- package/src/browser/querier/index.ts +3 -0
- package/src/browser/querier/querier.util.spec.ts +35 -0
- package/src/browser/querier/querier.util.ts +18 -0
- package/src/browser/type/clientQuerier.ts +45 -0
- package/src/browser/type/clientQuerierPool.ts +5 -0
- package/src/browser/type/clientRepository.ts +22 -0
- package/src/browser/type/index.ts +4 -0
- package/src/browser/type/request.ts +25 -0
- package/src/dialect/abstractDialect.ts +28 -0
- package/src/dialect/abstractSqlDialect-spec.ts +1309 -0
- package/src/dialect/abstractSqlDialect.ts +805 -0
- package/src/dialect/index.ts +3 -0
- package/src/dialect/namingStrategy.spec.ts +52 -0
- package/src/dialect/queryContext.ts +69 -0
- package/src/entity/decorator/definition.spec.ts +736 -0
- package/src/entity/decorator/definition.ts +265 -0
- package/src/entity/decorator/entity.ts +8 -0
- package/src/entity/decorator/field.ts +9 -0
- package/src/entity/decorator/id.ts +9 -0
- package/src/entity/decorator/index.ts +5 -0
- package/src/entity/decorator/relation.spec.ts +41 -0
- package/src/entity/decorator/relation.ts +34 -0
- package/src/entity/index.ts +1 -0
- package/src/express/@types/express.d.ts +8 -0
- package/src/express/@types/index.d.ts +1 -0
- package/src/express/index.ts +2 -0
- package/src/express/querierMiddleware.ts +217 -0
- package/src/express/query.util.spec.ts +40 -0
- package/src/express/query.util.ts +21 -0
- package/src/index.ts +9 -0
- package/src/maria/index.ts +3 -0
- package/src/maria/mariaDialect.spec.ts +207 -0
- package/src/maria/mariaDialect.ts +42 -0
- package/src/maria/mariaQuerierPool.test.ts +23 -0
- package/src/maria/mariadbQuerier.test.ts +23 -0
- package/src/maria/mariadbQuerier.ts +45 -0
- package/src/maria/mariadbQuerierPool.ts +21 -0
- package/src/migrate/cli.ts +301 -0
- package/src/migrate/generator/index.ts +4 -0
- package/src/migrate/generator/mongoSchemaGenerator.spec.ts +112 -0
- package/src/migrate/generator/mongoSchemaGenerator.ts +115 -0
- package/src/migrate/generator/mysqlSchemaGenerator.spec.ts +34 -0
- package/src/migrate/generator/mysqlSchemaGenerator.ts +92 -0
- package/src/migrate/generator/postgresSchemaGenerator.spec.ts +44 -0
- package/src/migrate/generator/postgresSchemaGenerator.ts +127 -0
- package/src/migrate/generator/sqliteSchemaGenerator.spec.ts +33 -0
- package/src/migrate/generator/sqliteSchemaGenerator.ts +81 -0
- package/src/migrate/index.ts +41 -0
- package/src/migrate/introspection/index.ts +4 -0
- package/src/migrate/introspection/mongoIntrospector.spec.ts +75 -0
- package/src/migrate/introspection/mongoIntrospector.ts +47 -0
- package/src/migrate/introspection/mysqlIntrospector.spec.ts +113 -0
- package/src/migrate/introspection/mysqlIntrospector.ts +278 -0
- package/src/migrate/introspection/postgresIntrospector.spec.ts +112 -0
- package/src/migrate/introspection/postgresIntrospector.ts +329 -0
- package/src/migrate/introspection/sqliteIntrospector.spec.ts +112 -0
- package/src/migrate/introspection/sqliteIntrospector.ts +296 -0
- package/src/migrate/migrator-mongo.test.ts +54 -0
- package/src/migrate/migrator.spec.ts +255 -0
- package/src/migrate/migrator.test.ts +94 -0
- package/src/migrate/migrator.ts +719 -0
- package/src/migrate/namingStrategy.spec.ts +22 -0
- package/src/migrate/schemaGenerator-advanced.spec.ts +138 -0
- package/src/migrate/schemaGenerator.spec.ts +190 -0
- package/src/migrate/schemaGenerator.ts +478 -0
- package/src/migrate/storage/databaseStorage.spec.ts +69 -0
- package/src/migrate/storage/databaseStorage.ts +100 -0
- package/src/migrate/storage/index.ts +2 -0
- package/src/migrate/storage/jsonStorage.ts +58 -0
- package/src/migrate/type.ts +1 -0
- package/src/mongo/index.ts +3 -0
- package/src/mongo/mongoDialect.spec.ts +251 -0
- package/src/mongo/mongoDialect.ts +238 -0
- package/src/mongo/mongodbQuerier.test.ts +45 -0
- package/src/mongo/mongodbQuerier.ts +256 -0
- package/src/mongo/mongodbQuerierPool.test.ts +25 -0
- package/src/mongo/mongodbQuerierPool.ts +24 -0
- package/src/mysql/index.ts +3 -0
- package/src/mysql/mysql2Querier.test.ts +20 -0
- package/src/mysql/mysql2Querier.ts +49 -0
- package/src/mysql/mysql2QuerierPool.test.ts +20 -0
- package/src/mysql/mysql2QuerierPool.ts +21 -0
- package/src/mysql/mysqlDialect.spec.ts +20 -0
- package/src/mysql/mysqlDialect.ts +16 -0
- package/src/namingStrategy/defaultNamingStrategy.ts +18 -0
- package/src/namingStrategy/index.spec.ts +36 -0
- package/src/namingStrategy/index.ts +2 -0
- package/src/namingStrategy/snakeCaseNamingStrategy.ts +15 -0
- package/src/options.spec.ts +41 -0
- package/src/options.ts +18 -0
- package/src/postgres/index.ts +3 -0
- package/src/postgres/manual-types.d.ts +4 -0
- package/src/postgres/pgQuerier.test.ts +25 -0
- package/src/postgres/pgQuerier.ts +45 -0
- package/src/postgres/pgQuerierPool.test.ts +28 -0
- package/src/postgres/pgQuerierPool.ts +21 -0
- package/src/postgres/postgresDialect.spec.ts +428 -0
- package/src/postgres/postgresDialect.ts +144 -0
- package/src/querier/abstractQuerier-test.ts +584 -0
- package/src/querier/abstractQuerier.ts +353 -0
- package/src/querier/abstractQuerierPool-test.ts +20 -0
- package/src/querier/abstractQuerierPool.ts +18 -0
- package/src/querier/abstractSqlQuerier-spec.ts +979 -0
- package/src/querier/abstractSqlQuerier-test.ts +21 -0
- package/src/querier/abstractSqlQuerier.ts +138 -0
- package/src/querier/decorator/index.ts +3 -0
- package/src/querier/decorator/injectQuerier.spec.ts +74 -0
- package/src/querier/decorator/injectQuerier.ts +45 -0
- package/src/querier/decorator/serialized.spec.ts +98 -0
- package/src/querier/decorator/serialized.ts +13 -0
- package/src/querier/decorator/transactional.spec.ts +240 -0
- package/src/querier/decorator/transactional.ts +56 -0
- package/src/querier/index.ts +4 -0
- package/src/repository/genericRepository.spec.ts +111 -0
- package/src/repository/genericRepository.ts +74 -0
- package/src/repository/index.ts +1 -0
- package/src/sqlite/index.ts +3 -0
- package/src/sqlite/manual-types.d.ts +4 -0
- package/src/sqlite/sqliteDialect.spec.ts +155 -0
- package/src/sqlite/sqliteDialect.ts +76 -0
- package/src/sqlite/sqliteQuerier.spec.ts +36 -0
- package/src/sqlite/sqliteQuerier.test.ts +21 -0
- package/src/sqlite/sqliteQuerier.ts +37 -0
- package/src/sqlite/sqliteQuerierPool.test.ts +12 -0
- package/src/sqlite/sqliteQuerierPool.ts +38 -0
- package/src/test/entityMock.ts +375 -0
- package/src/test/index.ts +3 -0
- package/src/test/it.util.ts +69 -0
- package/src/test/spec.util.ts +57 -0
- package/src/type/entity.ts +218 -0
- package/src/type/index.ts +9 -0
- package/src/type/migration.ts +241 -0
- package/src/type/namingStrategy.ts +17 -0
- package/src/type/querier.ts +143 -0
- package/src/type/querierPool.ts +26 -0
- package/src/type/query.ts +506 -0
- package/src/type/repository.ts +142 -0
- package/src/type/universalQuerier.ts +133 -0
- package/src/type/utility.ts +21 -0
- package/src/util/dialect.util-extra.spec.ts +96 -0
- package/src/util/dialect.util.spec.ts +23 -0
- package/src/util/dialect.util.ts +134 -0
- package/src/util/index.ts +5 -0
- package/src/util/object.util.spec.ts +29 -0
- package/src/util/object.util.ts +27 -0
- package/src/util/raw.ts +11 -0
- package/src/util/sql.util-extra.spec.ts +17 -0
- package/src/util/sql.util.spec.ts +208 -0
- package/src/util/sql.util.ts +104 -0
- package/src/util/string.util.spec.ts +46 -0
- package/src/util/string.util.ts +35 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +8 -0
- package/README.md +0 -179
- package/dialect/abstractSqlDialect.d.ts +0 -30
- package/dialect/abstractSqlDialect.js +0 -365
- package/dialect/index.d.ts +0 -4
- package/dialect/index.js +0 -8
- package/dialect/mysqlDialect.d.ts +0 -6
- package/dialect/mysqlDialect.js +0 -21
- package/dialect/postgresDialect.d.ts +0 -8
- package/dialect/postgresDialect.js +0 -44
- package/dialect/sqliteDialect.d.ts +0 -4
- package/dialect/sqliteDialect.js +0 -11
- package/entity/decorator/definition.js +0 -223
- package/entity/decorator/entity.js +0 -11
- package/entity/decorator/field.js +0 -12
- package/entity/decorator/id.js +0 -12
- package/entity/decorator/index.d.ts +0 -5
- package/entity/decorator/index.js +0 -12
- package/entity/decorator/relation.js +0 -27
- package/entity/index.d.ts +0 -1
- package/entity/index.js +0 -5
- package/index.d.ts +0 -1
- package/index.js +0 -5
- package/options.js +0 -20
- package/querier/abstractQuerier.d.ts +0 -30
- package/querier/abstractQuerier.js +0 -230
- package/querier/abstractSqlQuerier.d.ts +0 -27
- package/querier/abstractSqlQuerier.js +0 -88
- package/querier/decorator/index.d.ts +0 -2
- package/querier/decorator/index.js +0 -6
- package/querier/decorator/injectQuerier.d.ts +0 -3
- package/querier/decorator/injectQuerier.js +0 -39
- package/querier/decorator/transactional.js +0 -52
- package/querier/index.d.ts +0 -3
- package/querier/index.js +0 -7
- package/repository/genericRepository.d.ts +0 -19
- package/repository/genericRepository.js +0 -52
- package/repository/index.d.ts +0 -1
- package/repository/index.js +0 -5
- package/type/entity.d.ts +0 -76
- package/type/entity.js +0 -5
- package/type/index.d.ts +0 -7
- package/type/index.js +0 -11
- package/type/querier.d.ts +0 -53
- package/type/querier.js +0 -3
- package/type/querierPool.d.ts +0 -18
- package/type/querierPool.js +0 -3
- package/type/query.d.ts +0 -394
- package/type/query.js +0 -13
- package/type/repository.js +0 -3
- package/type/universalQuerier.js +0 -3
- package/type/utility.d.ts +0 -12
- package/type/utility.js +0 -3
- package/util/dialect.util.d.ts +0 -17
- package/util/dialect.util.js +0 -114
- package/util/index.d.ts +0 -5
- package/util/index.js +0 -9
- package/util/object.util.d.ts +0 -3
- package/util/object.util.js +0 -22
- package/util/raw.d.ts +0 -2
- package/util/raw.js +0 -9
- package/util/sql.util.d.ts +0 -2
- package/util/sql.util.js +0 -55
- package/util/string.util.js +0 -20
package/dist/README.md
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
<!--  -->
|
|
2
|
+
|
|
3
|
+
[](https://uql.app)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/rogerpadilla/uql) [](https://coveralls.io/r/rogerpadilla/uql?branch=main) [](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [](https://www.npmjs.com/package/@uql/core)
|
|
6
|
+
|
|
7
|
+
[uql](https://uql.app) is the [smartest ORM](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d) for TypeScript, it is designed to be fast, safe, and easy to integrate into any application.
|
|
8
|
+
|
|
9
|
+
It can run in Node.js, Browser, React Native, Expo, Electron, Deno, Bun, and many more!
|
|
10
|
+
|
|
11
|
+
Uses a consistent API for distinct databases, including PostgreSQL, MySQL, MariaDB, and SQLite (inspired by MongoDB glorious syntax).
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const companyUsers = await userRepository.findMany({
|
|
17
|
+
$select: { email: true, profile: { $select: { picture: true } } },
|
|
18
|
+
$where: { email: { $endsWith: '@domain.com' } },
|
|
19
|
+
$sort: { createdAt: 'desc' },
|
|
20
|
+
$limit: 100,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Why uql?
|
|
27
|
+
|
|
28
|
+
See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d) in medium.com.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Type-safe and Context-aware queries**: Squeeze the power of `TypeScript` for auto-completion and validation of operators at any depth, [including relations and their fields](https://www.uql.app/docs/querying-relations).
|
|
35
|
+
- **Context-Object SQL Generation**: Uses a sophisticated `QueryContext` pattern to ensure perfectly indexed placeholders ($1, $2, etc.) and robust SQL fragment management, even in the most complex sub-queries.
|
|
36
|
+
- **Unified API across Databases**: Write once, run anywhere. Seamlessly switch between `PostgreSQL`, `MySQL`, `MariaDB`, `SQLite`, and even `MongoDB`.
|
|
37
|
+
- **Serializable JSON Syntax**: Queries can be expressed as `100%` valid `JSON`, allowing them to be easily transported from frontend to backend.
|
|
38
|
+
- **Naming Strategies**: Effortlessly translate between TypeScript `CamelCase` and database `snake_case` (or any custom format) with a pluggable system.
|
|
39
|
+
- **Built-in Serialization**: A centralized task queue and `@Serialized()` decorator ensure database operations are thread-safe and race-condition free by default.
|
|
40
|
+
- **Database Migrations**: Integrated migration system for version-controlled schema management and auto-generation from entities.
|
|
41
|
+
- **High Performance**: Optimized "Sticky Connections" and human-readable, minimal SQL generation.
|
|
42
|
+
- **Modern Architecture**: Pure `ESM` support, designed for `Node.js`, `Bun`, `Deno`, and even mobile/browser environments.
|
|
43
|
+
- **Rich Feature Set**: [Soft-delete](https://uql.app/docs/entities-soft-delete), [virtual fields](https://uql.app/docs/entities-virtual-fields), [repositories](https://uql.app/docs/querying-repository), and automatic handling of `JSON`, `JSONB`, and `Vector` types.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## 1. Install
|
|
48
|
+
|
|
49
|
+
1. Install the core package:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npm install @uql/core
|
|
53
|
+
# or
|
|
54
|
+
bun add @uql/core
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. Install one of the specific adapters for your database:
|
|
58
|
+
|
|
59
|
+
| Database | Driver | UQL Adapter |
|
|
60
|
+
| ------------ | ---------------- | ---------------- |
|
|
61
|
+
| `PostgreSQL` | `pg` | `uql-postgres` |
|
|
62
|
+
| `SQLite` | `better-sqlite3` | `uql-sqlite` |
|
|
63
|
+
| `MariaDB` | `mariadb` | `uql-maria` |
|
|
64
|
+
| `MySQL` | `mysql2` | `uql-mysql` |
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
For example, for `Postgres` install the `pg` driver:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm install pg
|
|
72
|
+
# or
|
|
73
|
+
bun add pg
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
3. Additionally, your `tsconfig.json` may need the following flags:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
"target": "es2022",
|
|
80
|
+
"experimentalDecorators": true,
|
|
81
|
+
"emitDecoratorMetadata": true
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
> **Note**: UQL provides first-class support for **Bun**. It is recommended to use Bun for a significantly faster developer experience.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## 2. Define the entities
|
|
93
|
+
|
|
94
|
+
Annotate your classes with decorators from `uql/entity`. UQL supports detailed schema metadata for precise DDL generation.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { Entity, Id, Field, OneToOne, OneToMany, ManyToOne, ManyToMany } from '@uql/core/entity';
|
|
98
|
+
import type { Relation } from '@uql/core/type';
|
|
99
|
+
|
|
100
|
+
@Entity()
|
|
101
|
+
export class User {
|
|
102
|
+
@Id()
|
|
103
|
+
id?: string;
|
|
104
|
+
|
|
105
|
+
@Field({ length: 100, index: true })
|
|
106
|
+
name?: string;
|
|
107
|
+
|
|
108
|
+
@Field({ unique: true, comment: 'User login email' })
|
|
109
|
+
email?: string;
|
|
110
|
+
|
|
111
|
+
@OneToOne({ entity: () => Profile, mappedBy: 'user', cascade: true })
|
|
112
|
+
profile?: Relation<Profile>; // Relation<T> handles circular dependencies
|
|
113
|
+
|
|
114
|
+
@OneToMany({ entity: () => Post, mappedBy: 'author' })
|
|
115
|
+
posts?: Relation<Post>[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@Entity()
|
|
119
|
+
export class Profile {
|
|
120
|
+
@Id()
|
|
121
|
+
id?: string;
|
|
122
|
+
|
|
123
|
+
@Field()
|
|
124
|
+
bio?: string;
|
|
125
|
+
|
|
126
|
+
@Field({ reference: () => User })
|
|
127
|
+
userId?: string;
|
|
128
|
+
|
|
129
|
+
@OneToOne({ entity: () => User })
|
|
130
|
+
user?: User;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Entity()
|
|
134
|
+
export class Post {
|
|
135
|
+
@Id()
|
|
136
|
+
id?: number;
|
|
137
|
+
|
|
138
|
+
@Field()
|
|
139
|
+
title?: string;
|
|
140
|
+
|
|
141
|
+
@Field({ reference: () => User })
|
|
142
|
+
authorId?: string;
|
|
143
|
+
|
|
144
|
+
@ManyToOne({ entity: () => User })
|
|
145
|
+
author?: User;
|
|
146
|
+
|
|
147
|
+
@ManyToMany({ entity: () => Tag, through: () => PostTag })
|
|
148
|
+
tags?: Tag[];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Entity()
|
|
152
|
+
export class Tag {
|
|
153
|
+
@Id()
|
|
154
|
+
id?: string;
|
|
155
|
+
|
|
156
|
+
@Field()
|
|
157
|
+
name?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@Entity()
|
|
161
|
+
export class PostTag {
|
|
162
|
+
@Id()
|
|
163
|
+
id?: string;
|
|
164
|
+
|
|
165
|
+
@Field({ reference: () => Post })
|
|
166
|
+
postId?: number;
|
|
167
|
+
|
|
168
|
+
@Field({ reference: () => Tag })
|
|
169
|
+
tagId?: string;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
## 3. Setup a querier-pool
|
|
176
|
+
|
|
177
|
+
A querier-pool can be set in any of the bootstrap files of your app (e.g. in the `server.ts`).
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// file: ./shared/orm.ts
|
|
181
|
+
import { SnakeCaseNamingStrategy } from '@uql/core';
|
|
182
|
+
import { PgQuerierPool } from 'uql-postgres';
|
|
183
|
+
|
|
184
|
+
export const querierPool = new PgQuerierPool(
|
|
185
|
+
{
|
|
186
|
+
host: 'localhost',
|
|
187
|
+
user: 'theUser',
|
|
188
|
+
password: 'thePassword',
|
|
189
|
+
database: 'theDatabase',
|
|
190
|
+
min: 1,
|
|
191
|
+
max: 10,
|
|
192
|
+
},
|
|
193
|
+
// Optional extra options.
|
|
194
|
+
{
|
|
195
|
+
// Optional, any custom logger function can be passed here (optional).
|
|
196
|
+
logger: console.debug,
|
|
197
|
+
// Automatically translate between TypeScript camelCase and database snake_case.
|
|
198
|
+
// This affects both queries and schema generation.
|
|
199
|
+
namingStrategy: new SnakeCaseNamingStrategy()
|
|
200
|
+
},
|
|
201
|
+
);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## 4. Manipulate the data
|
|
207
|
+
|
|
208
|
+
UQL provides multiple ways to interact with your data, from low-level `Queriers` to high-level `Repositories`.
|
|
209
|
+
|
|
210
|
+
### Using Repositories (Recommended)
|
|
211
|
+
|
|
212
|
+
Repositories provide a clean, Data-Mapper style interface for your entities.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { GenericRepository } from '@uql/core/repository';
|
|
216
|
+
import { User } from './shared/models/index.js';
|
|
217
|
+
import { querierPool } from './shared/orm.js';
|
|
218
|
+
|
|
219
|
+
// Get a querier from the pool
|
|
220
|
+
const querier = await querierPool.getQuerier();
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
const userRepository = new GenericRepository(User, querier);
|
|
224
|
+
|
|
225
|
+
// Advanced querying with relations and virtual fields
|
|
226
|
+
const users = await userRepository.findMany({
|
|
227
|
+
$select: {
|
|
228
|
+
id: true,
|
|
229
|
+
name: true,
|
|
230
|
+
profile: ['picture'], // Select specific fields from a 1-1 relation
|
|
231
|
+
tagsCount: true // Virtual field (calculated at runtime)
|
|
232
|
+
},
|
|
233
|
+
$where: {
|
|
234
|
+
email: { $iincludes: '@uql/core' }, // Case-insensitive search
|
|
235
|
+
status: 'active'
|
|
236
|
+
},
|
|
237
|
+
$sort: { createdAt: -1 },
|
|
238
|
+
$limit: 50
|
|
239
|
+
});
|
|
240
|
+
} finally {
|
|
241
|
+
// Always release the querier to the pool
|
|
242
|
+
await querier.release();
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Advanced: Deep Selection & Filtering
|
|
247
|
+
|
|
248
|
+
UQL's query syntax is context-aware. When you query a relation, the available fields and operators are automatically suggested and validated based on that related entity.
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { GenericRepository } from '@uql/core/repository';
|
|
252
|
+
import { User } from './shared/models/index.js';
|
|
253
|
+
import { querierPool } from './shared/orm.js';
|
|
254
|
+
|
|
255
|
+
const authorsWithPopularPosts = await querierPool.transaction(async (querier) => {
|
|
256
|
+
const userRepository = new GenericRepository(User, querier);
|
|
257
|
+
|
|
258
|
+
return userRepository.findMany({
|
|
259
|
+
$select: {
|
|
260
|
+
id: true,
|
|
261
|
+
name: true,
|
|
262
|
+
profile: {
|
|
263
|
+
$select: ['bio'],
|
|
264
|
+
// Filter related record and enforce INNER JOIN
|
|
265
|
+
$where: { bio: { $ne: null } },
|
|
266
|
+
$required: true
|
|
267
|
+
},
|
|
268
|
+
posts: {
|
|
269
|
+
$select: ['title', 'createdAt'],
|
|
270
|
+
// Filter the related collection directly
|
|
271
|
+
$where: { title: { $iincludes: 'typescript' } },
|
|
272
|
+
$sort: { createdAt: -1 },
|
|
273
|
+
$limit: 5
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
$where: {
|
|
277
|
+
name: { $istartsWith: 'a' }
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Advanced: Virtual Fields & Raw SQL
|
|
284
|
+
|
|
285
|
+
Define complex logic directly in your entities using `raw` functions from `uql/util`. These are highly efficient as they are resolved during SQL generation.
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import { Entity, Id, Field } from '@uql/core/entity';
|
|
289
|
+
import { raw } from '@uql/core/util';
|
|
290
|
+
import { ItemTag } from './shared/models/index.js';
|
|
291
|
+
|
|
292
|
+
@Entity()
|
|
293
|
+
export class Item {
|
|
294
|
+
@Id()
|
|
295
|
+
id: number;
|
|
296
|
+
|
|
297
|
+
@Field()
|
|
298
|
+
name: string;
|
|
299
|
+
|
|
300
|
+
@Field({
|
|
301
|
+
virtual: raw(({ ctx, dialect, escapedPrefix }) => {
|
|
302
|
+
ctx.append('(');
|
|
303
|
+
dialect.count(ctx, ItemTag, {
|
|
304
|
+
$where: {
|
|
305
|
+
itemId: raw(({ ctx }) => ctx.append(`${escapedPrefix}.id`))
|
|
306
|
+
}
|
|
307
|
+
}, { autoPrefix: true });
|
|
308
|
+
ctx.append(')');
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
tagsCount?: number;
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Thread-Safe Transactions
|
|
316
|
+
|
|
317
|
+
UQL ensures your operations are serialized and thread-safe.
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
import { User, Profile } from './shared/models/index.js';
|
|
321
|
+
import { querierPool } from './shared/orm.js';
|
|
322
|
+
|
|
323
|
+
const result = await querierPool.transaction(async (querier) => {
|
|
324
|
+
const user = await querier.findOne(User, { $where: { email: '...' } });
|
|
325
|
+
const profileId = await querier.insertOne(Profile, { userId: user.id, ... });
|
|
326
|
+
return { userId: user.id, profileId };
|
|
327
|
+
});
|
|
328
|
+
// Connection is automatically released after transaction
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
## 5. Migrations & Synchronization
|
|
334
|
+
|
|
335
|
+
UQL includes a robust migration system and an "Entity-First" synchronization engine built directly into the core.
|
|
336
|
+
|
|
337
|
+
### 1. Create Configuration
|
|
338
|
+
|
|
339
|
+
Create a `uql.config.ts` file in your project root:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
import { PgQuerierPool } from 'uql-postgres';
|
|
343
|
+
import { User, Post } from './src/entities/index.js';
|
|
344
|
+
|
|
345
|
+
export default {
|
|
346
|
+
querierPool: new PgQuerierPool({ /* config */ }),
|
|
347
|
+
dialect: 'postgres',
|
|
348
|
+
entities: [User, Post],
|
|
349
|
+
migrationsPath: './migrations',
|
|
350
|
+
};
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### 2. Manage via CLI
|
|
354
|
+
|
|
355
|
+
UQL provides a dedicated CLI tool for migrations.
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# Generate a migration by comparing entities vs database
|
|
359
|
+
npx uql-migrate generate:entities initial_schema
|
|
360
|
+
# or
|
|
361
|
+
bunx uql-migrate generate:entities initial_schema
|
|
362
|
+
|
|
363
|
+
# Run pending migrations
|
|
364
|
+
npx uql-migrate up
|
|
365
|
+
# or
|
|
366
|
+
bunx uql-migrate up
|
|
367
|
+
|
|
368
|
+
# Rollback the last migration
|
|
369
|
+
npx uql-migrate down
|
|
370
|
+
# or
|
|
371
|
+
bunx uql-migrate down
|
|
372
|
+
|
|
373
|
+
# Check status
|
|
374
|
+
npx uql-migrate status
|
|
375
|
+
# or
|
|
376
|
+
bunx uql-migrate status
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### 3. Entity-First Synchronization (Development)
|
|
380
|
+
|
|
381
|
+
In development, you can use `autoSync` to automatically keep your database in sync with your entities without manual migrations. It is **safe by default**, meaning it only adds missing tables and columns.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
import { Migrator } from '@uql/core/migrate';
|
|
385
|
+
import { querierPool } from './shared/orm.js';
|
|
386
|
+
|
|
387
|
+
const migrator = new Migrator(querierPool);
|
|
388
|
+
await migrator.autoSync({ logging: true });
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Check out the full [documentation](https://uql.app/docs/migrations) for detailed CLI commands and advanced usage.
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
Check out the full documentation at [uql.app](https://uql.app) for details on:
|
|
396
|
+
- [Complex Logical Operators](https://uql.app/docs/querying-logical-operators)
|
|
397
|
+
- [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/docs/querying-relations)
|
|
398
|
+
- [Soft Deletes & Auditing](https://uql.app/docs/entities-soft-delete)
|
|
399
|
+
- [Database Migration & Syncing](https://uql.app/docs/migrations)
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## 🛠 Deep Dive: Tests & Technical Resources
|
|
404
|
+
|
|
405
|
+
For those who want to see the "engine under the hood," check out these resources in the source code:
|
|
406
|
+
|
|
407
|
+
- **Entity Mocks**: See how complex entities and virtual fields are defined in [entityMock.ts](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/test/entityMock.ts).
|
|
408
|
+
- **Core Dialect Logic**: The foundation of our context-aware SQL generation in [abstractSqlDialect.ts](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/dialect/abstractSqlDialect.ts).
|
|
409
|
+
- **Comprehensive Test Suite**:
|
|
410
|
+
- [Abstract SQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/dialect/abstractSqlDialect-spec.ts): The base test suite shared by all dialects.
|
|
411
|
+
- [PostgreSQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/postgres/src/postgresDialect.spec.ts) | [MySQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/mysql/src/mysqlDialect.spec.ts) | [SQLite Spec](https://github.com/rogerpadilla/uql/blob/main/packages/sqlite/src/sqliteDialect.spec.ts).
|
|
412
|
+
- [Querier Integration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/querier/abstractSqlQuerier-spec.ts): Testing the interaction between SQL generation and connection management.
|
|
413
|
+
- [MongoDB Migration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/uql/src/migrate/migrator-mongo.it.ts): Integration tests ensuring correct collection and index synchronization for MongoDB.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const subscriptors = [];
|
|
2
|
+
export function notify(notification) {
|
|
3
|
+
for (const subscriptor of subscriptors) {
|
|
4
|
+
subscriptor(notification);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function on(cb) {
|
|
8
|
+
subscriptors.push(cb);
|
|
9
|
+
const index = subscriptors.length - 1;
|
|
10
|
+
return () => {
|
|
11
|
+
subscriptors.splice(index, 1);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2Jyb3dzZXIvaHR0cC9idXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsTUFBTSxZQUFZLEdBQXNCLEVBQUUsQ0FBQztBQUUzQyxNQUFNLFVBQVUsTUFBTSxDQUFDLFlBQWlDO0lBQ3RELEtBQUssTUFBTSxXQUFXLElBQUksWUFBWSxFQUFFLENBQUM7UUFDdkMsV0FBVyxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBQzVCLENBQUM7QUFDSCxDQUFDO0FBRUQsTUFBTSxVQUFVLEVBQUUsQ0FBQyxFQUFtQjtJQUNwQyxZQUFZLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDO0lBQ3RCLE1BQU0sS0FBSyxHQUFHLFlBQVksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDO0lBQ3RDLE9BQU8sR0FBUyxFQUFFO1FBQ2hCLFlBQVksQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQyxDQUFDO0lBQ2hDLENBQUMsQ0FBQztBQUNKLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFJlcXVlc3RDYWxsYmFjaywgUmVxdWVzdE5vdGlmaWNhdGlvbiB9IGZyb20gJy4uL3R5cGUvaW5kZXguanMnO1xuXG5jb25zdCBzdWJzY3JpcHRvcnM6IFJlcXVlc3RDYWxsYmFja1tdID0gW107XG5cbmV4cG9ydCBmdW5jdGlvbiBub3RpZnkobm90aWZpY2F0aW9uOiBSZXF1ZXN0Tm90aWZpY2F0aW9uKTogdm9pZCB7XG4gIGZvciAoY29uc3Qgc3Vic2NyaXB0b3Igb2Ygc3Vic2NyaXB0b3JzKSB7XG4gICAgc3Vic2NyaXB0b3Iobm90aWZpY2F0aW9uKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gb24oY2I6IFJlcXVlc3RDYWxsYmFjayk6ICgpID0+IHZvaWQge1xuICBzdWJzY3JpcHRvcnMucHVzaChjYik7XG4gIGNvbnN0IGluZGV4ID0gc3Vic2NyaXB0b3JzLmxlbmd0aCAtIDE7XG4gIHJldHVybiAoKTogdm9pZCA9PiB7XG4gICAgc3Vic2NyaXB0b3JzLnNwbGljZShpbmRleCwgMSk7XG4gIH07XG59XG4iXX0=
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RequestOptions, RequestSuccessResponse } from '../type/index.js';
|
|
2
|
+
export declare function get<T>(url: string, opts?: RequestOptions): Promise<RequestSuccessResponse<T>>;
|
|
3
|
+
export declare function post<T>(url: string, payload: unknown, opts?: RequestOptions): Promise<RequestSuccessResponse<T>>;
|
|
4
|
+
export declare function patch<T>(url: string, payload: unknown, opts?: RequestOptions): Promise<RequestSuccessResponse<T>>;
|
|
5
|
+
export declare function put<T>(url: string, payload: unknown, opts?: RequestOptions): Promise<RequestSuccessResponse<T>>;
|
|
6
|
+
export declare function remove<T>(url: string, opts?: RequestOptions): Promise<RequestSuccessResponse<T>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { notify } from './bus.js';
|
|
2
|
+
export function get(url, opts) {
|
|
3
|
+
return request(url, { method: 'get' }, opts);
|
|
4
|
+
}
|
|
5
|
+
export function post(url, payload, opts) {
|
|
6
|
+
const body = JSON.stringify(payload);
|
|
7
|
+
return request(url, { method: 'post', body }, opts);
|
|
8
|
+
}
|
|
9
|
+
export function patch(url, payload, opts) {
|
|
10
|
+
const body = JSON.stringify(payload);
|
|
11
|
+
return request(url, { method: 'patch', body }, opts);
|
|
12
|
+
}
|
|
13
|
+
export function put(url, payload, opts) {
|
|
14
|
+
const body = JSON.stringify(payload);
|
|
15
|
+
return request(url, { method: 'put', body }, opts);
|
|
16
|
+
}
|
|
17
|
+
export function remove(url, opts) {
|
|
18
|
+
return request(url, { method: 'delete' }, opts);
|
|
19
|
+
}
|
|
20
|
+
function request(url, init, opts) {
|
|
21
|
+
notify({ phase: 'start', opts });
|
|
22
|
+
init.headers = {
|
|
23
|
+
accept: 'application/json',
|
|
24
|
+
'content-type': 'application/json',
|
|
25
|
+
};
|
|
26
|
+
return fetch(url, init)
|
|
27
|
+
.then((rawResp) => rawResp.json().then((resp) => {
|
|
28
|
+
const isSuccess = rawResp.status >= 200 && rawResp.status < 300;
|
|
29
|
+
if (isSuccess) {
|
|
30
|
+
notify({ phase: 'success', opts });
|
|
31
|
+
return resp;
|
|
32
|
+
}
|
|
33
|
+
const errorResp = resp;
|
|
34
|
+
notify({
|
|
35
|
+
phase: 'error',
|
|
36
|
+
error: errorResp.error,
|
|
37
|
+
opts,
|
|
38
|
+
});
|
|
39
|
+
throw Error(errorResp.error.message);
|
|
40
|
+
}))
|
|
41
|
+
.finally(() => {
|
|
42
|
+
notify({ phase: 'complete', opts });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9icm93c2VyL2h0dHAvaHR0cC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEV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gcmV0dXJuIHJlc3AgYXMgUmVxdWVzdFN1Y2Nlc3NSZXNwb25zZTxUPjtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBlcnJvclJlc3AgPSByZXNwIGFzIFJlcXVlc3RFcnJvclJlc3BvbnNlO1xuICAgICAgICBub3RpZnkoe1xuICAgICAgICAgIHBoYXNlOiAnZXJyb3InLFxuICAgICAgICAgIGVycm9yOiBlcnJvclJlc3AuZXJyb3IsXG4gICAgICAgICAgb3B0cyxcbiAgICAgICAgfSk7XG4gICAgICAgIHRocm93IEVycm9yKGVycm9yUmVzcC5lcnJvci5tZXNzYWdlKTtcbiAgICAgIH0pLFxuICAgIClcbiAgICAuZmluYWxseSgoKSA9PiB7XG4gICAgICBub3RpZnkoeyBwaGFzZTogJ2NvbXBsZXRlJywgb3B0cyB9KTtcbiAgICB9KTtcbn1cbiJdfQ==
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './bus.js';
|
|
2
|
+
export * from './http.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYnJvd3Nlci9odHRwL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsV0FBVyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9idXMuanMnO1xuZXhwb3J0ICogZnJvbSAnLi9odHRwLmpzJztcbiJdfQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './http/index.js';
|
|
2
|
+
export * from './options.js';
|
|
3
|
+
export * from './querier/index.js';
|
|
4
|
+
export * from './type/index.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYnJvd3Nlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxpQkFBaUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vaHR0cC9pbmRleC5qcyc7XG5leHBvcnQgKiBmcm9tICcuL29wdGlvbnMuanMnO1xuZXhwb3J0ICogZnJvbSAnLi9xdWVyaWVyL2luZGV4LmpzJztcbmV4cG9ydCAqIGZyb20gJy4vdHlwZS9pbmRleC5qcyc7XG4iXX0=
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ClientQuerier, ClientQuerierPool } from './type/index.js';
|
|
2
|
+
export declare function setQuerierPool<T extends ClientQuerierPool>(pool: T): void;
|
|
3
|
+
export declare function getQuerierPool(): ClientQuerierPool;
|
|
4
|
+
export declare function getQuerier(): ClientQuerier;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpQuerier } from './querier/httpQuerier.js';
|
|
2
|
+
let defaultPool = {
|
|
3
|
+
getQuerier: () => new HttpQuerier('/api'),
|
|
4
|
+
};
|
|
5
|
+
export function setQuerierPool(pool) {
|
|
6
|
+
defaultPool = pool;
|
|
7
|
+
}
|
|
8
|
+
export function getQuerierPool() {
|
|
9
|
+
return defaultPool;
|
|
10
|
+
}
|
|
11
|
+
export function getQuerier() {
|
|
12
|
+
return getQuerierPool().getQuerier();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9icm93c2VyL29wdGlvbnMudHMiXSwibmFtZX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VyaWVyIHtcbiAgcmV0dXJuIGdldFF1ZXJpZXJQb29sKCkuZ2V0UXVlcmllcigpO1xufVxuIl19
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IdValue, Query, QueryOne, QueryOptions, QuerySearch, Type } from '../../type/index.js';
|
|
2
|
+
import type { ClientQuerier, ClientRepository, RequestOptions } from '../type/index.js';
|
|
3
|
+
export declare class GenericClientRepository<E> implements ClientRepository<E> {
|
|
4
|
+
readonly entity: Type<E>;
|
|
5
|
+
readonly querier: ClientQuerier;
|
|
6
|
+
constructor(entity: Type<E>, querier: ClientQuerier);
|
|
7
|
+
findOneById(id: IdValue<E>, q?: QueryOne<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E>>;
|
|
8
|
+
findOne(q: QueryOne<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E>>;
|
|
9
|
+
findMany(q: Query<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E[]>>;
|
|
10
|
+
findManyAndCount(q: Query<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E[]>>;
|
|
11
|
+
count(qm?: QuerySearch<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<number>>;
|
|
12
|
+
insertOne(payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
13
|
+
updateOneById(id: IdValue<E>, payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
14
|
+
saveOne(payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
15
|
+
deleteOneById(id: IdValue<E>, opts?: QueryOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
16
|
+
deleteMany(qm: QuerySearch<E>, opts?: QueryOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>[]>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class GenericClientRepository {
|
|
2
|
+
entity;
|
|
3
|
+
querier;
|
|
4
|
+
constructor(entity, querier) {
|
|
5
|
+
this.entity = entity;
|
|
6
|
+
this.querier = querier;
|
|
7
|
+
}
|
|
8
|
+
findOneById(id, q, opts) {
|
|
9
|
+
return this.querier.findOneById(this.entity, id, q, opts);
|
|
10
|
+
}
|
|
11
|
+
findOne(q, opts) {
|
|
12
|
+
return this.querier.findOne(this.entity, q, opts);
|
|
13
|
+
}
|
|
14
|
+
findMany(q, opts) {
|
|
15
|
+
return this.querier.findMany(this.entity, q, opts);
|
|
16
|
+
}
|
|
17
|
+
findManyAndCount(q, opts) {
|
|
18
|
+
return this.querier.findManyAndCount(this.entity, q, opts);
|
|
19
|
+
}
|
|
20
|
+
count(qm, opts) {
|
|
21
|
+
return this.querier.count(this.entity, qm, opts);
|
|
22
|
+
}
|
|
23
|
+
insertOne(payload, opts) {
|
|
24
|
+
return this.querier.insertOne(this.entity, payload, opts);
|
|
25
|
+
}
|
|
26
|
+
updateOneById(id, payload, opts) {
|
|
27
|
+
return this.querier.updateOneById(this.entity, id, payload, opts);
|
|
28
|
+
}
|
|
29
|
+
saveOne(payload, opts) {
|
|
30
|
+
return this.querier.saveOne(this.entity, payload, opts);
|
|
31
|
+
}
|
|
32
|
+
deleteOneById(id, opts) {
|
|
33
|
+
return this.querier.deleteOneById(this.entity, id, opts);
|
|
34
|
+
}
|
|
35
|
+
deleteMany(qm, opts) {
|
|
36
|
+
return this.querier.deleteMany(this.entity, qm, opts);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJpY0NsaWVudFJlcG9zaXRvcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYnJvd3Nlci9xdWVyaWVyL2dlbmVyaWNDbGllbnRSZ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../../type/index.js';
|
|
2
|
+
import type { ClientQuerier, ClientRepository, RequestFindOptions, RequestOptions } from '../type/index.js';
|
|
3
|
+
export declare class HttpQuerier implements ClientQuerier {
|
|
4
|
+
readonly basePath: string;
|
|
5
|
+
constructor(basePath: string);
|
|
6
|
+
findOneById<E>(entity: Type<E>, id: IdValue<E>, q?: QueryOne<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E>>;
|
|
7
|
+
findOne<E>(entity: Type<E>, q: QueryOne<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<E>>;
|
|
8
|
+
findMany<E>(entity: Type<E>, q: Query<E>, opts?: RequestFindOptions): Promise<import("../type/request.js").RequestSuccessResponse<E[]>>;
|
|
9
|
+
findManyAndCount<E>(entity: Type<E>, q: Query<E>, opts?: RequestFindOptions): Promise<import("../type/request.js").RequestSuccessResponse<E[]>>;
|
|
10
|
+
count<E>(entity: Type<E>, q: QuerySearch<E>, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<number>>;
|
|
11
|
+
insertOne<E>(entity: Type<E>, payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<any>>;
|
|
12
|
+
updateOneById<E>(entity: Type<E>, id: IdValue<E>, payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
13
|
+
saveOne<E>(entity: Type<E>, payload: E, opts?: RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<any>> | Promise<{
|
|
14
|
+
data: E[import("../../type/entity.js").IdKey<E>];
|
|
15
|
+
}>;
|
|
16
|
+
deleteOneById<E>(entity: Type<E>, id: IdValue<E>, opts?: QueryOptions & RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>>>;
|
|
17
|
+
deleteMany<E>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions & RequestOptions): Promise<import("../type/request.js").RequestSuccessResponse<IdValue<E>[]>>;
|
|
18
|
+
getRepository<E>(entity: Type<E>): ClientRepository<E>;
|
|
19
|
+
getBasePath<E>(entity: Type<E>): string;
|
|
20
|
+
}
|