@eide/foir-cli 0.1.11 → 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,
|
|
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"}
|
|
@@ -17,19 +17,32 @@ fragment ${typeName}Fields on Record {
|
|
|
17
17
|
naturalKey
|
|
18
18
|
data
|
|
19
19
|
metadata
|
|
20
|
-
versionNumber
|
|
21
20
|
publishedVersionNumber
|
|
22
|
-
|
|
21
|
+
publishedAt
|
|
22
|
+
versionNumber
|
|
23
|
+
changeDescription
|
|
23
24
|
createdAt
|
|
24
25
|
updatedAt
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
query Get${typeName}($id: ID
|
|
28
|
-
record(
|
|
28
|
+
query Get${typeName}($id: ID!, $locale: String, $preview: Boolean) {
|
|
29
|
+
record(id: $id) {
|
|
30
|
+
...${typeName}Fields
|
|
31
|
+
resolved(locale: $locale, preview: $preview) {
|
|
32
|
+
content
|
|
33
|
+
record { id modelKey naturalKey }
|
|
34
|
+
version { id versionNumber }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
query Get${typeName}ByKey($naturalKey: String!, $locale: String, $preview: Boolean) {
|
|
40
|
+
recordByKey(modelKey: "${model.key}", naturalKey: $naturalKey) {
|
|
29
41
|
...${typeName}Fields
|
|
30
|
-
resolved {
|
|
42
|
+
resolved(locale: $locale, preview: $preview) {
|
|
43
|
+
content
|
|
31
44
|
record { id modelKey naturalKey }
|
|
32
|
-
|
|
45
|
+
version { id versionNumber }
|
|
33
46
|
}
|
|
34
47
|
}
|
|
35
48
|
}
|
|
@@ -39,7 +52,6 @@ query List${pluralName}(
|
|
|
39
52
|
$offset: Int
|
|
40
53
|
$filters: [FilterInput!]
|
|
41
54
|
$sort: SortInput
|
|
42
|
-
$preview: Boolean
|
|
43
55
|
) {
|
|
44
56
|
records(
|
|
45
57
|
modelKey: "${model.key}"
|
|
@@ -47,50 +59,55 @@ query List${pluralName}(
|
|
|
47
59
|
offset: $offset
|
|
48
60
|
filters: $filters
|
|
49
61
|
sort: $sort
|
|
50
|
-
preview: $preview
|
|
51
62
|
) {
|
|
52
63
|
items {
|
|
53
64
|
...${typeName}Fields
|
|
54
65
|
}
|
|
55
66
|
total
|
|
56
|
-
hasMore
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
mutation Create${typeName}($
|
|
61
|
-
createRecord(
|
|
62
|
-
|
|
70
|
+
mutation Create${typeName}($input: CreateRecordInput!) {
|
|
71
|
+
createRecord(input: $input) {
|
|
72
|
+
record {
|
|
73
|
+
...${typeName}Fields
|
|
74
|
+
}
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
77
|
|
|
66
|
-
mutation Update${typeName}($
|
|
67
|
-
updateRecord(
|
|
68
|
-
|
|
78
|
+
mutation Update${typeName}($input: UpdateRecordInput!) {
|
|
79
|
+
updateRecord(input: $input) {
|
|
80
|
+
record {
|
|
81
|
+
...${typeName}Fields
|
|
82
|
+
}
|
|
83
|
+
matched
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
86
|
|
|
72
87
|
mutation Delete${typeName}($id: ID!) {
|
|
73
|
-
deleteRecord(
|
|
74
|
-
|
|
75
|
-
message
|
|
88
|
+
deleteRecord(id: $id) {
|
|
89
|
+
id
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
|
|
79
|
-
mutation Publish${typeName}($
|
|
80
|
-
publishVersion(
|
|
81
|
-
...${typeName}Fields
|
|
82
|
-
}
|
|
93
|
+
mutation Publish${typeName}Version($versionId: ID!) {
|
|
94
|
+
publishVersion(versionId: $versionId)
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
mutation Unpublish${typeName}($id: ID!) {
|
|
86
|
-
unpublishRecord(
|
|
87
|
-
...${typeName}Fields
|
|
88
|
-
}
|
|
98
|
+
unpublishRecord(id: $id)
|
|
89
99
|
}
|
|
90
100
|
${model.config.sharing?.enabled ? generateSharingOperations(model.key, typeName, pluralName) : ''}`;
|
|
91
101
|
}
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
|
|
94
111
|
fragment ShareFields on Share {
|
|
95
112
|
id
|
|
96
113
|
resourceType
|
|
@@ -102,6 +119,10 @@ fragment ShareFields on Share {
|
|
|
102
119
|
createdAt
|
|
103
120
|
revokedAt
|
|
104
121
|
}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
function generateSharingOperations(modelKey, typeName, pluralName) {
|
|
125
|
+
return `# Sharing operations
|
|
105
126
|
|
|
106
127
|
mutation Share${typeName}($recordId: ID!, $sharedWithCustomerId: ID!, $permission: SharePermission!) {
|
|
107
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,
|
|
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"}
|
package/dist/commands/pull.js
CHANGED
|
@@ -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'),
|