@asteroidcms/core-utils 0.1.1 → 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/README.md +71 -0
- 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 +49 -670
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -157
- package/dist/index.d.ts +12 -157
- package/dist/index.js +48 -661
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
import * as _apollo_client from '@apollo/client';
|
|
5
|
-
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient } from '@apollo/client';
|
|
6
|
-
import { useMutation } from '@apollo/client/react';
|
|
1
|
+
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient, DocumentNode } from '@apollo/client';
|
|
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,15 +41,15 @@ declare module "@apollo/client" {
|
|
|
65
41
|
}
|
|
66
42
|
declare function createApolloClient(config: AsteroidCMSConfig): ApolloClient;
|
|
67
43
|
|
|
68
|
-
type FieldSelector
|
|
44
|
+
type FieldSelector = string | {
|
|
69
45
|
field: string;
|
|
70
46
|
as?: string;
|
|
71
47
|
};
|
|
72
|
-
type ReferenceExpansion
|
|
48
|
+
type ReferenceExpansion = {
|
|
73
49
|
field: string;
|
|
74
50
|
as?: string;
|
|
75
51
|
single?: boolean;
|
|
76
|
-
select?: readonly (FieldSelector
|
|
52
|
+
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
77
53
|
};
|
|
78
54
|
type ContentStatus = "DRAFT" | "PUBLISHED" | "ARCHIVED";
|
|
79
55
|
type CmsSearchCondition = {
|
|
@@ -84,126 +60,22 @@ type CmsSearchCondition = {
|
|
|
84
60
|
type UseCmsContentOptions = {
|
|
85
61
|
schema_slug: string;
|
|
86
62
|
entrySlug?: string;
|
|
87
|
-
select?: readonly (FieldSelector
|
|
63
|
+
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
88
64
|
fullData?: boolean;
|
|
89
65
|
limit?: number;
|
|
90
66
|
offset?: number;
|
|
91
67
|
status?: ContentStatus;
|
|
92
68
|
filter?: Record<string, string | number | boolean | null>;
|
|
93
69
|
search?: CmsSearchCondition[];
|
|
94
|
-
variables?: Record<string,
|
|
70
|
+
variables?: Record<string, unknown>;
|
|
95
71
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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): {
|
|
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;
|
|
72
|
+
declare function buildCmsQuery({ schema_slug, entrySlug, select, fullData, limit, offset, status, filter, search, variables, }: UseCmsContentOptions): {
|
|
73
|
+
query: DocumentNode;
|
|
74
|
+
variables: Record<string, unknown>;
|
|
75
|
+
isSingle: boolean;
|
|
168
76
|
};
|
|
169
77
|
|
|
170
|
-
|
|
171
|
-
field: string;
|
|
172
|
-
as?: string;
|
|
173
|
-
single?: boolean;
|
|
174
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
175
|
-
};
|
|
176
|
-
type ReferenceExpansion = {
|
|
177
|
-
field: string;
|
|
178
|
-
as?: string;
|
|
179
|
-
single?: boolean;
|
|
180
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
181
|
-
};
|
|
182
|
-
type MutationType = "create" | "update" | "delete";
|
|
183
|
-
type UseCmsMutateOptions = {
|
|
184
|
-
schema_slug: string;
|
|
185
|
-
entrySlug?: string;
|
|
186
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
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
|
-
};
|
|
78
|
+
declare function fetchCmsContent<T>(getClient: () => ApolloClient, opts: UseCmsContentOptions): Promise<T>;
|
|
207
79
|
|
|
208
80
|
/**
|
|
209
81
|
* Build a canonical media URL from an asset id. Pass `cmsUrl` explicitly when
|
|
@@ -214,8 +86,6 @@ declare function cmsImage(id: string | undefined, options: {
|
|
|
214
86
|
cmsUrl: string;
|
|
215
87
|
mediaPath?: string;
|
|
216
88
|
}): string;
|
|
217
|
-
/** Hook variant that pulls `cmsUrl`/`mediaPath` from the provider. */
|
|
218
|
-
declare function useCmsImage(): (id?: string) => string;
|
|
219
89
|
|
|
220
90
|
type ReadTimeUnit = "short" | "long";
|
|
221
91
|
interface GetContentReadTimeOptions {
|
|
@@ -280,19 +150,4 @@ declare function parseRichText(html: string, options?: ParseRichTextOptions): st
|
|
|
280
150
|
*/
|
|
281
151
|
declare function removeEmptyParagraphs(html: string): string;
|
|
282
152
|
|
|
283
|
-
|
|
284
|
-
html: string;
|
|
285
|
-
classMap?: RichTextClassMap;
|
|
286
|
-
/** Wrapper element. Defaults to `div`. Use `article` for blog content. */
|
|
287
|
-
as?: keyof React.JSX.IntrinsicElements;
|
|
288
|
-
className?: string;
|
|
289
|
-
}
|
|
290
|
-
declare function RichTextContent({ html, classMap, as, className, }: RichTextContentProps): react.DOMElement<{
|
|
291
|
-
ref: react.MutableRefObject<HTMLElement | null>;
|
|
292
|
-
className: string | undefined;
|
|
293
|
-
dangerouslySetInnerHTML: {
|
|
294
|
-
__html: string;
|
|
295
|
-
};
|
|
296
|
-
}, HTMLElement>;
|
|
297
|
-
|
|
298
|
-
export { type AsteroidCMSConfig, AsteroidCMSProvider, type AsteroidCMSProviderProps, type ParseRichTextOptions, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, RichTextContent, type UseCmsContentOptions, type UseCmsMutateOptions, cmsImage, createApolloClient, 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
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
import * as _apollo_client from '@apollo/client';
|
|
5
|
-
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient } from '@apollo/client';
|
|
6
|
-
import { useMutation } from '@apollo/client/react';
|
|
1
|
+
import { InMemoryCacheConfig, ApolloClientOptions, ApolloClient, DocumentNode } from '@apollo/client';
|
|
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,15 +41,15 @@ declare module "@apollo/client" {
|
|
|
65
41
|
}
|
|
66
42
|
declare function createApolloClient(config: AsteroidCMSConfig): ApolloClient;
|
|
67
43
|
|
|
68
|
-
type FieldSelector
|
|
44
|
+
type FieldSelector = string | {
|
|
69
45
|
field: string;
|
|
70
46
|
as?: string;
|
|
71
47
|
};
|
|
72
|
-
type ReferenceExpansion
|
|
48
|
+
type ReferenceExpansion = {
|
|
73
49
|
field: string;
|
|
74
50
|
as?: string;
|
|
75
51
|
single?: boolean;
|
|
76
|
-
select?: readonly (FieldSelector
|
|
52
|
+
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
77
53
|
};
|
|
78
54
|
type ContentStatus = "DRAFT" | "PUBLISHED" | "ARCHIVED";
|
|
79
55
|
type CmsSearchCondition = {
|
|
@@ -84,126 +60,22 @@ type CmsSearchCondition = {
|
|
|
84
60
|
type UseCmsContentOptions = {
|
|
85
61
|
schema_slug: string;
|
|
86
62
|
entrySlug?: string;
|
|
87
|
-
select?: readonly (FieldSelector
|
|
63
|
+
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
88
64
|
fullData?: boolean;
|
|
89
65
|
limit?: number;
|
|
90
66
|
offset?: number;
|
|
91
67
|
status?: ContentStatus;
|
|
92
68
|
filter?: Record<string, string | number | boolean | null>;
|
|
93
69
|
search?: CmsSearchCondition[];
|
|
94
|
-
variables?: Record<string,
|
|
70
|
+
variables?: Record<string, unknown>;
|
|
95
71
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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): {
|
|
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;
|
|
72
|
+
declare function buildCmsQuery({ schema_slug, entrySlug, select, fullData, limit, offset, status, filter, search, variables, }: UseCmsContentOptions): {
|
|
73
|
+
query: DocumentNode;
|
|
74
|
+
variables: Record<string, unknown>;
|
|
75
|
+
isSingle: boolean;
|
|
168
76
|
};
|
|
169
77
|
|
|
170
|
-
|
|
171
|
-
field: string;
|
|
172
|
-
as?: string;
|
|
173
|
-
single?: boolean;
|
|
174
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
175
|
-
};
|
|
176
|
-
type ReferenceExpansion = {
|
|
177
|
-
field: string;
|
|
178
|
-
as?: string;
|
|
179
|
-
single?: boolean;
|
|
180
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
181
|
-
};
|
|
182
|
-
type MutationType = "create" | "update" | "delete";
|
|
183
|
-
type UseCmsMutateOptions = {
|
|
184
|
-
schema_slug: string;
|
|
185
|
-
entrySlug?: string;
|
|
186
|
-
select?: readonly (FieldSelector | ReferenceExpansion)[];
|
|
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
|
-
};
|
|
78
|
+
declare function fetchCmsContent<T>(getClient: () => ApolloClient, opts: UseCmsContentOptions): Promise<T>;
|
|
207
79
|
|
|
208
80
|
/**
|
|
209
81
|
* Build a canonical media URL from an asset id. Pass `cmsUrl` explicitly when
|
|
@@ -214,8 +86,6 @@ declare function cmsImage(id: string | undefined, options: {
|
|
|
214
86
|
cmsUrl: string;
|
|
215
87
|
mediaPath?: string;
|
|
216
88
|
}): string;
|
|
217
|
-
/** Hook variant that pulls `cmsUrl`/`mediaPath` from the provider. */
|
|
218
|
-
declare function useCmsImage(): (id?: string) => string;
|
|
219
89
|
|
|
220
90
|
type ReadTimeUnit = "short" | "long";
|
|
221
91
|
interface GetContentReadTimeOptions {
|
|
@@ -280,19 +150,4 @@ declare function parseRichText(html: string, options?: ParseRichTextOptions): st
|
|
|
280
150
|
*/
|
|
281
151
|
declare function removeEmptyParagraphs(html: string): string;
|
|
282
152
|
|
|
283
|
-
|
|
284
|
-
html: string;
|
|
285
|
-
classMap?: RichTextClassMap;
|
|
286
|
-
/** Wrapper element. Defaults to `div`. Use `article` for blog content. */
|
|
287
|
-
as?: keyof React.JSX.IntrinsicElements;
|
|
288
|
-
className?: string;
|
|
289
|
-
}
|
|
290
|
-
declare function RichTextContent({ html, classMap, as, className, }: RichTextContentProps): react.DOMElement<{
|
|
291
|
-
ref: react.MutableRefObject<HTMLElement | null>;
|
|
292
|
-
className: string | undefined;
|
|
293
|
-
dangerouslySetInnerHTML: {
|
|
294
|
-
__html: string;
|
|
295
|
-
};
|
|
296
|
-
}, HTMLElement>;
|
|
297
|
-
|
|
298
|
-
export { type AsteroidCMSConfig, AsteroidCMSProvider, type AsteroidCMSProviderProps, type ParseRichTextOptions, type ResolvedAsteroidCMSConfig, type RichTextClassKey, type RichTextClassMap, RichTextContent, type UseCmsContentOptions, type UseCmsMutateOptions, cmsImage, createApolloClient, 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 };
|