@eide/foir-cli 0.1.12 → 0.1.13

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.
@@ -3,4 +3,10 @@
3
3
  */
4
4
  import type { CodegenModel } from '../fetch-models.js';
5
5
  export declare function generateModelDocuments(model: CodegenModel): string;
6
+ /**
7
+ * Generate the shared ShareFields fragment file.
8
+ * This must be emitted once (not per-model) to avoid duplicate fragment errors
9
+ * in Apollo iOS and other codegen tools that validate across all .graphql files.
10
+ */
11
+ export declare function generateSharedFragments(): string;
6
12
  //# sourceMappingURL=documents.d.ts.map
@@ -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"}
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"}
@@ -99,8 +99,15 @@ mutation Unpublish${typeName}($id: ID!) {
99
99
  }
100
100
  ${model.config.sharing?.enabled ? generateSharingOperations(model.key, typeName, pluralName) : ''}`;
101
101
  }
102
- function generateSharingOperations(modelKey, typeName, pluralName) {
103
- return `# Sharing operations
102
+ /**
103
+ * Generate the shared ShareFields fragment file.
104
+ * This must be emitted once (not per-model) to avoid duplicate fragment errors
105
+ * in Apollo iOS and other codegen tools that validate across all .graphql files.
106
+ */
107
+ export function generateSharedFragments() {
108
+ return `# Shared fragments used across multiple model documents
109
+ # @generated by foir — DO NOT EDIT MANUALLY
110
+
104
111
  fragment ShareFields on Share {
105
112
  id
106
113
  resourceType
@@ -112,6 +119,10 @@ fragment ShareFields on Share {
112
119
  createdAt
113
120
  revokedAt
114
121
  }
122
+ `;
123
+ }
124
+ function generateSharingOperations(modelKey, typeName, pluralName) {
125
+ return `# Sharing operations
115
126
 
116
127
  mutation Share${typeName}($recordId: ID!, $sharedWithCustomerId: ID!, $permission: SharePermission!) {
117
128
  shareRecord(recordId: $recordId, sharedWithCustomerId: $sharedWithCustomerId, permission: $permission) {
@@ -1 +1 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAuBtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA4LN"}
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAuBtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAuMN"}
@@ -10,7 +10,7 @@ import { generateFieldTypesFile } from '../codegen/generators/field-types.js';
10
10
  import { generateConfigFile } from '../codegen/generators/config.js';
11
11
  import { generateModelTypes } from '../codegen/generators/model-types.js';
12
12
  import { generateModelIndex } from '../codegen/generators/model-index.js';
13
- import { generateModelDocuments } from '../codegen/generators/documents.js';
13
+ import { generateModelDocuments, generateSharedFragments } from '../codegen/generators/documents.js';
14
14
  import { generateSwiftModelFile } from '../codegen/generators/swift-types.js';
15
15
  import { generateSwiftFieldTypesFile } from '../codegen/generators/swift-field-types.js';
16
16
  import { generateSwiftModelKeys } from '../codegen/generators/swift-model-keys.js';
@@ -96,6 +96,14 @@ export function registerPullCommand(program, globalOpts) {
96
96
  content: generateModelDocuments(model),
97
97
  });
98
98
  }
99
+ // 5a. Shared fragments (emitted once when any model uses sharing)
100
+ const hasSharingModels = publicModels.some((m) => m.config.sharing?.enabled);
101
+ if (hasSharingModels) {
102
+ files.push({
103
+ path: resolve(docsDir, '_shared.graphql'),
104
+ content: generateSharedFragments(),
105
+ });
106
+ }
99
107
  // 5b. Customer profile GraphQL documents (always — static platform operations)
100
108
  files.push({
101
109
  path: resolve(docsDir, 'customer-profile.graphql'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Universal platform CLI for EIDE — scriptable, composable resource management",
5
5
  "type": "module",
6
6
  "publishConfig": {