Skip to main content

@krakentech/blueprint-api

3.4.1

Patch Changes

  • 2567a7c: New bundling strategy for better performance

    • Unbundle mode Packages are now bundled using tsdown's unbundle mode. This mode drastically reduces the number of generated file compared to the glob-filtered entries we used before, and prevented proper tree-shaking.

    • Automatic package.json exports tsdown is now responsible for generating the package.json exports, main, module, and types fields. This ensures packages follow best practices.

3.4.0

Minor Changes

  • 87323b6: SessionState: add isScopedSession "flag"

    type SessionState = {
    isAuthenticated: boolean;
    isMasquerading: boolean;
    isMobileWebView: boolean;
    + isScopedSession: boolean;
    sub: string | null;
    };

3.3.0

Minor Changes

  • 7dc77b4: Expose toAbsoluteUrl. This function converts a relative URL to an absolute URL based on the current environment.

3.2.1

Patch Changes

  • e4dc37d: Export graphqlRequest types in blueprint-api package

3.2.0

Minor Changes

  • 12e020f: 🎉 Release new package: Dashboard

    Added

    • New @blueprint/dashboard package - A comprehensive dashboard solution for Blueprint applications
    • API Access Feature - Integrated API access functionality within user accounts
      • Users can now manage API credentials directly from their dashboard
      • Secure API key generation and management interface
      • Real-time API usage monitoring and analytics

    Features

    • Account management with API access controls

    Dependencies

    • Leverages @blueprint/api types for consistent data handling Seamless integration with existing Blueprint ecosystem

    Note: This is the initial release of the dashboard package. Future releases will look to migrate existing core dashboard functionality.

    Breaking Changes: None (new package)

    Migration: No migration required for existing Blueprint users. The dashboard packages api-access feature can be optionally integrated into existing applications.

Patch Changes

  • 72176a1: Export splitOptions from api package

3.1.0

Minor Changes

  • 8982f0f: Added a new React hook for calling custom API routes with React Query integration. Note that this is for mutation only

    • Provides a streamlined way to make HTTP requests to custom API endpoints (GET, POST, PUT, DELETE, PATCH)

    • Built on top of React Query's useMutation for state management and caching

    • Includes automatic error handling through the existing Kraken error system

    • Supports TypeScript generics for type-safe request/response handling

    • Configurable HTTP methods (defaults to POST)

    • Custom headers support

    • JSON request/response handling

    • Built-in error handling via handleKrakenErrors

    • No retry by default (suitable for mutations)

    The endpoint parameter should match your custom API route path. For example, if you create a file at pages/api/org/initialize-user.ts, your endpoint would be /api/org/initialize-user.

    import { useApiRouteMutation } from '@krakentech/blueprint-api/client';

    // Define your types
    interface MyResponse {
    success: boolean;
    data: { id: string; name: string };
    }

    interface MyVariables {
    userId: string;
    settings: { theme: string };
    }

    // Create the mutation hook
    const useMyCustomMutation = () => {
    return useApiRouteMutation<MyResponse, ApiRouteMutationError, MyVariables>({
    endpoint: '/api/my-custom-route', // Must match your API file path
    method: 'POST', // Optional, defaults to POST
    mutationKey: ['myCustomMutation'], // Optional, for React Query caching
    onSuccess: (data) => { // Optional
    // Do something with data
    },
    onError: (error) => { // Optional
    // Do something with error
    }
    });
    };


    • API file: pages/api/users/profile.ts → endpoint: /api/users/profile
    • API file: pages/api/settings.ts → endpoint: /api/settings
    • API file: pages/api/org/initialize-user.ts → endpoint: /api/org/initialize-user

3.0.1

Patch Changes

  • bf089bc: Use QueryKey type from @tanstack/react-query for every operation.

    Previously, we were using the string[] type for query keys, which is not compatible with the QueryKey type from react-query. This change ensures that all query keys are now typed correctly, improving type safety and consistency with the library.

3.0.0

Major Changes

  • bad97b4: Bump graphql-request from ^6.1.0 to ^7.2.0

2.0.0

Major Changes

  • 6ed7c25: Changes how the api hooks prop types are defined to provide greater type inference and type safety. Does require updating all usage of these hooks to change the query/mutation prop to be called document (same value). The rest of the props remain the same.

1.2.1

Patch Changes

  • 8f195fc: Set files: ["dist"]

1.2.0

Minor Changes

  • 0401bcc: Add optional graphqlClient prop to ApiProvider to allow the consumer to pass a custom GraphQL client instance. This is useful for scenarios where the consumer needs to use a specific client configuration or instance.

1.1.0

Minor Changes

  • 9926ab8: Removes gql.tada's TadaDocumentType when defining query/mutation prop types in the API hooks (to remove this dependency) and adds a new all-purpose TypedDocumentNode type (taken from @graphql-typed-document-node/core) to represent both gql.tada and GraphQL Codegens typed document nodes. This enables support for both types of document nodes in the API hooks.

1.0.0

Major Changes

  • 507d46c: Move all client-side code into a dedicated /client submodule.

0.8.0

Minor Changes

  • 639224c: useApi().graphqlClient: ensure the url to which the request is being made is a full url, with protocol and base, even when the apiRoute passed to the ApiProvider is a relative path. This is a requirement when using graphql-request v7+.

0.7.0

Minor Changes

  • 6343863: Turn the package into an ES Module. This includes:

    • Adding "type": "module" to the package.json
    • Updating the exports field to include both ESM and CommonJS versions
    • Ensuring all imports and exports are compatible with ESM

    It shouldn't break any existing functionality, as the CommonJS version is still available for compatibility.

0.6.1

Patch Changes

  • 971dd01: # Enable tree-shaking of blueprint packages

    The blueprint packages are now code-split and tagged as side-effect free. Bundlers such as Webpack are able to perform tree-shaking and only include necessary code in application bundles.

0.6.0

Minor Changes

  • d580b2f: APIProvider: update the sessionState type so that it matches the useSession.data return type of the @krakentech/blueprint-auth > v25.0.0.

0.5.1

Patch Changes

  • 3c29cde: Create tsup.config file and mark react/react-dom as externals

0.5.0

Minor Changes

  • ebf8ae7: Add Kraken hooks: useKrakenQuery, useInfiniteKrakenQuery and useKrakenMutation. Consumers now need to wrap their app with an ApiProvider to use these hooks.

0.4.0

Minor Changes

  • 66a8c3f: Add getErrorCode function

0.3.0

Minor Changes

  • 8bda073: Add setErrorSearchParam helper

0.2.0

Minor Changes

  • a0bd6b8: Add more errors to the errorTypeToCodeMap

0.1.0

Minor Changes

  • c5c0279: Add kraken api error related utils