shelving 1.258.6 → 1.258.8
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/api/cache/APICache.d.ts +0 -7
- package/api/cache/APICache.js +0 -7
- package/api/cache/EndpointCache.d.ts +0 -8
- package/api/cache/EndpointCache.js +0 -8
- package/api/endpoint/Endpoint.d.ts +1 -8
- package/api/endpoint/Endpoint.js +1 -8
- package/api/provider/APIProvider.d.ts +0 -5
- package/api/provider/APIProvider.js +0 -5
- package/api/provider/CachedAPIProvider.d.ts +1 -25
- package/api/provider/CachedAPIProvider.js +1 -25
- package/api/provider/ClientAPIProvider.d.ts +4 -62
- package/api/provider/ClientAPIProvider.js +4 -62
- package/api/provider/DebugAPIProvider.d.ts +3 -35
- package/api/provider/DebugAPIProvider.js +3 -35
- package/api/provider/JSONAPIProvider.d.ts +1 -17
- package/api/provider/JSONAPIProvider.js +1 -17
- package/api/provider/LoggingAPIProvider.d.ts +1 -21
- package/api/provider/LoggingAPIProvider.js +1 -21
- package/api/provider/MockAPIProvider.d.ts +3 -40
- package/api/provider/MockAPIProvider.js +3 -40
- package/api/provider/MockEndpointAPIProvider.d.ts +0 -14
- package/api/provider/MockEndpointAPIProvider.js +0 -14
- package/api/provider/ThroughAPIProvider.d.ts +0 -58
- package/api/provider/ThroughAPIProvider.js +0 -58
- package/api/provider/ValidationAPIProvider.d.ts +2 -26
- package/api/provider/ValidationAPIProvider.js +2 -26
- package/api/provider/XMLAPIProvider.d.ts +1 -17
- package/api/provider/XMLAPIProvider.js +1 -17
- package/api/store/EndpointStore.d.ts +0 -8
- package/api/store/EndpointStore.js +0 -8
- package/bun/BunPostgreSQLProvider.d.ts +1 -29
- package/bun/BunPostgreSQLProvider.js +1 -29
- package/cloudflare/CloudflareD1Provider.d.ts +1 -22
- package/cloudflare/CloudflareD1Provider.js +1 -22
- package/cloudflare/CloudflareKVProvider.d.ts +8 -113
- package/cloudflare/CloudflareKVProvider.js +8 -113
- package/db/cache/CollectionCache.d.ts +0 -8
- package/db/cache/CollectionCache.js +0 -8
- package/db/cache/DBCache.d.ts +0 -6
- package/db/cache/DBCache.js +0 -6
- package/db/collection/Collection.d.ts +1 -14
- package/db/collection/Collection.js +1 -14
- package/db/migrate/DBMigrator.d.ts +1 -11
- package/db/migrate/DBMigrator.js +0 -9
- package/db/migrate/PostgreSQLMigrator.d.ts +0 -3
- package/db/migrate/PostgreSQLMigrator.js +0 -3
- package/db/migrate/SQLMigrator.d.ts +1 -12
- package/db/migrate/SQLMigrator.js +1 -12
- package/db/migrate/SQLiteMigrator.d.ts +0 -3
- package/db/migrate/SQLiteMigrator.js +0 -3
- package/db/provider/CacheDBProvider.d.ts +11 -113
- package/db/provider/CacheDBProvider.js +11 -113
- package/db/provider/ChangesDBProvider.d.ts +7 -66
- package/db/provider/ChangesDBProvider.js +7 -66
- package/db/provider/DebugDBProvider.d.ts +0 -106
- package/db/provider/DebugDBProvider.js +0 -106
- package/db/provider/MemoryDBProvider.d.ts +0 -116
- package/db/provider/MemoryDBProvider.js +0 -116
- package/db/provider/MockDBProvider.d.ts +0 -88
- package/db/provider/MockDBProvider.js +0 -88
- package/db/provider/PostgreSQLProvider.d.ts +3 -29
- package/db/provider/PostgreSQLProvider.js +3 -29
- package/db/provider/SQLProvider.d.ts +11 -137
- package/db/provider/SQLProvider.js +12 -137
- package/db/provider/SQLiteProvider.d.ts +4 -39
- package/db/provider/SQLiteProvider.js +4 -39
- package/db/provider/ThroughDBProvider.d.ts +0 -143
- package/db/provider/ThroughDBProvider.js +0 -143
- package/db/provider/ValidationDBProvider.d.ts +9 -111
- package/db/provider/ValidationDBProvider.js +9 -111
- package/db/store/ItemStore.d.ts +0 -9
- package/db/store/ItemStore.js +0 -9
- package/db/store/QueryStore.d.ts +0 -9
- package/db/store/QueryStore.js +0 -9
- package/error/BaseError.d.ts +1 -3
- package/error/BaseError.js +1 -3
- package/error/Errors.d.ts +0 -2
- package/error/Errors.js +0 -2
- package/error/NetworkError.d.ts +1 -7
- package/error/NetworkError.js +1 -7
- package/error/RequestError.d.ts +10 -38
- package/error/RequestError.js +6 -38
- package/error/RequiredError.d.ts +1 -7
- package/error/RequiredError.js +1 -7
- package/error/ResponseError.d.ts +5 -8
- package/error/ResponseError.js +1 -8
- package/error/UnexpectedError.d.ts +1 -7
- package/error/UnexpectedError.js +1 -7
- package/error/UnimplementedError.d.ts +1 -7
- package/error/UnimplementedError.js +1 -7
- package/error/ValueError.d.ts +1 -7
- package/error/ValueError.js +1 -7
- package/extract/DirectoryExtractor.d.ts +0 -16
- package/extract/DirectoryExtractor.js +0 -16
- package/extract/IndexExtractor.d.ts +0 -18
- package/extract/IndexExtractor.js +0 -18
- package/extract/MarkupExtractor.d.ts +1 -10
- package/extract/MarkupExtractor.js +1 -10
- package/extract/MergingExtractor.d.ts +0 -18
- package/extract/MergingExtractor.js +0 -18
- package/extract/ModuleExtractor.d.ts +0 -10
- package/extract/ModuleExtractor.js +0 -10
- package/extract/PackageExtractor.d.ts +1 -16
- package/extract/PackageExtractor.js +1 -16
- package/extract/ThroughExtractor.d.ts +0 -6
- package/extract/ThroughExtractor.js +0 -6
- package/extract/TypescriptExtractor.d.ts +1 -11
- package/extract/TypescriptExtractor.js +1 -11
- package/firestore/client/FirestoreClientProvider.d.ts +0 -122
- package/firestore/client/FirestoreClientProvider.js +0 -122
- package/firestore/lite/FirestoreLiteProvider.d.ts +2 -122
- package/firestore/lite/FirestoreLiteProvider.js +2 -122
- package/firestore/server/FirestoreServerProvider.d.ts +4 -122
- package/firestore/server/FirestoreServerProvider.js +4 -122
- package/markup/MarkupParser.d.ts +0 -8
- package/markup/MarkupParser.js +0 -8
- package/package.json +1 -1
- package/react/createAPIContext.d.ts +0 -3
- package/react/createAPIContext.js +0 -3
- package/react/createDBContext.d.ts +0 -3
- package/react/createDBContext.js +0 -3
- package/react/useInstance.d.ts +0 -3
- package/react/useInstance.js +0 -3
- package/react/useLazy.d.ts +0 -3
- package/react/useMap.d.ts +0 -6
- package/react/useMap.js +0 -6
- package/react/useReduce.d.ts +0 -5
- package/react/useSequence.d.ts +0 -3
- package/react/useSequence.js +0 -3
- package/react/useStore.d.ts +0 -5
- package/schema/AddressSchema.d.ts +1 -11
- package/schema/AddressSchema.js +1 -11
- package/schema/ArraySchema.d.ts +2 -34
- package/schema/ArraySchema.js +2 -34
- package/schema/BooleanSchema.d.ts +3 -26
- package/schema/BooleanSchema.js +3 -26
- package/schema/ChoiceSchema.d.ts +1 -15
- package/schema/ChoiceSchema.js +1 -15
- package/schema/ColorSchema.d.ts +1 -14
- package/schema/ColorSchema.js +1 -14
- package/schema/CurrencyAmountSchema.d.ts +2 -19
- package/schema/CurrencyAmountSchema.js +2 -19
- package/schema/CurrencyCodeSchema.d.ts +2 -23
- package/schema/CurrencyCodeSchema.js +2 -23
- package/schema/DataSchema.d.ts +2 -26
- package/schema/DataSchema.js +2 -25
- package/schema/DateSchema.d.ts +2 -20
- package/schema/DateSchema.js +2 -20
- package/schema/DateTimeSchema.d.ts +2 -19
- package/schema/DateTimeSchema.js +2 -19
- package/schema/DictionarySchema.d.ts +2 -20
- package/schema/DictionarySchema.js +2 -20
- package/schema/EmailSchema.d.ts +1 -14
- package/schema/EmailSchema.js +1 -14
- package/schema/EntitySchema.d.ts +1 -12
- package/schema/EntitySchema.js +1 -12
- package/schema/FileSchema.d.ts +1 -12
- package/schema/FileSchema.js +1 -12
- package/schema/KeySchema.d.ts +1 -11
- package/schema/KeySchema.js +1 -11
- package/schema/NullableSchema.d.ts +3 -36
- package/schema/NullableSchema.js +3 -36
- package/schema/NumberSchema.d.ts +12 -60
- package/schema/NumberSchema.js +12 -60
- package/schema/OptionalSchema.d.ts +3 -36
- package/schema/OptionalSchema.js +3 -36
- package/schema/PasswordSchema.d.ts +1 -12
- package/schema/PasswordSchema.js +1 -12
- package/schema/PhoneSchema.d.ts +1 -14
- package/schema/PhoneSchema.js +1 -14
- package/schema/RequiredSchema.d.ts +2 -17
- package/schema/RequiredSchema.js +2 -17
- package/schema/Schema.d.ts +0 -3
- package/schema/Schema.js +0 -3
- package/schema/SlugSchema.d.ts +1 -11
- package/schema/SlugSchema.js +1 -11
- package/schema/StringSchema.d.ts +9 -54
- package/schema/StringSchema.js +9 -54
- package/schema/ThroughSchema.d.ts +1 -11
- package/schema/ThroughSchema.js +1 -11
- package/schema/TimeSchema.d.ts +2 -19
- package/schema/TimeSchema.js +2 -19
- package/schema/URISchema.d.ts +3 -32
- package/schema/URISchema.js +3 -32
- package/schema/URLSchema.d.ts +3 -32
- package/schema/URLSchema.js +3 -32
- package/schema/UUIDSchema.d.ts +1 -11
- package/schema/UUIDSchema.js +1 -11
- package/sequence/DeferredSequence.d.ts +0 -6
- package/sequence/DeferredSequence.js +0 -6
- package/sequence/InspectSequence.d.ts +0 -29
- package/sequence/InspectSequence.js +2 -31
- package/sequence/LazySequence.d.ts +0 -11
- package/sequence/LazySequence.js +0 -11
- package/sequence/Sequence.d.ts +0 -4
- package/sequence/Sequence.js +0 -4
- package/sequence/ThroughSequence.d.ts +0 -8
- package/sequence/ThroughSequence.js +0 -8
- package/store/ArrayStore.d.ts +0 -9
- package/store/ArrayStore.js +0 -9
- package/store/BooleanStore.d.ts +0 -6
- package/store/BooleanStore.js +0 -6
- package/store/BusyStore.d.ts +0 -4
- package/store/BusyStore.js +1 -5
- package/store/DataStore.d.ts +0 -17
- package/store/DataStore.js +0 -17
- package/store/DictionaryStore.d.ts +0 -11
- package/store/DictionaryStore.js +0 -11
- package/store/FetchStore.d.ts +0 -9
- package/store/FetchStore.js +0 -9
- package/store/PathStore.d.ts +0 -15
- package/store/PathStore.js +0 -15
- package/store/PayloadFetchStore.d.ts +0 -7
- package/store/PayloadFetchStore.js +0 -7
- package/store/Store.d.ts +0 -6
- package/store/Store.js +0 -6
- package/store/URLStore.d.ts +0 -18
- package/store/URLStore.js +0 -18
- package/test/util.d.ts +0 -2
- package/test/util.js +0 -2
- package/ui/app/App.d.ts +0 -4
- package/ui/app/App.js +0 -4
- package/ui/app/App.tsx +0 -4
- package/ui/block/Block.d.ts +0 -1
- package/ui/block/Block.js +0 -1
- package/ui/block/Block.tsx +0 -1
- package/ui/block/Card.d.ts +0 -3
- package/ui/block/Card.js +0 -3
- package/ui/block/Card.tsx +0 -3
- package/ui/block/Column.d.ts +0 -2
- package/ui/block/Column.js +0 -2
- package/ui/block/Column.tsx +0 -2
- package/ui/block/Heading.d.ts +0 -2
- package/ui/block/Heading.js +0 -2
- package/ui/block/Heading.tsx +0 -2
- package/ui/block/Image.d.ts +0 -1
- package/ui/block/Image.js +0 -1
- package/ui/block/Image.tsx +0 -1
- package/ui/block/Label.d.ts +0 -1
- package/ui/block/Label.js +0 -1
- package/ui/block/Label.tsx +0 -1
- package/ui/block/List.d.ts +0 -3
- package/ui/block/List.js +0 -3
- package/ui/block/List.tsx +0 -3
- package/ui/block/Panel.d.ts +0 -3
- package/ui/block/Panel.js +0 -3
- package/ui/block/Panel.md +2 -1
- package/ui/block/Panel.tsx +0 -3
- package/ui/block/Paragraph.d.ts +0 -2
- package/ui/block/Paragraph.js +0 -2
- package/ui/block/Paragraph.tsx +0 -2
- package/ui/block/Preformatted.d.ts +0 -1
- package/ui/block/Preformatted.js +0 -1
- package/ui/block/Preformatted.tsx +0 -1
- package/ui/block/Prose.d.ts +0 -2
- package/ui/block/Prose.js +0 -2
- package/ui/block/Prose.md +1 -7
- package/ui/block/Prose.tsx +0 -2
- package/ui/block/Row.d.ts +0 -2
- package/ui/block/Row.js +0 -2
- package/ui/block/Row.tsx +0 -2
- package/ui/block/Section.d.ts +0 -9
- package/ui/block/Section.js +0 -9
- package/ui/block/Section.tsx +0 -9
- package/ui/block/Subheading.d.ts +0 -2
- package/ui/block/Subheading.js +0 -2
- package/ui/block/Subheading.tsx +0 -2
- package/ui/block/Title.d.ts +0 -2
- package/ui/block/Title.js +0 -2
- package/ui/block/Title.tsx +0 -2
- package/ui/block/Video.d.ts +0 -3
- package/ui/block/Video.js +0 -3
- package/ui/block/Video.tsx +0 -3
- package/ui/dialog/Dialog.d.ts +0 -5
- package/ui/dialog/Dialog.js +0 -5
- package/ui/dialog/Dialog.tsx +0 -5
- package/ui/dialog/Dialogs.d.ts +0 -9
- package/ui/dialog/Dialogs.js +0 -9
- package/ui/dialog/Dialogs.tsx +0 -9
- package/ui/dialog/Modal.d.ts +0 -3
- package/ui/dialog/Modal.js +0 -3
- package/ui/dialog/Modal.tsx +0 -3
- package/ui/docs/DocumentationCard.d.ts +0 -2
- package/ui/docs/DocumentationCard.js +0 -2
- package/ui/docs/DocumentationCard.tsx +0 -2
- package/ui/docs/DocumentationDescription.d.ts +0 -1
- package/ui/docs/DocumentationDescription.js +0 -1
- package/ui/docs/DocumentationDescription.tsx +0 -1
- package/ui/docs/DocumentationKind.d.ts +0 -1
- package/ui/docs/DocumentationKind.js +0 -1
- package/ui/docs/DocumentationKind.tsx +0 -1
- package/ui/docs/DocumentationPage.d.ts +0 -2
- package/ui/docs/DocumentationPage.js +0 -2
- package/ui/docs/DocumentationPage.md +1 -1
- package/ui/docs/DocumentationPage.tsx +0 -2
- package/ui/docs/DocumentationParams.d.ts +0 -1
- package/ui/docs/DocumentationParams.js +0 -1
- package/ui/docs/DocumentationParams.tsx +0 -1
- package/ui/docs/DocumentationProperties.d.ts +3 -4
- package/ui/docs/DocumentationProperties.js +3 -4
- package/ui/docs/DocumentationProperties.tsx +3 -4
- package/ui/docs/DocumentationReferences.d.ts +0 -1
- package/ui/docs/DocumentationReferences.js +0 -1
- package/ui/docs/DocumentationReferences.tsx +0 -1
- package/ui/docs/DocumentationReturns.d.ts +0 -1
- package/ui/docs/DocumentationReturns.js +0 -1
- package/ui/docs/DocumentationReturns.tsx +0 -1
- package/ui/docs/DocumentationSearchPage.d.ts +0 -1
- package/ui/docs/DocumentationSearchPage.js +0 -1
- package/ui/docs/DocumentationSearchPage.tsx +0 -1
- package/ui/docs/DocumentationSignatures.d.ts +0 -1
- package/ui/docs/DocumentationSignatures.js +0 -1
- package/ui/docs/DocumentationSignatures.tsx +0 -1
- package/ui/docs/DocumentationThrows.d.ts +0 -1
- package/ui/docs/DocumentationThrows.js +0 -1
- package/ui/docs/DocumentationThrows.tsx +0 -1
- package/ui/docs/DocumentationType.d.ts +2 -3
- package/ui/docs/DocumentationType.js +1 -2
- package/ui/docs/DocumentationType.tsx +2 -3
- package/ui/form/Button.d.ts +0 -3
- package/ui/form/Button.js +0 -3
- package/ui/form/Button.md +1 -1
- package/ui/form/Button.tsx +0 -3
- package/ui/form/Field.md +3 -1
- package/ui/form/Form.d.ts +0 -1
- package/ui/form/Form.md +1 -7
- package/ui/form/Form.tsx +0 -1
- package/ui/form/FormMessage.d.ts +0 -1
- package/ui/form/FormMessage.js +0 -1
- package/ui/form/FormMessage.tsx +0 -1
- package/ui/form/FormNotice.d.ts +0 -1
- package/ui/form/FormNotice.js +0 -1
- package/ui/form/FormNotice.tsx +0 -1
- package/ui/form/FormStore.d.ts +0 -11
- package/ui/form/FormStore.js +0 -11
- package/ui/form/FormStore.tsx +0 -11
- package/ui/form/QueryInput.d.ts +1 -5
- package/ui/form/QueryInput.tsx +1 -5
- package/ui/form/SchemaInput.d.ts +0 -4
- package/ui/form/SchemaInput.js +0 -2
- package/ui/form/SchemaInput.tsx +0 -4
- package/ui/inline/Code.d.ts +0 -2
- package/ui/inline/Code.js +0 -2
- package/ui/inline/Code.tsx +0 -2
- package/ui/inline/Deleted.d.ts +0 -1
- package/ui/inline/Deleted.js +0 -1
- package/ui/inline/Deleted.tsx +0 -1
- package/ui/inline/Emphasis.d.ts +0 -1
- package/ui/inline/Emphasis.js +0 -1
- package/ui/inline/Emphasis.tsx +0 -1
- package/ui/inline/Inserted.d.ts +0 -1
- package/ui/inline/Inserted.js +0 -1
- package/ui/inline/Inserted.tsx +0 -1
- package/ui/inline/Link.d.ts +0 -2
- package/ui/inline/Link.js +0 -2
- package/ui/inline/Link.tsx +0 -2
- package/ui/inline/Mark.d.ts +0 -2
- package/ui/inline/Mark.js +0 -2
- package/ui/inline/Mark.tsx +0 -2
- package/ui/inline/Small.d.ts +0 -1
- package/ui/inline/Small.js +0 -1
- package/ui/inline/Small.tsx +0 -1
- package/ui/inline/Strong.d.ts +0 -2
- package/ui/inline/Strong.js +0 -2
- package/ui/inline/Strong.tsx +0 -2
- package/ui/inline/Subscript.d.ts +0 -1
- package/ui/inline/Subscript.js +0 -1
- package/ui/inline/Subscript.tsx +0 -1
- package/ui/inline/Superscript.d.ts +0 -1
- package/ui/inline/Superscript.js +0 -1
- package/ui/inline/Superscript.tsx +0 -1
- package/ui/inline/When.d.ts +0 -3
- package/ui/inline/When.js +0 -3
- package/ui/inline/When.tsx +0 -3
- package/ui/layout/CenteredLayout.d.ts +4 -4
- package/ui/layout/CenteredLayout.js +0 -4
- package/ui/layout/CenteredLayout.md +2 -2
- package/ui/layout/CenteredLayout.tsx +4 -4
- package/ui/layout/Layout.d.ts +0 -1
- package/ui/layout/Layout.js +0 -1
- package/ui/layout/Layout.ts +0 -1
- package/ui/layout/SidebarLayout.d.ts +0 -6
- package/ui/layout/SidebarLayout.js +0 -6
- package/ui/layout/SidebarLayout.tsx +0 -6
- package/ui/menu/Menu.d.ts +0 -7
- package/ui/menu/Menu.js +0 -7
- package/ui/menu/Menu.tsx +0 -7
- package/ui/misc/Catcher.d.ts +0 -13
- package/ui/misc/Catcher.js +0 -13
- package/ui/misc/Catcher.tsx +0 -13
- package/ui/misc/Icon.d.ts +1 -2
- package/ui/misc/Icon.js +0 -1
- package/ui/misc/Icon.md +3 -3
- package/ui/misc/Icon.tsx +1 -2
- package/ui/misc/Loading.d.ts +0 -3
- package/ui/misc/Loading.js +0 -3
- package/ui/misc/Loading.tsx +0 -3
- package/ui/misc/Mapper.d.ts +0 -13
- package/ui/misc/Mapper.js +0 -13
- package/ui/misc/Mapper.tsx +0 -13
- package/ui/misc/Markup.d.ts +0 -1
- package/ui/misc/Markup.js +0 -1
- package/ui/misc/Markup.tsx +0 -1
- package/ui/misc/Tag.d.ts +0 -3
- package/ui/misc/Tag.js +0 -3
- package/ui/misc/Tag.tsx +0 -3
- package/ui/notice/Message.d.ts +0 -2
- package/ui/notice/Message.js +0 -2
- package/ui/notice/Message.tsx +0 -2
- package/ui/notice/Notice.d.ts +0 -5
- package/ui/notice/Notice.js +0 -5
- package/ui/notice/Notice.tsx +0 -5
- package/ui/notice/NoticeStore.d.ts +0 -7
- package/ui/notice/NoticeStore.js +0 -7
- package/ui/notice/NoticeStore.ts +0 -7
- package/ui/notice/Notices.d.ts +0 -2
- package/ui/notice/Notices.js +0 -2
- package/ui/notice/Notices.tsx +0 -2
- package/ui/page/HTML.d.ts +0 -4
- package/ui/page/HTML.js +0 -4
- package/ui/page/HTML.tsx +0 -4
- package/ui/page/Head.d.ts +0 -2
- package/ui/page/Head.js +0 -2
- package/ui/page/Head.tsx +0 -2
- package/ui/page/Page.d.ts +0 -4
- package/ui/page/Page.js +0 -4
- package/ui/page/Page.tsx +0 -4
- package/ui/router/Navigation.d.ts +0 -4
- package/ui/router/Navigation.js +0 -4
- package/ui/router/Navigation.tsx +0 -4
- package/ui/router/NavigationContext.d.ts +0 -1
- package/ui/router/NavigationContext.js +0 -1
- package/ui/router/NavigationContext.tsx +0 -1
- package/ui/router/NavigationStore.d.ts +0 -7
- package/ui/router/NavigationStore.js +0 -7
- package/ui/router/NavigationStore.tsx +0 -7
- package/ui/router/RouteCache.d.ts +0 -4
- package/ui/router/RouteCache.js +0 -4
- package/ui/router/RouteCache.tsx +0 -4
- package/ui/router/Router.d.ts +0 -5
- package/ui/router/Router.js +0 -5
- package/ui/router/Router.md +2 -22
- package/ui/router/Router.tsx +0 -5
- package/ui/style/Block.d.ts +0 -1
- package/ui/style/Block.js +0 -1
- package/ui/style/Block.tsx +0 -1
- package/ui/style/Color.d.ts +0 -1
- package/ui/style/Color.js +0 -1
- package/ui/style/Color.tsx +0 -1
- package/ui/style/Duration.d.ts +0 -1
- package/ui/style/Duration.js +0 -1
- package/ui/style/Duration.tsx +0 -1
- package/ui/style/Flex.d.ts +0 -1
- package/ui/style/Flex.js +0 -1
- package/ui/style/Flex.tsx +0 -1
- package/ui/style/Gap.d.ts +0 -1
- package/ui/style/Gap.js +0 -1
- package/ui/style/Gap.tsx +0 -1
- package/ui/style/Indent.d.ts +0 -1
- package/ui/style/Indent.js +0 -1
- package/ui/style/Indent.tsx +0 -1
- package/ui/style/Padding.d.ts +0 -1
- package/ui/style/Padding.js +0 -1
- package/ui/style/Padding.tsx +0 -1
- package/ui/style/Radius.d.ts +0 -1
- package/ui/style/Radius.js +0 -1
- package/ui/style/Radius.tsx +0 -1
- package/ui/style/Scroll.d.ts +0 -1
- package/ui/style/Scroll.js +0 -1
- package/ui/style/Scroll.tsx +0 -1
- package/ui/style/Shadow.d.ts +0 -1
- package/ui/style/Shadow.js +0 -1
- package/ui/style/Shadow.tsx +0 -1
- package/ui/style/Space.d.ts +0 -1
- package/ui/style/Space.js +0 -1
- package/ui/style/Space.tsx +0 -1
- package/ui/style/Status.d.ts +0 -1
- package/ui/style/Status.js +0 -1
- package/ui/style/Status.tsx +0 -1
- package/ui/style/Stroke.d.ts +0 -1
- package/ui/style/Stroke.js +0 -1
- package/ui/style/Stroke.tsx +0 -1
- package/ui/style/getRadiusClass.md +1 -1
- package/ui/style/getSpaceClass.md +1 -1
- package/ui/style/getTypographyClass.md +1 -1
- package/ui/style/getWidthClass.md +1 -1
- package/ui/table/Cell.d.ts +0 -2
- package/ui/table/Cell.js +0 -2
- package/ui/table/Cell.tsx +0 -2
- package/ui/table/Table.d.ts +0 -3
- package/ui/table/Table.js +0 -2
- package/ui/table/Table.tsx +0 -3
- package/ui/transition/CollapseTransition.d.ts +0 -2
- package/ui/transition/CollapseTransition.js +0 -2
- package/ui/transition/CollapseTransition.tsx +0 -2
- package/ui/transition/FadeTransition.d.ts +0 -2
- package/ui/transition/FadeTransition.js +0 -2
- package/ui/transition/FadeTransition.tsx +0 -2
- package/ui/transition/HorizontalTransition.d.ts +0 -2
- package/ui/transition/HorizontalTransition.js +0 -2
- package/ui/transition/HorizontalTransition.tsx +0 -2
- package/ui/transition/Transition.d.ts +0 -2
- package/ui/transition/Transition.js +0 -2
- package/ui/transition/Transition.tsx +0 -2
- package/ui/transition/VerticalTransition.d.ts +0 -2
- package/ui/transition/VerticalTransition.js +0 -2
- package/ui/transition/VerticalTransition.tsx +0 -2
- package/ui/tree/TreeApp.d.ts +0 -2
- package/ui/tree/TreeApp.js +0 -2
- package/ui/tree/TreeApp.tsx +0 -2
- package/ui/tree/TreeBreadcrumbs.d.ts +0 -1
- package/ui/tree/TreeBreadcrumbs.js +0 -1
- package/ui/tree/TreeBreadcrumbs.tsx +0 -1
- package/ui/tree/TreeButton.d.ts +0 -1
- package/ui/tree/TreeButton.js +0 -1
- package/ui/tree/TreeButton.tsx +0 -1
- package/ui/tree/TreeCard.d.ts +0 -1
- package/ui/tree/TreeCard.js +0 -1
- package/ui/tree/TreeCard.tsx +0 -1
- package/ui/tree/TreeCards.d.ts +0 -1
- package/ui/tree/TreeCards.js +0 -1
- package/ui/tree/TreeCards.tsx +0 -1
- package/ui/tree/TreeContext.d.ts +0 -2
- package/ui/tree/TreeContext.js +0 -2
- package/ui/tree/TreeContext.tsx +0 -2
- package/ui/tree/TreeLink.d.ts +0 -1
- package/ui/tree/TreeLink.js +0 -1
- package/ui/tree/TreeLink.tsx +0 -1
- package/ui/tree/TreeMarkup.d.ts +0 -1
- package/ui/tree/TreeMarkup.js +0 -1
- package/ui/tree/TreeMarkup.tsx +0 -1
- package/ui/tree/TreeMenu.d.ts +0 -4
- package/ui/tree/TreeMenu.js +0 -4
- package/ui/tree/TreeMenu.tsx +0 -4
- package/ui/tree/TreePage.d.ts +0 -1
- package/ui/tree/TreePage.js +0 -1
- package/ui/tree/TreePage.tsx +0 -1
- package/ui/tree/TreeRouter.d.ts +0 -1
- package/ui/tree/TreeRouter.js +0 -1
- package/ui/tree/TreeRouter.tsx +0 -1
- package/ui/tree/TreeSidebar.d.ts +0 -2
- package/ui/tree/TreeSidebar.js +0 -2
- package/ui/tree/TreeSidebar.md +2 -1
- package/ui/tree/TreeSidebar.tsx +0 -2
- package/ui/util/context.d.ts +0 -1
- package/ui/util/context.ts +0 -1
- package/ui/util/css.d.ts +0 -2
- package/ui/util/css.js +0 -2
- package/ui/util/css.ts +0 -2
- package/ui/util/notice.d.ts +0 -7
- package/ui/util/notice.js +0 -7
- package/ui/util/notice.ts +0 -7
- package/util/ansi.d.ts +0 -1
- package/util/ansi.js +0 -1
- package/util/array.d.ts +0 -70
- package/util/array.js +0 -57
- package/util/async.d.ts +0 -8
- package/util/async.js +0 -7
- package/util/base64.d.ts +0 -6
- package/util/base64.js +0 -6
- package/util/bytes.d.ts +0 -3
- package/util/bytes.js +0 -3
- package/util/class.d.ts +0 -5
- package/util/class.js +0 -5
- package/util/color.d.ts +0 -16
- package/util/color.js +0 -16
- package/util/crypto.d.ts +0 -5
- package/util/crypto.js +0 -5
- package/util/currency.d.ts +0 -8
- package/util/currency.js +0 -8
- package/util/data.d.ts +0 -11
- package/util/data.js +0 -4
- package/util/date.d.ts +0 -18
- package/util/date.js +0 -18
- package/util/debug.d.ts +0 -12
- package/util/debug.js +0 -12
- package/util/dictionary.d.ts +0 -26
- package/util/dictionary.js +0 -24
- package/util/diff.d.ts +0 -7
- package/util/diff.js +0 -2
- package/util/dispose.d.ts +5 -41
- package/util/dispose.js +5 -41
- package/util/duration.d.ts +0 -28
- package/util/duration.js +0 -28
- package/util/element.d.ts +0 -8
- package/util/element.js +0 -6
- package/util/entity.d.ts +0 -3
- package/util/entry.d.ts +0 -5
- package/util/entry.js +0 -4
- package/util/env.d.ts +0 -4
- package/util/env.js +0 -4
- package/util/equal.d.ts +0 -22
- package/util/equal.js +0 -22
- package/util/error.d.ts +0 -7
- package/util/error.js +0 -7
- package/util/file.d.ts +0 -6
- package/util/file.js +0 -6
- package/util/filter.d.ts +0 -3
- package/util/filter.js +0 -3
- package/util/focus.d.ts +0 -1
- package/util/focus.js +0 -1
- package/util/format.d.ts +0 -14
- package/util/format.js +0 -14
- package/util/function.d.ts +0 -3
- package/util/function.js +0 -3
- package/util/geo.d.ts +0 -4
- package/util/geo.js +0 -4
- package/util/hash.d.ts +0 -2
- package/util/hash.js +0 -2
- package/util/http.d.ts +0 -15
- package/util/http.js +0 -15
- package/util/hydrate.d.ts +0 -2
- package/util/hydrate.js +0 -2
- package/util/item.d.ts +0 -4
- package/util/item.js +0 -4
- package/util/iterate.d.ts +0 -11
- package/util/iterate.js +0 -9
- package/util/jwt.d.ts +0 -7
- package/util/jwt.js +0 -7
- package/util/lazy.d.ts +0 -1
- package/util/link.d.ts +0 -5
- package/util/link.js +0 -5
- package/util/log.d.ts +0 -3
- package/util/log.js +0 -3
- package/util/map.d.ts +0 -11
- package/util/map.js +0 -10
- package/util/merge.d.ts +0 -5
- package/util/merge.js +0 -1
- package/util/null.d.ts +0 -3
- package/util/null.js +0 -3
- package/util/number.d.ts +2 -19
- package/util/number.js +2 -19
- package/util/object.d.ts +0 -34
- package/util/object.js +0 -22
- package/util/path.d.ts +0 -15
- package/util/path.js +0 -8
- package/util/query.d.ts +0 -7
- package/util/query.js +0 -7
- package/util/random.d.ts +0 -10
- package/util/random.js +0 -10
- package/util/regexp.d.ts +0 -28
- package/util/regexp.js +0 -18
- package/util/sequence.d.ts +0 -6
- package/util/sequence.js +0 -6
- package/util/serialise.d.ts +0 -1
- package/util/serialise.js +0 -1
- package/util/set.d.ts +0 -7
- package/util/set.js +0 -7
- package/util/sort.d.ts +0 -3
- package/util/sort.js +0 -3
- package/util/source.d.ts +0 -2
- package/util/source.js +0 -2
- package/util/start.d.ts +0 -13
- package/util/start.js +0 -13
- package/util/string.d.ts +0 -13
- package/util/string.js +0 -12
- package/util/timeout.d.ts +0 -14
- package/util/timeout.js +0 -14
- package/util/transform.d.ts +0 -8
- package/util/transform.js +0 -7
- package/util/tree.d.ts +0 -1
- package/util/tree.js +0 -1
- package/util/undefined.d.ts +0 -3
- package/util/undefined.js +0 -3
- package/util/units.d.ts +0 -11
- package/util/units.js +0 -11
- package/util/update.d.ts +1 -3
- package/util/update.js +0 -2
- package/util/uri.d.ts +0 -4
- package/util/uri.js +0 -4
- package/util/url.d.ts +1 -28
- package/util/url.js +0 -27
- package/util/uuid.d.ts +0 -3
- package/util/uuid.js +0 -3
- package/util/validate.d.ts +0 -5
- package/util/validate.js +0 -5
- package/util/xml.d.ts +0 -2
- package/util/xml.js +0 -2
package/api/cache/APICache.d.ts
CHANGED
|
@@ -21,13 +21,6 @@ export declare class APICache<P, R> implements AsyncDisposable {
|
|
|
21
21
|
* @see https://shelving.cc/api/APICache/provider
|
|
22
22
|
*/
|
|
23
23
|
readonly provider: APIProvider<P, R>;
|
|
24
|
-
/**
|
|
25
|
-
* Create a new `APICache` backed by an `APIProvider`.
|
|
26
|
-
*
|
|
27
|
-
* @param provider The `APIProvider` used to fetch results for every cached endpoint.
|
|
28
|
-
* @example new APICache(provider)
|
|
29
|
-
* @see https://shelving.cc/api/APICache
|
|
30
|
-
*/
|
|
31
24
|
constructor(provider: APIProvider<P, R>);
|
|
32
25
|
private _get;
|
|
33
26
|
/**
|
package/api/cache/APICache.js
CHANGED
|
@@ -21,13 +21,6 @@ export class APICache {
|
|
|
21
21
|
* @see https://shelving.cc/api/APICache/provider
|
|
22
22
|
*/
|
|
23
23
|
provider;
|
|
24
|
-
/**
|
|
25
|
-
* Create a new `APICache` backed by an `APIProvider`.
|
|
26
|
-
*
|
|
27
|
-
* @param provider The `APIProvider` used to fetch results for every cached endpoint.
|
|
28
|
-
* @example new APICache(provider)
|
|
29
|
-
* @see https://shelving.cc/api/APICache
|
|
30
|
-
*/
|
|
31
24
|
constructor(provider) {
|
|
32
25
|
this.provider = provider;
|
|
33
26
|
}
|
|
@@ -27,14 +27,6 @@ export declare class EndpointCache<P = unknown, R = unknown> implements AsyncDis
|
|
|
27
27
|
* @see https://shelving.cc/api/EndpointCache/provider
|
|
28
28
|
*/
|
|
29
29
|
readonly provider: APIProvider<P, R>;
|
|
30
|
-
/**
|
|
31
|
-
* Create a new `EndpointCache` for a single endpoint and provider.
|
|
32
|
-
*
|
|
33
|
-
* @param endpoint The endpoint that every cached store fetches from.
|
|
34
|
-
* @param provider The `APIProvider` used to render URLs and fetch results.
|
|
35
|
-
* @example new EndpointCache(getUser, provider)
|
|
36
|
-
* @see https://shelving.cc/api/EndpointCache
|
|
37
|
-
*/
|
|
38
30
|
constructor(endpoint: Endpoint<P, R>, provider: APIProvider<P, R>);
|
|
39
31
|
/**
|
|
40
32
|
* Get (or create) the `EndpointStore` for the given payload.
|
|
@@ -28,14 +28,6 @@ export class EndpointCache {
|
|
|
28
28
|
* @see https://shelving.cc/api/EndpointCache/provider
|
|
29
29
|
*/
|
|
30
30
|
provider;
|
|
31
|
-
/**
|
|
32
|
-
* Create a new `EndpointCache` for a single endpoint and provider.
|
|
33
|
-
*
|
|
34
|
-
* @param endpoint The endpoint that every cached store fetches from.
|
|
35
|
-
* @param provider The `APIProvider` used to render URLs and fetch results.
|
|
36
|
-
* @example new EndpointCache(getUser, provider)
|
|
37
|
-
* @see https://shelving.cc/api/EndpointCache
|
|
38
|
-
*/
|
|
39
31
|
constructor(endpoint, provider) {
|
|
40
32
|
this.endpoint = endpoint;
|
|
41
33
|
this.provider = provider;
|
|
@@ -11,14 +11,7 @@ import type { EndpointCallback, EndpointHandler } from "./util.js";
|
|
|
11
11
|
* - Acts as the contract both ends of an API agree on: providers render requests from it, handlers validate against it.
|
|
12
12
|
* - Path may contain `{placeholder}` segments that are filled from the payload at request time.
|
|
13
13
|
*
|
|
14
|
-
* @
|
|
15
|
-
* @param path Endpoint path, possibly including placeholders e.g. `/users/{id}`
|
|
16
|
-
* @param payload A `Schema` for the payload of the endpoint.
|
|
17
|
-
* @param result A `Schema` for the result of the endpoint.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const getUser = new Endpoint("GET", "/users/{id}", USER_PAYLOAD, USER_RESULT);
|
|
21
|
-
*
|
|
14
|
+
* @example const getUser = new Endpoint("GET", "/users/{id}", USER_PAYLOAD, USER_RESULT);
|
|
22
15
|
* @see https://shelving.cc/api/Endpoint
|
|
23
16
|
*/
|
|
24
17
|
export declare class Endpoint<P = unknown, R = unknown> {
|
package/api/endpoint/Endpoint.js
CHANGED
|
@@ -7,14 +7,7 @@ import { getPlaceholders, matchPathTemplate, renderPathTemplate } from "../../ut
|
|
|
7
7
|
* - Acts as the contract both ends of an API agree on: providers render requests from it, handlers validate against it.
|
|
8
8
|
* - Path may contain `{placeholder}` segments that are filled from the payload at request time.
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @param path Endpoint path, possibly including placeholders e.g. `/users/{id}`
|
|
12
|
-
* @param payload A `Schema` for the payload of the endpoint.
|
|
13
|
-
* @param result A `Schema` for the result of the endpoint.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const getUser = new Endpoint("GET", "/users/{id}", USER_PAYLOAD, USER_RESULT);
|
|
17
|
-
*
|
|
10
|
+
* @example const getUser = new Endpoint("GET", "/users/{id}", USER_PAYLOAD, USER_RESULT);
|
|
18
11
|
* @see https://shelving.cc/api/Endpoint
|
|
19
12
|
*/
|
|
20
13
|
export class Endpoint {
|
|
@@ -6,10 +6,6 @@ import type { Endpoint } from "../endpoint/Endpoint.js";
|
|
|
6
6
|
* - Concrete subclasses implement `renderURL()`, `createRequest()`, `fetch()`, and `parseResponse()`; `call()` orchestrates them.
|
|
7
7
|
* - Implements `AsyncDisposable` so providers can be wrapped and disposed in a chain.
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
10
|
-
* const provider = new ClientAPIProvider({ url: "https://api.example.com" });
|
|
11
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
12
|
-
*
|
|
13
9
|
* @see https://shelving.cc/api/APIProvider
|
|
14
10
|
*/
|
|
15
11
|
export declare abstract class APIProvider<P = unknown, R = unknown> implements AsyncDisposable {
|
|
@@ -83,7 +79,6 @@ export declare abstract class APIProvider<P = unknown, R = unknown> implements A
|
|
|
83
79
|
* @param caller The function to attribute thrown errors to.
|
|
84
80
|
* @returns A promise resolving to the parsed result.
|
|
85
81
|
* @throws {ResponseError} if the response status is non-2xx.
|
|
86
|
-
* @example const user = await provider.call(getUser, { id: "abc" });
|
|
87
82
|
* @see https://shelving.cc/api/APIProvider/call
|
|
88
83
|
*/
|
|
89
84
|
call<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, options?: RequestOptions, caller?: AnyCaller): Promise<RR>;
|
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
* - Concrete subclasses implement `renderURL()`, `createRequest()`, `fetch()`, and `parseResponse()`; `call()` orchestrates them.
|
|
4
4
|
* - Implements `AsyncDisposable` so providers can be wrapped and disposed in a chain.
|
|
5
5
|
*
|
|
6
|
-
* @example
|
|
7
|
-
* const provider = new ClientAPIProvider({ url: "https://api.example.com" });
|
|
8
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
9
|
-
*
|
|
10
6
|
* @see https://shelving.cc/api/APIProvider
|
|
11
7
|
*/
|
|
12
8
|
export class APIProvider {
|
|
@@ -20,7 +16,6 @@ export class APIProvider {
|
|
|
20
16
|
* @param caller The function to attribute thrown errors to.
|
|
21
17
|
* @returns A promise resolving to the parsed result.
|
|
22
18
|
* @throws {ResponseError} if the response status is non-2xx.
|
|
23
|
-
* @example const user = await provider.call(getUser, { id: "abc" });
|
|
24
19
|
* @see https://shelving.cc/api/APIProvider/call
|
|
25
20
|
*/
|
|
26
21
|
async call(endpoint, payload, options, caller) {
|
|
@@ -8,9 +8,6 @@ import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
|
8
8
|
* - On `call(...)`, triggers `cache.refresh(maxAge)` for the endpoint+payload before awaiting `cache.call(...)`.
|
|
9
9
|
* - `invalidate`, `invalidateAll`, `refresh`, and `refreshAll` pass through to the underlying cache and use `this.maxAge` as the default refresh timing.
|
|
10
10
|
*
|
|
11
|
-
* @example
|
|
12
|
-
* const api = new CachedAPIProvider(source);
|
|
13
|
-
* const result = await api.call(endpoint, payload);
|
|
14
11
|
* @see https://shelving.cc/api/CachedAPIProvider
|
|
15
12
|
*/
|
|
16
13
|
export declare class CachedAPIProvider<P, R> extends ThroughAPIProvider<P, R> implements AsyncDisposable {
|
|
@@ -21,32 +18,14 @@ export declare class CachedAPIProvider<P, R> extends ThroughAPIProvider<P, R> im
|
|
|
21
18
|
*/
|
|
22
19
|
readonly maxAge: number | undefined;
|
|
23
20
|
private readonly _cache;
|
|
24
|
-
/**
|
|
25
|
-
* Create a cached provider wrapping a source provider.
|
|
26
|
-
*
|
|
27
|
-
* @param source The source provider whose results are cached.
|
|
28
|
-
* @param maxAge Default maximum age in milliseconds for `call()` (defaults to `AVOID_REFRESH`).
|
|
29
|
-
* @example new CachedAPIProvider(source)
|
|
30
|
-
*/
|
|
31
21
|
constructor(source: APIProvider<P, R>, maxAge?: number);
|
|
32
|
-
/**
|
|
33
|
-
* Call an endpoint through the cache, reusing a cached result where possible instead of fetching fresh.
|
|
34
|
-
*
|
|
35
|
-
* @param endpoint The endpoint to call.
|
|
36
|
-
* @param payload The payload to call the endpoint with.
|
|
37
|
-
* @param _options Request options (unused; the cache key is derived from endpoint and payload).
|
|
38
|
-
* @param caller The calling function used for error stack traces.
|
|
39
|
-
* @returns Promise resolving to the (possibly cached) result.
|
|
40
|
-
* @example await api.call(endpoint, payload)
|
|
41
|
-
* @see https://shelving.cc/api/CachedAPIProvider/call
|
|
42
|
-
*/
|
|
22
|
+
/** Serves the call through the cache, reusing a cached result where possible; request options are ignored as the cache key is derived from `endpoint` and `payload`. */
|
|
43
23
|
call<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, _options?: RequestOptions, caller?: AnyCaller): Promise<RR>;
|
|
44
24
|
/**
|
|
45
25
|
* Invalidate the cached result for a specific endpoint and payload.
|
|
46
26
|
*
|
|
47
27
|
* @param endpoint The endpoint whose cached result should be invalidated.
|
|
48
28
|
* @param payload The payload identifying the cached result.
|
|
49
|
-
* @example api.invalidate(endpoint, payload)
|
|
50
29
|
* @see https://shelving.cc/api/CachedAPIProvider/invalidate
|
|
51
30
|
*/
|
|
52
31
|
invalidate<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP): void;
|
|
@@ -54,7 +33,6 @@ export declare class CachedAPIProvider<P, R> extends ThroughAPIProvider<P, R> im
|
|
|
54
33
|
* Invalidate every cached result for an endpoint, across all payloads.
|
|
55
34
|
*
|
|
56
35
|
* @param endpoint The endpoint whose cached results should be invalidated.
|
|
57
|
-
* @example api.invalidateAll(endpoint)
|
|
58
36
|
* @see https://shelving.cc/api/CachedAPIProvider/invalidateAll
|
|
59
37
|
*/
|
|
60
38
|
invalidateAll<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>): void;
|
|
@@ -63,7 +41,6 @@ export declare class CachedAPIProvider<P, R> extends ThroughAPIProvider<P, R> im
|
|
|
63
41
|
*
|
|
64
42
|
* @param endpoint The endpoint whose cached result should be refreshed.
|
|
65
43
|
* @param payload The payload identifying the cached result.
|
|
66
|
-
* @example api.refresh(endpoint, payload)
|
|
67
44
|
* @see https://shelving.cc/api/CachedAPIProvider/refresh
|
|
68
45
|
*/
|
|
69
46
|
refresh<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP): void;
|
|
@@ -71,7 +48,6 @@ export declare class CachedAPIProvider<P, R> extends ThroughAPIProvider<P, R> im
|
|
|
71
48
|
* Refresh every cached result for an endpoint, across all payloads.
|
|
72
49
|
*
|
|
73
50
|
* @param endpoint The endpoint whose cached results should be refreshed.
|
|
74
|
-
* @example api.refreshAll(endpoint)
|
|
75
51
|
* @see https://shelving.cc/api/CachedAPIProvider/refreshAll
|
|
76
52
|
*/
|
|
77
53
|
refreshAll<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>): void;
|
|
@@ -7,9 +7,6 @@ import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
|
7
7
|
* - On `call(...)`, triggers `cache.refresh(maxAge)` for the endpoint+payload before awaiting `cache.call(...)`.
|
|
8
8
|
* - `invalidate`, `invalidateAll`, `refresh`, and `refreshAll` pass through to the underlying cache and use `this.maxAge` as the default refresh timing.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
11
|
-
* const api = new CachedAPIProvider(source);
|
|
12
|
-
* const result = await api.call(endpoint, payload);
|
|
13
10
|
* @see https://shelving.cc/api/CachedAPIProvider
|
|
14
11
|
*/
|
|
15
12
|
export class CachedAPIProvider extends ThroughAPIProvider {
|
|
@@ -20,29 +17,12 @@ export class CachedAPIProvider extends ThroughAPIProvider {
|
|
|
20
17
|
*/
|
|
21
18
|
maxAge;
|
|
22
19
|
_cache;
|
|
23
|
-
/**
|
|
24
|
-
* Create a cached provider wrapping a source provider.
|
|
25
|
-
*
|
|
26
|
-
* @param source The source provider whose results are cached.
|
|
27
|
-
* @param maxAge Default maximum age in milliseconds for `call()` (defaults to `AVOID_REFRESH`).
|
|
28
|
-
* @example new CachedAPIProvider(source)
|
|
29
|
-
*/
|
|
30
20
|
constructor(source, maxAge = AVOID_REFRESH) {
|
|
31
21
|
super(source);
|
|
32
22
|
this.maxAge = maxAge;
|
|
33
23
|
this._cache = new APICache(source);
|
|
34
24
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Call an endpoint through the cache, reusing a cached result where possible instead of fetching fresh.
|
|
37
|
-
*
|
|
38
|
-
* @param endpoint The endpoint to call.
|
|
39
|
-
* @param payload The payload to call the endpoint with.
|
|
40
|
-
* @param _options Request options (unused; the cache key is derived from endpoint and payload).
|
|
41
|
-
* @param caller The calling function used for error stack traces.
|
|
42
|
-
* @returns Promise resolving to the (possibly cached) result.
|
|
43
|
-
* @example await api.call(endpoint, payload)
|
|
44
|
-
* @see https://shelving.cc/api/CachedAPIProvider/call
|
|
45
|
-
*/
|
|
25
|
+
/** Serves the call through the cache, reusing a cached result where possible; request options are ignored as the cache key is derived from `endpoint` and `payload`. */
|
|
46
26
|
call(endpoint, payload, _options, caller = this.call) {
|
|
47
27
|
return this._cache.call(endpoint, payload, this.maxAge, caller);
|
|
48
28
|
}
|
|
@@ -51,7 +31,6 @@ export class CachedAPIProvider extends ThroughAPIProvider {
|
|
|
51
31
|
*
|
|
52
32
|
* @param endpoint The endpoint whose cached result should be invalidated.
|
|
53
33
|
* @param payload The payload identifying the cached result.
|
|
54
|
-
* @example api.invalidate(endpoint, payload)
|
|
55
34
|
* @see https://shelving.cc/api/CachedAPIProvider/invalidate
|
|
56
35
|
*/
|
|
57
36
|
invalidate(endpoint, payload) {
|
|
@@ -61,7 +40,6 @@ export class CachedAPIProvider extends ThroughAPIProvider {
|
|
|
61
40
|
* Invalidate every cached result for an endpoint, across all payloads.
|
|
62
41
|
*
|
|
63
42
|
* @param endpoint The endpoint whose cached results should be invalidated.
|
|
64
|
-
* @example api.invalidateAll(endpoint)
|
|
65
43
|
* @see https://shelving.cc/api/CachedAPIProvider/invalidateAll
|
|
66
44
|
*/
|
|
67
45
|
invalidateAll(endpoint) {
|
|
@@ -72,7 +50,6 @@ export class CachedAPIProvider extends ThroughAPIProvider {
|
|
|
72
50
|
*
|
|
73
51
|
* @param endpoint The endpoint whose cached result should be refreshed.
|
|
74
52
|
* @param payload The payload identifying the cached result.
|
|
75
|
-
* @example api.refresh(endpoint, payload)
|
|
76
53
|
* @see https://shelving.cc/api/CachedAPIProvider/refresh
|
|
77
54
|
*/
|
|
78
55
|
refresh(endpoint, payload) {
|
|
@@ -82,7 +59,6 @@ export class CachedAPIProvider extends ThroughAPIProvider {
|
|
|
82
59
|
* Refresh every cached result for an endpoint, across all payloads.
|
|
83
60
|
*
|
|
84
61
|
* @param endpoint The endpoint whose cached results should be refreshed.
|
|
85
|
-
* @example api.refreshAll(endpoint)
|
|
86
62
|
* @see https://shelving.cc/api/CachedAPIProvider/refreshAll
|
|
87
63
|
*/
|
|
88
64
|
refreshAll(endpoint) {
|
|
@@ -40,18 +40,9 @@ export interface ClientAPIProviderOptions {
|
|
|
40
40
|
* - Extendable with custom request-building and response-parsing logic by overriding `createRequest()` and `parseResponse()`.
|
|
41
41
|
* - Wrap in `ValidationAPIProvider` to add automatic validation of request payloads and response results against endpoint schemas.
|
|
42
42
|
*
|
|
43
|
-
* @example
|
|
44
|
-
* const provider = new ClientAPIProvider({ url: "https://api.example.com" });
|
|
45
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
46
|
-
*
|
|
47
43
|
* @see https://shelving.cc/api/ClientAPIProvider
|
|
48
44
|
*/
|
|
49
45
|
export declare class ClientAPIProvider<P = unknown, R = unknown> extends APIProvider<P, R> {
|
|
50
|
-
/**
|
|
51
|
-
* The common base URL for all rendered endpoint requests.
|
|
52
|
-
*
|
|
53
|
-
* @see https://shelving.cc/api/ClientAPIProvider/url
|
|
54
|
-
*/
|
|
55
46
|
readonly url: URL;
|
|
56
47
|
/**
|
|
57
48
|
* Default options used for HTTP requests created with `this.createRequest()` and `this.fetch()`
|
|
@@ -65,42 +56,10 @@ export declare class ClientAPIProvider<P = unknown, R = unknown> extends APIProv
|
|
|
65
56
|
* @see https://shelving.cc/api/ClientAPIProvider/timeout
|
|
66
57
|
*/
|
|
67
58
|
readonly timeout: number;
|
|
68
|
-
/**
|
|
69
|
-
* Create a `ClientAPIProvider` from a base URL and request options.
|
|
70
|
-
*
|
|
71
|
-
* @throws {RequiredError} if `url` cannot be resolved to a valid base URL.
|
|
72
|
-
* @example new ClientAPIProvider({ url: "https://api.example.com" })
|
|
73
|
-
* @see https://shelving.cc/api/ClientAPIProvider
|
|
74
|
-
*/
|
|
59
|
+
/** @throws {RequiredError} if `url` cannot be resolved to a valid base URL. */
|
|
75
60
|
constructor({ url, options, timeout }: ClientAPIProviderOptions);
|
|
76
|
-
/**
|
|
77
|
-
* Render the full request URL, appending `?query` params for `HEAD` and `GET` requests.
|
|
78
|
-
*
|
|
79
|
-
* @param endpoint The endpoint whose path is rendered into the base URL.
|
|
80
|
-
* @param payload The payload supplying `{placeholder}` and query-param values.
|
|
81
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
82
|
-
* @returns The fully resolved request `URL`.
|
|
83
|
-
* @throws {RequiredError} if this endpoint's path has `{placeholders}` but `payload` is not a data object.
|
|
84
|
-
* @throws {RequiredError} if this is a `HEAD` or `GET` request but `payload` is not a data object.
|
|
85
|
-
* @example provider.renderURL(getUser, { id: "abc" })
|
|
86
|
-
* @see https://shelving.cc/api/ClientAPIProvider/renderURL
|
|
87
|
-
*/
|
|
88
61
|
renderURL<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, caller?: AnyCaller): URL;
|
|
89
|
-
/**
|
|
90
|
-
* Create a `Request` for an endpoint, rendering payload into the URL or body depending on the method.
|
|
91
|
-
* - `HEAD` and `GET` requests carry their payload as `?query` params; other methods carry it as the body.
|
|
92
|
-
* - Merges `options` over the provider's default options and attaches a timeout `AbortSignal` when `timeout` is set.
|
|
93
|
-
*
|
|
94
|
-
* @param endpoint The endpoint the request targets.
|
|
95
|
-
* @param payload The payload to embed into the `Request`.
|
|
96
|
-
* @param options Per-call `RequestOptions` merged over the provider's defaults.
|
|
97
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
98
|
-
* @returns The created `Request`.
|
|
99
|
-
* @throws {RequiredError} if this endpoint's path has `{placeholders}` but `payload` is not a data object.
|
|
100
|
-
* @throws {RequiredError} if this is a `HEAD` or `GET` request but `payload` is not a data object.
|
|
101
|
-
* @example provider.createRequest(getUser, { id: "abc" })
|
|
102
|
-
* @see https://shelving.cc/api/ClientAPIProvider/createRequest
|
|
103
|
-
*/
|
|
62
|
+
/** Merges `options` over the provider's defaults and attaches a timeout `AbortSignal` when `timeout` is set. */
|
|
104
63
|
createRequest<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, options?: RequestOptions, caller?: AnyCaller): Request;
|
|
105
64
|
/** Internal implementation function for `createRequest()` used for requests that have no body. */
|
|
106
65
|
protected _createHeadRequest(method: RequestHeadMethod, //
|
|
@@ -108,25 +67,8 @@ export declare class ClientAPIProvider<P = unknown, R = unknown> extends APIProv
|
|
|
108
67
|
/** Internal implementation function for `createRequest()` used for requests that have a body. */
|
|
109
68
|
protected _createBodyRequest(method: RequestBodyMethod, //
|
|
110
69
|
url: PossibleURL, payload: P, options: RequestOptions, caller: AnyCaller): Request;
|
|
111
|
-
/**
|
|
112
|
-
* Send the request over the network using the global `fetch()` API.
|
|
113
|
-
*
|
|
114
|
-
* @param request The `Request` to send.
|
|
115
|
-
* @returns A promise resolving to the `Response`.
|
|
116
|
-
* @example await provider.fetch(request)
|
|
117
|
-
* @see https://shelving.cc/api/ClientAPIProvider/fetch
|
|
118
|
-
*/
|
|
70
|
+
/** Sends the request over the network using the global `fetch()` API. */
|
|
119
71
|
fetch(request: Request): Promise<Response>;
|
|
120
|
-
/**
|
|
121
|
-
* Parse a response body into a result, throwing `ResponseError` for non-2xx responses.
|
|
122
|
-
*
|
|
123
|
-
* @param _endpoint The endpoint the response was produced for.
|
|
124
|
-
* @param response The `Response` to parse.
|
|
125
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
126
|
-
* @returns A promise resolving to the parsed result.
|
|
127
|
-
* @throws {ResponseError} if the response status is non-2xx.
|
|
128
|
-
* @example await provider.parseResponse(getUser, response)
|
|
129
|
-
* @see https://shelving.cc/api/ClientAPIProvider/parseResponse
|
|
130
|
-
*/
|
|
72
|
+
/** Parses the response body as JSON. */
|
|
131
73
|
parseResponse<PP extends P, RR extends R>(_endpoint: Endpoint<PP, RR>, response: Response, caller?: AnyCaller): Promise<RR>;
|
|
132
74
|
}
|
|
@@ -14,18 +14,9 @@ import { APIProvider } from "./APIProvider.js";
|
|
|
14
14
|
* - Extendable with custom request-building and response-parsing logic by overriding `createRequest()` and `parseResponse()`.
|
|
15
15
|
* - Wrap in `ValidationAPIProvider` to add automatic validation of request payloads and response results against endpoint schemas.
|
|
16
16
|
*
|
|
17
|
-
* @example
|
|
18
|
-
* const provider = new ClientAPIProvider({ url: "https://api.example.com" });
|
|
19
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
20
|
-
*
|
|
21
17
|
* @see https://shelving.cc/api/ClientAPIProvider
|
|
22
18
|
*/
|
|
23
19
|
export class ClientAPIProvider extends APIProvider {
|
|
24
|
-
/**
|
|
25
|
-
* The common base URL for all rendered endpoint requests.
|
|
26
|
-
*
|
|
27
|
-
* @see https://shelving.cc/api/ClientAPIProvider/url
|
|
28
|
-
*/
|
|
29
20
|
url;
|
|
30
21
|
/**
|
|
31
22
|
* Default options used for HTTP requests created with `this.createRequest()` and `this.fetch()`
|
|
@@ -39,31 +30,13 @@ export class ClientAPIProvider extends APIProvider {
|
|
|
39
30
|
* @see https://shelving.cc/api/ClientAPIProvider/timeout
|
|
40
31
|
*/
|
|
41
32
|
timeout;
|
|
42
|
-
/**
|
|
43
|
-
* Create a `ClientAPIProvider` from a base URL and request options.
|
|
44
|
-
*
|
|
45
|
-
* @throws {RequiredError} if `url` cannot be resolved to a valid base URL.
|
|
46
|
-
* @example new ClientAPIProvider({ url: "https://api.example.com" })
|
|
47
|
-
* @see https://shelving.cc/api/ClientAPIProvider
|
|
48
|
-
*/
|
|
33
|
+
/** @throws {RequiredError} if `url` cannot be resolved to a valid base URL. */
|
|
49
34
|
constructor({ url, options = {}, timeout = 20_000 }) {
|
|
50
35
|
super();
|
|
51
36
|
this.url = requireBaseURL(url, ClientAPIProvider);
|
|
52
37
|
this.options = options;
|
|
53
38
|
this.timeout = timeout;
|
|
54
39
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Render the full request URL, appending `?query` params for `HEAD` and `GET` requests.
|
|
57
|
-
*
|
|
58
|
-
* @param endpoint The endpoint whose path is rendered into the base URL.
|
|
59
|
-
* @param payload The payload supplying `{placeholder}` and query-param values.
|
|
60
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
61
|
-
* @returns The fully resolved request `URL`.
|
|
62
|
-
* @throws {RequiredError} if this endpoint's path has `{placeholders}` but `payload` is not a data object.
|
|
63
|
-
* @throws {RequiredError} if this is a `HEAD` or `GET` request but `payload` is not a data object.
|
|
64
|
-
* @example provider.renderURL(getUser, { id: "abc" })
|
|
65
|
-
* @see https://shelving.cc/api/ClientAPIProvider/renderURL
|
|
66
|
-
*/
|
|
67
40
|
renderURL(endpoint, payload, caller = this.renderURL) {
|
|
68
41
|
// Construct the full URL from `this.url` and the rendered path.
|
|
69
42
|
// Adding the `.` turns the absolute path from `renderPath()` into a relative URL.
|
|
@@ -80,21 +53,7 @@ export class ClientAPIProvider extends APIProvider {
|
|
|
80
53
|
}
|
|
81
54
|
return url;
|
|
82
55
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Create a `Request` for an endpoint, rendering payload into the URL or body depending on the method.
|
|
85
|
-
* - `HEAD` and `GET` requests carry their payload as `?query` params; other methods carry it as the body.
|
|
86
|
-
* - Merges `options` over the provider's default options and attaches a timeout `AbortSignal` when `timeout` is set.
|
|
87
|
-
*
|
|
88
|
-
* @param endpoint The endpoint the request targets.
|
|
89
|
-
* @param payload The payload to embed into the `Request`.
|
|
90
|
-
* @param options Per-call `RequestOptions` merged over the provider's defaults.
|
|
91
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
92
|
-
* @returns The created `Request`.
|
|
93
|
-
* @throws {RequiredError} if this endpoint's path has `{placeholders}` but `payload` is not a data object.
|
|
94
|
-
* @throws {RequiredError} if this is a `HEAD` or `GET` request but `payload` is not a data object.
|
|
95
|
-
* @example provider.createRequest(getUser, { id: "abc" })
|
|
96
|
-
* @see https://shelving.cc/api/ClientAPIProvider/createRequest
|
|
97
|
-
*/
|
|
56
|
+
/** Merges `options` over the provider's defaults and attaches a timeout `AbortSignal` when `timeout` is set. */
|
|
98
57
|
createRequest(endpoint, payload, options, caller = this.createRequest) {
|
|
99
58
|
// Render the path into the base URL.
|
|
100
59
|
const url = this.renderURL(endpoint, payload, caller);
|
|
@@ -119,28 +78,11 @@ export class ClientAPIProvider extends APIProvider {
|
|
|
119
78
|
url, payload, options, caller) {
|
|
120
79
|
return createRequest(method, url, payload, options, caller);
|
|
121
80
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Send the request over the network using the global `fetch()` API.
|
|
124
|
-
*
|
|
125
|
-
* @param request The `Request` to send.
|
|
126
|
-
* @returns A promise resolving to the `Response`.
|
|
127
|
-
* @example await provider.fetch(request)
|
|
128
|
-
* @see https://shelving.cc/api/ClientAPIProvider/fetch
|
|
129
|
-
*/
|
|
81
|
+
/** Sends the request over the network using the global `fetch()` API. */
|
|
130
82
|
async fetch(request) {
|
|
131
83
|
return fetch(request);
|
|
132
84
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Parse a response body into a result, throwing `ResponseError` for non-2xx responses.
|
|
135
|
-
*
|
|
136
|
-
* @param _endpoint The endpoint the response was produced for.
|
|
137
|
-
* @param response The `Response` to parse.
|
|
138
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
139
|
-
* @returns A promise resolving to the parsed result.
|
|
140
|
-
* @throws {ResponseError} if the response status is non-2xx.
|
|
141
|
-
* @example await provider.parseResponse(getUser, response)
|
|
142
|
-
* @see https://shelving.cc/api/ClientAPIProvider/parseResponse
|
|
143
|
-
*/
|
|
85
|
+
/** Parses the response body as JSON. */
|
|
144
86
|
async parseResponse(_endpoint, response, caller = this.parseResponse) {
|
|
145
87
|
const { ok, status } = response;
|
|
146
88
|
const content = await parseResponseBody(response, caller);
|
|
@@ -5,45 +5,13 @@ import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Provider that logs every request, response, and error to the console in detail to help diagnose issues in development.
|
|
7
7
|
*
|
|
8
|
-
* @example
|
|
9
|
-
* const api = new DebugAPIProvider(source);
|
|
10
|
-
* await api.call(endpoint, payload); // logs request, response, and result
|
|
11
8
|
* @see https://shelving.cc/api/DebugAPIProvider
|
|
12
9
|
*/
|
|
13
10
|
export declare class DebugAPIProvider<P, R> extends ThroughAPIProvider<P, R> {
|
|
14
|
-
/**
|
|
15
|
-
* Build a request via the source provider, logging the endpoint and payload (or any error).
|
|
16
|
-
*
|
|
17
|
-
* @param endpoint The endpoint to build a request for.
|
|
18
|
-
* @param payload The payload to send.
|
|
19
|
-
* @param options Optional request options.
|
|
20
|
-
* @param caller The calling function used for error stack traces.
|
|
21
|
-
* @returns The built request.
|
|
22
|
-
* @throws Rethrows any error thrown while building the request (after logging it).
|
|
23
|
-
* @example api.createRequest(endpoint, payload)
|
|
24
|
-
* @see https://shelving.cc/api/DebugAPIProvider/createRequest
|
|
25
|
-
*/
|
|
11
|
+
/** Log the endpoint and payload (or any error) while building the request. */
|
|
26
12
|
createRequest<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, options?: RequestOptions, caller?: AnyCaller): Request;
|
|
27
|
-
/**
|
|
28
|
-
* Fetch a request via the source provider, logging the full request and response (or any error).
|
|
29
|
-
*
|
|
30
|
-
* @param request The request to fetch.
|
|
31
|
-
* @returns Promise resolving to the response.
|
|
32
|
-
* @throws Rethrows any error thrown by the source provider (after logging it).
|
|
33
|
-
* @example await api.fetch(request)
|
|
34
|
-
* @see https://shelving.cc/api/DebugAPIProvider/fetch
|
|
35
|
-
*/
|
|
13
|
+
/** Log the full request and response (or any error) while fetching. */
|
|
36
14
|
fetch(request: Request): Promise<Response>;
|
|
37
|
-
/**
|
|
38
|
-
* Parse a response via the source provider, logging the parsed result (or any error).
|
|
39
|
-
*
|
|
40
|
-
* @param endpoint The endpoint the response came from.
|
|
41
|
-
* @param response The response to parse.
|
|
42
|
-
* @param caller The calling function used for error stack traces.
|
|
43
|
-
* @returns Promise resolving to the parsed result.
|
|
44
|
-
* @throws Rethrows any error thrown while parsing (after logging it).
|
|
45
|
-
* @example await api.parseResponse(endpoint, response)
|
|
46
|
-
* @see https://shelving.cc/api/DebugAPIProvider/parseResponse
|
|
47
|
-
*/
|
|
15
|
+
/** Log the parsed result (or any error) while parsing the response. */
|
|
48
16
|
parseResponse<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, response: Response, caller?: AnyCaller): Promise<RR>;
|
|
49
17
|
}
|
|
@@ -4,24 +4,10 @@ import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Provider that logs every request, response, and error to the console in detail to help diagnose issues in development.
|
|
6
6
|
*
|
|
7
|
-
* @example
|
|
8
|
-
* const api = new DebugAPIProvider(source);
|
|
9
|
-
* await api.call(endpoint, payload); // logs request, response, and result
|
|
10
7
|
* @see https://shelving.cc/api/DebugAPIProvider
|
|
11
8
|
*/
|
|
12
9
|
export class DebugAPIProvider extends ThroughAPIProvider {
|
|
13
|
-
/**
|
|
14
|
-
* Build a request via the source provider, logging the endpoint and payload (or any error).
|
|
15
|
-
*
|
|
16
|
-
* @param endpoint The endpoint to build a request for.
|
|
17
|
-
* @param payload The payload to send.
|
|
18
|
-
* @param options Optional request options.
|
|
19
|
-
* @param caller The calling function used for error stack traces.
|
|
20
|
-
* @returns The built request.
|
|
21
|
-
* @throws Rethrows any error thrown while building the request (after logging it).
|
|
22
|
-
* @example api.createRequest(endpoint, payload)
|
|
23
|
-
* @see https://shelving.cc/api/DebugAPIProvider/createRequest
|
|
24
|
-
*/
|
|
10
|
+
/** Log the endpoint and payload (or any error) while building the request. */
|
|
25
11
|
createRequest(endpoint, payload, options, caller = this.createRequest) {
|
|
26
12
|
try {
|
|
27
13
|
const request = super.createRequest(endpoint, payload, options, caller);
|
|
@@ -33,15 +19,7 @@ export class DebugAPIProvider extends ThroughAPIProvider {
|
|
|
33
19
|
throw reason;
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Fetch a request via the source provider, logging the full request and response (or any error).
|
|
38
|
-
*
|
|
39
|
-
* @param request The request to fetch.
|
|
40
|
-
* @returns Promise resolving to the response.
|
|
41
|
-
* @throws Rethrows any error thrown by the source provider (after logging it).
|
|
42
|
-
* @example await api.fetch(request)
|
|
43
|
-
* @see https://shelving.cc/api/DebugAPIProvider/fetch
|
|
44
|
-
*/
|
|
22
|
+
/** Log the full request and response (or any error) while fetching. */
|
|
45
23
|
async fetch(request) {
|
|
46
24
|
try {
|
|
47
25
|
console.debug(`${ANSI_RIGHT} ${await debugFullRequest(request)}`);
|
|
@@ -54,17 +32,7 @@ export class DebugAPIProvider extends ThroughAPIProvider {
|
|
|
54
32
|
throw reason;
|
|
55
33
|
}
|
|
56
34
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Parse a response via the source provider, logging the parsed result (or any error).
|
|
59
|
-
*
|
|
60
|
-
* @param endpoint The endpoint the response came from.
|
|
61
|
-
* @param response The response to parse.
|
|
62
|
-
* @param caller The calling function used for error stack traces.
|
|
63
|
-
* @returns Promise resolving to the parsed result.
|
|
64
|
-
* @throws Rethrows any error thrown while parsing (after logging it).
|
|
65
|
-
* @example await api.parseResponse(endpoint, response)
|
|
66
|
-
* @see https://shelving.cc/api/DebugAPIProvider/parseResponse
|
|
67
|
-
*/
|
|
35
|
+
/** Log the parsed result (or any error) while parsing the response. */
|
|
68
36
|
async parseResponse(endpoint, response, caller = this.parseResponse) {
|
|
69
37
|
try {
|
|
70
38
|
const result = await super.parseResponse(endpoint, response, caller);
|
|
@@ -7,26 +7,10 @@ import { ClientAPIProvider } from "./ClientAPIProvider.js";
|
|
|
7
7
|
* Client API provider that always sends request bodies as JSON and parses responses as JSON.
|
|
8
8
|
* - Forces JSON encoding regardless of the `Content-Type` the server returns.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
11
|
-
* const provider = new JSONAPIProvider({ url: "https://api.example.com" });
|
|
12
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
13
|
-
*
|
|
14
10
|
* @see https://shelving.cc/api/JSONAPIProvider
|
|
15
11
|
*/
|
|
16
12
|
export declare class JSONAPIProvider<P = unknown, R = unknown> extends ClientAPIProvider<P, R> {
|
|
17
13
|
protected _createBodyRequest(method: RequestBodyMethod, url: PossibleURL, payload: P, options: RequestOptions, caller: AnyCaller): Request;
|
|
18
|
-
/**
|
|
19
|
-
* Parse a JSON `Response` for an endpoint.
|
|
20
|
-
* - Non-2xx responses become `ResponseError`.
|
|
21
|
-
* - JSON is parsed even if the server omitted or mis-set the response content type.
|
|
22
|
-
*
|
|
23
|
-
* @param _endpoint The endpoint the response was produced for.
|
|
24
|
-
* @param response The `Response` to parse as JSON.
|
|
25
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
26
|
-
* @returns A promise resolving to the parsed JSON result.
|
|
27
|
-
* @throws {ResponseError} if the response status is non-2xx.
|
|
28
|
-
* @example await provider.parseResponse(getUser, response)
|
|
29
|
-
* @see https://shelving.cc/api/JSONAPIProvider/parseResponse
|
|
30
|
-
*/
|
|
14
|
+
/** Parse the response body as JSON, even if the server omitted or mis-set the content type. */
|
|
31
15
|
parseResponse<PP extends P, RR extends R>(_endpoint: Endpoint<PP, RR>, response: Response, caller?: AnyCaller): Promise<RR>;
|
|
32
16
|
}
|
|
@@ -6,29 +6,13 @@ import { ClientAPIProvider } from "./ClientAPIProvider.js";
|
|
|
6
6
|
* Client API provider that always sends request bodies as JSON and parses responses as JSON.
|
|
7
7
|
* - Forces JSON encoding regardless of the `Content-Type` the server returns.
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
10
|
-
* const provider = new JSONAPIProvider({ url: "https://api.example.com" });
|
|
11
|
-
* const user = await provider.call(getUser, { id: "abc" });
|
|
12
|
-
*
|
|
13
9
|
* @see https://shelving.cc/api/JSONAPIProvider
|
|
14
10
|
*/
|
|
15
11
|
export class JSONAPIProvider extends ClientAPIProvider {
|
|
16
12
|
_createBodyRequest(method, url, payload, options, caller) {
|
|
17
13
|
return createJSONRequest(method, url, payload, options, caller);
|
|
18
14
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Parse a JSON `Response` for an endpoint.
|
|
21
|
-
* - Non-2xx responses become `ResponseError`.
|
|
22
|
-
* - JSON is parsed even if the server omitted or mis-set the response content type.
|
|
23
|
-
*
|
|
24
|
-
* @param _endpoint The endpoint the response was produced for.
|
|
25
|
-
* @param response The `Response` to parse as JSON.
|
|
26
|
-
* @param caller The function to attribute thrown errors to (defaults to this method).
|
|
27
|
-
* @returns A promise resolving to the parsed JSON result.
|
|
28
|
-
* @throws {ResponseError} if the response status is non-2xx.
|
|
29
|
-
* @example await provider.parseResponse(getUser, response)
|
|
30
|
-
* @see https://shelving.cc/api/JSONAPIProvider/parseResponse
|
|
31
|
-
*/
|
|
15
|
+
/** Parse the response body as JSON, even if the server omitted or mis-set the content type. */
|
|
32
16
|
async parseResponse(_endpoint, response, caller = this.parseResponse) {
|
|
33
17
|
const { ok, status } = response;
|
|
34
18
|
const content = await parseResponseJSON(response, caller);
|