@ethlete/query 5.25.1 → 5.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,12 @@
1
+ import { GQL } from '../../gql';
1
2
  import { QueryClientConfig } from '../http';
2
3
  import { GqlQueryArgs } from './gql-query';
3
4
  import { CreateGqlQueryCreatorOptions } from './gql-query-creator';
4
5
  /** A query creator that creates a GQL query where the payload is sent via GET (query params) */
5
- export declare const createGqlQueryViaGet: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(creatorOptions: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
6
+ export declare const createGqlQueryViaGet: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
6
7
  /** A query creator that creates a GQL query where the payload is sent via POST (body) */
7
- export declare const createGqlQueryViaPost: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(creatorOptions: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
8
+ export declare const createGqlQueryViaPost: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
8
9
  /** A query creator that creates a GQL mutation where the payload is sent via GET (query params) */
9
- export declare const createGqlMutationViaGet: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(creatorOptions: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
10
+ export declare const createGqlMutationViaGet: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
10
11
  /** A query creator that creates a GQL mutation where the payload is sent via POST (body) */
11
- export declare const createGqlMutationViaPost: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(creatorOptions: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
12
+ export declare const createGqlMutationViaPost: (client: QueryClientConfig) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => import("../http").QueryCreator<TArgs>;
@@ -1,7 +1,6 @@
1
1
  import { CreateQueryCreatorOptions, QueryClientConfig, QueryCreator, RouteType } from '../http';
2
2
  import { GqlQueryArgs } from './gql-query';
3
- export type CreateGqlQueryCreatorOptions<TArgs extends GqlQueryArgs> = Omit<CreateQueryCreatorOptions<TArgs>, 'route'> & {
4
- query: string;
3
+ export type CreateGqlQueryCreatorOptions<TArgs extends GqlQueryArgs> = Omit<CreateQueryCreatorOptions, 'route'> & {
5
4
  route?: RouteType<TArgs>;
6
5
  };
7
6
  export type GqlQueryMethod = 'QUERY' | 'MUTATE';
@@ -10,5 +9,6 @@ export type InternalCreateGqlQueryCreatorOptions = {
10
9
  method: GqlQueryMethod;
11
10
  transport: GqlQueryTransport;
12
11
  client: QueryClientConfig;
12
+ query: string;
13
13
  };
14
- export declare const createGqlQueryCreator: <TArgs extends GqlQueryArgs>(options: CreateGqlQueryCreatorOptions<TArgs>, internals: InternalCreateGqlQueryCreatorOptions) => QueryCreator<TArgs>;
14
+ export declare const createGqlQueryCreator: <TArgs extends GqlQueryArgs>(options: CreateGqlQueryCreatorOptions<TArgs> | undefined, internals: InternalCreateGqlQueryCreatorOptions) => QueryCreator<TArgs>;
@@ -4,7 +4,7 @@ import { CreateGqlQueryCreatorOptions, InternalCreateGqlQueryCreatorOptions } fr
4
4
  export type CreateGqlQueryExecuteOptions<TArgs extends QueryArgs> = {
5
5
  deps: QueryDependencies;
6
6
  state: QueryState<TArgs>;
7
- creator: CreateGqlQueryCreatorOptions<TArgs>;
7
+ creator?: CreateGqlQueryCreatorOptions<TArgs>;
8
8
  creatorInternals: InternalCreateGqlQueryCreatorOptions;
9
9
  queryConfig: QueryConfig;
10
10
  };
@@ -4,7 +4,7 @@ export type GqlQueryArgs = QueryArgs & {
4
4
  variables?: Record<string, unknown>;
5
5
  };
6
6
  export type CreateGqlQueryOptions<TArgs extends GqlQueryArgs> = Omit<CreateQueryOptions<TArgs>, 'creator' | 'creatorInternals'> & {
7
- creator: CreateGqlQueryCreatorOptions<TArgs>;
7
+ creator?: CreateGqlQueryCreatorOptions<TArgs>;
8
8
  creatorInternals: InternalCreateGqlQueryCreatorOptions;
9
9
  };
10
10
  export type GqlVariablesType<T extends GqlQueryArgs | null> = T extends GqlQueryArgs ? T['variables'] : never;
@@ -1,24 +1,24 @@
1
1
  import { AnyBearerAuthProviderConfig } from '../auth/bearer-auth-provider-config';
2
2
  import { QueryArgs } from './query';
3
3
  import { QueryClientConfig } from './query-client-config';
4
- import { CreateQueryCreatorOptions } from './query-creator';
4
+ import { CreateQueryCreatorOptions, RouteType } from './query-creator';
5
5
  /** A query creator that creates a GET query */
6
- export declare const createGetQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
6
+ export declare const createGetQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
7
7
  /** A query creator that creates a secure GET query (requires authentication) */
8
- export declare const createSecureGetQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
8
+ export declare const createSecureGetQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
9
9
  /** A query creator that creates a POST query */
10
- export declare const createPostQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
10
+ export declare const createPostQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
11
11
  /** A query creator that creates a secure POST query (requires authentication) */
12
- export declare const createSecurePostQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
12
+ export declare const createSecurePostQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
13
13
  /** A query creator that creates a PUT query */
14
- export declare const createPutQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
14
+ export declare const createPutQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
15
15
  /** A query creator that creates a secure PUT query (requires authentication) */
16
- export declare const createSecurePutQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
16
+ export declare const createSecurePutQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
17
17
  /** A query creator that creates a DELETE query */
18
- export declare const createDeleteQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
18
+ export declare const createDeleteQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
19
19
  /** A query creator that creates a secure DELETE query (requires authentication) */
20
- export declare const createSecureDeleteQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
20
+ export declare const createSecureDeleteQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
21
21
  /** A query creator that creates a PATCH query */
22
- export declare const createPatchQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
22
+ export declare const createPatchQuery: (client: QueryClientConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
23
23
  /** A query creator that creates a secure PATCH query (requires authentication) */
24
- export declare const createSecurePatchQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(creatorOptions: CreateQueryCreatorOptions<TArgs>) => import("./query-creator").QueryCreator<TArgs>;
24
+ export declare const createSecurePatchQuery: (client: QueryClientConfig, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => import("./query-creator").QueryCreator<TArgs>;
@@ -6,13 +6,7 @@ export type RouteType<TArgs extends QueryArgs> = PathParamsType<TArgs> extends {
6
6
  [key: string]: unknown;
7
7
  } ? (args: TArgs['pathParams']) => RouteString : RouteString;
8
8
  export type RouteString = `/${string}`;
9
- export type CreateQueryCreatorOptions<TArgs extends QueryArgs> = {
10
- /**
11
- * The route of the query.
12
- * If the query has path params, the route should be a function that takes the path params as an argument.
13
- * Otherwise, it should be a string.
14
- */
15
- route: RouteType<TArgs>;
9
+ export type CreateQueryCreatorOptions = {
16
10
  /**
17
11
  * If true, the query loading state will include progress information.
18
12
  * This is useful for file uploads and downloads.
@@ -53,7 +47,13 @@ export type AnyQueryCreator = QueryCreator<any>;
53
47
  export type QueryArgsOf<T extends AnyQueryCreator | AnyQuery> = T extends QueryCreator<infer TArgs> ? TArgs : T extends Query<infer TArgs> ? TArgs : never;
54
48
  export type RunQueryCreator<TCreator extends AnyQueryCreator> = ReturnType<TCreator>;
55
49
  export type QueryMethod = 'GET' | 'OPTIONS' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'TRACE' | 'CONNECT';
56
- export type InternalCreateQueryCreatorOptions = {
50
+ export type InternalCreateQueryCreatorOptions<TArgs extends QueryArgs> = {
51
+ /**
52
+ * The route of the query.
53
+ * If the query has path params, the route should be a function that takes the path params as an argument.
54
+ * Otherwise, it should be a string.
55
+ */
56
+ route: RouteType<TArgs>;
57
57
  method: QueryMethod;
58
58
  client: QueryClientConfig;
59
59
  };
@@ -70,4 +70,4 @@ export declare const splitQueryConfig: <TArgs extends QueryArgs>(args: (QueryFea
70
70
  features: QueryFeature<TArgs>[];
71
71
  queryConfig: QueryConfig;
72
72
  };
73
- export declare const createQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions<TArgs>, internals: InternalCreateQueryCreatorOptions) => QueryCreator<TArgs>;
73
+ export declare const createQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions | undefined, internals: InternalCreateQueryCreatorOptions<TArgs>) => QueryCreator<TArgs>;
@@ -8,8 +8,8 @@ import { QueryState } from './query-state';
8
8
  export type CreateQueryExecuteOptions<TArgs extends QueryArgs> = {
9
9
  deps: QueryDependencies;
10
10
  state: QueryState<TArgs>;
11
- creator: CreateQueryCreatorOptions<TArgs>;
12
- creatorInternals: InternalCreateQueryCreatorOptions;
11
+ creator?: CreateQueryCreatorOptions;
12
+ creatorInternals: InternalCreateQueryCreatorOptions<TArgs>;
13
13
  queryConfig: QueryConfig;
14
14
  };
15
15
  export type QueryExecuteArgs<TArgs extends QueryArgs> = {
@@ -17,8 +17,8 @@ export type QueryParamsType<T extends QueryArgs | null> = T extends QueryArgs ?
17
17
  export type BodyType<T extends QueryArgs | null> = T extends QueryArgs ? T['body'] : never;
18
18
  export type RequestArgs<T extends QueryArgs | null> = T extends QueryArgs ? Omit<T, 'response'> : never;
19
19
  export type CreateQueryOptions<TArgs extends QueryArgs> = {
20
- creator: CreateQueryCreatorOptions<TArgs>;
21
- creatorInternals: InternalCreateQueryCreatorOptions;
20
+ creator?: CreateQueryCreatorOptions;
21
+ creatorInternals: InternalCreateQueryCreatorOptions<TArgs>;
22
22
  features: QueryFeature<TArgs>[];
23
23
  queryConfig: QueryConfig;
24
24
  };
@@ -1,7 +1,7 @@
1
1
  import { AnyBearerAuthProviderConfig } from '../auth/bearer-auth-provider-config';
2
2
  import { QueryArgs } from './query';
3
3
  import { CreateQueryCreatorOptions, InternalCreateQueryCreatorOptions, QueryCreator } from './query-creator';
4
- export type InternalSecureCreateQueryCreatorOptions = InternalCreateQueryCreatorOptions & {
4
+ export type InternalSecureCreateQueryCreatorOptions<TArgs extends QueryArgs> = InternalCreateQueryCreatorOptions<TArgs> & {
5
5
  authProvider: AnyBearerAuthProviderConfig;
6
6
  };
7
- export declare const createSecureQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions<TArgs>, internals: InternalSecureCreateQueryCreatorOptions) => QueryCreator<TArgs>;
7
+ export declare const createSecureQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions | undefined, internals: InternalSecureCreateQueryCreatorOptions<TArgs>) => QueryCreator<TArgs>;
@@ -2,6 +2,6 @@ import { QueryArgs } from './query';
2
2
  import { CreateQueryExecuteOptions, InternalQueryExecute } from './query-execute';
3
3
  import { InternalSecureCreateQueryCreatorOptions } from './secure-query-creator';
4
4
  export type CreateSecureQueryExecuteOptions<TArgs extends QueryArgs> = Omit<CreateQueryExecuteOptions<TArgs>, 'creatorInternals'> & {
5
- creatorInternals: InternalSecureCreateQueryCreatorOptions;
5
+ creatorInternals: InternalSecureCreateQueryCreatorOptions<TArgs>;
6
6
  };
7
7
  export declare const createSecureExecuteFn: <TArgs extends QueryArgs>(options: CreateSecureQueryExecuteOptions<TArgs>) => InternalQueryExecute<TArgs>;
@@ -1,6 +1,6 @@
1
1
  import { CreateQueryOptions, QueryArgs } from './query';
2
2
  import { InternalSecureCreateQueryCreatorOptions } from './secure-query-creator';
3
3
  export type CreateSecureQueryOptions<TArgs extends QueryArgs> = Omit<CreateQueryOptions<TArgs>, 'creatorInternals'> & {
4
- creatorInternals: InternalSecureCreateQueryCreatorOptions;
4
+ creatorInternals: InternalSecureCreateQueryCreatorOptions<TArgs>;
5
5
  };
6
6
  export declare const createSecureQuery: <TArgs extends QueryArgs>(options: CreateSecureQueryOptions<TArgs>) => import("./query").Query<TArgs>;
package/lib/gql/gql.d.ts CHANGED
@@ -4,4 +4,7 @@ export type TransformedGqlQuery = {
4
4
  operationName?: string;
5
5
  };
6
6
  export declare const transformGql: (str: string) => (variables: Record<string, unknown> | null | undefined) => TransformedGqlQuery;
7
- export declare const gql: (strings: TemplateStringsArray, ...values: string[]) => string;
7
+ export type GQL = string & {
8
+ gql: 'tag';
9
+ };
10
+ export declare const gql: (strings: TemplateStringsArray, ...values: string[]) => GQL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethlete/query",
3
- "version": "5.25.1",
3
+ "version": "5.26.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@angular/common": "19.1.4",