@laioutr/app-hygraph 1.1.8 → 1.3.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.
Files changed (31) hide show
  1. package/dist/codegen/index.d.mts +18 -0
  2. package/dist/codegen/index.mjs +41 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +1 -1
  5. package/dist/queries/index.d.mts +1 -0
  6. package/dist/queries/index.mjs +1 -0
  7. package/dist/runtime/index.d.ts +4 -0
  8. package/dist/runtime/index.js +3 -0
  9. package/dist/runtime/server/client/hygraph.d.ts +4 -2
  10. package/dist/runtime/server/client/hygraph.js +2 -2
  11. package/dist/runtime/server/const/passthroughTokens.d.ts +1 -0
  12. package/dist/runtime/server/const/passthroughTokens.js +1 -0
  13. package/dist/runtime/server/generated/graphql.d.ts +8062 -0
  14. package/dist/runtime/server/generated/graphql.js +367 -0
  15. package/dist/runtime/server/hygraph-utils/mediaMapper.d.ts +6 -1
  16. package/dist/runtime/server/hygraph-utils/mediaMapper.js +5 -5
  17. package/dist/runtime/server/media-library/hygraph.js +2 -2
  18. package/dist/runtime/server/middleware/defineHygraph.js +3 -1
  19. package/dist/runtime/server/orchestr/blog/blogCollection.resolver.js +15 -11
  20. package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.query.js +15 -3
  21. package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.template.js +8 -6
  22. package/dist/runtime/server/orchestr/blog/blogCollectionPosts.link.js +14 -9
  23. package/dist/runtime/server/orchestr/blog/blogPost.resolver.js +7 -3
  24. package/dist/runtime/server/orchestr/blog/blogPostBySlug.query.js +2 -2
  25. package/dist/runtime/server/queries/blog.d.ts +4 -2
  26. package/dist/runtime/server/queries/blog.js +29 -4
  27. package/dist/runtime/server/queries/mediaLibrary.d.ts +1 -1
  28. package/dist/runtime/server/queries/mediaLibrary.js +1 -1
  29. package/dist/runtime/server/types/hygraph.d.ts +18 -0
  30. package/dist/runtime/server/types/hygraph.js +0 -0
  31. package/package.json +37 -2
@@ -0,0 +1,18 @@
1
+ import { CodegenConfig } from '@graphql-codegen/cli';
2
+
3
+ interface HygraphCodegenOptions {
4
+ /** Hygraph Content API endpoint URL. Defaults to process.env.HYGRAPH_CONTENT_API_URL */
5
+ schemaUrl?: string;
6
+ /** Hygraph API token. Defaults to process.env.HYGRAPH_TOKEN */
7
+ token?: string;
8
+ /** Glob pattern for GraphQL document files. Defaults to 'src/runtime/server/queries/**\/*.ts' */
9
+ documents?: string;
10
+ /** Output file path for generated types. Defaults to 'src/runtime/server/generated/graphql.ts' */
11
+ outputPath?: string;
12
+ /** Additional custom scalar mappings (merged with Hygraph defaults) */
13
+ scalars?: Record<string, string>;
14
+ }
15
+ declare const defineHygraphCodegen: (options?: HygraphCodegenOptions) => CodegenConfig;
16
+
17
+ export { defineHygraphCodegen };
18
+ export type { HygraphCodegenOptions };
@@ -0,0 +1,41 @@
1
+ const DEFAULT_SCALARS = {
2
+ DateTime: "string",
3
+ Date: "string",
4
+ Json: "Record<string, unknown>",
5
+ Long: "number",
6
+ RichTextAST: "Record<string, unknown>",
7
+ Hex: "string",
8
+ RGBAHue: "string",
9
+ RGBATransparency: "number"
10
+ };
11
+ const defineHygraphCodegen = (options = {}) => {
12
+ const schemaUrl = options.schemaUrl ?? process.env.HYGRAPH_CONTENT_API_URL;
13
+ const token = options.token ?? process.env.HYGRAPH_TOKEN;
14
+ const documents = options.documents ?? "src/runtime/server/queries/**/*.ts";
15
+ const outputPath = options.outputPath ?? "src/runtime/server/generated/graphql.ts";
16
+ return {
17
+ overwrite: true,
18
+ schema: [
19
+ {
20
+ [schemaUrl]: {
21
+ headers: {
22
+ Authorization: `Bearer ${token}`
23
+ }
24
+ }
25
+ }
26
+ ],
27
+ documents,
28
+ generates: {
29
+ [outputPath]: {
30
+ plugins: ["typescript", "typescript-operations"],
31
+ config: {
32
+ skipTypename: true,
33
+ maybeValue: "T | null",
34
+ scalars: { ...DEFAULT_SCALARS, ...options.scalars }
35
+ }
36
+ }
37
+ }
38
+ };
39
+ };
40
+
41
+ export { defineHygraphCodegen };
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-hygraph",
3
- "version": "1.1.8",
3
+ "version": "1.3.0",
4
4
  "configKey": "@laioutr/app-hygraph",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { defu } from 'defu';
