@eide/foir-cli 0.1.16 → 0.1.18

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 (59) hide show
  1. package/dist/cli.js +3 -0
  2. package/dist/codegen/field-mapping.d.ts +1 -0
  3. package/dist/codegen/field-mapping.d.ts.map +1 -1
  4. package/dist/codegen/field-mapping.js +8 -0
  5. package/dist/codegen/generators/customer-profile-hooks.d.ts +5 -0
  6. package/dist/codegen/generators/customer-profile-hooks.d.ts.map +1 -0
  7. package/dist/codegen/generators/customer-profile-hooks.js +78 -0
  8. package/dist/codegen/generators/customer-profile-loaders.d.ts +5 -0
  9. package/dist/codegen/generators/customer-profile-loaders.d.ts.map +1 -0
  10. package/dist/codegen/generators/customer-profile-loaders.js +67 -0
  11. package/dist/codegen/generators/customer-profile-operations.d.ts +5 -0
  12. package/dist/codegen/generators/customer-profile-operations.d.ts.map +1 -0
  13. package/dist/codegen/generators/customer-profile-operations.js +126 -0
  14. package/dist/codegen/generators/documents.d.ts.map +1 -1
  15. package/dist/codegen/generators/documents.js +4 -0
  16. package/dist/codegen/generators/public-schema-content.d.ts +14 -0
  17. package/dist/codegen/generators/public-schema-content.d.ts.map +1 -0
  18. package/dist/codegen/generators/public-schema-content.js +22 -0
  19. package/dist/codegen/generators/react-hooks-index.d.ts +6 -0
  20. package/dist/codegen/generators/react-hooks-index.d.ts.map +1 -0
  21. package/dist/codegen/generators/react-hooks-index.js +20 -0
  22. package/dist/codegen/generators/react-hooks.d.ts +7 -0
  23. package/dist/codegen/generators/react-hooks.d.ts.map +1 -0
  24. package/dist/codegen/generators/react-hooks.js +139 -0
  25. package/dist/codegen/generators/remix-loaders-index.d.ts +6 -0
  26. package/dist/codegen/generators/remix-loaders-index.d.ts.map +1 -0
  27. package/dist/codegen/generators/remix-loaders-index.js +20 -0
  28. package/dist/codegen/generators/remix-loaders.d.ts +7 -0
  29. package/dist/codegen/generators/remix-loaders.d.ts.map +1 -0
  30. package/dist/codegen/generators/remix-loaders.js +107 -0
  31. package/dist/codegen/generators/static-documents.d.ts +14 -0
  32. package/dist/codegen/generators/static-documents.d.ts.map +1 -0
  33. package/dist/codegen/generators/static-documents.js +766 -0
  34. package/dist/codegen/generators/typed-operations-common.d.ts +6 -0
  35. package/dist/codegen/generators/typed-operations-common.d.ts.map +1 -0
  36. package/dist/codegen/generators/typed-operations-common.js +74 -0
  37. package/dist/codegen/generators/typed-operations-index.d.ts +6 -0
  38. package/dist/codegen/generators/typed-operations-index.d.ts.map +1 -0
  39. package/dist/codegen/generators/typed-operations-index.js +22 -0
  40. package/dist/codegen/generators/typed-operations.d.ts +11 -0
  41. package/dist/codegen/generators/typed-operations.d.ts.map +1 -0
  42. package/dist/codegen/generators/typed-operations.js +251 -0
  43. package/dist/commands/create-extension.d.ts +4 -0
  44. package/dist/commands/create-extension.d.ts.map +1 -0
  45. package/dist/commands/create-extension.js +60 -0
  46. package/dist/commands/pull.d.ts.map +1 -1
  47. package/dist/commands/pull.js +135 -25
  48. package/dist/config/pull-config.d.ts +6 -0
  49. package/dist/config/pull-config.d.ts.map +1 -1
  50. package/dist/config/pull-config.js +50 -1
  51. package/dist/config/types.d.ts +23 -0
  52. package/dist/config/types.d.ts.map +1 -1
  53. package/dist/scaffold/package-manager.d.ts +12 -0
  54. package/dist/scaffold/package-manager.d.ts.map +1 -0
  55. package/dist/scaffold/package-manager.js +51 -0
  56. package/dist/scaffold/scaffold.d.ts +4 -0
  57. package/dist/scaffold/scaffold.d.ts.map +1 -0
  58. package/dist/scaffold/scaffold.js +462 -0
  59. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -36,6 +36,7 @@ import { registerFilesCommands } from './commands/files.js';
