goatly 0.1.0 → 0.1.1

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.
Files changed (158) hide show
  1. package/README.md +853 -1
  2. package/bin/goatly.js +91 -0
  3. package/dist/cli/index.js +234 -0
  4. package/dist/compat/gatsby-node-entry.js +16 -0
  5. package/dist/compat/gatsby-package.json +6 -0
  6. package/dist/compat/md5-file.js +47 -0
  7. package/dist/compat-apis.json +72 -0
  8. package/dist/compat-apis.json.js +62 -0
  9. package/dist/graphql.js +3 -0
  10. package/dist/node/actions/index.js +619 -0
  11. package/dist/node/actions/job-store.js +180 -0
  12. package/dist/node/actions/jobs.js +174 -0
  13. package/dist/node/api-runner.js +258 -0
  14. package/dist/node/bootstrap.js +539 -0
  15. package/dist/node/build/assets.js +110 -0
  16. package/dist/node/build/incremental.js +208 -0
  17. package/dist/node/build/index.js +752 -0
  18. package/dist/node/build/memory-governor.js +448 -0
  19. package/dist/node/build/output-dirs.js +70 -0
  20. package/dist/node/build/page-data.js +40 -0
  21. package/dist/node/build/page-files.js +54 -0
  22. package/dist/node/build/partitioned-state.js +258 -0
  23. package/dist/node/build/query-worker.js +536 -0
  24. package/dist/node/build/query-workers.js +832 -0
  25. package/dist/node/build/render-worker.js +131 -0
  26. package/dist/node/build/state.js +24 -0
  27. package/dist/node/build/timing-breakdown.js +155 -0
  28. package/dist/node/build/worker-pool.js +236 -0
  29. package/dist/node/cache-layout.js +99 -0
  30. package/dist/node/cache.js +1430 -0
  31. package/dist/node/compat/chokidar-shim.js +148 -0
  32. package/dist/node/compat/core-utils-lmdb.js +145 -0
  33. package/dist/node/compat/create-node-id-shim.js +1 -0
  34. package/dist/node/compat/module-hooks.js +245 -0
  35. package/dist/node/compat/redux-shim.js +1 -0
  36. package/dist/node/config/index.js +162 -0
  37. package/dist/node/config/not-found-pages.js +95 -0
  38. package/dist/node/datastore/codec.js +144 -0
  39. package/dist/node/datastore/index.js +127 -0
  40. package/dist/node/datastore/logfile/cache.js +89 -0
  41. package/dist/node/datastore/logfile/index.js +1329 -0
  42. package/dist/node/datastore/logfile/record.js +71 -0
  43. package/dist/node/datastore/types.js +1 -0
  44. package/dist/node/develop/express-compat.js +207 -0
  45. package/dist/node/develop/graphiql.js +22 -0
  46. package/dist/node/develop/hydration-report.js +41 -0
  47. package/dist/node/develop/index.js +618 -0
  48. package/dist/node/develop/local-url.js +10 -0
  49. package/dist/node/develop/ssr-runner.js +66 -0
  50. package/dist/node/gql.js +5 -0
  51. package/dist/node/index.js +15 -0
  52. package/dist/node/info.js +270 -0
  53. package/dist/node/internal-plugins/data-bridge.js +196 -0
  54. package/dist/node/internal-plugins/page-creator.js +318 -0
  55. package/dist/node/loader/import-module.js +160 -0
  56. package/dist/node/node-helpers.js +66 -0
  57. package/dist/node/not-found-pages.js +220 -0
  58. package/dist/node/plugins/api-list.js +12 -0
  59. package/dist/node/plugins/load-plugins.js +427 -0
  60. package/dist/node/plugins/resolve-plugin.js +79 -0
  61. package/dist/node/plugins/static-exports.js +64 -0
  62. package/dist/node/query/compile.js +326 -0
  63. package/dist/node/query/dependencies.js +45 -0
  64. package/dist/node/query/execute.js +417 -0
  65. package/dist/node/query/extract.js +372 -0
  66. package/dist/node/query/gql-tada-introspection.js +124 -0
  67. package/dist/node/query/graphql-env.js +231 -0
  68. package/dist/node/query/graphql-runner.js +79 -0
  69. package/dist/node/redux/actions.js +1 -0
  70. package/dist/node/redux/index.js +133 -0
  71. package/dist/node/redux/node-changes.js +128 -0
  72. package/dist/node/redux/reducers.js +193 -0
  73. package/dist/node/redux/state.js +71 -0
  74. package/dist/node/renderer.js +124 -0
  75. package/dist/node/reporter-transports.js +259 -0
  76. package/dist/node/reporter.js +497 -0
  77. package/dist/node/schema/date.js +539 -0
  78. package/dist/node/schema/extensions.js +315 -0
  79. package/dist/node/schema/index.js +542 -0
  80. package/dist/node/schema/infer.js +388 -0
  81. package/dist/node/schema/inline-objects.js +128 -0
  82. package/dist/node/schema/naming.js +20 -0
  83. package/dist/node/schema/node-model.js +207 -0
  84. package/dist/node/schema/query-engine.js +1808 -0
  85. package/dist/node/schema/resolver-kinds.js +7 -0
  86. package/dist/node/schema/resolvers.js +273 -0
  87. package/dist/node/schema/type-builders.js +45 -0
  88. package/dist/node/schema/types.js +241 -0
  89. package/dist/node/serve.js +90 -0
  90. package/dist/node/site-page-nodes.js +277 -0
  91. package/dist/node/types.js +1 -0
  92. package/dist/node/utils/content-digest.js +107 -0
  93. package/dist/node/utils/create-node-id.js +51 -0
  94. package/dist/node/utils/env.js +24 -0
  95. package/dist/node/utils/fs-retry.js +74 -0
  96. package/dist/node/utils/memory-signals.js +410 -0
  97. package/dist/node/utils/memory.js +400 -0
  98. package/dist/node/utils/murmurhash.js +32 -0
  99. package/dist/node/utils/parser.js +33 -0
  100. package/dist/node/utils/partition-hash.js +19 -0
  101. package/dist/node/utils/paths.js +122 -0
  102. package/dist/node/utils/resolver.js +48 -0
  103. package/dist/node/utils/runtime.js +5 -0
  104. package/dist/node/utils/serializable.js +41 -0
  105. package/dist/node/utils/strings.js +41 -0
  106. package/dist/node/vite/config.js +289 -0
  107. package/dist/node/vite/paths.js +12 -0
  108. package/dist/node/vite/plugin-deps.js +232 -0
  109. package/dist/node/vite/plugin.js +281 -0
  110. package/dist/node/vite/react-compiler.js +362 -0
  111. package/dist/node/vite/source-files.js +83 -0
  112. package/dist/node/vite/static-image.js +136 -0
  113. package/dist/node/vite/styled-components.js +73 -0
  114. package/dist/node/vite/transforms.js +299 -0
  115. package/dist/node/wasm-data/host.js +406 -0
  116. package/dist/node/wasm-data/lower.js +406 -0
  117. package/dist/node/wasm-data/runner.js +79 -0
  118. package/dist/node/wasm-data/worker.js +95 -0
  119. package/dist/reporter.js +5 -0
  120. package/dist/runtime/api-runner.js +81 -0
  121. package/dist/runtime/app.js +256 -0
  122. package/dist/runtime/client-entry.js +4 -0
  123. package/dist/runtime/client.js +383 -0
  124. package/dist/runtime/default-html.js +31 -0
  125. package/dist/runtime/head-markup.js +100 -0
  126. package/dist/runtime/head-sync.js +101 -0
  127. package/dist/runtime/head-tags.js +45 -0
  128. package/dist/runtime/hydration-report.js +111 -0
  129. package/dist/runtime/index.js +12 -0
  130. package/dist/runtime/link.js +293 -0
  131. package/dist/runtime/loader.js +449 -0
  132. package/dist/runtime/not-found.js +61 -0
  133. package/dist/runtime/page-renderer.js +35 -0
  134. package/dist/runtime/preamble.js +47 -0
  135. package/dist/runtime/react-compat.js +14 -0
  136. package/dist/runtime/renderer-shared.js +10 -0
  137. package/dist/runtime/renderers/react-client.js +14 -0
  138. package/dist/runtime/renderers/react-server.js +99 -0
  139. package/dist/runtime/renderers/react.js +17 -0
  140. package/dist/runtime/renderers/types.js +1 -0
  141. package/dist/runtime/root-error-handlers.js +29 -0
  142. package/dist/runtime/router/history.js +132 -0
  143. package/dist/runtime/router/index.js +240 -0
  144. package/dist/runtime/router/utils.js +118 -0
  145. package/dist/runtime/script.js +110 -0
  146. package/dist/runtime/scroll.js +40 -0
  147. package/dist/runtime/slice.js +11 -0
  148. package/dist/runtime/ssr.js +240 -0
  149. package/dist/runtime/static-query.js +47 -0
  150. package/dist/utils.js +4 -0
  151. package/package.json +105 -3
  152. package/types/graphql-tada.d.ts +223 -0
  153. package/types/graphql.d.ts +2 -0
  154. package/types/index.d.ts +2287 -0
  155. package/types/node.d.ts +380 -0
  156. package/types/reporter.d.ts +187 -0
  157. package/types/router.d.ts +102 -0
  158. package/types/vendor/gql-tada.d.ts +2529 -0
