@primate/core 0.1.10 → 0.2.1
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/lib/private/App.d.ts +54 -0
- package/lib/private/App.js +128 -0
- package/lib/private/AppError.d.ts +4 -0
- package/lib/private/AppError.js +8 -0
- package/lib/private/Binder.d.ts +13 -0
- package/lib/private/Binder.js +2 -0
- package/lib/private/BindingContext.d.ts +3 -0
- package/lib/private/BindingContext.js +2 -0
- package/lib/private/BuildApp.d.ts +23 -0
- package/lib/private/BuildApp.js +121 -0
- package/lib/private/CSP.d.ts +6 -0
- package/lib/private/CSP.js +2 -0
- package/lib/private/Loader.d.ts +17 -0
- package/lib/private/Loader.js +46 -0
- package/lib/private/Mode.d.ts +3 -0
- package/lib/private/Mode.js +2 -0
- package/lib/private/Module.d.ts +18 -0
- package/lib/private/Module.js +18 -0
- package/lib/private/ServeApp.d.ts +89 -0
- package/lib/private/ServeApp.js +305 -0
- package/lib/private/ServeInit.d.ts +29 -0
- package/lib/private/ServeInit.js +2 -0
- package/lib/private/asset/Asset.d.ts +11 -0
- package/lib/private/asset/Asset.js +2 -0
- package/lib/private/asset/Font.d.ts +8 -0
- package/lib/private/asset/Font.js +2 -0
- package/lib/private/asset/Script.d.ts +9 -0
- package/lib/private/asset/Script.js +2 -0
- package/lib/private/asset/Style.d.ts +6 -0
- package/lib/private/asset/Style.js +2 -0
- package/lib/private/backend/Module.d.ts +18 -0
- package/lib/private/backend/Module.js +22 -0
- package/lib/private/build.d.ts +4 -0
- package/lib/private/build.js +45 -0
- package/lib/private/builtin/DevModule.d.ts +11 -0
- package/lib/private/builtin/DevModule.js +32 -0
- package/lib/private/builtin/HandleModule.d.ts +10 -0
- package/lib/private/builtin/HandleModule.js +15 -0
- package/lib/private/bye.d.ts +3 -0
- package/{src → lib}/private/bye.js +2 -2
- package/lib/private/client/App.d.ts +4 -0
- package/lib/private/client/App.js +12 -0
- package/lib/private/client/Data.d.ts +9 -0
- package/lib/private/client/Data.js +2 -0
- package/lib/private/client/ValidateInit.d.ts +13 -0
- package/lib/private/client/ValidateInit.js +2 -0
- package/lib/private/client/ValidateUpdater.d.ts +3 -0
- package/lib/private/client/ValidateUpdater.js +2 -0
- package/lib/private/client/ValidationError.d.ts +6 -0
- package/lib/private/client/ValidationError.js +2 -0
- package/lib/private/client/spa/index.d.ts +6 -0
- package/lib/private/client/spa/index.js +192 -0
- package/lib/private/client/spa/storage.d.ts +12 -0
- package/lib/private/client/spa/storage.js +54 -0
- package/lib/private/client/toValidated.d.ts +17 -0
- package/lib/private/client/toValidated.js +21 -0
- package/lib/private/client/validate.d.ts +3 -0
- package/lib/private/client/validate.js +54 -0
- package/lib/private/config/Config.d.ts +4 -0
- package/lib/private/config/Config.js +2 -0
- package/lib/private/config/config/app.d.ts +3 -0
- package/lib/private/config/config/app.js +3 -0
- package/lib/private/config/config/database/index.d.ts +3 -0
- package/lib/private/config/config/database/index.js +3 -0
- package/lib/private/config/config/session.d.ts +3 -0
- package/lib/private/config/config/session.js +3 -0
- package/lib/private/config/index.d.ts +25 -0
- package/lib/private/config/index.js +3 -0
- package/lib/private/config/schema.d.ts +26 -0
- package/lib/private/config/schema.js +34 -0
- package/lib/private/cookie.d.ts +11 -0
- package/lib/private/cookie.js +30 -0
- package/lib/private/database/As.d.ts +7 -0
- package/lib/private/database/As.js +2 -0
- package/lib/private/database/Binds.d.ts +4 -0
- package/lib/private/database/Binds.js +2 -0
- package/lib/private/database/Changes.d.ts +11 -0
- package/lib/private/database/Changes.js +2 -0
- package/lib/private/database/ColumnTypes.d.ts +11 -0
- package/lib/private/database/ColumnTypes.js +2 -0
- package/lib/private/database/DataDict.d.ts +5 -0
- package/lib/private/database/DataDict.js +2 -0
- package/lib/private/database/DataKey.d.ts +4 -0
- package/lib/private/database/DataKey.js +2 -0
- package/lib/private/database/DataRecord.d.ts +8 -0
- package/lib/private/database/DataRecord.js +3 -0
- package/lib/private/database/DataValue.d.ts +5 -0
- package/lib/private/database/DataValue.js +2 -0
- package/lib/private/database/Database.d.ts +56 -0
- package/lib/private/database/Database.js +153 -0
- package/lib/private/database/InMemoryDatabase.d.ts +37 -0
- package/lib/private/database/InMemoryDatabase.js +181 -0
- package/lib/private/database/Query.d.ts +14 -0
- package/lib/private/database/Query.js +15 -0
- package/lib/private/database/QueryBuilder.d.ts +14 -0
- package/lib/private/database/QueryBuilder.js +3 -0
- package/lib/private/database/Sort.d.ts +4 -0
- package/lib/private/database/Sort.js +2 -0
- package/lib/private/database/Store.d.ts +169 -0
- package/lib/private/database/Store.js +255 -0
- package/lib/private/database/TypeMap.d.ts +14 -0
- package/lib/private/database/TypeMap.js +2 -0
- package/lib/private/database/Types.d.ts +6 -0
- package/lib/private/database/Types.js +2 -0
- package/lib/private/database/primary.d.ts +3 -0
- package/lib/private/database/primary.js +2 -0
- package/lib/private/database/storage.d.ts +4 -0
- package/lib/private/database/storage.js +3 -0
- package/lib/private/database/symbol/wrap.d.ts +3 -0
- package/lib/private/database/symbol/wrap.js +2 -0
- package/lib/private/database/symbol.d.ts +3 -0
- package/lib/private/database/symbol.js +2 -0
- package/lib/private/database/test.d.ts +4 -0
- package/lib/private/database/test.js +678 -0
- package/lib/private/database/wrap.d.ts +5 -0
- package/lib/private/database/wrap.js +5 -0
- package/lib/private/fail.d.ts +3 -0
- package/lib/private/fail.js +5 -0
- package/lib/private/frontend/Component.d.ts +8 -0
- package/lib/private/frontend/Component.js +2 -0
- package/lib/private/frontend/Module.d.ts +60 -0
- package/lib/private/frontend/Module.js +241 -0
- package/lib/private/frontend/Publish.d.ts +5 -0
- package/lib/private/frontend/Publish.js +2 -0
- package/lib/private/frontend/Render.d.ts +9 -0
- package/lib/private/frontend/Render.js +2 -0
- package/lib/private/frontend/ServerComponent.d.ts +5 -0
- package/lib/private/frontend/ServerComponent.js +2 -0
- package/lib/private/frontend/ServerData.d.ts +7 -0
- package/lib/private/frontend/ServerData.js +2 -0
- package/lib/private/frontend/ViewOptions.d.ts +12 -0
- package/lib/private/frontend/ViewOptions.js +3 -0
- package/lib/private/frontend/ViewResponse.d.ts +6 -0
- package/lib/private/frontend/ViewResponse.js +2 -0
- package/lib/private/frontend/bundle-server.d.ts +11 -0
- package/lib/private/frontend/bundle-server.js +48 -0
- package/lib/private/hash.d.ts +3 -0
- package/lib/private/hash.js +10 -0
- package/lib/private/hook/build.d.ts +4 -0
- package/lib/private/hook/build.js +246 -0
- package/lib/private/hook/serve.d.ts +4 -0
- package/lib/private/hook/serve.js +13 -0
- package/lib/private/i18n/API.d.ts +21 -0
- package/lib/private/i18n/API.js +2 -0
- package/lib/private/i18n/Catalog.d.ts +4 -0
- package/lib/private/i18n/Catalog.js +2 -0
- package/lib/private/i18n/Catalogs.d.ts +4 -0
- package/lib/private/i18n/Catalogs.js +2 -0
- package/lib/private/i18n/Config.d.ts +10 -0
- package/lib/private/i18n/Config.js +2 -0
- package/lib/private/i18n/ContextData.d.ts +6 -0
- package/lib/private/i18n/ContextData.js +2 -0
- package/lib/private/i18n/Formatter.d.ts +18 -0
- package/lib/private/i18n/Formatter.js +108 -0
- package/lib/private/i18n/Module.d.ts +16 -0
- package/lib/private/i18n/Module.js +109 -0
- package/lib/private/i18n/PersistMode.d.ts +3 -0
- package/lib/private/i18n/PersistMode.js +2 -0
- package/lib/private/i18n/TypeOf.d.ts +4 -0
- package/lib/private/i18n/TypeOf.js +2 -0
- package/lib/private/i18n/constant/COOKIE_NAME.d.ts +3 -0
- package/lib/private/i18n/constant/COOKIE_NAME.js +2 -0
- package/lib/private/i18n/constant/DEFAULT_LOCALE.d.ts +3 -0
- package/lib/private/i18n/constant/DEFAULT_LOCALE.js +2 -0
- package/lib/private/i18n/constant/DEFAULT_PERSIST_MODE.d.ts +3 -0
- package/lib/private/i18n/constant/DEFAULT_PERSIST_MODE.js +2 -0
- package/lib/private/i18n/constant/PERSIST_HEADER.d.ts +3 -0
- package/lib/private/i18n/constant/PERSIST_HEADER.js +2 -0
- package/lib/private/i18n/constant/PERSIST_METHOD.d.ts +3 -0
- package/lib/private/i18n/constant/PERSIST_METHOD.js +2 -0
- package/lib/private/i18n/constant/PERSIST_STORAGE_KEY.d.ts +3 -0
- package/lib/private/i18n/constant/PERSIST_STORAGE_KEY.js +2 -0
- package/lib/private/i18n/index.d.ts +28 -0
- package/lib/private/i18n/index.js +236 -0
- package/lib/private/i18n/locale.d.ts +5 -0
- package/lib/private/i18n/locale.js +4 -0
- package/lib/private/i18n/ordinals.d.ts +4 -0
- package/lib/private/i18n/ordinals.js +52 -0
- package/lib/private/i18n/schema.d.ts +8 -0
- package/lib/private/i18n/schema.js +13 -0
- package/lib/private/i18n/symbol/internal.d.ts +3 -0
- package/lib/private/i18n/symbol/internal.js +3 -0
- package/lib/private/i18n/toIntlUnit.d.ts +3 -0
- package/lib/private/i18n/toIntlUnit.js +125 -0
- package/lib/private/inline.d.ts +7 -0
- package/lib/private/inline.js +12 -0
- package/lib/private/location.d.ts +17 -0
- package/lib/private/location.js +29 -0
- package/lib/private/log.d.ts +19 -0
- package/lib/private/log.js +46 -0
- package/lib/private/module/BuildHook.d.ts +5 -0
- package/lib/private/module/BuildHook.js +2 -0
- package/lib/private/module/Hook.d.ts +5 -0
- package/lib/private/module/Hook.js +2 -0
- package/lib/private/module/Next.d.ts +4 -0
- package/lib/private/module/Next.js +2 -0
- package/lib/private/module/NextBuild.d.ts +5 -0
- package/lib/private/module/NextBuild.js +2 -0
- package/lib/private/module/NextHandle.d.ts +5 -0
- package/lib/private/module/NextHandle.js +2 -0
- package/lib/private/module/NextRoute.d.ts +6 -0
- package/lib/private/module/NextRoute.js +2 -0
- package/lib/private/module/NextServe.d.ts +5 -0
- package/lib/private/module/NextServe.js +2 -0
- package/lib/private/module/RequestHook.d.ts +6 -0
- package/lib/private/module/RequestHook.js +2 -0
- package/lib/private/reducer.d.ts +24 -0
- package/lib/private/reducer.js +10 -0
- package/lib/private/request/RequestBag.d.ts +80 -0
- package/lib/private/request/RequestBag.js +119 -0
- package/lib/private/request/RequestBody.d.ts +39 -0
- package/lib/private/request/RequestBody.js +91 -0
- package/lib/private/request/RequestFacade.d.ts +20 -0
- package/lib/private/request/RequestFacade.js +2 -0
- package/lib/private/request/Verb.d.ts +4 -0
- package/lib/private/request/Verb.js +2 -0
- package/lib/private/request/parse.d.ts +4 -0
- package/lib/private/request/parse.js +69 -0
- package/lib/private/request/route.d.ts +4 -0
- package/lib/private/request/route.js +61 -0
- package/lib/private/request/router.d.ts +5 -0
- package/lib/private/request/router.js +56 -0
- package/lib/private/request/verbs.d.ts +3 -0
- package/lib/private/request/verbs.js +12 -0
- package/lib/private/response/ResponseFunction.d.ts +8 -0
- package/lib/private/response/ResponseFunction.js +2 -0
- package/lib/private/response/ResponseLike.d.ts +6 -0
- package/lib/private/response/ResponseLike.js +2 -0
- package/lib/private/response/binary.d.ts +10 -0
- package/lib/private/response/binary.js +47 -0
- package/lib/private/response/error.d.ts +18 -0
- package/lib/private/response/error.js +18 -0
- package/lib/private/response/json.d.ts +9 -0
- package/lib/private/response/json.js +10 -0
- package/lib/private/response/redirect.d.ts +11 -0
- package/lib/private/response/redirect.js +62 -0
- package/lib/private/response/respond.d.ts +5 -0
- package/lib/private/response/respond.js +31 -0
- package/lib/private/response/sse.d.ts +15 -0
- package/lib/private/response/sse.js +25 -0
- package/lib/private/response/text.d.ts +9 -0
- package/lib/private/response/text.js +11 -0
- package/lib/private/response/view.d.ts +11 -0
- package/lib/private/response/view.js +41 -0
- package/lib/private/response/ws.d.ts +5 -0
- package/lib/private/response/ws.js +2 -0
- package/lib/private/response.d.ts +5 -0
- package/lib/private/response.js +2 -0
- package/lib/private/route/Handler.d.ts +6 -0
- package/lib/private/route/Handler.js +2 -0
- package/lib/private/route/Options.d.ts +5 -0
- package/lib/private/route/Options.js +2 -0
- package/lib/private/route/Path.d.ts +11 -0
- package/lib/private/route/Path.js +2 -0
- package/lib/private/route/guard.d.ts +4 -0
- package/lib/private/route/guard.js +22 -0
- package/lib/private/route/router.d.ts +51 -0
- package/lib/private/route/router.js +32 -0
- package/lib/private/route/wrap.d.ts +6 -0
- package/lib/private/route/wrap.js +17 -0
- package/lib/private/route.d.ts +9 -0
- package/lib/private/route.js +6 -0
- package/lib/private/serve.d.ts +5 -0
- package/lib/private/serve.js +8 -0
- package/lib/private/session/Config.d.ts +4 -0
- package/lib/private/session/Config.js +2 -0
- package/lib/private/session/Data.d.ts +5 -0
- package/lib/private/session/Data.js +2 -0
- package/lib/private/session/InMemoryManager.d.ts +9 -0
- package/lib/private/session/InMemoryManager.js +23 -0
- package/lib/private/session/Manager.d.ts +9 -0
- package/lib/private/session/Manager.js +4 -0
- package/lib/private/session/SessionFacade.d.ts +56 -0
- package/lib/private/session/SessionFacade.js +2 -0
- package/lib/private/session/SessionHandle.d.ts +20 -0
- package/lib/private/session/SessionHandle.js +67 -0
- package/lib/private/session/SessionModule.d.ts +13 -0
- package/lib/private/session/SessionModule.js +99 -0
- package/lib/private/session/index.d.ts +13 -0
- package/lib/private/session/index.js +41 -0
- package/lib/private/session/k-serialize.d.ts +3 -0
- package/lib/private/session/k-serialize.js +2 -0
- package/lib/private/session/schema.d.ts +14 -0
- package/lib/private/session/schema.js +20 -0
- package/lib/private/session/storage.d.ts +5 -0
- package/lib/private/session/storage.js +5 -0
- package/lib/private/symbol/config.d.ts +3 -0
- package/lib/private/symbol/config.js +2 -0
- package/lib/private/symbol/layout-depth.d.ts +3 -0
- package/lib/private/symbol/layout-depth.js +2 -0
- package/lib/private/tags.d.ts +10 -0
- package/lib/private/tags.js +29 -0
- package/lib/private/target/Manager.d.ts +14 -0
- package/lib/private/target/Manager.js +44 -0
- package/lib/private/target/Target.d.ts +8 -0
- package/lib/private/target/Target.js +3 -0
- package/lib/private/target/web.d.ts +4 -0
- package/lib/private/target/web.js +68 -0
- package/lib/private/wasm/API.d.ts +7 -0
- package/lib/private/wasm/API.js +2 -0
- package/lib/private/wasm/BufferViewSource.d.ts +4 -0
- package/lib/private/wasm/BufferViewSource.js +2 -0
- package/lib/private/wasm/Exports.d.ts +23 -0
- package/lib/private/wasm/Exports.js +2 -0
- package/lib/private/wasm/I32.d.ts +5 -0
- package/lib/private/wasm/I32.js +2 -0
- package/lib/private/wasm/I32_SIZE.d.ts +3 -0
- package/lib/private/wasm/I32_SIZE.js +2 -0
- package/lib/private/wasm/Instantiation.d.ts +12 -0
- package/lib/private/wasm/Instantiation.js +2 -0
- package/lib/private/wasm/Tagged.d.ts +7 -0
- package/lib/private/wasm/Tagged.js +2 -0
- package/lib/private/wasm/buffersize.d.ts +2 -0
- package/lib/private/wasm/buffersize.js +5 -0
- package/lib/private/wasm/decode-bytes.d.ts +3 -0
- package/lib/private/wasm/decode-bytes.js +5 -0
- package/lib/private/wasm/decode-json.d.ts +7 -0
- package/lib/private/wasm/decode-json.js +11 -0
- package/lib/private/wasm/decode-option.d.ts +5 -0
- package/lib/private/wasm/decode-option.js +10 -0
- package/lib/private/wasm/decode-response.d.ts +19 -0
- package/lib/private/wasm/decode-response.js +90 -0
- package/lib/private/wasm/decode-string.d.ts +3 -0
- package/lib/private/wasm/decode-string.js +5 -0
- package/lib/private/wasm/decode-websocket-close.d.ts +5 -0
- package/lib/private/wasm/decode-websocket-close.js +6 -0
- package/lib/private/wasm/decode-websocket-send.d.ts +6 -0
- package/lib/private/wasm/decode-websocket-send.js +19 -0
- package/lib/private/wasm/encode-buffer.d.ts +3 -0
- package/lib/private/wasm/encode-buffer.js +6 -0
- package/lib/private/wasm/encode-request.d.ts +9 -0
- package/lib/private/wasm/encode-request.js +198 -0
- package/lib/private/wasm/encode-session.d.ts +3 -0
- package/lib/private/wasm/encode-session.js +25 -0
- package/lib/private/wasm/encode-string-map.d.ts +5 -0
- package/lib/private/wasm/encode-string-map.js +14 -0
- package/lib/private/wasm/encode-string.d.ts +13 -0
- package/lib/private/wasm/encode-string.js +17 -0
- package/lib/private/wasm/encode-url.d.ts +11 -0
- package/lib/private/wasm/encode-url.js +14 -0
- package/lib/private/wasm/encode-websocket-close.d.ts +2 -0
- package/lib/private/wasm/encode-websocket-close.js +7 -0
- package/lib/private/wasm/encode-websocket-message.d.ts +4 -0
- package/lib/private/wasm/encode-websocket-message.js +30 -0
- package/lib/private/wasm/encode-websocket-open.d.ts +2 -0
- package/lib/private/wasm/encode-websocket-open.js +7 -0
- package/lib/private/wasm/filesize.d.ts +2 -0
- package/lib/private/wasm/filesize.js +8 -0
- package/lib/private/wasm/instantiate.d.ts +37 -0
- package/lib/private/wasm/instantiate.js +408 -0
- package/lib/private/wasm/open-websocket.d.ts +4 -0
- package/lib/private/wasm/open-websocket.js +26 -0
- package/lib/private/wasm/stringsize.d.ts +3 -0
- package/lib/private/wasm/stringsize.js +5 -0
- package/lib/private/wasm/urlsize.d.ts +2 -0
- package/lib/private/wasm/urlsize.js +5 -0
- package/lib/public/App.d.ts +2 -0
- package/lib/public/App.js +2 -0
- package/lib/public/AppError.d.ts +2 -0
- package/lib/public/AppError.js +2 -0
- package/lib/public/BuildApp.d.ts +2 -0
- package/lib/public/BuildApp.js +2 -0
- package/lib/public/BuildHook.d.ts +2 -0
- package/lib/public/BuildHook.js +2 -0
- package/lib/public/Database.d.ts +2 -0
- package/lib/public/Database.js +2 -0
- package/lib/public/Loader.d.ts +2 -0
- package/lib/public/Loader.js +2 -0
- package/lib/public/Mode.d.ts +2 -0
- package/lib/public/Mode.js +2 -0
- package/lib/public/Module.d.ts +2 -0
- package/lib/public/Module.js +2 -0
- package/lib/public/Next.d.ts +2 -0
- package/lib/public/Next.js +2 -0
- package/lib/public/NextBuild.d.ts +2 -0
- package/lib/public/NextBuild.js +2 -0
- package/lib/public/NextHandle.d.ts +2 -0
- package/lib/public/NextHandle.js +2 -0
- package/lib/public/NextRoute.d.ts +3 -0
- package/lib/public/NextRoute.js +2 -0
- package/lib/public/NextServe.d.ts +2 -0
- package/lib/public/NextServe.js +2 -0
- package/lib/public/ServeApp.d.ts +2 -0
- package/lib/public/ServeApp.js +2 -0
- package/lib/public/Target.d.ts +2 -0
- package/lib/public/Target.js +2 -0
- package/lib/public/backend/Module.d.ts +2 -0
- package/lib/public/backend/Module.js +2 -0
- package/lib/public/build.d.ts +2 -0
- package/lib/public/build.js +2 -0
- package/lib/public/client/App.d.ts +2 -0
- package/lib/public/client/App.js +2 -0
- package/lib/public/client/Data.d.ts +2 -0
- package/lib/public/client/Data.js +2 -0
- package/lib/public/client/ValidateInit.d.ts +2 -0
- package/lib/public/client/ValidateInit.js +2 -0
- package/lib/public/client/ValidateUpdater.d.ts +2 -0
- package/lib/public/client/ValidateUpdater.js +2 -0
- package/lib/public/client/ValidationError.d.ts +2 -0
- package/lib/public/client/ValidationError.js +2 -0
- package/lib/public/client/spa.d.ts +2 -0
- package/lib/public/client/spa.js +2 -0
- package/lib/public/client/toValidated.d.ts +2 -0
- package/lib/public/client/toValidated.js +2 -0
- package/lib/public/client/validate.d.ts +2 -0
- package/lib/public/client/validate.js +2 -0
- package/lib/public/config.d.ts +2 -0
- package/lib/public/config.js +2 -0
- package/lib/public/database/As.d.ts +2 -0
- package/lib/public/database/As.js +2 -0
- package/lib/public/database/DataDict.d.ts +2 -0
- package/lib/public/database/DataDict.js +2 -0
- package/lib/public/database/InMemoryDatabase.d.ts +2 -0
- package/lib/public/database/InMemoryDatabase.js +2 -0
- package/lib/public/database/Sort.d.ts +2 -0
- package/lib/public/database/Sort.js +2 -0
- package/lib/public/database/Store.d.ts +2 -0
- package/lib/public/database/Store.js +2 -0
- package/lib/public/database/TypeMap.d.ts +2 -0
- package/lib/public/database/TypeMap.js +2 -0
- package/lib/public/database/Types.d.ts +2 -0
- package/lib/public/database/Types.js +2 -0
- package/lib/public/database/test.d.ts +2 -0
- package/lib/public/database/test.js +2 -0
- package/lib/public/database/wrap.d.ts +2 -0
- package/lib/public/database/wrap.js +2 -0
- package/lib/public/frontend/Module.d.ts +2 -0
- package/lib/public/frontend/Module.js +2 -0
- package/lib/public/frontend/Publish.d.ts +2 -0
- package/lib/public/frontend/Publish.js +2 -0
- package/lib/public/frontend/Render.d.ts +2 -0
- package/lib/public/frontend/Render.js +2 -0
- package/lib/public/frontend/ViewResponse.d.ts +2 -0
- package/lib/public/frontend/ViewResponse.js +2 -0
- package/lib/public/i18n/API.d.ts +2 -0
- package/lib/public/i18n/API.js +2 -0
- package/lib/public/i18n/Catalogs.d.ts +2 -0
- package/lib/public/i18n/Catalogs.js +2 -0
- package/lib/public/i18n/ContextData.d.ts +2 -0
- package/lib/public/i18n/ContextData.js +2 -0
- package/lib/public/i18n/config.d.ts +2 -0
- package/lib/public/i18n/config.js +2 -0
- package/lib/public/i18n/locale.d.ts +2 -0
- package/lib/public/i18n/locale.js +2 -0
- package/lib/public/i18n/sInternal.d.ts +2 -0
- package/lib/public/i18n/sInternal.js +2 -0
- package/lib/public/inline.d.ts +2 -0
- package/lib/public/inline.js +2 -0
- package/lib/public/location.d.ts +2 -0
- package/lib/public/location.js +2 -0
- package/lib/public/log.d.ts +2 -0
- package/{src/log/index.js → lib/public/log.js} +1 -0
- package/lib/public/request/RequestBody.d.ts +2 -0
- package/lib/public/request/RequestBody.js +2 -0
- package/lib/public/request/RequestFacade.d.ts +2 -0
- package/lib/public/request/RequestFacade.js +2 -0
- package/lib/public/request/Verb.d.ts +2 -0
- package/lib/public/request/Verb.js +2 -0
- package/lib/public/request/verbs.d.ts +2 -0
- package/lib/public/request/verbs.js +2 -0
- package/lib/public/response/ResponseFunction.d.ts +2 -0
- package/lib/public/response/ResponseFunction.js +2 -0
- package/lib/public/response/ResponseLike.d.ts +2 -0
- package/lib/public/response/ResponseLike.js +2 -0
- package/lib/public/response/binary.d.ts +2 -0
- package/lib/public/response/binary.js +2 -0
- package/lib/public/response/error.d.ts +2 -0
- package/lib/public/response/error.js +2 -0
- package/lib/public/response/json.d.ts +2 -0
- package/lib/public/response/json.js +2 -0
- package/lib/public/response/redirect.d.ts +2 -0
- package/lib/public/response/redirect.js +2 -0
- package/lib/public/response/sse.d.ts +2 -0
- package/lib/public/response/sse.js +2 -0
- package/lib/public/response/text.d.ts +2 -0
- package/lib/public/response/text.js +2 -0
- package/lib/public/response/view.d.ts +2 -0
- package/lib/public/response/view.js +2 -0
- package/lib/public/response/ws.d.ts +2 -0
- package/lib/public/response/ws.js +2 -0
- package/lib/public/route/router.d.ts +2 -0
- package/lib/public/route/router.js +2 -0
- package/lib/public/route/wrap.d.ts +2 -0
- package/lib/public/route/wrap.js +2 -0
- package/lib/public/route.d.ts +2 -0
- package/lib/public/route.js +2 -0
- package/lib/public/serve.d.ts +2 -0
- package/lib/public/serve.js +2 -0
- package/lib/public/session/Manager.d.ts +2 -0
- package/lib/public/session/Manager.js +2 -0
- package/lib/public/session/config.d.ts +2 -0
- package/lib/public/session/config.js +2 -0
- package/lib/public/symbol/config.d.ts +2 -0
- package/lib/public/symbol/config.js +2 -0
- package/lib/public/wasm/decode-json.d.ts +5 -0
- package/lib/public/wasm/decode-json.js +3 -0
- package/lib/public/wasm/decode-response.d.ts +3 -0
- package/lib/public/wasm/decode-response.js +3 -0
- package/lib/public/wasm/encode-request.d.ts +3 -0
- package/lib/public/wasm/encode-request.js +3 -0
- package/lib/public/wasm/encode-session.d.ts +3 -0
- package/lib/public/wasm/encode-session.js +3 -0
- package/lib/public/wasm/instantiate.d.ts +4 -0
- package/lib/public/wasm/instantiate.js +3 -0
- package/package.json +41 -36
- package/src/build/app.js +0 -99
- package/src/build/hook/build.js +0 -188
- package/src/build/hook/copy_includes.js +0 -20
- package/src/build/hook/exports.js +0 -2
- package/src/build/hook/init.js +0 -3
- package/src/build/hook/router.js +0 -33
- package/src/build/index.js +0 -49
- package/src/build/module_loader.js +0 -30
- package/src/build/targets/exports.js +0 -1
- package/src/build/targets/web.js +0 -70
- package/src/dispatch/index.js +0 -1
- package/src/http/verbs.js +0 -11
- package/src/private/config-filename.js +0 -1
- package/src/private/config.js +0 -48
- package/src/private/depend.js +0 -20
- package/src/private/dispatch.js +0 -18
- package/src/private/error/bad-body.js +0 -6
- package/src/private/error/bad-default-export.js +0 -6
- package/src/private/error/bad-path.js +0 -6
- package/src/private/error/bad-type-export.js +0 -6
- package/src/private/error/bad-type-name.js +0 -6
- package/src/private/error/double-extension.js +0 -6
- package/src/private/error/double-module.js +0 -6
- package/src/private/error/double-path-parameter.js +0 -6
- package/src/private/error/double-route.js +0 -6
- package/src/private/error/empty-config-file.js +0 -6
- package/src/private/error/empty-directory.js +0 -6
- package/src/private/error/empty-path-parameter.js +0 -6
- package/src/private/error/empty-route-file.js +0 -6
- package/src/private/error/error-in-config-file.js +0 -6
- package/src/private/error/mismatched-body.js +0 -6
- package/src/private/error/mismatched-path.js +0 -6
- package/src/private/error/mismatched-type.js +0 -6
- package/src/private/error/module-no-name.js +0 -6
- package/src/private/error/modules-array.js +0 -6
- package/src/private/error/no-handler.js +0 -6
- package/src/private/error/no-route-to-path.js +0 -6
- package/src/private/error/optional-route.js +0 -6
- package/src/private/error/reserved-type-name.js +0 -6
- package/src/private/error/rest-route.js +0 -6
- package/src/private/error.js +0 -15
- package/src/private/log.js +0 -69
- package/src/private/loglevel.js +0 -9
- package/src/private/mark.js +0 -5
- package/src/private/validate.js +0 -11
- package/src/serve/app.js +0 -206
- package/src/serve/handler/error.js +0 -10
- package/src/serve/handler/json.js +0 -10
- package/src/serve/handler/redirect.js +0 -11
- package/src/serve/handler/shared/base.js +0 -4
- package/src/serve/handler/sse.js +0 -24
- package/src/serve/handler/stream.js +0 -4
- package/src/serve/handler/text.js +0 -10
- package/src/serve/handler/view.js +0 -15
- package/src/serve/handler/ws.js +0 -2
- package/src/serve/hook/exports.js +0 -5
- package/src/serve/hook/handle.js +0 -106
- package/src/serve/hook/init.js +0 -3
- package/src/serve/hook/parse.js +0 -17
- package/src/serve/hook/respond.js +0 -28
- package/src/serve/hook/route.js +0 -50
- package/src/serve/hook/serve.js +0 -53
- package/src/serve/index.js +0 -9
- package/src/serve/module_loader.js +0 -16
- package/src/serve/to_sorted.js +0 -1
- /package/{src/build → lib/private}/defaults/app.html +0 -0
- /package/{src/build → lib/private}/defaults/error.html +0 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import Store from "#database/Store";
|
|
2
|
+
import test from "@rcompat/test";
|
|
3
|
+
import any from "@rcompat/test/any";
|
|
4
|
+
import boolean from "pema/boolean";
|
|
5
|
+
import date from "pema/date";
|
|
6
|
+
import f32 from "pema/f32";
|
|
7
|
+
import f64 from "pema/f64";
|
|
8
|
+
import i128 from "pema/i128";
|
|
9
|
+
import i16 from "pema/i16";
|
|
10
|
+
import i32 from "pema/i32";
|
|
11
|
+
import i64 from "pema/i64";
|
|
12
|
+
import i8 from "pema/i8";
|
|
13
|
+
import optional from "pema/optional";
|
|
14
|
+
import primary from "pema/primary";
|
|
15
|
+
import string from "pema/string";
|
|
16
|
+
import u128 from "pema/u128";
|
|
17
|
+
import u16 from "pema/u16";
|
|
18
|
+
import u32 from "pema/u32";
|
|
19
|
+
import u64 from "pema/u64";
|
|
20
|
+
import u8 from "pema/u8";
|
|
21
|
+
import uint from "pema/uint";
|
|
22
|
+
function pick(record, ...projection) {
|
|
23
|
+
return Object.fromEntries(Object.entries(record)
|
|
24
|
+
.filter(([key]) => projection.includes(key)));
|
|
25
|
+
}
|
|
26
|
+
;
|
|
27
|
+
const users = {
|
|
28
|
+
ben: { age: 60, lastname: "Miller", name: "Ben" },
|
|
29
|
+
donald: { age: 30, lastname: "Duck", name: "Donald" },
|
|
30
|
+
jeremy: { age: 20, name: "Just Jeremy" },
|
|
31
|
+
paul: { age: 40, lastname: "Miller", name: "Paul" },
|
|
32
|
+
ryan: { age: 40, lastname: "Wilson", name: "Ryan" },
|
|
33
|
+
};
|
|
34
|
+
export default (database) => {
|
|
35
|
+
test.ended(() => database.close());
|
|
36
|
+
const _Post = new Store({
|
|
37
|
+
id: primary,
|
|
38
|
+
title: string,
|
|
39
|
+
user_id: uint,
|
|
40
|
+
}, { database, name: "post" });
|
|
41
|
+
_Post.update;
|
|
42
|
+
const User = new Store({
|
|
43
|
+
age: u8.optional(),
|
|
44
|
+
id: primary,
|
|
45
|
+
lastname: optional(string),
|
|
46
|
+
name: string.default("Donald"),
|
|
47
|
+
}, { database, name: "user" });
|
|
48
|
+
const Type = new Store({
|
|
49
|
+
boolean: boolean.optional(),
|
|
50
|
+
date: date.optional(),
|
|
51
|
+
f32: f32.optional(),
|
|
52
|
+
f64: f64.optional(),
|
|
53
|
+
i128: i128.optional(),
|
|
54
|
+
i16: i16.optional(),
|
|
55
|
+
i32: i32.optional(),
|
|
56
|
+
i64: i64.optional(),
|
|
57
|
+
i8: i8.optional(),
|
|
58
|
+
id: primary,
|
|
59
|
+
string: string.optional(),
|
|
60
|
+
u128: u128.optional(),
|
|
61
|
+
u16: u16.optional(),
|
|
62
|
+
u32: u32.optional(),
|
|
63
|
+
u64: u64.optional(),
|
|
64
|
+
u8: u8.optional(),
|
|
65
|
+
}, { database, name: "type" });
|
|
66
|
+
const bootstrap = async (tester) => {
|
|
67
|
+
await User.schema.create();
|
|
68
|
+
for (const user of Object.values(users)) {
|
|
69
|
+
await User.insert(user);
|
|
70
|
+
}
|
|
71
|
+
await tester();
|
|
72
|
+
await User.schema.delete();
|
|
73
|
+
};
|
|
74
|
+
const typestrap = async (tester) => {
|
|
75
|
+
await Type.schema.create();
|
|
76
|
+
await tester();
|
|
77
|
+
await Type.schema.delete();
|
|
78
|
+
};
|
|
79
|
+
test.case("insert", async (assert) => {
|
|
80
|
+
await User.schema.create();
|
|
81
|
+
const donald = await User.insert({ age: 30, name: "Donald" });
|
|
82
|
+
assert(await User.has(donald.id)).true();
|
|
83
|
+
const ryan = await User.insert({ age: 40, name: "Ryan" });
|
|
84
|
+
assert(await User.has(donald.id)).true();
|
|
85
|
+
assert(await User.has(ryan.id)).true();
|
|
86
|
+
await User.schema.delete();
|
|
87
|
+
});
|
|
88
|
+
test.case("find - basic query", async (assert) => {
|
|
89
|
+
await bootstrap(async () => {
|
|
90
|
+
const result = await User.find({ name: "Ryan" });
|
|
91
|
+
assert(result.length).equals(1);
|
|
92
|
+
assert(result[0]).equals({ id: result[0].id, ...users.ryan });
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
test.case("find - sorting by multiple fields", async (assert) => {
|
|
96
|
+
await bootstrap(async () => {
|
|
97
|
+
// sorting by multiple fields: age descending, then Lastname ascending
|
|
98
|
+
const sorted = await User.find({}, {
|
|
99
|
+
select: { age: true, name: true },
|
|
100
|
+
sort: { age: "desc", lastname: "asc" },
|
|
101
|
+
});
|
|
102
|
+
assert(sorted.length).equals(5);
|
|
103
|
+
["ben", "paul", "ryan", "donald", "jeremy"].forEach((user, i) => {
|
|
104
|
+
assert(sorted[i]).equals(pick(users[user], "name", "age"));
|
|
105
|
+
});
|
|
106
|
+
const descending = await User.find({}, {
|
|
107
|
+
select: { age: true, name: true },
|
|
108
|
+
sort: { age: "desc", lastname: "desc" },
|
|
109
|
+
});
|
|
110
|
+
const descended = ["ben", "ryan", "paul", "donald", "jeremy"];
|
|
111
|
+
descended.forEach((user, i) => {
|
|
112
|
+
assert(descending[i]).equals(pick(users[user], "name", "age"));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
test.case("find - sorting ascending and descending", async (assert) => {
|
|
117
|
+
await bootstrap(async () => {
|
|
118
|
+
const ascending = await User.find({}, {
|
|
119
|
+
limit: 2,
|
|
120
|
+
select: { age: true, name: true },
|
|
121
|
+
sort: { age: "asc" },
|
|
122
|
+
});
|
|
123
|
+
const ascended = ["jeremy", "donald"];
|
|
124
|
+
ascended.forEach((user, i) => {
|
|
125
|
+
assert(ascending[i]).equals(pick(users[user], "name", "age"));
|
|
126
|
+
});
|
|
127
|
+
const descending = await User.find({}, {
|
|
128
|
+
limit: 1,
|
|
129
|
+
select: { age: true, name: true },
|
|
130
|
+
sort: { age: "desc" },
|
|
131
|
+
});
|
|
132
|
+
assert(descending[0]).equals(pick(users.ben, "name", "age"));
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
test.case("find - limiting", async (assert) => {
|
|
136
|
+
await bootstrap(async () => {
|
|
137
|
+
const ascending = await User.find({}, {
|
|
138
|
+
limit: 2,
|
|
139
|
+
select: { age: true, name: true },
|
|
140
|
+
sort: { age: "asc" },
|
|
141
|
+
});
|
|
142
|
+
assert(ascending.length).equals(2);
|
|
143
|
+
const ascended = ["jeremy", "donald"];
|
|
144
|
+
ascended.forEach((user, i) => {
|
|
145
|
+
assert(ascending[i]).equals(pick(users[user], "name", "age"));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
test.case("find - null criteria uses IS NULL semantics", async (assert) => {
|
|
150
|
+
await bootstrap(async () => {
|
|
151
|
+
// inserted fixtures include Jeremy without a lastname (NULL in DB)
|
|
152
|
+
// querying with { lastname: null } should find him
|
|
153
|
+
const rows = await User.find({ lastname: null }, {
|
|
154
|
+
select: { name: true, lastname: true },
|
|
155
|
+
sort: { name: "asc" },
|
|
156
|
+
});
|
|
157
|
+
assert(rows.length).equals(1);
|
|
158
|
+
if (rows.length > 0) {
|
|
159
|
+
assert(rows[0].name).equals("Just Jeremy");
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
test.case("find - $like operator for strings", async (assert) => {
|
|
164
|
+
await bootstrap(async () => {
|
|
165
|
+
const prefix = await User.find({ name: { $like: "J%" } });
|
|
166
|
+
assert(prefix.length).equals(1);
|
|
167
|
+
if (prefix.length > 0)
|
|
168
|
+
assert(prefix[0].name).equals("Just Jeremy");
|
|
169
|
+
const suffix = await User.find({ lastname: { $like: "%er" } });
|
|
170
|
+
assert(suffix.length).equals(2);
|
|
171
|
+
const lastnames = suffix.map(u => u.lastname).sort();
|
|
172
|
+
assert(lastnames).equals(["Miller", "Miller"]);
|
|
173
|
+
const contains = await User.find({ name: { $like: "%on%" } });
|
|
174
|
+
assert(contains.length).equals(1);
|
|
175
|
+
if (contains.length > 0)
|
|
176
|
+
assert(contains[0].name).equals("Donald");
|
|
177
|
+
const exact = await User.find({ name: { $like: "Ryan" } });
|
|
178
|
+
assert(exact.length).equals(1);
|
|
179
|
+
if (exact.length > 0)
|
|
180
|
+
assert(exact[0].name).equals("Ryan");
|
|
181
|
+
const none = await User.find({ name: { $like: "xyz%" } });
|
|
182
|
+
assert(none.length).equals(0);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
test.case("find - $like with null/undefined fields", async (assert) => {
|
|
186
|
+
await bootstrap(async () => {
|
|
187
|
+
// Jeremy has no lastname (null), should not match ANY $like patterns
|
|
188
|
+
const results = await User.find({ lastname: { $like: "%ll%" } });
|
|
189
|
+
assert(results.length).equals(2); // Ben, Paul
|
|
190
|
+
const names = results.map(u => u.name).sort();
|
|
191
|
+
assert(names).equals(["Ben", "Paul"]);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
test.case("find - $like: reject non-string types", async (assert) => {
|
|
195
|
+
await bootstrap(async () => {
|
|
196
|
+
let threw = false;
|
|
197
|
+
try {
|
|
198
|
+
// age is u8, should not accept $like
|
|
199
|
+
await User.find({ age: { $like: "30%" } });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
threw = true;
|
|
203
|
+
}
|
|
204
|
+
assert(threw).true();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
test.case("update - single record", async (assert) => {
|
|
208
|
+
await bootstrap(async () => {
|
|
209
|
+
const [donald] = (await User.find({ name: "Donald" }));
|
|
210
|
+
await User.update(donald.id, { age: 35 });
|
|
211
|
+
const [updated] = (await User.find({ name: "Donald" }));
|
|
212
|
+
assert(updated.age).equals(35);
|
|
213
|
+
assert(updated).equals({ ...users.donald, age: 35, id: donald.id });
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
test.case("update - unset fields", async (assert) => {
|
|
217
|
+
await bootstrap(async () => {
|
|
218
|
+
const [donald] = (await User.find({ name: "Donald" }));
|
|
219
|
+
assert(donald.age).equals(30);
|
|
220
|
+
await User.update(donald.id, { age: null });
|
|
221
|
+
const [updated] = (await User.find({ name: "Donald" }));
|
|
222
|
+
assert(updated.age).undefined();
|
|
223
|
+
const [paul] = (await User.find({ name: "Paul" }));
|
|
224
|
+
await User.update(paul.id, { age: null, lastname: null });
|
|
225
|
+
const [updated_pual] = (await User.find({ name: "Paul" }));
|
|
226
|
+
assert(updated_pual).equals({ id: updated_pual.id, name: "Paul" });
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
test.case("update - multiple records", async (assert) => {
|
|
230
|
+
await bootstrap(async () => {
|
|
231
|
+
const n_updated = await User.update({ age: 40 }, { age: 45 });
|
|
232
|
+
assert(n_updated).equals(2);
|
|
233
|
+
const updated = await User.find({ age: 45 });
|
|
234
|
+
assert(updated.length).equals(2);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
test.case("update - criteria and changes share a column", async (assert) => {
|
|
238
|
+
await bootstrap(async () => {
|
|
239
|
+
// Donald has age 30; update age using criteria on the same column
|
|
240
|
+
const n = await User.update({ age: 30 }, { age: 31 });
|
|
241
|
+
assert(n).equals(1);
|
|
242
|
+
assert(await User.count({ age: 30 })).equals(0);
|
|
243
|
+
assert(await User.count({ age: 31 })).equals(1);
|
|
244
|
+
const [donald] = await User.find({ name: "Donald" });
|
|
245
|
+
assert(donald.age).equals(31);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
test.case("update - reject missing criteria", async (assert) => {
|
|
249
|
+
await bootstrap(async () => {
|
|
250
|
+
let error;
|
|
251
|
+
try {
|
|
252
|
+
// should be rejected; otherwise updates all rows
|
|
253
|
+
await User.update({}, { age: 99 });
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
error = e;
|
|
257
|
+
}
|
|
258
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
259
|
+
assert(!!error).true();
|
|
260
|
+
assert(msg.includes("update: no criteria")).true();
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
test.case("update - $like criteria", async (assert) => {
|
|
264
|
+
await bootstrap(async () => {
|
|
265
|
+
// update all users whose names start with "J"
|
|
266
|
+
const updated = await User.update({ name: { $like: "J%" } }, { age: 25 });
|
|
267
|
+
assert(updated).equals(1);
|
|
268
|
+
const jeremy = await User.find({ name: "Just Jeremy" });
|
|
269
|
+
assert(jeremy[0].age).equals(25);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
test.case("delete - single record", async (assert) => {
|
|
273
|
+
await bootstrap(async () => {
|
|
274
|
+
const [donald] = await User.find({ name: "Donald" });
|
|
275
|
+
await User.delete(donald.id);
|
|
276
|
+
const deleted = await User.find({ name: "Donald" });
|
|
277
|
+
assert(deleted.length).equals(0);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
test.case("delete - multiple records", async (assert) => {
|
|
281
|
+
await bootstrap(async () => {
|
|
282
|
+
const n = await User.delete({ age: 40 });
|
|
283
|
+
assert(n).equals(2);
|
|
284
|
+
const remaining = await User.find({}, { sort: { age: "asc" } });
|
|
285
|
+
assert(remaining.length).equals(3);
|
|
286
|
+
assert(remaining[0].name).equals("Just Jeremy");
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
test.case("delete - $like criteria", async (assert) => {
|
|
290
|
+
await bootstrap(async () => {
|
|
291
|
+
// Delete all users with "Miller" lastname
|
|
292
|
+
const deleted = await User.delete({ lastname: { $like: "%Miller%" } });
|
|
293
|
+
assert(deleted).equals(2);
|
|
294
|
+
const remaining = await User.find({});
|
|
295
|
+
assert(remaining.length).equals(3);
|
|
296
|
+
const remainingNames = remaining.map(u => u.name).sort();
|
|
297
|
+
assert(remainingNames).equals(["Donald", "Just Jeremy", "Ryan"]);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
test.case("count", async (assert) => {
|
|
301
|
+
await bootstrap(async () => {
|
|
302
|
+
assert(await User.count()).equals(5);
|
|
303
|
+
assert(await User.count({ name: "Ryan" })).equals(1);
|
|
304
|
+
assert(await User.count({ age: 40 })).equals(2);
|
|
305
|
+
assert(await User.count({ age: 30 })).equals(1);
|
|
306
|
+
assert(await User.count({ age: 35 })).equals(0);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
test.case("count - $like operator", async (assert) => {
|
|
310
|
+
await bootstrap(async () => {
|
|
311
|
+
assert(await User.count({ name: { $like: "J%" } })).equals(1);
|
|
312
|
+
assert(await User.count({ lastname: { $like: "%er" } })).equals(2);
|
|
313
|
+
assert(await User.count({ name: { $like: "%xyz%" } })).equals(0);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
test.case("has", async (assert) => {
|
|
317
|
+
await bootstrap(async () => {
|
|
318
|
+
const [donald] = await User.find({ name: "Donald" });
|
|
319
|
+
assert(await User.has(donald.id)).true();
|
|
320
|
+
await User.delete(donald.id);
|
|
321
|
+
assert(await User.has(donald.id)).false();
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
test.case("type - boolean", async (assert) => {
|
|
325
|
+
await typestrap(async () => {
|
|
326
|
+
const t = await Type.insert({ boolean: true });
|
|
327
|
+
assert(t.boolean).equals(true);
|
|
328
|
+
assert((await Type.get(t.id)).boolean).equals(true);
|
|
329
|
+
await Type.update(t.id, { boolean: false });
|
|
330
|
+
assert((await Type.get(t.id)).boolean).equals(false);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
test.case("type - string", async (assert) => {
|
|
334
|
+
await typestrap(async () => {
|
|
335
|
+
const t = await Type.insert({ string: "foo" });
|
|
336
|
+
assert(t.string).equals("foo");
|
|
337
|
+
assert((await Type.get(t.id)).string).equals("foo");
|
|
338
|
+
await Type.update(t.id, { string: "bar" });
|
|
339
|
+
assert((await Type.get(t.id)).string).equals("bar");
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
test.case("type - date", async (assert) => {
|
|
343
|
+
await typestrap(async () => {
|
|
344
|
+
const now = new Date();
|
|
345
|
+
const t = await Type.insert({ date: now });
|
|
346
|
+
assert(t.date).equals(now);
|
|
347
|
+
assert((await Type.get(t.id)).date).equals(now);
|
|
348
|
+
const next = new Date();
|
|
349
|
+
await Type.update(t.id, { date: next });
|
|
350
|
+
assert((await Type.get(t.id)).date).equals(next);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
test.case("type - f32", async (assert) => {
|
|
354
|
+
await typestrap(async () => {
|
|
355
|
+
const t = await Type.insert({ f32: 1.5 });
|
|
356
|
+
assert(t.f32).equals(1.5);
|
|
357
|
+
assert((await Type.get(t.id)).f32).equals(1.5);
|
|
358
|
+
await Type.update(t.id, { f32: 123456.75 });
|
|
359
|
+
assert((await Type.get(t.id)).f32).equals(123456.75);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
test.case("type - f64", async (assert) => {
|
|
363
|
+
await typestrap(async () => {
|
|
364
|
+
const f1 = 123456.78901;
|
|
365
|
+
const t = await Type.insert({ f64: f1 });
|
|
366
|
+
assert(t.f64).equals(f1);
|
|
367
|
+
assert((await Type.get(t.id)).f64).equals(f1);
|
|
368
|
+
await Type.update(t.id, { f32: 1.5 });
|
|
369
|
+
assert((await Type.get(t.id)).f32).equals(1.5);
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
[8, 16, 32].forEach(n => {
|
|
373
|
+
test.case(`type - l${n}`, async (assert) => {
|
|
374
|
+
await typestrap(async () => {
|
|
375
|
+
const key = `i${n}`;
|
|
376
|
+
// lower bound
|
|
377
|
+
const lb = -(2 ** (n - 1));
|
|
378
|
+
const t = await Type.insert({ [key]: lb });
|
|
379
|
+
assert(t[any(key)]).equals(lb);
|
|
380
|
+
assert((await Type.get(t.id))[any(key)]).equals(lb);
|
|
381
|
+
// upper bound
|
|
382
|
+
const ub = 2 ** (n - 1) - 1;
|
|
383
|
+
await Type.update(t.id, { [key]: ub });
|
|
384
|
+
assert((await Type.get(t.id))[any(key)]).equals(ub);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
test.case(`type - u${n}`, async (assert) => {
|
|
388
|
+
await typestrap(async () => {
|
|
389
|
+
const key = `u${n}`;
|
|
390
|
+
// lower bound
|
|
391
|
+
const lb = 0;
|
|
392
|
+
const t = await Type.insert({ [key]: lb });
|
|
393
|
+
assert(t[any(key)]).equals(lb);
|
|
394
|
+
assert((await Type.get(t.id))[any(key)]).equals(lb);
|
|
395
|
+
// upper bound
|
|
396
|
+
const ub = 2 ** n - 1;
|
|
397
|
+
await Type.update(t.id, { [key]: ub });
|
|
398
|
+
assert((await Type.get(t.id))[any(key)]).equals(ub);
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
[64n, 128n].forEach(i => {
|
|
403
|
+
test.case(`type - i${i}`, async (assert) => {
|
|
404
|
+
await typestrap(async () => {
|
|
405
|
+
const key = `i${i}`;
|
|
406
|
+
// lower bound
|
|
407
|
+
const lb = -(2n ** (i - 1n));
|
|
408
|
+
const t = await Type.insert({ [key]: lb });
|
|
409
|
+
assert(t[any(key)]).equals(lb);
|
|
410
|
+
assert((await Type.get(t.id))[any(key)]).equals(lb);
|
|
411
|
+
// upper bound
|
|
412
|
+
const ub = 2n ** (i - 1n) - 1n;
|
|
413
|
+
const tu = await Type.insert({ [key]: ub });
|
|
414
|
+
assert(tu[any(key)]).equals(ub);
|
|
415
|
+
assert((await Type.get(tu.id))[any(key)]).equals(ub);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
test.case(`type - u${i}`, async (assert) => {
|
|
419
|
+
await typestrap(async () => {
|
|
420
|
+
const key = `u${i}`;
|
|
421
|
+
// lower bound
|
|
422
|
+
const lb = 0n;
|
|
423
|
+
const t = await Type.insert({ [key]: lb });
|
|
424
|
+
assert(t[any(key)]).equals(lb);
|
|
425
|
+
assert((await Type.get(t.id))[any(key)]).equals(lb);
|
|
426
|
+
// upper bound
|
|
427
|
+
const ub = 2n ** i - 1n;
|
|
428
|
+
const tu = await Type.insert({ [key]: ub });
|
|
429
|
+
assert(tu[any(key)]).equals(ub);
|
|
430
|
+
assert((await Type.get(tu.id))[any(key)]).equals(ub);
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
test.case("security - find: reject unknown criteria column", async (assert) => {
|
|
435
|
+
await bootstrap(async () => {
|
|
436
|
+
let threw = false;
|
|
437
|
+
try {
|
|
438
|
+
await User.find({ nope: "x" });
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
threw = true;
|
|
442
|
+
}
|
|
443
|
+
assert(threw).true();
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
test.case("security - find: reject empty select", async (assert) => {
|
|
447
|
+
await bootstrap(async () => {
|
|
448
|
+
let threw = false;
|
|
449
|
+
try {
|
|
450
|
+
await User.find({}, { select: {} });
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
threw = true;
|
|
454
|
+
}
|
|
455
|
+
assert(threw).true();
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
test.case("security - find: reject unknown select column", async (assert) => {
|
|
459
|
+
await bootstrap(async () => {
|
|
460
|
+
let threw = false;
|
|
461
|
+
try {
|
|
462
|
+
await User.find({}, { select: { nope: true } });
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
threw = true;
|
|
466
|
+
}
|
|
467
|
+
assert(threw).true();
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
test.case("security - find: reject empty sort", async (assert) => {
|
|
471
|
+
await bootstrap(async () => {
|
|
472
|
+
let threw = false;
|
|
473
|
+
try {
|
|
474
|
+
await User.find({}, { sort: {} });
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
threw = true;
|
|
478
|
+
}
|
|
479
|
+
assert(threw).true();
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
test.case("security - find: reject unknown sort column", async (assert) => {
|
|
483
|
+
await bootstrap(async () => {
|
|
484
|
+
let threw = false;
|
|
485
|
+
try {
|
|
486
|
+
await User.find({}, { sort: { nope: "asc" } });
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
threw = true;
|
|
490
|
+
}
|
|
491
|
+
assert(threw).true();
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
test.case("security - find: projection limits fields", async (assert) => {
|
|
495
|
+
await bootstrap(async () => {
|
|
496
|
+
const records = await User.find({}, { select: { id: true, name: true } });
|
|
497
|
+
assert(records.length).equals(5);
|
|
498
|
+
for (const r of records) {
|
|
499
|
+
// only id + name must be present
|
|
500
|
+
assert(Object.keys(r).toSorted()).equals(["id", "name"].toSorted());
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
test.case("security - update: reject unknown change column", async (assert) => {
|
|
505
|
+
await bootstrap(async () => {
|
|
506
|
+
const [donald] = await User.find({ name: "Donald" });
|
|
507
|
+
let threw = false;
|
|
508
|
+
try {
|
|
509
|
+
await User.update(donald.id, { nope: 1 });
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
threw = true;
|
|
513
|
+
}
|
|
514
|
+
assert(threw).true();
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
test.case("security - update: reject empty changes object", async (assert) => {
|
|
518
|
+
await bootstrap(async () => {
|
|
519
|
+
const [donald] = await User.find({ name: "Donald" });
|
|
520
|
+
let threw = false;
|
|
521
|
+
try {
|
|
522
|
+
await User.update(donald.id, {});
|
|
523
|
+
}
|
|
524
|
+
catch {
|
|
525
|
+
threw = true;
|
|
526
|
+
}
|
|
527
|
+
assert(threw).true();
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
test.case("security - delete: reject missing criteria", async (assert) => {
|
|
531
|
+
await bootstrap(async () => {
|
|
532
|
+
let threw = false;
|
|
533
|
+
try {
|
|
534
|
+
await User.delete({});
|
|
535
|
+
}
|
|
536
|
+
catch {
|
|
537
|
+
threw = true;
|
|
538
|
+
}
|
|
539
|
+
assert(threw).true();
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
test.case("security - inject invalid identifier (criteria)", async (assert) => {
|
|
543
|
+
await bootstrap(async () => {
|
|
544
|
+
let threw = false;
|
|
545
|
+
try {
|
|
546
|
+
// attempted injection via bogus key
|
|
547
|
+
await User.find({ "name; DROP TABLE user;": "x" });
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
threw = true;
|
|
551
|
+
}
|
|
552
|
+
assert(threw).true();
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
test.case("security - inject invalid identifier (select)", async (assert) => {
|
|
556
|
+
await bootstrap(async () => {
|
|
557
|
+
let threw = false;
|
|
558
|
+
try {
|
|
559
|
+
const options = { select: { "name; DROP TABLE user;": true } };
|
|
560
|
+
await User.find({}, options);
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
threw = true;
|
|
564
|
+
}
|
|
565
|
+
assert(threw).true();
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
test.case("security - update respects unset rules and binding map", async (assert) => {
|
|
569
|
+
await bootstrap(async () => {
|
|
570
|
+
const [paul] = await User.find({ name: "Paul" });
|
|
571
|
+
// allowed, lastname is optional
|
|
572
|
+
await User.update(paul.id, { lastname: null });
|
|
573
|
+
const [after] = await User.find({ id: paul.id }, {
|
|
574
|
+
select: { id: true, name: true, lastname: true },
|
|
575
|
+
});
|
|
576
|
+
assert(after.lastname).undefined();
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
test.case("security - count: reject unknown criteria column", async (assert) => {
|
|
580
|
+
await bootstrap(async () => {
|
|
581
|
+
let threw = false;
|
|
582
|
+
try {
|
|
583
|
+
await User.count({ nope: 1 });
|
|
584
|
+
}
|
|
585
|
+
catch {
|
|
586
|
+
threw = true;
|
|
587
|
+
}
|
|
588
|
+
assert(threw).true();
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
test.case("security - sort: reject invalid direction", async (assert) => {
|
|
592
|
+
await bootstrap(async () => {
|
|
593
|
+
let error;
|
|
594
|
+
try {
|
|
595
|
+
// intentionally wrong: should be "asc" | "desc"
|
|
596
|
+
await User.find({}, { sort: { age: "ascending" } });
|
|
597
|
+
}
|
|
598
|
+
catch (e) {
|
|
599
|
+
error = e;
|
|
600
|
+
}
|
|
601
|
+
// we expect our own validation error, not a SQLite syntax error
|
|
602
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
603
|
+
assert(!!error).true();
|
|
604
|
+
assert(message.includes("invalid sort direction")).true();
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
test.case("security - sort: reject undefined direction", async (assert) => {
|
|
608
|
+
await bootstrap(async () => {
|
|
609
|
+
let error;
|
|
610
|
+
try {
|
|
611
|
+
await User.find({}, { sort: { age: undefined } });
|
|
612
|
+
}
|
|
613
|
+
catch (e) {
|
|
614
|
+
error = e;
|
|
615
|
+
}
|
|
616
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
617
|
+
assert(!!error).true();
|
|
618
|
+
assert(message.includes("invalid sort direction")).true();
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
test.case("security - $like: reject unknown field", async (assert) => {
|
|
622
|
+
await bootstrap(async () => {
|
|
623
|
+
let threw = false;
|
|
624
|
+
try {
|
|
625
|
+
await User.find({ unknownField: { $like: "test%" } });
|
|
626
|
+
}
|
|
627
|
+
catch {
|
|
628
|
+
threw = true;
|
|
629
|
+
}
|
|
630
|
+
assert(threw).true();
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
/*test.case("security - number operators: reject on non-number fields", async assert => {
|
|
634
|
+
await bootstrap(async () => {
|
|
635
|
+
let threw = false;
|
|
636
|
+
try {
|
|
637
|
+
// name is string, should not accept $gte
|
|
638
|
+
await User.find({ name: { $gte: 10 } } as any);
|
|
639
|
+
} catch { threw = true; }
|
|
640
|
+
assert(threw).true();
|
|
641
|
+
});
|
|
642
|
+
});*/
|
|
643
|
+
/*test.case("security - mixed operators: reject invalid combinations", async assert => {
|
|
644
|
+
await bootstrap(async () => {
|
|
645
|
+
let threw = false;
|
|
646
|
+
try {
|
|
647
|
+
// can't mix string and number operators
|
|
648
|
+
await User.find({ name: { $like: "test%", $gte: 5 } } as any);
|
|
649
|
+
} catch { threw = true; }
|
|
650
|
+
assert(threw).true();
|
|
651
|
+
});
|
|
652
|
+
});*/
|
|
653
|
+
test.case("quote safety - reserved table & column names", async (assert) => {
|
|
654
|
+
// this stresses identifier quoting in CREATE/INSERT/SELECT/UPDATE/DELETE
|
|
655
|
+
const Reserved = new Store({
|
|
656
|
+
id: primary,
|
|
657
|
+
// deliberately reserved-looking column name
|
|
658
|
+
order: u8.optional(),
|
|
659
|
+
name: string,
|
|
660
|
+
}, { database, name: "select" }); // deliberately reserved-like table name
|
|
661
|
+
await Reserved.schema.create();
|
|
662
|
+
const a = await Reserved.insert({ name: "alpha", order: 1 });
|
|
663
|
+
const b = await Reserved.insert({ name: "beta", order: 2 });
|
|
664
|
+
const got = await Reserved.find({ name: "alpha" });
|
|
665
|
+
assert(got.length).equals(1);
|
|
666
|
+
assert(got[0]).equals({ id: a.id, name: "alpha", order: 1 });
|
|
667
|
+
// update using the reserved column
|
|
668
|
+
const n = await Reserved.update({ name: "beta" }, { order: 9 });
|
|
669
|
+
assert(n).equals(1);
|
|
670
|
+
const [after] = await Reserved.find({ id: b.id });
|
|
671
|
+
assert(after.order).equals(9);
|
|
672
|
+
// and delete to complete the cycle
|
|
673
|
+
const d = await Reserved.delete({ id: a.id });
|
|
674
|
+
assert(d).equals(1);
|
|
675
|
+
await Reserved.schema.delete();
|
|
676
|
+
});
|
|
677
|
+
};
|
|
678
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type Database from "#database/Database";
|
|
2
|
+
import type Store from "#database/Store";
|
|
3
|
+
import type StoreSchema from "pema/StoreSchema";
|
|
4
|
+
export default function wrapStore<T extends StoreSchema>(name: string, store: Store<T>, database: Database): Store<T>;
|
|
5
|
+
//# sourceMappingURL=wrap.d.ts.map
|