36
36
  import { registerNotesCommands } from './commands/notes.js';
37
37
  import { registerVariantCatalogCommands } from './commands/variant-catalog.js';
38
38
  import { registerPullCommand } from './commands/pull.js';
39
+ import { registerCreateExtensionCommand } from './commands/create-extension.js';
39
40
  const program = new Command();
40
41
  program
41
42
  .name('foir')
@@ -81,4 +82,6 @@ registerNotesCommands(program, getGlobalOpts);
81
82
  registerVariantCatalogCommands(program, getGlobalOpts);
82
83
  // Codegen
83
84
  registerPullCommand(program, getGlobalOpts);
85
+ // Scaffolding
86
+ registerCreateExtensionCommand(program, getGlobalOpts);
84
87
  program.parse();
@@ -23,6 +23,7 @@ export declare function getRequiredImports(fields: FieldSchemaForGen[]): Set<str
23
23
  export declare function getInlineSchemaReferences(fields: FieldSchemaForGen[]): Set<string>;
24
24
  export declare function toCamelCase(str: string): string;
25
25
  export declare function toPascalCase(str: string): string;
26
+ export declare function toUpperSnakeCase(str: string): string;
26
27
  export declare function sanitizeFieldName(key: string): string;
27
28
  export declare function generateFieldDef(field: FieldSchemaForGen): string;
28
29
  //# sourceMappingURL=field-mapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../src/codegen/field-mapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,aAsBhC,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA0D1D,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,IAAI,GAAE,QAAQ,GAAG,OAAkB,GAClC,MAAM,CAwCR;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAc3E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,iBAAiB,EAAE,GAC1B,GAAG,CAAC,MAAM,CAAC,CAiBb;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiFjE"}
1
+ {"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../src/codegen/field-mapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,aAsBhC,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA0D1D,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,IAAI,GAAE,QAAQ,GAAG,OAAkB,GAClC,MAAM,CAwCR;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAc3E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,iBAAiB,EAAE,GAC1B,GAAG,CAAC,MAAM,CAAC,CAiBb;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiFjE"}
@@ -164,6 +164,14 @@ export function toPascalCase(str) {
164
164
  const camel = toCamelCase(str);
165
165
  return camel.charAt(0).toUpperCase() + camel.slice(1);
166
166
  }