@@ -0,0 +1,207 @@
1
+ import { isAbstractType } from "../gql.js";
2
+ import { getDataStore, getNode, readingAllNodes, readingNodesOfTypes } from "../datastore/index.js";
3
+ import { withSitePageType } from "../site-page-nodes.js";
4
+ import { getNodeTypeNames, isLazyStore, nodesByIds, resolveFieldPath, runQuery, runQueryIds } from "./query-engine.js";
5
+ import "../query/dependencies.js";
6
+ import { inlineObjectRoots, trackInlineObjects } from "./inline-objects.js";
7
+ // src/node/schema/node-model.ts
8
+ /**
9
+ * Gatsby's `context.nodeModel` (findAll / findOne / getNodeById / getNodesByIds ...).
10
+ */
11
+ var LocalNodeModel = class LocalNodeModel {
12
+ getSchema;
13
+ path;
14
+ /** data dependencies of the running query (incremental query running) */
15
+ dependencies;
16
+ customContext;
17
+ constructor(options, path, dependencies) {
18
+ this.getSchema = options.schema;
19
+ this.customContext = options.customContext ?? {};
20
+ this.path = path;
21
+ this.dependencies = dependencies;
22
+ }
23
+ get schema() {
24
+ return this.getSchema();
25
+ }
26
+ /** like Gatsby: the derived model keeps the context (path, dependency tracking) unless overridden */
27
+ withContext({ path = this.path, dependencies = this.dependencies } = {}) {
28
+ return new LocalNodeModel({
29
+ schema: this.getSchema,
30
+ customContext: this.customContext
31
+ }, path, dependencies);
32
+ }
33
+ /** the same node model recording reads into `dependencies` */
34
+ withDependencies(dependencies) {
35
+ return new LocalNodeModel({
36
+ schema: this.getSchema,
37
+ customContext: this.customContext
38
+ }, this.path, dependencies);
39
+ }
40
+ resolveType(type) {
41
+ if (!type) return void 0;
42
+ if (typeof type === "string") return this.schema.getType(type) ?? void 0;
43
+ return type;
44
+ }
45
+ matchesType(node, type) {
46
+ return this.typeMatcher(type)(node);
47
+ }
48
+ /** `matchesType` for one type and many nodes (the type is looked up once) */
49
+ typeMatcher(type) {
50
+ if (!type) return () => true;
51
+ const t = this.resolveType(type);
52
+ if (!t) return (node) => node.internal.type === type;
53
+ if (isAbstractType(t)) {
54
+ const names = getNodeTypeNames(t, this.schema);
55
+ return (node) => names.includes(node.internal.type);
56
+ }
57
+ const name = t.name;
58
+ return (node) => name === node.internal.type;
59
+ }
60
+ getNodeById(args, _pageDependencies) {
61
+ const { id, type } = args ?? {};
62
+ if (!id) return null;
63
+ this.dependencies?.addNode(id);
64
+ const node = getNode(id);
65
+ if (!node || !this.matchesType(node, type)) return null;
66
+ trackInlineObjects(node);
67
+ return node;
68
+ }
69
+ getNodesByIds(args, _pageDependencies) {
70
+ const { ids, type } = args ?? {};
71
+ if (!Array.isArray(ids)) return [];
72
+ const result = [];
73
+ let matches;
74
+ for (const id of ids) {
75
+ this.dependencies?.addNode(id);
76
+ const node = getNode(id);
77
+ if (node && (matches ??= this.typeMatcher(type))(node)) {
78
+ trackInlineObjects(node);
79
+ result.push(node);
80
+ }
81
+ }
82
+ return result;
83
+ }
84
+ /** @deprecated removed in Gatsby 5 – kept for older plugins */
85
+ getAllNodes(args = {}) {
86
+ const ds = getDataStore();
87
+ if (!args.type) {
88
+ this.dependencies?.addConnection("*");
89
+ readingAllNodes("nodeModel.getAllNodes()");
90
+ return ds.getNodes();
91
+ }
92
+ const t = this.resolveType(args.type);
93
+ if (!t) return [];
94
+ const typeNames = getNodeTypeNames(t, this.schema);
95
+ readingNodesOfTypes(typeNames);
96
+ for (const n of typeNames) this.dependencies?.addConnection(n);
97
+ return typeNames.flatMap((n) => ds.getNodesByType(n));
98
+ }
99
+ async findAll(args, _options) {
100
+ const type = this.resolveType(args.type);
101
+ if (!type) return {
102
+ entries: [],
103
+ totalCount: async () => 0
104
+ };
105
+ if (isLazyStore()) {
106
+ const ids = await runQueryIds({
107
+ type,
108
+ query: args.query
109
+ }, {
110
+ schema: this.schema,
111
+ context: this.createResolverContext()
112
+ });
113
+ const skip = args.query?.skip ?? 0;
114
+ const limit = args.query?.limit;
115
+ const pageIds = skip || limit !== void 0 ? ids.slice(skip, limit !== void 0 ? skip + limit : void 0) : ids;
116
+ const entries = nodesByIds(pageIds);
117
+ for (const n of entries) trackInlineObjects(n);
118
+ return {
119
+ entries,
120
+ totalCount: async () => ids.length
121
+ };
122
+ }
123
+ const all = await runQuery({
124
+ type,
125
+ query: args.query
126
+ }, {
127
+ schema: this.schema,
128
+ context: this.createResolverContext()
129
+ });
130
+ const skip = args.query?.skip ?? 0;
131
+ const limit = args.query?.limit;
132
+ const entries = all.slice(skip, limit !== void 0 ? skip + limit : void 0);
133
+ for (const n of entries) trackInlineObjects(n);
134
+ return {
135
+ entries,
136
+ totalCount: async () => all.length
137
+ };
138
+ }
139
+ async findOne(args, _options) {
140
+ const type = this.resolveType(args.type);
141
+ if (!type) return null;
142
+ const node = (await runQuery({
143
+ type,
144
+ query: args.query,
145
+ firstOnly: true
146
+ }, {
147
+ schema: this.schema,
148
+ context: this.createResolverContext()
149
+ }))[0] ?? null;
150
+ if (node) trackInlineObjects(node);
151
+ return node;
152
+ }
153
+ /** @deprecated Gatsby 4 API */
154
+ async runQuery(args) {
155
+ if (args.firstOnly) return this.findOne(args);
156
+ return (await this.findAll(args)).entries;
157
+ }
158
+ getTypes() {
159
+ return withSitePageType(getDataStore().getTypes());
160
+ }
161
+ trackPageDependencies(result, pageDependencies) {
162
+ const deps = this.dependencies;
163
+ if (!deps) return result;
164
+ if (pageDependencies?.connectionType) deps.addConnection(pageDependencies.connectionType);
165
+ if (pageDependencies?.nodeId) deps.addNode(pageDependencies.nodeId);
166
+ if (!pageDependencies?.connectionType) {
167
+ for (const node of Array.isArray(result) ? result : [result]) if (node && typeof node === "object" && node.internal) deps.addNode(node.id);
168
+ }
169
+ return result;
170
+ }
171
+ findRootNodeAncestor(obj, predicate) {
172
+ let node;
173
+ if (obj?.internal?.type && obj.id) node = obj;
174
+ else {
175
+ const rootId = obj && typeof obj === "object" ? inlineObjectRoots.get(obj) : void 0;
176
+ node = rootId ? getNode(rootId) : void 0;
177
+ }
178
+ let last;
179
+ while (node) {
180
+ this.dependencies?.addNode(node.id);
181
+ if (predicate?.(node)) return node;
182
+ last = node;
183
+ node = node.parent ? getNode(node.parent) : void 0;
184
+ }
185
+ return predicate ? null : last ?? null;
186
+ }
187
+ trackInlineObjectsInRootNode(node) {
188
+ trackInlineObjects(node);
189
+ }
190
+ async getFieldValue(node, fieldPath) {
191
+ const type = this.schema.getType(node.internal.type);
192
+ if (!type) return void 0;
193
+ return resolveFieldPath(node, type, fieldPath.split("."), {
194
+ schema: this.schema,
195
+ context: this.createResolverContext()
196
+ });
197
+ }
198
+ async prepareNodes() {}
199
+ createResolverContext() {
200
+ return {
201
+ ...this.customContext,
202
+ nodeModel: this,
203
+ path: this.path
204
+ };
205
+ }
206
+ };
207
+ export { LocalNodeModel };