3
3
  import { registerLaioutrApp } from '@laioutr-core/kit';
4
4
 
5
5
  const name = "@laioutr/app-hygraph";
6
- const version = "1.1.8";
6
+ const version = "1.3.0";
7
7
 
8
8
  const module = defineNuxtModule({
9
9
  meta: {
@@ -0,0 +1 @@
1
+ export { AssetFragment } from '../../dist/runtime/server/queries/asset.js';
@@ -0,0 +1 @@
1
+ export { AssetFragment } from '../../dist/runtime/server/queries/asset.js';
@@ -0,0 +1,4 @@
1
+ export { hygraphClientFactory } from './server/client/hygraph.js';
2
+ export { defineHygraph } from './server/middleware/defineHygraph.js';
3
+ export { mapHygraphMedia, filenameToAlt, stripFileExtension } from './server/hygraph-utils/mediaMapper.js';
4
+ export type { HygraphAsset, HygraphClientConfig, HygraphResponse } from './server/types/hygraph.js';
@@ -0,0 +1,3 @@
1
+ export { hygraphClientFactory } from "./server/client/hygraph.js";
2
+ export { defineHygraph } from "./server/middleware/defineHygraph.js";
3
+ export { mapHygraphMedia, filenameToAlt, stripFileExtension } from "./server/hygraph-utils/mediaMapper.js";
@@ -1,3 +1,5 @@
1
- export declare const hygraphClientFactory: () => {
2
- request: (query: string, variables?: unknown) => Promise<any>;
1
+ import type { HygraphClientConfig, HygraphResponse } from '../types/hygraph.js';
2
+ export type { HygraphResponse };
3
+ export declare const hygraphClientFactory: (explicitConfig?: HygraphClientConfig) => {
4
+ request: <TData = unknown>(query: string, variables?: unknown) => Promise<HygraphResponse<TData>>;
3
5
  };
@@ -1,6 +1,6 @@
1
1
  import { useRuntimeConfig } from "#imports";
2
- export const hygraphClientFactory = () => {
3
- const config = useRuntimeConfig()["@laioutr/app-hygraph"];
2
+ export const hygraphClientFactory = (explicitConfig) => {
3
+ const config = explicitConfig ?? useRuntimeConfig()["@laioutr/app-hygraph"];
4
4
  const request = async (query, variables = null) => {
5
5
  const res = await fetch(config.contentApiUrl, {
6
6
  method: "POST",
@@ -1 +1,2 @@
1
+ export declare const blogCollectionToken: any;
1
2
  export declare const blogPostsToken: any;
@@ -1,2 +1,3 @@
1
1
  import { createPassthroughToken } from "#imports";
2
+ export const blogCollectionToken = createPassthroughToken("hygraph/blog-collection");
2
3
  export const blogPostsToken = createPassthroughToken("hygraph/blog-posts");