167
+ export function toUpperSnakeCase(str) {
168
+ if (!str)
169
+ return 'UNKNOWN';
170
+ return str
171
+ .replace(/([a-z])([A-Z])/g, '$1_$2')
172
+ .replace(/[-\s]+/g, '_')
173
+ .toUpperCase();
174
+ }
167
175
  export function sanitizeFieldName(key) {
168
176
  if (!key)
169
177
  return 'unknown';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generates React Apollo hooks for customer profiles.
3
+ */
4
+ export declare function generateCustomerProfileHooks(): string;
5
+ //# sourceMappingURL=customer-profile-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-profile-hooks.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/customer-profile-hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,4BAA4B,IAAI,MAAM,CA0ErD"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Generates React Apollo hooks for customer profiles.
3
+ */
4
+ export function generateCustomerProfileHooks() {
5
+ return `/**
6
+ * React Apollo hooks for Customer Profiles
7
+ *
8
+ * @generated by foir — DO NOT EDIT MANUALLY
9
+ */
10
+
11
+ import { useQuery, useMutation } from '@apollo/client';
12
+ import type { QueryHookOptions, MutationHookOptions } from '@apollo/client';
13
+ import { gql } from '@apollo/client';
14
+ import {
15
+ GET_MY_PROFILE,
16
+ GET_CUSTOMER_PROFILE,
17
+ SET_MY_PROFILE,
18
+ UPDATE_CUSTOMER_PROFILE,
19
+ DELETE_MY_PROFILE,
20
+ } from '../operations/customer-profile.js';
21
+ import type {
22
+ GetMyProfileResult,
23
+ GetCustomerProfileVariables,
24
+ GetCustomerProfileResult,
25
+ SetMyProfileVariables,
26
+ SetMyProfileResult,
27
+ UpdateCustomerProfileVariables,
28
+ UpdateCustomerProfileResult,
29
+ DeleteMyProfileResult,
30
+ } from '../operations/customer-profile.js';
31
+
32
+ export function useMyProfile(
33
+ options?: QueryHookOptions<GetMyProfileResult>
34
+ ) {
35
+ return useQuery<GetMyProfileResult>(
36
+ gql\`\${GET_MY_PROFILE}\`,
37
+ options
38
+ );
39
+ }
40
+
41
+ export function useCustomerProfile(
42
+ customerId: string | null | undefined,
43
+ options?: Omit<QueryHookOptions<GetCustomerProfileResult, GetCustomerProfileVariables>, 'variables' | 'skip'>
44
+ ) {
45
+ return useQuery<GetCustomerProfileResult, GetCustomerProfileVariables>(
46
+ gql\`\${GET_CUSTOMER_PROFILE}\`,
47
+ { ...options, variables: { customerId: customerId! }, skip: !customerId }
48
+ );
49
+ }
50
+
51
+ export function useSetMyProfile(
52
+ options?: MutationHookOptions<SetMyProfileResult, SetMyProfileVariables>
53
+ ) {
54
+ return useMutation<SetMyProfileResult, SetMyProfileVariables>(
55
+ gql\`\${SET_MY_PROFILE}\`,
56
+ options
57
+ );
58
+ }
59
+
60
+ export function useUpdateCustomerProfile(
61
+ options?: MutationHookOptions<UpdateCustomerProfileResult, UpdateCustomerProfileVariables>
62
+ ) {
63
+ return useMutation<UpdateCustomerProfileResult, UpdateCustomerProfileVariables>(
64
+ gql\`\${UPDATE_CUSTOMER_PROFILE}\`,
65
+ options
66
+ );
67
+ }
68
+
69
+ export function useDeleteMyProfile(
70
+ options?: MutationHookOptions<DeleteMyProfileResult>
71
+ ) {
72
+ return useMutation<DeleteMyProfileResult>(
73
+ gql\`\${DELETE_MY_PROFILE}\`,
74
+ options
75
+ );
76
+ }
77
+ `;
78
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generates Remix/server-side loader functions for customer profiles.
3
+ */
4
+ export declare function generateCustomerProfileLoaders(): string;
5
+ //# sourceMappingURL=customer-profile-loaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-profile-loaders.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/customer-profile-loaders.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,8BAA8B,IAAI,MAAM,CA+DvD"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Generates Remix/server-side loader functions for customer profiles.
3
+ */
4
+ export function generateCustomerProfileLoaders() {
5
+ return `/**
6
+ * Remix / server-side loader functions for Customer Profiles
7
+ *
8
+ * @generated by foir — DO NOT EDIT MANUALLY
9
+ */
10
+
11
+ import {
12
+ GET_MY_PROFILE,
13
+ GET_CUSTOMER_PROFILE,
14
+ SET_MY_PROFILE,
15
+ UPDATE_CUSTOMER_PROFILE,
16
+ DELETE_MY_PROFILE,
17
+ } from '../operations/customer-profile.js';
18
+ import type {
19
+ GetMyProfileResult,
20
+ GetCustomerProfileVariables,
21
+ GetCustomerProfileResult,
22
+ SetMyProfileVariables,
23
+ SetMyProfileResult,
24
+ UpdateCustomerProfileVariables,
25
+ UpdateCustomerProfileResult,
26
+ DeleteMyProfileResult,
27
+ } from '../operations/customer-profile.js';
28
+
29
+ /** A minimal GraphQL client interface (works with graphql-request, urql, or custom). */
30
+ export interface GraphQLClient {
31
+ request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
32
+ }
33
+
34
+ export async function getMyProfile(
35
+ client: GraphQLClient
36
+ ): Promise<GetMyProfileResult> {
37
+ return client.request<GetMyProfileResult>(GET_MY_PROFILE);
38
+ }
39
+
40
+ export async function getCustomerProfile(
41
+ client: GraphQLClient,
42
+ variables: GetCustomerProfileVariables
43
+ ): Promise<GetCustomerProfileResult> {
44
+ return client.request<GetCustomerProfileResult>(GET_CUSTOMER_PROFILE, variables as Record<string, unknown>);
45
+ }
46
+
47
+ export async function setMyProfile(
48
+ client: GraphQLClient,
49
+ variables: SetMyProfileVariables
50
+ ): Promise<SetMyProfileResult> {
51
+ return client.request<SetMyProfileResult>(SET_MY_PROFILE, variables as Record<string, unknown>);
52
+ }
53
+
54
+ export async function updateCustomerProfile(
55
+ client: GraphQLClient,
56
+ variables: UpdateCustomerProfileVariables
57
+ ): Promise<UpdateCustomerProfileResult> {
58
+ return client.request<UpdateCustomerProfileResult>(UPDATE_CUSTOMER_PROFILE, variables as Record<string, unknown>);
59
+ }
60
+
61
+ export async function deleteMyProfile(
62
+ client: GraphQLClient
63
+ ): Promise<DeleteMyProfileResult> {
64
+ return client.request<DeleteMyProfileResult>(DELETE_MY_PROFILE);
65
+ }
66
+ `;
67
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generates typed operations for customer profiles.
3
+ */
4
+ export declare function generateCustomerProfileOperations(typesRelPath: string): string;
5
+ //# sourceMappingURL=customer-profile-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-profile-operations.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/customer-profile-operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,MAAM,GACnB,MAAM,CA0HR"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Generates typed operations for customer profiles.
3
+ */
4
+ export function generateCustomerProfileOperations(typesRelPath) {
5
+ return `/**
6
+ * Typed operations for Customer Profiles
7
+ *
8
+ * @generated by foir — DO NOT EDIT MANUALLY
9
+ */
10
+
11
+ import type { CustomerProfileData } from '${typesRelPath}/customer-profile.js';
12
+
13
+ export const GET_MY_PROFILE = \`
14
+ query GetMyProfile {
15
+ myProfile {
16
+ id
17
+ customerId
18
+ data
19
+ createdAt
20
+ updatedAt
21
+ }
22
+ }
23
+ \`;
24
+
25
+ export interface GetMyProfileResult {
26
+ myProfile: {
27
+ id: string;
28
+ customerId: string;
29
+ data: CustomerProfileData;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ } | null;
33
+ }
34
+
35
+ export const GET_CUSTOMER_PROFILE = \`
36
+ query GetCustomerProfile($customerId: ID!) {
37
+ customerProfile(customerId: $customerId) {
38
+ id
39
+ customerId
40
+ data
41
+ createdAt
42
+ updatedAt
43
+ }
44
+ }
45
+ \`;
46
+
47
+ export interface GetCustomerProfileVariables {
48
+ customerId: string;
49
+ }
50
+
51
+ export interface GetCustomerProfileResult {
52
+ customerProfile: {
53
+ id: string;
54
+ customerId: string;
55
+ data: CustomerProfileData;
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ } | null;
59
+ }
60
+
61
+ export const SET_MY_PROFILE = \`
62
+ mutation SetMyProfile($data: JSON!) {
63
+ setMyProfile(data: $data) {
64
+ id
65
+ customerId
66
+ data
67
+ createdAt
68
+ updatedAt
69
+ }
70
+ }
71
+ \`;
72
+
73
+ export interface SetMyProfileVariables {
74
+ data: Partial<CustomerProfileData>;
75
+ }
76
+
77
+ export interface SetMyProfileResult {
78
+ setMyProfile: {
79
+ id: string;
80
+ customerId: string;
81
+ data: CustomerProfileData;
82
+ createdAt: string;
83
+ updatedAt: string;
84
+ };
85
+ }
86
+
87
+ export const UPDATE_CUSTOMER_PROFILE = \`
88
+ mutation UpdateCustomerProfile($customerId: ID, $input: CustomerProfileInput!) {
89
+ updateCustomerProfile(customerId: $customerId, input: $input) {
90
+ id
91
+ customerId
92
+ data
93
+ createdAt
94
+ updatedAt
95
+ }
96
+ }
97
+ \`;
98
+
99
+ export interface UpdateCustomerProfileVariables {
100
+ customerId?: string;
101
+ input: {
102
+ data: Partial<CustomerProfileData>;
103
+ };
104
+ }
105
+
106
+ export interface UpdateCustomerProfileResult {
107
+ updateCustomerProfile: {
108
+ id: string;
109
+ customerId: string;
110
+ data: CustomerProfileData;
111
+ createdAt: string;
112
+ updatedAt: string;
113
+ };
114
+ }
115
+
116
+ export const DELETE_MY_PROFILE = \`
117
+ mutation DeleteMyProfile {
118
+ deleteMyProfile
119
+ }
120
+ \`;
121
+
122
+ export interface DeleteMyProfileResult {
123
+ deleteMyProfile: boolean;
124
+ }
125
+ `;
126
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/documents.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAiGlE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAgBhD"}
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/documents.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAiGlE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAoBhD"}
@@ -111,12 +111,16 @@ export function generateSharedFragments() {
111
111
  fragment ShareFields on Share {
112
112
  id
113
113
  resourceType
114
+ recordId
115
+ fileId
114
116
  permission
115
117
  status
118
+ sharedWithCustomerId
116
119
  acceptedAt
117
120
  declinedAt
118
121
  expiresAt
119
122
  createdAt
123
+ createdBy
120
124
  revokedAt
121
125
  }
122
126
  `;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Fetches the public schema from the platform and writes it for consumer codegen.
3
+ *
4
+ * Instead of bundling a static copy, we fetch it at `foir pull` time
5
+ * using the introspection-like projectSchemas query. This ensures
6
+ * the schema always matches the connected platform version.
7
+ */
8
+ import type { GraphQLClient } from 'graphql-request';
9
+ /**
10
+ * Fetch the public schema SDL from the platform.
11
+ * Falls back to empty string if not available (non-critical).
12
+ */
13
+ export declare function fetchPublicSchema(client: GraphQLClient): Promise<string | null>;
14
+ //# sourceMappingURL=public-schema-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-schema-content.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/public-schema-content.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxB"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Fetches the public schema from the platform and writes it for consumer codegen.
3
+ *
4
+ * Instead of bundling a static copy, we fetch it at `foir pull` time
5
+ * using the introspection-like projectSchemas query. This ensures
6
+ * the schema always matches the connected platform version.
7
+ */
8
+ /**
9
+ * Fetch the public schema SDL from the platform.
10
+ * Falls back to empty string if not available (non-critical).
11
+ */
12
+ export async function fetchPublicSchema(client) {
13
+ try {
14
+ // The public API exposes an SDL endpoint; if not available, skip.
15
+ const res = await client.request(`query { _service { sdl } }`);
16
+ return res._service?.sdl ?? null;
17
+ }
18
+ catch {
19
+ // Schema fetch is best-effort — not all deployments expose _service
20
+ return null;
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the hooks/index.ts barrel re-export file.
3
+ */
4
+ import type { CodegenModel } from '../fetch-models.js';
5
+ export declare function generateReactHooksIndex(models: CodegenModel[], hasCustomerProfile: boolean): string;
6
+ //# sourceMappingURL=react-hooks-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-hooks-index.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/react-hooks-index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EAAE,EACtB,kBAAkB,EAAE,OAAO,GAC1B,MAAM,CAoBR"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Generates the hooks/index.ts barrel re-export file.
3
+ */
4
+ export function generateReactHooksIndex(models, hasCustomerProfile) {
5
+ const lines = [];
6
+ lines.push(`/**
7
+ * React Apollo hooks for all models.
8
+ *
9
+ * @generated by foir — DO NOT EDIT MANUALLY
10
+ */
11
+ `);
12
+ for (const model of models) {
13
+ lines.push(`export * from './${model.key}.js';`);
14
+ }
15
+ if (hasCustomerProfile) {
16
+ lines.push(`export * from './customer-profile.js';`);
17
+ }
18
+ lines.push('');
19
+ return lines.join('\n');
20
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates per-model React Apollo hooks.
3
+ * Each hook file imports from ../operations/{key}.js and wraps useQuery/useMutation.
4
+ */
5
+ import type { CodegenModel } from '../fetch-models.js';
6
+ export declare function generateReactHooks(model: CodegenModel): string;
7
+ //# sourceMappingURL=react-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/react-hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAiJ9D"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Generates per-model React Apollo hooks.
3
+ * Each hook file imports from ../operations/{key}.js and wraps useQuery/useMutation.
4
+ */
5
+ import { toPascalCase, toUpperSnakeCase } from '../field-mapping.js';
6
+ export function generateReactHooks(model) {
7
+ const typeName = toPascalCase(model.key);
8
+ const upperSnake = toUpperSnakeCase(model.key);
9
+ const pluralName = model.pluralName
10
+ ? toPascalCase(model.pluralName.replace(/\s+/g, ''))
11
+ : `${typeName}s`;
12
+ const pluralUpperSnake = model.pluralName
13
+ ? toUpperSnakeCase(model.pluralName.replace(/\s+/g, ''))
14
+ : `${upperSnake}S`;
15
+ const lines = [];
16
+ // Imports
17
+ lines.push(`/**
18
+ * React Apollo hooks for ${model.name ?? model.key}
19
+ *
20
+ * @generated by foir — DO NOT EDIT MANUALLY
21
+ */
22
+
23
+ import { useQuery, useMutation } from '@apollo/client';
24
+ import type { QueryHookOptions, MutationHookOptions } from '@apollo/client';
25
+ import { gql } from '@apollo/client';
26
+ import {
27
+ GET_${upperSnake},
28
+ GET_${upperSnake}_BY_KEY,
29
+ LIST_${pluralUpperSnake},
30
+ CREATE_${upperSnake},
31
+ UPDATE_${upperSnake},
32
+ DELETE_${upperSnake},
33
+ PUBLISH_${upperSnake}_VERSION,
34
+ UNPUBLISH_${upperSnake},
35
+ } from '../operations/${model.key}.js';
36
+ import type {
37
+ ${typeName}Record,
38
+ Get${typeName}Variables,
39
+ Get${typeName}Result,
40
+ Get${typeName}ByKeyVariables,
41
+ Get${typeName}ByKeyResult,
42
+ List${pluralName}Variables,
43
+ List${pluralName}Result,
44
+ Create${typeName}Variables,
45
+ Create${typeName}Result,
46
+ Update${typeName}Variables,
47
+ Update${typeName}Result,
48
+ Delete${typeName}Variables,
49
+ Delete${typeName}Result,
50
+ } from '../operations/${model.key}.js';
51
+ `);
52
+ // Re-export types for convenience
53
+ lines.push(`export type { ${typeName}Record };`);
54
+ lines.push('');
55
+ // useGet{Model}
56
+ lines.push(`export function useGet${typeName}(
57
+ id: string | null | undefined,
58
+ options?: Omit<QueryHookOptions<Get${typeName}Result, Get${typeName}Variables>, 'variables' | 'skip'>
59
+ ) {
60
+ return useQuery<Get${typeName}Result, Get${typeName}Variables>(
61
+ gql\`\${GET_${upperSnake}}\`,
62
+ { ...options, variables: { id: id! }, skip: !id }
63
+ );
64
+ }`);
65
+ lines.push('');
66
+ // useGet{Model}ByKey
67
+ lines.push(`export function useGet${typeName}ByKey(
68
+ naturalKey: string | null | undefined,
69
+ options?: Omit<QueryHookOptions<Get${typeName}ByKeyResult, Get${typeName}ByKeyVariables>, 'variables' | 'skip'>
70
+ ) {
71
+ return useQuery<Get${typeName}ByKeyResult, Get${typeName}ByKeyVariables>(
72
+ gql\`\${GET_${upperSnake}_BY_KEY}\`,
73
+ { ...options, variables: { naturalKey: naturalKey! }, skip: !naturalKey }
74
+ );
75
+ }`);
76
+ lines.push('');
77
+ // useList{Models}
78
+ lines.push(`export function useList${pluralName}(
79
+ variables?: List${pluralName}Variables,
80
+ options?: Omit<QueryHookOptions<List${pluralName}Result, List${pluralName}Variables>, 'variables'>
81
+ ) {
82
+ return useQuery<List${pluralName}Result, List${pluralName}Variables>(
83
+ gql\`\${LIST_${pluralUpperSnake}}\`,
84
+ { ...options, variables }
85
+ );
86
+ }`);
87
+ lines.push('');
88
+ // useCreate{Model}
89
+ lines.push(`export function useCreate${typeName}(
90
+ options?: MutationHookOptions<Create${typeName}Result, Create${typeName}Variables>
91
+ ) {
92
+ return useMutation<Create${typeName}Result, Create${typeName}Variables>(
93
+ gql\`\${CREATE_${upperSnake}}\`,
94
+ options
95
+ );
96
+ }`);
97
+ lines.push('');
98
+ // useUpdate{Model}
99
+ lines.push(`export function useUpdate${typeName}(
100
+ options?: MutationHookOptions<Update${typeName}Result, Update${typeName}Variables>
101
+ ) {
102
+ return useMutation<Update${typeName}Result, Update${typeName}Variables>(
103
+ gql\`\${UPDATE_${upperSnake}}\`,
104
+ options
105
+ );
106
+ }`);
107
+ lines.push('');
108
+ // useDelete{Model}
109
+ lines.push(`export function useDelete${typeName}(
110
+ options?: MutationHookOptions<Delete${typeName}Result, Delete${typeName}Variables>
111
+ ) {
112
+ return useMutation<Delete${typeName}Result, Delete${typeName}Variables>(
113
+ gql\`\${DELETE_${upperSnake}}\`,
114
+ options
115
+ );
116
+ }`);
117
+ lines.push('');
118
+ // usePublish{Model}Version
119
+ lines.push(`export function usePublish${typeName}Version(
120
+ options?: MutationHookOptions<{ publishVersion: boolean }, { versionId: string }>
121
+ ) {
122
+ return useMutation<{ publishVersion: boolean }, { versionId: string }>(
123
+ gql\`\${PUBLISH_${upperSnake}_VERSION}\`,
124
+ options
125
+ );
126
+ }`);
127
+ lines.push('');
128
+ // useUnpublish{Model}
129
+ lines.push(`export function useUnpublish${typeName}(
130
+ options?: MutationHookOptions<{ unpublishRecord: boolean }, { id: string }>
131
+ ) {
132
+ return useMutation<{ unpublishRecord: boolean }, { id: string }>(
133
+ gql\`\${UNPUBLISH_${upperSnake}}\`,
134
+ options
135
+ );
136
+ }`);
137
+ lines.push('');
138
+ return lines.join('\n');
139
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the loaders/index.ts barrel re-export file.
3
+ */
4
+ import type { CodegenModel } from '../fetch-models.js';
5
+ export declare function generateRemixLoadersIndex(models: CodegenModel[], hasCustomerProfile: boolean): string;
6
+ //# sourceMappingURL=remix-loaders-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remix-loaders-index.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/remix-loaders-index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,EAAE,EACtB,kBAAkB,EAAE,OAAO,GAC1B,MAAM,CAoBR"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Generates the loaders/index.ts barrel re-export file.
3
+ */
4
+ export function generateRemixLoadersIndex(models, hasCustomerProfile) {
5
+ const lines = [];
6
+ lines.push(`/**
7
+ * Remix / server-side loader functions for all models.
8
+ *
9
+ * @generated by foir — DO NOT EDIT MANUALLY
10
+ */
11
+ `);
12
+ for (const model of models) {
13
+ lines.push(`export * from './${model.key}.js';`);
14
+ }
15
+ if (hasCustomerProfile) {
16
+ lines.push(`export * from './customer-profile.js';`);
17
+ }
18
+ lines.push('');
19
+ return lines.join('\n');
20
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates per-model Remix loader functions.
3
+ * Each function is a typed async wrapper over a generic GraphQL client.
4
+ */
5
+ import type { CodegenModel } from '../fetch-models.js';
6
+ export declare function generateRemixLoaders(model: CodegenModel): string;
7
+ //# sourceMappingURL=remix-loaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remix-loaders.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/remix-loaders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAsGhE"}