@asteroidcms/core-utils 0.1.2 → 0.1.3
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/dist/client.cjs +1466 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +229 -0
- package/dist/client.d.ts +229 -0
- package/dist/client.js +1455 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +1 -747
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -182
- package/dist/index.d.ts +1 -182
- package/dist/index.js +2 -738
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
import * as _apollo_client from '@apollo/client';
|
|
5
1
|
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient, DocumentNode } from '@apollo/client';
|
|
6
|
-
import { useMutation } from '@apollo/client/react';
|
|
7
2
|
|
|
8
3
|
type AsteroidCMSConfig = {
|
|
9
4
|
/** Base URL of the Asteroid CMS API (e.g. https://cms-api.example.com). */
|
|
@@ -30,25 +25,6 @@ type ResolvedAsteroidCMSConfig = Required<Pick<AsteroidCMSConfig, "cmsUrl" | "ap
|
|
|
30
25
|
onError?: AsteroidCMSConfig["onError"];
|
|
31
26
|
};
|
|
32
27
|
|
|
33
|
-
type AsteroidCMSProviderProps = PropsWithChildren<AsteroidCMSConfig>;
|
|
34
|
-
/**
|
|
35
|
-
* Root provider for `@asteroidcms/core-utils`.
|
|
36
|
-
*
|
|
37
|
-
* Wrap your app once at the top level:
|
|
38
|
-
*
|
|
39
|
-
* ```tsx
|
|
40
|
-
* <AsteroidCMSProvider cmsUrl="https://cms.example.com" apiKey="...">
|
|
41
|
-
* <App />
|
|
42
|
-
* </AsteroidCMSProvider>
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* Everything below — `useCmsContent`, `useCmsMutate`, `useCmsImage`,
|
|
46
|
-
* `<RichTextContent>` — picks up `cmsUrl` and `apiKey` from this provider.
|
|
47
|
-
*/
|
|
48
|
-
declare function AsteroidCMSProvider({ children, ...config }: AsteroidCMSProviderProps): react_jsx_runtime.JSX.Element;
|
|
49
|
-
|
|
50
|
-
declare function useAsteroidCMSConfig(): ResolvedAsteroidCMSConfig;
|
|
51
|
-
|
|
52
28
|
declare module "@apollo/client" {
|
|
53
29
|
namespace ApolloClient.DeclareDefaultOptions {
|
|
54
30
|
interface WatchQuery {
|
|
@@ -65,146 +41,6 @@ declare module "@apollo/client" {
|
|
|
65
41
|
}
|
|
66
42
|
declare function createApolloClient(config: AsteroidCMSConfig): ApolloClient;
|
|
67
43
|
|
|
68
|
-
type FieldSelector$2 = string | {
|
|
69
|
-
field: string;
|
|
70
|
-
as?: string;
|
|
71
|
-
};
|
|
72
|
-
type ReferenceExpansion$2 = {
|
|
73
|
-
field: string;
|
|
74
|
-
as?: string;
|
|
75
|
-
single?: boolean;
|
|
76
|
-
select?: readonly (FieldSelector$2 | ReferenceExpansion$2)[];
|
|
77
|
-
};
|
|
78
|
-
type ContentStatus$1 = "DRAFT" | "PUBLISHED" | "ARCHIVED";
|
|
79
|
-
type CmsSearchCondition$1 = {
|
|
80
|
-
field: string;
|
|
81
|
-
value: string;
|
|
82
|
-
mode?: string;
|
|
83
|
-
};
|
|
84
|
-
type UseCmsContentOptions$1 = {
|
|
85
|
-
schema_slug: string;
|
|
86
|
-
entrySlug?: string;
|
|
87
|
-
select?: readonly (FieldSelector$2 | ReferenceExpansion$2)[];
|
|
88
|
-
fullData?: boolean;
|
|
89
|
-
limit?: number;
|
|
90
|
-
offset?: number;
|
|
91
|
-
status?: ContentStatus$1;
|
|
92
|
-
filter?: Record<string, string | number | boolean | null>;
|
|
93
|
-
search?: CmsSearchCondition$1[];
|
|
94
|
-
variables?: Record<string, any>;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* React hook for querying content from Asteroid CMS via a flexible GraphQL API.
|
|
98
|
-
*
|
|
99
|
-
* Supports single-entry fetches (`entrySlug`) and paginated/filtered lists,
|
|
100
|
-
* with arbitrarily nested reference expansion and field aliasing.
|
|
101
|
-
*/
|
|
102
|
-
declare function useCmsContent<T = unknown>({ schema_slug, entrySlug, select, fullData, limit, offset, status, filter, search, variables, }: UseCmsContentOptions$1): {
|
|
103
|
-
client: _apollo_client.ApolloClient;
|
|
104
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
105
|
-
previousData?: unknown;
|
|
106
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
107
|
-
startPolling: (pollInterval: number) => void;
|
|
108
|
-
stopPolling: () => void;
|
|
109
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
110
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
111
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
112
|
-
data: unknown;
|
|
113
|
-
error?: _apollo_client.ErrorLike;
|
|
114
|
-
}>;
|
|
115
|
-
variables: _apollo_client.OperationVariables;
|
|
116
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
117
|
-
data: TFetchData | undefined;
|
|
118
|
-
error?: _apollo_client.ErrorLike;
|
|
119
|
-
}>;
|
|
120
|
-
dataState: "empty";
|
|
121
|
-
loading: boolean;
|
|
122
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
123
|
-
data: T | undefined;
|
|
124
|
-
} | {
|
|
125
|
-
client: _apollo_client.ApolloClient;
|
|
126
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
127
|
-
previousData?: unknown;
|
|
128
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
129
|
-
startPolling: (pollInterval: number) => void;
|
|
130
|
-
stopPolling: () => void;
|
|
131
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
132
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
133
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
134
|
-
data: unknown;
|
|
135
|
-
error?: _apollo_client.ErrorLike;
|
|
136
|
-
}>;
|
|
137
|
-
variables: _apollo_client.OperationVariables;
|
|
138
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
139
|
-
data: TFetchData | undefined;
|
|
140
|
-
error?: _apollo_client.ErrorLike;
|
|
141
|
-
}>;
|
|
142
|
-
dataState: "complete";
|
|
143
|
-
loading: boolean;
|
|
144
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
145
|
-
data: T | undefined;
|
|
146
|
-
} | {
|
|
147
|
-
client: _apollo_client.ApolloClient;
|
|
148
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
149
|
-
previousData?: unknown;
|
|
150
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
151
|
-
startPolling: (pollInterval: number) => void;
|
|
152
|
-
stopPolling: () => void;
|
|
153
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
154
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
155
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
156
|
-
data: unknown;
|
|
157
|
-
error?: _apollo_client.ErrorLike;
|
|
158
|
-
}>;
|
|
159
|
-
variables: _apollo_client.OperationVariables;
|
|
160
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
161
|
-
data: TFetchData | undefined;
|
|
162
|
-
error?: _apollo_client.ErrorLike;
|
|
163
|
-
}>;
|
|
164
|
-
dataState: "streaming";
|
|
165
|
-
loading: boolean;
|
|
166
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
167
|
-
data: T | undefined;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
type FieldSelector$1 = string | {
|
|
171
|
-
field: string;
|
|
172
|
-
as?: string;
|
|
173
|
-
single?: boolean;
|
|
174
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
175
|
-
};
|
|
176
|
-
type ReferenceExpansion$1 = {
|
|
177
|
-
field: string;
|
|
178
|
-
as?: string;
|
|
179
|
-
single?: boolean;
|
|
180
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
181
|
-
};
|
|
182
|
-
type MutationType = "create" | "update" | "delete";
|
|
183
|
-
type UseCmsMutateOptions = {
|
|
184
|
-
schema_slug: string;
|
|
185
|
-
entrySlug?: string;
|
|
186
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
187
|
-
fullData?: boolean;
|
|
188
|
-
mutationType?: MutationType;
|
|
189
|
-
entryId?: string;
|
|
190
|
-
variables?: Record<string, any>;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* React hook for mutating content in Asteroid CMS (`create` / `update` / `delete`).
|
|
194
|
-
* Uses the same selection syntax as `useCmsContent`.
|
|
195
|
-
*/
|
|
196
|
-
declare function useCmsMutate<TData = unknown>({ schema_slug, select, fullData, mutationType, entryId, variables: inputVariables, }: UseCmsMutateOptions): {
|
|
197
|
-
readonly data: TData | undefined;
|
|
198
|
-
readonly loading: boolean;
|
|
199
|
-
readonly called: boolean;
|
|
200
|
-
readonly client: _apollo_client.ApolloClient;
|
|
201
|
-
readonly reset: () => void;
|
|
202
|
-
readonly error: _apollo_client.ErrorLike | undefined;
|
|
203
|
-
readonly mutate: useMutation.MutationFunction<unknown, {
|
|
204
|
-
[x: string]: any;
|
|
205
|
-
}, _apollo_client.ApolloCache, "none">;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
44
|
type FieldSelector = string | {
|
|
209
45
|
field: string;
|
|
210
46
|
as?: string;
|
|
@@ -250,8 +86,6 @@ declare function cmsImage(id: string | undefined, options: {
|
|
|
250
86
|
cmsUrl: string;
|
|
251
87
|
mediaPath?: string;
|
|
252
88
|
}): string;
|
|
253
|
-
/** Hook variant that pulls `cmsUrl`/`mediaPath` from the provider. */
|
|
254
|
-
declare function useCmsImage(): (id?: string) => string;
|
|
255
89
|
|
|
256
90
|
type ReadTimeUnit = "short" | "long";
|
|
257
91
|
interface GetContentReadTimeOptions {
|
|
@@ -316,19 +150,4 @@ declare function parseRichText(html: string, options?: ParseRichTextOptions): st
|
|
|
316
150
|
*/
|
|
317
151
|
declare function removeEmptyParagraphs(html: string): string;
|
|
318
152
|
|
|
319
|
-
|
|
320
|
-
html: string;
|
|
321
|
-
classMap?: RichTextClassMap;
|
|
322
|
-
/** Wrapper element. Defaults to `div`. Use `article` for blog content. */
|
|
323
|
-
as?: keyof React.JSX.IntrinsicElements;
|
|
324
|
-
className?: string;
|
|
325
|
-
}
|
|
326
|
-
declare function RichTextContent({ html, classMap, as, className, }: RichTextContentProps): react.DOMElement<{
|
|
327
|
-
ref: react.MutableRefObject<HTMLElement | null>;
|
|
328
|
-
className: string | undefined;
|
|
329
|
-
dangerouslySetInnerHTML: {
|
|
330
|
-
__html: string;
|
|
331
|
-
};
|
|
332
|
-
}, HTMLElement>;
|
|
333
|
-
|
|
334
|
-
export { type AsteroidCMSConfig, AsteroidCMSProvider, type AsteroidCMSProviderProps, type CmsSearchCondition, type ContentStatus, type FieldSelector, type ParseRichTextOptions, type ReferenceExpansion, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, RichTextContent, type UseCmsContentOptions$1 as UseCmsContentOptions, type UseCmsMutateOptions, buildCmsQuery, cmsImage, createApolloClient, fetchCmsContent, getContentReadTime, parseRichText, removeEmptyParagraphs, useAsteroidCMSConfig, useCmsContent, useCmsImage, useCmsMutate };
|
|
153
|
+
export { type AsteroidCMSConfig, type CmsSearchCondition, type ContentStatus, type FieldSelector, type ParseRichTextOptions, type ReferenceExpansion, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, type UseCmsContentOptions, buildCmsQuery, cmsImage, createApolloClient, fetchCmsContent, getContentReadTime, parseRichText, removeEmptyParagraphs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
import * as _apollo_client from '@apollo/client';
|
|
5
1
|
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient, DocumentNode } from '@apollo/client';
|
|
6
|
-
import { useMutation } from '@apollo/client/react';
|
|
7
2
|
|
|
8
3
|
type AsteroidCMSConfig = {
|
|
9
4
|
/** Base URL of the Asteroid CMS API (e.g. https://cms-api.example.com). */
|
|
@@ -30,25 +25,6 @@ type ResolvedAsteroidCMSConfig = Required<Pick<AsteroidCMSConfig, "cmsUrl" | "ap
|
|
|
30
25
|
onError?: AsteroidCMSConfig["onError"];
|
|
31
26
|
};
|
|
32
27
|
|
|
33
|
-
type AsteroidCMSProviderProps = PropsWithChildren<AsteroidCMSConfig>;
|
|
34
|
-
/**
|
|
35
|
-
* Root provider for `@asteroidcms/core-utils`.
|
|
36
|
-
*
|
|
37
|
-
* Wrap your app once at the top level:
|
|
38
|
-
*
|
|
39
|
-
* ```tsx
|
|
40
|
-
* <AsteroidCMSProvider cmsUrl="https://cms.example.com" apiKey="...">
|
|
41
|
-
* <App />
|
|
42
|
-
* </AsteroidCMSProvider>
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* Everything below — `useCmsContent`, `useCmsMutate`, `useCmsImage`,
|
|
46
|
-
* `<RichTextContent>` — picks up `cmsUrl` and `apiKey` from this provider.
|
|
47
|
-
*/
|
|
48
|
-
declare function AsteroidCMSProvider({ children, ...config }: AsteroidCMSProviderProps): react_jsx_runtime.JSX.Element;
|
|
49
|
-
|
|
50
|
-
declare function useAsteroidCMSConfig(): ResolvedAsteroidCMSConfig;
|
|
51
|
-
|
|
52
28
|
declare module "@apollo/client" {
|
|
53
29
|
namespace ApolloClient.DeclareDefaultOptions {
|
|
54
30
|
interface WatchQuery {
|
|
@@ -65,146 +41,6 @@ declare module "@apollo/client" {
|
|
|
65
41
|
}
|
|
66
42
|
declare function createApolloClient(config: AsteroidCMSConfig): ApolloClient;
|
|
67
43
|
|
|
68
|
-
type FieldSelector$2 = string | {
|
|
69
|
-
field: string;
|
|
70
|
-
as?: string;
|
|
71
|
-
};
|
|
72
|
-
type ReferenceExpansion$2 = {
|
|
73
|
-
field: string;
|
|
74
|
-
as?: string;
|
|
75
|
-
single?: boolean;
|
|
76
|
-
select?: readonly (FieldSelector$2 | ReferenceExpansion$2)[];
|
|
77
|
-
};
|
|
78
|
-
type ContentStatus$1 = "DRAFT" | "PUBLISHED" | "ARCHIVED";
|
|
79
|
-
type CmsSearchCondition$1 = {
|
|
80
|
-
field: string;
|
|
81
|
-
value: string;
|
|
82
|
-
mode?: string;
|
|
83
|
-
};
|
|
84
|
-
type UseCmsContentOptions$1 = {
|
|
85
|
-
schema_slug: string;
|
|
86
|
-
entrySlug?: string;
|
|
87
|
-
select?: readonly (FieldSelector$2 | ReferenceExpansion$2)[];
|
|
88
|
-
fullData?: boolean;
|
|
89
|
-
limit?: number;
|
|
90
|
-
offset?: number;
|
|
91
|
-
status?: ContentStatus$1;
|
|
92
|
-
filter?: Record<string, string | number | boolean | null>;
|
|
93
|
-
search?: CmsSearchCondition$1[];
|
|
94
|
-
variables?: Record<string, any>;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* React hook for querying content from Asteroid CMS via a flexible GraphQL API.
|
|
98
|
-
*
|
|
99
|
-
* Supports single-entry fetches (`entrySlug`) and paginated/filtered lists,
|
|
100
|
-
* with arbitrarily nested reference expansion and field aliasing.
|
|
101
|
-
*/
|
|
102
|
-
declare function useCmsContent<T = unknown>({ schema_slug, entrySlug, select, fullData, limit, offset, status, filter, search, variables, }: UseCmsContentOptions$1): {
|
|
103
|
-
client: _apollo_client.ApolloClient;
|
|
104
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
105
|
-
previousData?: unknown;
|
|
106
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
107
|
-
startPolling: (pollInterval: number) => void;
|
|
108
|
-
stopPolling: () => void;
|
|
109
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
110
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
111
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
112
|
-
data: unknown;
|
|
113
|
-
error?: _apollo_client.ErrorLike;
|
|
114
|
-
}>;
|
|
115
|
-
variables: _apollo_client.OperationVariables;
|
|
116
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
117
|
-
data: TFetchData | undefined;
|
|
118
|
-
error?: _apollo_client.ErrorLike;
|
|
119
|
-
}>;
|
|
120
|
-
dataState: "empty";
|
|
121
|
-
loading: boolean;
|
|
122
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
123
|
-
data: T | undefined;
|
|
124
|
-
} | {
|
|
125
|
-
client: _apollo_client.ApolloClient;
|
|
126
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
127
|
-
previousData?: unknown;
|
|
128
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
129
|
-
startPolling: (pollInterval: number) => void;
|
|
130
|
-
stopPolling: () => void;
|
|
131
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
132
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
133
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
134
|
-
data: unknown;
|
|
135
|
-
error?: _apollo_client.ErrorLike;
|
|
136
|
-
}>;
|
|
137
|
-
variables: _apollo_client.OperationVariables;
|
|
138
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
139
|
-
data: TFetchData | undefined;
|
|
140
|
-
error?: _apollo_client.ErrorLike;
|
|
141
|
-
}>;
|
|
142
|
-
dataState: "complete";
|
|
143
|
-
loading: boolean;
|
|
144
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
145
|
-
data: T | undefined;
|
|
146
|
-
} | {
|
|
147
|
-
client: _apollo_client.ApolloClient;
|
|
148
|
-
observable: _apollo_client.ObservableQuery<unknown, _apollo_client.OperationVariables>;
|
|
149
|
-
previousData?: unknown;
|
|
150
|
-
networkStatus: _apollo_client.NetworkStatus;
|
|
151
|
-
startPolling: (pollInterval: number) => void;
|
|
152
|
-
stopPolling: () => void;
|
|
153
|
-
subscribeToMore: _apollo_client.SubscribeToMoreFunction<unknown, _apollo_client.OperationVariables>;
|
|
154
|
-
updateQuery: (mapFn: _apollo_client.UpdateQueryMapFn<unknown, _apollo_client.OperationVariables>) => void;
|
|
155
|
-
refetch: (variables?: Partial<_apollo_client.OperationVariables> | undefined) => Promise<{
|
|
156
|
-
data: unknown;
|
|
157
|
-
error?: _apollo_client.ErrorLike;
|
|
158
|
-
}>;
|
|
159
|
-
variables: _apollo_client.OperationVariables;
|
|
160
|
-
fetchMore: <TFetchData = unknown, TFetchVars extends _apollo_client.OperationVariables = _apollo_client.OperationVariables>(fetchMoreOptions: _apollo_client.ObservableQuery.FetchMoreOptions<unknown, _apollo_client.OperationVariables, TFetchData, TFetchVars>) => Promise<{
|
|
161
|
-
data: TFetchData | undefined;
|
|
162
|
-
error?: _apollo_client.ErrorLike;
|
|
163
|
-
}>;
|
|
164
|
-
dataState: "streaming";
|
|
165
|
-
loading: boolean;
|
|
166
|
-
error: _apollo_client.ErrorLike | undefined;
|
|
167
|
-
data: T | undefined;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
type FieldSelector$1 = string | {
|
|
171
|
-
field: string;
|
|
172
|
-
as?: string;
|
|
173
|
-
single?: boolean;
|
|
174
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
175
|
-
};
|
|
176
|
-
type ReferenceExpansion$1 = {
|
|
177
|
-
field: string;
|
|
178
|
-
as?: string;
|
|
179
|
-
single?: boolean;
|
|
180
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
181
|
-
};
|
|
182
|
-
type MutationType = "create" | "update" | "delete";
|
|
183
|
-
type UseCmsMutateOptions = {
|
|
184
|
-
schema_slug: string;
|
|
185
|
-
entrySlug?: string;
|
|
186
|
-
select?: readonly (FieldSelector$1 | ReferenceExpansion$1)[];
|
|
187
|
-
fullData?: boolean;
|
|
188
|
-
mutationType?: MutationType;
|
|
189
|
-
entryId?: string;
|
|
190
|
-
variables?: Record<string, any>;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* React hook for mutating content in Asteroid CMS (`create` / `update` / `delete`).
|
|
194
|
-
* Uses the same selection syntax as `useCmsContent`.
|
|
195
|
-
*/
|
|
196
|
-
declare function useCmsMutate<TData = unknown>({ schema_slug, select, fullData, mutationType, entryId, variables: inputVariables, }: UseCmsMutateOptions): {
|
|
197
|
-
readonly data: TData | undefined;
|
|
198
|
-
readonly loading: boolean;
|
|
199
|
-
readonly called: boolean;
|
|
200
|
-
readonly client: _apollo_client.ApolloClient;
|
|
201
|
-
readonly reset: () => void;
|
|
202
|
-
readonly error: _apollo_client.ErrorLike | undefined;
|
|
203
|
-
readonly mutate: useMutation.MutationFunction<unknown, {
|
|
204
|
-
[x: string]: any;
|
|
205
|
-
}, _apollo_client.ApolloCache, "none">;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
44
|
type FieldSelector = string | {
|
|
209
45
|
field: string;
|
|
210
46
|
as?: string;
|
|
@@ -250,8 +86,6 @@ declare function cmsImage(id: string | undefined, options: {
|
|
|
250
86
|
cmsUrl: string;
|
|
251
87
|
mediaPath?: string;
|
|
252
88
|
}): string;
|
|
253
|
-
/** Hook variant that pulls `cmsUrl`/`mediaPath` from the provider. */
|
|
254
|
-
declare function useCmsImage(): (id?: string) => string;
|
|
255
89
|
|
|
256
90
|
type ReadTimeUnit = "short" | "long";
|
|
257
91
|
interface GetContentReadTimeOptions {
|
|
@@ -316,19 +150,4 @@ declare function parseRichText(html: string, options?: ParseRichTextOptions): st
|
|
|
316
150
|
*/
|
|
317
151
|
declare function removeEmptyParagraphs(html: string): string;
|
|
318
152
|
|
|
319
|
-
|
|
320
|
-
html: string;
|
|
321
|
-
classMap?: RichTextClassMap;
|
|
322
|
-
/** Wrapper element. Defaults to `div`. Use `article` for blog content. */
|
|
323
|
-
as?: keyof React.JSX.IntrinsicElements;
|
|
324
|
-
className?: string;
|
|
325
|
-
}
|
|
326
|
-
declare function RichTextContent({ html, classMap, as, className, }: RichTextContentProps): react.DOMElement<{
|
|
327
|
-
ref: react.MutableRefObject<HTMLElement | null>;
|
|
328
|
-
className: string | undefined;
|
|
329
|
-
dangerouslySetInnerHTML: {
|
|
330
|
-
__html: string;
|
|
331
|
-
};
|
|
332
|
-
}, HTMLElement>;
|
|
333
|
-
|
|
334
|
-
export { type AsteroidCMSConfig, AsteroidCMSProvider, type AsteroidCMSProviderProps, type CmsSearchCondition, type ContentStatus, type FieldSelector, type ParseRichTextOptions, type ReferenceExpansion, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, RichTextContent, type UseCmsContentOptions$1 as UseCmsContentOptions, type UseCmsMutateOptions, buildCmsQuery, cmsImage, createApolloClient, fetchCmsContent, getContentReadTime, parseRichText, removeEmptyParagraphs, useAsteroidCMSConfig, useCmsContent, useCmsImage, useCmsMutate };
|
|
153
|
+
export { type AsteroidCMSConfig, type CmsSearchCondition, type ContentStatus, type FieldSelector, type ParseRichTextOptions, type ReferenceExpansion, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, type UseCmsContentOptions, buildCmsQuery, cmsImage, createApolloClient, fetchCmsContent, getContentReadTime, parseRichText, removeEmptyParagraphs };
|