goatly 0.1.0 → 0.1.2
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 +874 -1
- package/bin/goatly.js +99 -0
- package/dist/cli/index.js +234 -0
- package/dist/compat/gatsby-node-entry.js +16 -0
- package/dist/compat/gatsby-package.json +6 -0
- package/dist/compat/md5-file.js +47 -0
- package/dist/compat-apis.json +72 -0
- package/dist/compat-apis.json.js +62 -0
- package/dist/graphql.js +3 -0
- package/dist/node/actions/index.js +619 -0
- package/dist/node/actions/job-store.js +180 -0
- package/dist/node/actions/jobs.js +174 -0
- package/dist/node/api-runner.js +258 -0
- package/dist/node/bootstrap.js +569 -0
- package/dist/node/build/assets.js +110 -0
- package/dist/node/build/incremental.js +208 -0
- package/dist/node/build/index.js +763 -0
- package/dist/node/build/memory-governor.js +450 -0
- package/dist/node/build/output-dirs.js +70 -0
- package/dist/node/build/page-data.js +40 -0
- package/dist/node/build/page-files.js +186 -0
- package/dist/node/build/partitioned-state.js +258 -0
- package/dist/node/build/query-worker.js +626 -0
- package/dist/node/build/query-workers.js +863 -0
- package/dist/node/build/render-thread.js +103 -0
- package/dist/node/build/render-worker.js +162 -0
- package/dist/node/build/state.js +24 -0
- package/dist/node/build/timing-breakdown.js +216 -0
- package/dist/node/build/work-clock.js +75 -0
- package/dist/node/build/worker-pool.js +242 -0
- package/dist/node/cache-layout.js +99 -0
- package/dist/node/cache.js +1430 -0
- package/dist/node/compat/chokidar-shim.js +148 -0
- package/dist/node/compat/core-utils-lmdb.js +145 -0
- package/dist/node/compat/create-node-id-shim.js +1 -0
- package/dist/node/compat/module-hooks.js +245 -0
- package/dist/node/compat/redux-shim.js +1 -0
- package/dist/node/config/index.js +162 -0
- package/dist/node/config/not-found-pages.js +95 -0
- package/dist/node/datastore/codec.js +144 -0
- package/dist/node/datastore/index.js +127 -0
- package/dist/node/datastore/logfile/cache.js +89 -0
- package/dist/node/datastore/logfile/index.js +1329 -0
- package/dist/node/datastore/logfile/record.js +71 -0
- package/dist/node/datastore/types.js +1 -0
- package/dist/node/develop/express-compat.js +207 -0
- package/dist/node/develop/graphiql.js +22 -0
- package/dist/node/develop/hydration-report.js +41 -0
- package/dist/node/develop/index.js +618 -0
- package/dist/node/develop/local-url.js +10 -0
- package/dist/node/develop/ssr-runner.js +66 -0
- package/dist/node/gql.js +5 -0
- package/dist/node/index.js +15 -0
- package/dist/node/info.js +270 -0
- package/dist/node/internal-plugins/data-bridge.js +196 -0
- package/dist/node/internal-plugins/page-creator.js +318 -0
- package/dist/node/loader/import-module.js +160 -0
- package/dist/node/node-helpers.js +66 -0
- package/dist/node/not-found-pages.js +220 -0
- package/dist/node/plugins/api-list.js +12 -0
- package/dist/node/plugins/load-plugins.js +427 -0
- package/dist/node/plugins/resolve-plugin.js +79 -0
- package/dist/node/plugins/static-exports.js +64 -0
- package/dist/node/query/compile.js +326 -0
- package/dist/node/query/dependencies.js +45 -0
- package/dist/node/query/execute.js +417 -0
- package/dist/node/query/extract.js +372 -0
- package/dist/node/query/gql-tada-introspection.js +124 -0
- package/dist/node/query/graphql-env.js +231 -0
- package/dist/node/query/graphql-runner.js +79 -0
- package/dist/node/redux/actions.js +1 -0
- package/dist/node/redux/index.js +133 -0
- package/dist/node/redux/node-changes.js +128 -0
- package/dist/node/redux/reducers.js +193 -0
- package/dist/node/redux/state.js +71 -0
- package/dist/node/renderer.js +124 -0
- package/dist/node/reporter-transports.js +259 -0
- package/dist/node/reporter.js +497 -0
- package/dist/node/schema/date.js +539 -0
- package/dist/node/schema/extensions.js +315 -0
- package/dist/node/schema/index.js +542 -0
- package/dist/node/schema/infer.js +388 -0
- package/dist/node/schema/inline-objects.js +128 -0
- package/dist/node/schema/naming.js +20 -0
- package/dist/node/schema/node-model.js +207 -0
- package/dist/node/schema/query-engine.js +1808 -0
- package/dist/node/schema/resolver-kinds.js +7 -0
- package/dist/node/schema/resolvers.js +273 -0
- package/dist/node/schema/type-builders.js +45 -0
- package/dist/node/schema/types.js +241 -0
- package/dist/node/serve.js +90 -0
- package/dist/node/site-page-nodes.js +277 -0
- package/dist/node/types.js +1 -0
- package/dist/node/utils/content-digest.js +107 -0
- package/dist/node/utils/cpus.js +104 -0
- package/dist/node/utils/create-node-id.js +51 -0
- package/dist/node/utils/env.js +25 -0
- package/dist/node/utils/fs-retry.js +74 -0
- package/dist/node/utils/memory-signals.js +441 -0
- package/dist/node/utils/memory.js +657 -0
- package/dist/node/utils/murmurhash.js +32 -0
- package/dist/node/utils/parser.js +33 -0
- package/dist/node/utils/partition-hash.js +19 -0
- package/dist/node/utils/paths.js +122 -0
- package/dist/node/utils/resolver.js +48 -0
- package/dist/node/utils/runtime.js +5 -0
- package/dist/node/utils/serializable.js +41 -0
- package/dist/node/utils/strings.js +41 -0
- package/dist/node/vite/config.js +289 -0
- package/dist/node/vite/paths.js +12 -0
- package/dist/node/vite/plugin-deps.js +232 -0
- package/dist/node/vite/plugin.js +283 -0
- package/dist/node/vite/react-compiler.js +362 -0
- package/dist/node/vite/source-files.js +83 -0
- package/dist/node/vite/static-image.js +136 -0
- package/dist/node/vite/styled-components.js +73 -0
- package/dist/node/vite/transforms.js +330 -0
- package/dist/node/wasm-data/host.js +406 -0
- package/dist/node/wasm-data/lower.js +406 -0
- package/dist/node/wasm-data/runner.js +79 -0
- package/dist/node/wasm-data/worker.js +95 -0
- package/dist/reporter.js +5 -0
- package/dist/runtime/api-runner.js +81 -0
- package/dist/runtime/app.js +256 -0
- package/dist/runtime/client-entry.js +4 -0
- package/dist/runtime/client.js +383 -0
- package/dist/runtime/default-html.js +31 -0
- package/dist/runtime/head-markup.js +100 -0
- package/dist/runtime/head-sync.js +101 -0
- package/dist/runtime/head-tags.js +45 -0
- package/dist/runtime/hydration-report.js +111 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/link.js +293 -0
- package/dist/runtime/loader.js +449 -0
- package/dist/runtime/not-found.js +61 -0
- package/dist/runtime/page-renderer.js +35 -0
- package/dist/runtime/preamble.js +47 -0
- package/dist/runtime/react-compat.js +14 -0
- package/dist/runtime/renderer-shared.js +10 -0
- package/dist/runtime/renderers/react-client.js +14 -0
- package/dist/runtime/renderers/react-server.js +99 -0
- package/dist/runtime/renderers/react.js +17 -0
- package/dist/runtime/renderers/types.js +1 -0
- package/dist/runtime/root-error-handlers.js +29 -0
- package/dist/runtime/router/history.js +132 -0
- package/dist/runtime/router/index.js +240 -0
- package/dist/runtime/router/utils.js +118 -0
- package/dist/runtime/script.js +110 -0
- package/dist/runtime/scroll.js +40 -0
- package/dist/runtime/slice.js +11 -0
- package/dist/runtime/ssr.js +240 -0
- package/dist/runtime/static-query.js +47 -0
- package/dist/utils.js +4 -0
- package/package.json +105 -3
- package/types/graphql-tada.d.ts +223 -0
- package/types/graphql.d.ts +2 -0
- package/types/index.d.ts +2287 -0
- package/types/node.d.ts +389 -0
- package/types/reporter.d.ts +187 -0
- package/types/router.d.ts +102 -0
- package/types/vendor/gql-tada.d.ts +2529 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// gql.tada typing of `graphql()` documents (see `graphql` in ./index.d.ts and the README). Needs
|
|
2
|
+
// TypeScript >= 5.0, like gql.tada's types.
|
|
3
|
+
import type { StaticQueryDocument } from "./index.js"
|
|
4
|
+
import type {
|
|
5
|
+
DefinitionDecoration,
|
|
6
|
+
DocumentDecoration,
|
|
7
|
+
DocumentNodeLike,
|
|
8
|
+
FragmentOf,
|
|
9
|
+
ResultOf,
|
|
10
|
+
TadaDocumentNode,
|
|
11
|
+
VariablesOf,
|
|
12
|
+
getDocumentNode,
|
|
13
|
+
getFragmentsOfDocuments,
|
|
14
|
+
parseDocument,
|
|
15
|
+
schemaOfSetup,
|
|
16
|
+
} from "./vendor/gql-tada.js"
|
|
17
|
+
|
|
18
|
+
export type { FragmentOf, ResultOf, VariablesOf }
|
|
19
|
+
|
|
20
|
+
declare global {
|
|
21
|
+
/**
|
|
22
|
+
* The site's GraphQL schema and fragments for `graphql()` documents. goatly generates the
|
|
23
|
+
* declaration file that fills it (by default `src/gatsby-graphql-env.d.ts` in TypeScript sites)
|
|
24
|
+
* when it extracts the queries, in `build` and `develop`.
|
|
25
|
+
*/
|
|
26
|
+
interface GatsbyGraphQLTypes {}
|
|
27
|
+
/**
|
|
28
|
+
* TypeScript types of custom GraphQL scalars in `graphql()` results, merged over the defaults
|
|
29
|
+
* (`Date: string`, `JSON: any`, `GatsbyImageData` from gatsby-plugin-image if it is installed;
|
|
30
|
+
* other custom scalars are `any`), e.g. `interface GatsbyGraphQLScalars { Upload: File }`.
|
|
31
|
+
*/
|
|
32
|
+
interface GatsbyGraphQLScalars {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Introspection = GatsbyGraphQLTypes extends { introspection: infer I } ? I : never
|
|
36
|
+
type FragmentSources = GatsbyGraphQLTypes extends { fragments: infer F } ? F : {}
|
|
37
|
+
type GeneratedScalars = GatsbyGraphQLTypes extends { scalars: infer S } ? S : {}
|
|
38
|
+
type Scalars = Omit<{ Date: string; JSON: any } & GeneratedScalars, keyof GatsbyGraphQLScalars> &
|
|
39
|
+
GatsbyGraphQLScalars
|
|
40
|
+
|
|
41
|
+
/** `true` once the declaration file has been generated */
|
|
42
|
+
export type HasGraphQLTypes = [Introspection] extends [never] ? false : true
|
|
43
|
+
|
|
44
|
+
type Schema = schemaOfSetup<{ introspection: Introspection; scalars: Scalars }>
|
|
45
|
+
|
|
46
|
+
/** The definitions of a document with its operations first (gql.tada types the first definition) */
|
|
47
|
+
type OperationsFirst<
|
|
48
|
+
Definitions extends readonly unknown[],
|
|
49
|
+
Operations extends unknown[] = [],
|
|
50
|
+
Fragments extends unknown[] = [],
|
|
51
|
+
> = Definitions extends readonly [infer Head, ...infer Rest]
|
|
52
|
+
? Head extends { readonly kind: infer Kind }
|
|
53
|
+
? `${Kind & string}` extends "OperationDefinition"
|
|
54
|
+
? OperationsFirst<Rest, [...Operations, Head], Fragments>
|
|
55
|
+
: OperationsFirst<Rest, Operations, [...Fragments, Head]>
|
|
56
|
+
: OperationsFirst<Rest, Operations, [...Fragments, Head]>
|
|
57
|
+
: [...Operations, ...Fragments]
|
|
58
|
+
|
|
59
|
+
/** The fragment map of fragment documents for gql.tada (`{}`, not `never`, without any) */
|
|
60
|
+
type FragmentMap<Fragments extends readonly unknown[]> = [
|
|
61
|
+
getFragmentsOfDocuments<Fragments>,
|
|
62
|
+
] extends [never]
|
|
63
|
+
? {}
|
|
64
|
+
: getFragmentsOfDocuments<Fragments>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* gql.tada's document of `Source` with the fragment documents `Fragments`. The operation of a
|
|
68
|
+
* document comes first, so that fragments defined before it in the same string work (as in Gatsby).
|
|
69
|
+
* Fragments are not masked: like in Gatsby, results contain the fields of the fragments they spread.
|
|
70
|
+
*/
|
|
71
|
+
type TadaDocument<Source extends string, Fragments extends readonly unknown[]> =
|
|
72
|
+
parseDocument<Source> extends {
|
|
73
|
+
readonly kind: infer Kind
|
|
74
|
+
readonly definitions: infer Definitions extends readonly unknown[]
|
|
75
|
+
}
|
|
76
|
+
? { kind: Kind; definitions: OperationsFirst<Definitions> } extends infer Document extends
|
|
77
|
+
DocumentNodeLike
|
|
78
|
+
? getDocumentNode<Document, Schema, FragmentMap<Fragments>, true>
|
|
79
|
+
: never
|
|
80
|
+
: never
|
|
81
|
+
|
|
82
|
+
/** The document of a fragment of the site, with the fragments it spreads */
|
|
83
|
+
type FragmentDocument<Name> = Name extends keyof FragmentSources
|
|
84
|
+
? FragmentSources[Name] extends readonly [infer Source extends string, ...infer Spreads]
|
|
85
|
+
? TadaDocument<Source, FragmentDocument<Spreads[number]>[]>
|
|
86
|
+
: never
|
|
87
|
+
: never
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The names of the fragments spread in nodes of a document parsed by gql.tada (its `kind`s are
|
|
91
|
+
* graphql-js' `Kind` enum members).
|
|
92
|
+
*/
|
|
93
|
+
type Spreads<Node> = Node extends readonly unknown[]
|
|
94
|
+
? Spreads<Node[number]>
|
|
95
|
+
: Node extends { readonly kind: infer Kind }
|
|
96
|
+
? `${Kind & string}` extends "FragmentSpread"
|
|
97
|
+
? Node extends { readonly name: { readonly value: infer Name } }
|
|
98
|
+
? Name
|
|
99
|
+
: never
|
|
100
|
+
: Node extends { readonly selectionSet: { readonly selections: infer Selections } }
|
|
101
|
+
? Spreads<Selections>
|
|
102
|
+
: never
|
|
103
|
+
: never
|
|
104
|
+
|
|
105
|
+
/** The names of fragment documents */
|
|
106
|
+
type FragmentNames<Fragments extends readonly unknown[]> =
|
|
107
|
+
Fragments[number] extends DefinitionDecoration<infer Definition>
|
|
108
|
+
? Definition extends { fragment: infer Name }
|
|
109
|
+
? Name
|
|
110
|
+
: never
|
|
111
|
+
: never
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A typed `graphql()` document: its result type is `ResultOf<typeof document>`, its variables type
|
|
115
|
+
* `VariablesOf<typeof document>`. A `StaticQueryDocument`, so it goes wherever a tag's document goes.
|
|
116
|
+
*/
|
|
117
|
+
export interface GraphQLDocument<Result = any, Variables = any, Decoration = void>
|
|
118
|
+
extends
|
|
119
|
+
StaticQueryDocument,
|
|
120
|
+
DocumentDecoration<Result, Variables>,
|
|
121
|
+
DefinitionDecoration<Decoration> {}
|
|
122
|
+
|
|
123
|
+
type AsGraphQLDocument<Document> =
|
|
124
|
+
Document extends TadaDocumentNode<infer Result, infer Variables, infer Decoration>
|
|
125
|
+
? GraphQLDocument<Result, Variables, Decoration>
|
|
126
|
+
: never
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The typed document of a `graphql()` call. The fragments of the site can be spread by name (like
|
|
130
|
+
* in Gatsby), fragment documents passed as the second argument too (like in gql.tada; for the types
|
|
131
|
+
* only: the build finds fragments by their names, which are global). Only the site fragments the
|
|
132
|
+
* document spreads are passed to gql.tada, so that its cost does not grow with the number of
|
|
133
|
+
* fragments of the site. Until the declaration file exists, the document is typed `any`.
|
|
134
|
+
*/
|
|
135
|
+
export type GraphQLDocumentOf<
|
|
136
|
+
Source extends string,
|
|
137
|
+
Fragments extends readonly unknown[],
|
|
138
|
+
> = HasGraphQLTypes extends true
|
|
139
|
+
? AsGraphQLDocument<
|
|
140
|
+
TadaDocument<
|
|
141
|
+
Source,
|
|
142
|
+
[
|
|
143
|
+
...FragmentDocument<
|
|
144
|
+
Exclude<Spreads<parseDocument<Source>["definitions"]>, FragmentNames<Fragments>>
|
|
145
|
+
>[],
|
|
146
|
+
...Fragments,
|
|
147
|
+
]
|
|
148
|
+
>
|
|
149
|
+
>
|
|
150
|
+
: GraphQLDocument<any, any>
|
|
151
|
+
|
|
152
|
+
/** Makes the `source` argument an error when gql.tada can't type the document. */
|
|
153
|
+
export type GraphQLDocumentCheck<
|
|
154
|
+
Source extends string,
|
|
155
|
+
Fragments extends readonly unknown[],
|
|
156
|
+
> = HasGraphQLTypes extends true
|
|
157
|
+
? [GraphQLDocumentOf<Source, Fragments>] extends [never]
|
|
158
|
+
? {
|
|
159
|
+
"Invalid GraphQL document (a syntax error, or a fragment on a type that does not exist)": never
|
|
160
|
+
}
|
|
161
|
+
: unknown
|
|
162
|
+
: unknown
|
|
163
|
+
|
|
164
|
+
type QueryTable = GatsbyGraphQLTypes extends { queries: infer Q } ? Q : {}
|
|
165
|
+
|
|
166
|
+
/** The names of the site's named queries (any string until the declaration file exists) */
|
|
167
|
+
export type QueryName = HasGraphQLTypes extends true ? keyof QueryTable & string : string
|
|
168
|
+
/** The names of the site's fragments (any string until the declaration file exists) */
|
|
169
|
+
export type FragmentName = HasGraphQLTypes extends true ? keyof FragmentSources & string : string
|
|
170
|
+
|
|
171
|
+
type QueryDocument<Name> = Name extends keyof QueryTable
|
|
172
|
+
? QueryTable[Name] extends infer Source extends string
|
|
173
|
+
? GraphQLDocumentOf<Source, []>
|
|
174
|
+
: never
|
|
175
|
+
: never
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The data of the site's query named `Name`, in a tag (`graphql\`query Name { ... }\``) or a
|
|
179
|
+
* `graphql()` call: `PageProps<QueryResult<"Name">>`, `useStaticQuery<QueryResult<"Name">>(...)`.
|
|
180
|
+
* `any` until the declaration file exists.
|
|
181
|
+
*/
|
|
182
|
+
export type QueryResult<Name extends QueryName> = HasGraphQLTypes extends true
|
|
183
|
+
? ResultOf<QueryDocument<Name>>
|
|
184
|
+
: any
|
|
185
|
+
/** The variables of the site's query named `Name` */
|
|
186
|
+
export type QueryVariables<Name extends QueryName> = HasGraphQLTypes extends true
|
|
187
|
+
? VariablesOf<QueryDocument<Name>>
|
|
188
|
+
: any
|
|
189
|
+
/** The data of the site's fragment named `Name` */
|
|
190
|
+
export type FragmentResult<Name extends FragmentName> = HasGraphQLTypes extends true
|
|
191
|
+
? ResultOf<FragmentDocument<Name>>
|
|
192
|
+
: any
|
|
193
|
+
|
|
194
|
+
/** The data of `useStaticQuery(query)`: the result of a typed document, `any` otherwise */
|
|
195
|
+
export type DataOfQuery<Query> = unknown extends Query
|
|
196
|
+
? any
|
|
197
|
+
: Query extends DocumentDecoration<infer Result, any>
|
|
198
|
+
? unknown extends Result
|
|
199
|
+
? any
|
|
200
|
+
: Result
|
|
201
|
+
: any
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The data of the `graphql` function of Node APIs (`createPages`) for a query string literal,
|
|
205
|
+
* without the site's fragments (they aren't available there). `unknown` (as with Gatsby's types)
|
|
206
|
+
* until the declaration file exists, for strings that aren't literals, and for queries gql.tada
|
|
207
|
+
* can't type; `any` for `graphql<any>(…)`.
|
|
208
|
+
*/
|
|
209
|
+
export type NodeQueryData<Query> = unknown extends Query
|
|
210
|
+
? any
|
|
211
|
+
: HasGraphQLTypes extends false
|
|
212
|
+
? unknown
|
|
213
|
+
: string extends Query
|
|
214
|
+
? unknown
|
|
215
|
+
: Query extends string
|
|
216
|
+
? [TadaDocument<Query, []>] extends [never]
|
|
217
|
+
? unknown
|
|
218
|
+
: ResultOf<TadaDocument<Query, []>>
|
|
219
|
+
: unknown
|
|
220
|
+
|
|
221
|
+
// only the declarations marked `export` are exported (not `Schema`, `TadaDocument`, …)
|
|
222
|
+
// oxlint-disable-next-line unicorn/require-module-specifiers
|
|
223
|
+
export {}
|