@graphcommerce/hygraph-cli 7.1.0-canary.9 → 8.0.0-canary.100
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.
- package/CHANGELOG.md +179 -0
- package/Config.graphqls +5 -0
- package/dist/migrationAction.js +9 -3
- package/dist/migrations/graphcommerce6to7.js +7 -0
- package/dist/migrations/graphcommerce7to8.js +43 -0
- package/dist/migrations/graphcommerce8to9.js +22 -0
- package/dist/migrations/index.js +2 -0
- package/dist/readSchema.js +6 -3
- package/package.json +10 -12
- package/src/migrationAction.ts +9 -3
- package/src/migrations/graphcommerce6to7.ts +15 -0
- package/src/migrations/graphcommerce7to8.ts +60 -0
- package/src/migrations/graphcommerce8to9.ts +24 -0
- package/src/migrations/index.ts +2 -0
- package/src/readSchema.ts +7 -3
- package/tsconfig.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,184 @@
|
|
|
1
1
|
# @graphcommerce/hygraph-cli
|
|
2
2
|
|
|
3
|
+
## 8.0.0-canary.100
|
|
4
|
+
|
|
5
|
+
## 8.0.0-canary.99
|
|
6
|
+
|
|
7
|
+
## 8.0.0-canary.98
|
|
8
|
+
|
|
9
|
+
## 8.0.0-canary.97
|
|
10
|
+
|
|
11
|
+
## 8.0.0-canary.96
|
|
12
|
+
|
|
13
|
+
## 8.0.0-canary.95
|
|
14
|
+
|
|
15
|
+
## 8.0.0-canary.94
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#2169](https://github.com/graphcommerce-org/graphcommerce/pull/2169) [`eab3f0b`](https://github.com/graphcommerce-org/graphcommerce/commit/eab3f0b0b459f5b6cc4e50d787ac1e8ae545b708) - Solve issue where a Hygraph DynamicRow conditions were missing fields in the OrCondition
|
|
20
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
21
|
+
|
|
22
|
+
## 8.0.0-canary.93
|
|
23
|
+
|
|
24
|
+
## 8.0.0-canary.92
|
|
25
|
+
|
|
26
|
+
## 8.0.0-canary.91
|
|
27
|
+
|
|
28
|
+
## 8.0.0-canary.90
|
|
29
|
+
|
|
30
|
+
## 8.0.0-canary.89
|
|
31
|
+
|
|
32
|
+
## 8.0.0-canary.88
|
|
33
|
+
|
|
34
|
+
## 8.0.0-canary.87
|
|
35
|
+
|
|
36
|
+
## 8.0.0-canary.86
|
|
37
|
+
|
|
38
|
+
## 8.0.0-canary.85
|
|
39
|
+
|
|
40
|
+
## 8.0.0-canary.84
|
|
41
|
+
|
|
42
|
+
## 8.0.0-canary.83
|
|
43
|
+
|
|
44
|
+
## 8.0.0-canary.82
|
|
45
|
+
|
|
46
|
+
## 8.0.0-canary.81
|
|
47
|
+
|
|
48
|
+
## 8.0.0-canary.80
|
|
49
|
+
|
|
50
|
+
## 8.0.0-canary.79
|
|
51
|
+
|
|
52
|
+
## 8.0.0-canary.78
|
|
53
|
+
|
|
54
|
+
## 8.0.0-canary.77
|
|
55
|
+
|
|
56
|
+
## 8.0.0-canary.76
|
|
57
|
+
|
|
58
|
+
## 8.0.0-canary.75
|
|
59
|
+
|
|
60
|
+
## 8.0.0-canary.74
|
|
61
|
+
|
|
62
|
+
## 8.0.0-canary.73
|
|
63
|
+
|
|
64
|
+
## 8.0.0-canary.72
|
|
65
|
+
|
|
66
|
+
## 8.0.0-canary.71
|
|
67
|
+
|
|
68
|
+
## 8.0.0-canary.70
|
|
69
|
+
|
|
70
|
+
## 8.0.0-canary.69
|
|
71
|
+
|
|
72
|
+
## 7.1.0-canary.68
|
|
73
|
+
|
|
74
|
+
## 7.1.0-canary.67
|
|
75
|
+
|
|
76
|
+
## 7.1.0-canary.66
|
|
77
|
+
|
|
78
|
+
## 7.1.0-canary.65
|
|
79
|
+
|
|
80
|
+
## 7.1.0-canary.64
|
|
81
|
+
|
|
82
|
+
## 7.1.0-canary.63
|
|
83
|
+
|
|
84
|
+
## 7.1.0-canary.62
|
|
85
|
+
|
|
86
|
+
## 7.1.0-canary.61
|
|
87
|
+
|
|
88
|
+
## 7.1.0-canary.60
|
|
89
|
+
|
|
90
|
+
## 7.1.0-canary.59
|
|
91
|
+
|
|
92
|
+
## 7.1.0-canary.58
|
|
93
|
+
|
|
94
|
+
## 7.1.0-canary.57
|
|
95
|
+
|
|
96
|
+
## 7.1.0-canary.56
|
|
97
|
+
|
|
98
|
+
## 7.1.0-canary.55
|
|
99
|
+
|
|
100
|
+
## 7.1.0-canary.54
|
|
101
|
+
|
|
102
|
+
## 7.1.0-canary.53
|
|
103
|
+
|
|
104
|
+
## 7.1.0-canary.52
|
|
105
|
+
|
|
106
|
+
## 7.1.0-canary.51
|
|
107
|
+
|
|
108
|
+
## 7.1.0-canary.50
|
|
109
|
+
|
|
110
|
+
## 7.1.0-canary.49
|
|
111
|
+
|
|
112
|
+
## 7.1.0-canary.48
|
|
113
|
+
|
|
114
|
+
## 7.1.0-canary.47
|
|
115
|
+
|
|
116
|
+
## 7.1.0-canary.46
|
|
117
|
+
|
|
118
|
+
## 7.1.0-canary.45
|
|
119
|
+
|
|
120
|
+
## 7.1.0-canary.38
|
|
121
|
+
|
|
122
|
+
## 7.1.0-canary.37
|
|
123
|
+
|
|
124
|
+
## 7.1.0-canary.36
|
|
125
|
+
|
|
126
|
+
## 7.1.0-canary.35
|
|
127
|
+
|
|
128
|
+
## 7.1.0-canary.34
|
|
129
|
+
|
|
130
|
+
## 7.1.0-canary.33
|
|
131
|
+
|
|
132
|
+
## 7.1.0-canary.32
|
|
133
|
+
|
|
134
|
+
## 7.1.0-canary.31
|
|
135
|
+
|
|
136
|
+
## 7.1.0-canary.30
|
|
137
|
+
|
|
138
|
+
## 7.1.0-canary.29
|
|
139
|
+
|
|
140
|
+
## 7.1.0-canary.28
|
|
141
|
+
|
|
142
|
+
## 7.1.0-canary.27
|
|
143
|
+
|
|
144
|
+
## 7.1.0-canary.26
|
|
145
|
+
|
|
146
|
+
## 7.1.0-canary.25
|
|
147
|
+
|
|
148
|
+
## 7.1.0-canary.24
|
|
149
|
+
|
|
150
|
+
## 7.1.0-canary.23
|
|
151
|
+
|
|
152
|
+
## 7.1.0-canary.22
|
|
153
|
+
|
|
154
|
+
## 7.1.0-canary.21
|
|
155
|
+
|
|
156
|
+
## 7.1.0-canary.20
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- [#2095](https://github.com/graphcommerce-org/graphcommerce/pull/2095) [`519531eb4`](https://github.com/graphcommerce-org/graphcommerce/commit/519531eb48bf6c5b68703509d2bd64c8dfe5b92c) - Fix Hygraph CLI (Management SDK) | Add support for updating and deleting enumerations ([@JoshuaS98](https://github.com/JoshuaS98))
|
|
161
|
+
|
|
162
|
+
## 7.1.0-canary.19
|
|
163
|
+
|
|
164
|
+
## 7.1.0-canary.18
|
|
165
|
+
|
|
166
|
+
## 7.1.0-canary.17
|
|
167
|
+
|
|
168
|
+
## 7.1.0-canary.16
|
|
169
|
+
|
|
170
|
+
## 7.1.0-canary.15
|
|
171
|
+
|
|
172
|
+
## 7.1.0-canary.14
|
|
173
|
+
|
|
174
|
+
## 7.1.0-canary.13
|
|
175
|
+
|
|
176
|
+
## 7.1.0-canary.12
|
|
177
|
+
|
|
178
|
+
## 7.1.0-canary.11
|
|
179
|
+
|
|
180
|
+
## 7.1.0-canary.10
|
|
181
|
+
|
|
3
182
|
## 7.1.0-canary.9
|
|
4
183
|
|
|
5
184
|
## 7.1.0-canary.8
|
package/Config.graphqls
CHANGED
package/dist/migrationAction.js
CHANGED
|
@@ -74,8 +74,14 @@ const actionMap = exports.client
|
|
|
74
74
|
* component, you also need to pass the parentType, which is either 'model' or 'component'.
|
|
75
75
|
*/
|
|
76
76
|
const migrationAction = (schema, type, action, props, parentApiId, parentType) => {
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Check if the entity already exists.
|
|
79
|
+
* If an update or deletion is made, it does not matter if the entity already exists
|
|
80
|
+
*/
|
|
78
81
|
const alreadyExists = () => {
|
|
82
|
+
if (action !== 'create') {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
79
85
|
switch (type) {
|
|
80
86
|
case 'model':
|
|
81
87
|
return schema.models.some((model) => model.apiId === props.apiId);
|
|
@@ -99,12 +105,12 @@ const migrationAction = (schema, type, action, props, parentApiId, parentType) =
|
|
|
99
105
|
break;
|
|
100
106
|
}
|
|
101
107
|
default:
|
|
102
|
-
return false;
|
|
108
|
+
return false;
|
|
103
109
|
}
|
|
104
110
|
return parent?.fields.some((field) => field.apiId === props.apiId);
|
|
105
111
|
}
|
|
106
112
|
default: {
|
|
107
|
-
return false;
|
|
113
|
+
return false;
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
};
|
|
@@ -196,6 +196,13 @@ const graphcommerce6to7 = async (schema) => {
|
|
|
196
196
|
enumerationApiId: 'RowColumnOneVariants',
|
|
197
197
|
parentApiId: 'RowColumnOne',
|
|
198
198
|
}, 'RowColumnOne', 'model');
|
|
199
|
+
(0, migrationAction_1.migrationAction)(schema, 'componentUnionField', 'create', {
|
|
200
|
+
displayName: 'Conditions',
|
|
201
|
+
apiId: 'conditions',
|
|
202
|
+
parentApiId: 'ConditionOr',
|
|
203
|
+
componentApiIds: ['ConditionText', 'ConditionNumber'],
|
|
204
|
+
isList: true,
|
|
205
|
+
}, 'ConditionOr', 'component');
|
|
199
206
|
return migrationAction_1.client.run(true);
|
|
200
207
|
};
|
|
201
208
|
exports.graphcommerce6to7 = graphcommerce6to7;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.graphcommerce7to8 = void 0;
|
|
4
|
+
const management_sdk_1 = require("@hygraph/management-sdk");
|
|
5
|
+
const migrationAction_1 = require("../migrationAction");
|
|
6
|
+
const graphcommerce7to8 = async (schema) => {
|
|
7
|
+
if (!migrationAction_1.client) {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
const hasRow = schema.models
|
|
11
|
+
.find((m) => m.apiId === 'DynamicRow')
|
|
12
|
+
?.fields.some((f) => f.apiId === 'row');
|
|
13
|
+
if (hasRow) {
|
|
14
|
+
(0, migrationAction_1.migrationAction)(schema, 'unionField', 'update', {
|
|
15
|
+
apiId: 'row',
|
|
16
|
+
displayName: 'Row Deprecated',
|
|
17
|
+
parentApiId: 'DynamicRow',
|
|
18
|
+
description: 'This field is deprecated. Use Rows instead.',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
(0, migrationAction_1.migrationAction)(schema, 'unionField', 'create', {
|
|
22
|
+
displayName: 'Rows',
|
|
23
|
+
apiId: 'rows',
|
|
24
|
+
isList: true,
|
|
25
|
+
reverseField: {
|
|
26
|
+
modelApiIds: ['RowQuote', 'RowLinks', 'RowColumnOne'],
|
|
27
|
+
apiId: 'dynamicRows',
|
|
28
|
+
displayName: 'Dynamic Rows',
|
|
29
|
+
visibility: management_sdk_1.VisibilityTypes.Hidden,
|
|
30
|
+
isList: true,
|
|
31
|
+
},
|
|
32
|
+
parentApiId: 'DynamicRow',
|
|
33
|
+
}, 'DynamicRow', 'model');
|
|
34
|
+
(0, migrationAction_1.migrationAction)(schema, 'componentUnionField', 'create', {
|
|
35
|
+
displayName: 'Conditions',
|
|
36
|
+
apiId: 'conditions',
|
|
37
|
+
parentApiId: 'ConditionOr',
|
|
38
|
+
componentApiIds: ['ConditionText', 'ConditionNumber'],
|
|
39
|
+
isList: true,
|
|
40
|
+
}, 'ConditionOr', 'component');
|
|
41
|
+
return migrationAction_1.client.run(true);
|
|
42
|
+
};
|
|
43
|
+
exports.graphcommerce7to8 = graphcommerce7to8;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.graphcommerce8to9 = void 0;
|
|
4
|
+
const migrationAction_1 = require("../migrationAction");
|
|
5
|
+
const graphcommerce8to9 = async (schema) => {
|
|
6
|
+
if (!migrationAction_1.client) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
// This migration is for GC 8.0 and is not yet exported as a usable migration.
|
|
10
|
+
// Removes the deprecated 'Row' field which was deprecated in GC@7.1
|
|
11
|
+
const hasRow = schema.models
|
|
12
|
+
.find((m) => m.apiId === 'DynamicRow')
|
|
13
|
+
?.fields.some((f) => f.apiId === 'row');
|
|
14
|
+
if (hasRow) {
|
|
15
|
+
(0, migrationAction_1.migrationAction)(schema, 'simpleField', 'delete', {
|
|
16
|
+
apiId: 'row',
|
|
17
|
+
parentApiId: 'DynamicRow',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return migrationAction_1.client.run(true);
|
|
21
|
+
};
|
|
22
|
+
exports.graphcommerce8to9 = graphcommerce8to9;
|
package/dist/migrations/index.js
CHANGED
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./graphcommerce5to6"), exports);
|
|
18
18
|
__exportStar(require("./graphcommerce6to7"), exports);
|
|
19
|
+
__exportStar(require("./graphcommerce7to8"), exports);
|
|
20
|
+
__exportStar(require("./graphcommerce8to9"), exports);
|
package/dist/readSchema.js
CHANGED
|
@@ -5,15 +5,18 @@ const client_1 = require("@apollo/client");
|
|
|
5
5
|
const fetch_1 = require("@whatwg-node/fetch");
|
|
6
6
|
const readSchema = async (config) => {
|
|
7
7
|
if (!config.hygraphProjectId) {
|
|
8
|
-
throw new Error('Please provide GC_HYGRAPH_PROJECT_ID in your env file');
|
|
8
|
+
throw new Error('Please provide GC_HYGRAPH_PROJECT_ID in your env file.');
|
|
9
9
|
}
|
|
10
10
|
if (!config.hygraphWriteAccessToken) {
|
|
11
|
-
throw new Error('Please provide GC_HYGRAPH_WRITE_ACCESS_TOKEN in your env file');
|
|
11
|
+
throw new Error('Please provide GC_HYGRAPH_WRITE_ACCESS_TOKEN in your env file.');
|
|
12
12
|
}
|
|
13
13
|
const projectId = config.hygraphProjectId;
|
|
14
|
+
if (!config.hygraphManagementApi) {
|
|
15
|
+
throw new Error('Please provide GC_HYGRAPH_MANAGEMENT_API in your env file.');
|
|
16
|
+
}
|
|
14
17
|
const hygraphClient = new client_1.ApolloClient({
|
|
15
18
|
link: new client_1.HttpLink({
|
|
16
|
-
uri:
|
|
19
|
+
uri: config.hygraphManagementApi,
|
|
17
20
|
fetch: fetch_1.fetch,
|
|
18
21
|
headers: { Authorization: `Bearer ${config.hygraphWriteAccessToken}` },
|
|
19
22
|
}),
|
package/package.json
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/hygraph-cli",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "MIT",
|
|
5
|
+
"version": "8.0.0-canary.100",
|
|
8
6
|
"scripts": {
|
|
9
7
|
"dev": "tsc --preserveWatchOutput --watch",
|
|
10
8
|
"build": "tsc",
|
|
@@ -14,23 +12,23 @@
|
|
|
14
12
|
"main": "dist/index.js",
|
|
15
13
|
"types": "src/index.ts",
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"@hygraph/management-sdk": "1.2.3",
|
|
20
|
-
"@whatwg-node/fetch": "^0.9.4",
|
|
15
|
+
"@hygraph/management-sdk": "1.2.4",
|
|
16
|
+
"@whatwg-node/fetch": "^0.9.15",
|
|
21
17
|
"graphql-tag": "^2.12.6",
|
|
22
18
|
"prompts": "^2.4.2"
|
|
23
19
|
},
|
|
24
20
|
"peerDependencies": {
|
|
21
|
+
"@apollo/client": "^3",
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.0-canary.100",
|
|
23
|
+
"@graphcommerce/next-config": "^8.0.0-canary.100",
|
|
24
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.0-canary.100",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.0-canary.100",
|
|
25
26
|
"dotenv": "^16.1.4",
|
|
26
27
|
"graphql": "^16.7.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"@graphcommerce/typescript-config-pwa": "7.1.0-canary.9",
|
|
32
|
-
"@types/prompts": "^2.4.4",
|
|
33
|
-
"typescript": "5.2.2"
|
|
30
|
+
"@types/prompts": "^2.4.9",
|
|
31
|
+
"typescript": "5.3.3"
|
|
34
32
|
},
|
|
35
33
|
"sideEffects": false,
|
|
36
34
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
package/src/migrationAction.ts
CHANGED
|
@@ -159,8 +159,14 @@ export const migrationAction = (
|
|
|
159
159
|
parentApiId?: string,
|
|
160
160
|
parentType?: 'model' | 'component' | 'enumeration',
|
|
161
161
|
) => {
|
|
162
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Check if the entity already exists.
|
|
164
|
+
* If an update or deletion is made, it does not matter if the entity already exists
|
|
165
|
+
*/
|
|
163
166
|
const alreadyExists = () => {
|
|
167
|
+
if (action !== 'create') {
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
164
170
|
switch (type) {
|
|
165
171
|
case 'model':
|
|
166
172
|
return schema.models.some((model) => model.apiId === props.apiId)
|
|
@@ -187,12 +193,12 @@ export const migrationAction = (
|
|
|
187
193
|
break
|
|
188
194
|
}
|
|
189
195
|
default:
|
|
190
|
-
return false
|
|
196
|
+
return false
|
|
191
197
|
}
|
|
192
198
|
return parent?.fields.some((field) => field.apiId === props.apiId)
|
|
193
199
|
}
|
|
194
200
|
default: {
|
|
195
|
-
return false
|
|
201
|
+
return false
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
}
|
|
@@ -303,5 +303,20 @@ export const graphcommerce6to7 = async (schema: Schema) => {
|
|
|
303
303
|
'model',
|
|
304
304
|
)
|
|
305
305
|
|
|
306
|
+
migrationAction(
|
|
307
|
+
schema,
|
|
308
|
+
'componentUnionField',
|
|
309
|
+
'create',
|
|
310
|
+
{
|
|
311
|
+
displayName: 'Conditions',
|
|
312
|
+
apiId: 'conditions',
|
|
313
|
+
parentApiId: 'ConditionOr',
|
|
314
|
+
componentApiIds: ['ConditionText', 'ConditionNumber'],
|
|
315
|
+
isList: true,
|
|
316
|
+
},
|
|
317
|
+
'ConditionOr',
|
|
318
|
+
'component',
|
|
319
|
+
)
|
|
320
|
+
|
|
306
321
|
return client.run(true)
|
|
307
322
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { VisibilityTypes } from '@hygraph/management-sdk'
|
|
2
|
+
import { migrationAction, client } from '../migrationAction'
|
|
3
|
+
import { Schema } from '../types'
|
|
4
|
+
|
|
5
|
+
export const graphcommerce7to8 = async (schema: Schema) => {
|
|
6
|
+
if (!client) {
|
|
7
|
+
return 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const hasRow = schema.models
|
|
11
|
+
.find((m) => m.apiId === 'DynamicRow')
|
|
12
|
+
?.fields.some((f) => f.apiId === 'row')
|
|
13
|
+
|
|
14
|
+
if (hasRow) {
|
|
15
|
+
migrationAction(schema, 'unionField', 'update', {
|
|
16
|
+
apiId: 'row',
|
|
17
|
+
displayName: 'Row Deprecated',
|
|
18
|
+
parentApiId: 'DynamicRow',
|
|
19
|
+
description: 'This field is deprecated. Use Rows instead.',
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
migrationAction(
|
|
24
|
+
schema,
|
|
25
|
+
'unionField',
|
|
26
|
+
'create',
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Rows',
|
|
29
|
+
apiId: 'rows',
|
|
30
|
+
isList: true,
|
|
31
|
+
reverseField: {
|
|
32
|
+
modelApiIds: ['RowQuote', 'RowLinks', 'RowColumnOne'],
|
|
33
|
+
apiId: 'dynamicRows',
|
|
34
|
+
displayName: 'Dynamic Rows',
|
|
35
|
+
visibility: VisibilityTypes.Hidden,
|
|
36
|
+
isList: true,
|
|
37
|
+
},
|
|
38
|
+
parentApiId: 'DynamicRow',
|
|
39
|
+
},
|
|
40
|
+
'DynamicRow',
|
|
41
|
+
'model',
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
migrationAction(
|
|
45
|
+
schema,
|
|
46
|
+
'componentUnionField',
|
|
47
|
+
'create',
|
|
48
|
+
{
|
|
49
|
+
displayName: 'Conditions',
|
|
50
|
+
apiId: 'conditions',
|
|
51
|
+
parentApiId: 'ConditionOr',
|
|
52
|
+
componentApiIds: ['ConditionText', 'ConditionNumber'],
|
|
53
|
+
isList: true,
|
|
54
|
+
},
|
|
55
|
+
'ConditionOr',
|
|
56
|
+
'component',
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return client.run(true)
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { migrationAction, client } from '../migrationAction'
|
|
2
|
+
import { Schema } from '../types'
|
|
3
|
+
|
|
4
|
+
export const graphcommerce8to9 = async (schema: Schema) => {
|
|
5
|
+
if (!client) {
|
|
6
|
+
return 0
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// This migration is for GC 8.0 and is not yet exported as a usable migration.
|
|
10
|
+
|
|
11
|
+
// Removes the deprecated 'Row' field which was deprecated in GC@7.1
|
|
12
|
+
const hasRow = schema.models
|
|
13
|
+
.find((m) => m.apiId === 'DynamicRow')
|
|
14
|
+
?.fields.some((f) => f.apiId === 'row')
|
|
15
|
+
|
|
16
|
+
if (hasRow) {
|
|
17
|
+
migrationAction(schema, 'simpleField', 'delete', {
|
|
18
|
+
apiId: 'row',
|
|
19
|
+
parentApiId: 'DynamicRow',
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return client.run(true)
|
|
24
|
+
}
|
package/src/migrations/index.ts
CHANGED
package/src/readSchema.ts
CHANGED
|
@@ -4,18 +4,22 @@ import { fetch } from '@whatwg-node/fetch'
|
|
|
4
4
|
|
|
5
5
|
export const readSchema = async (config: GraphCommerceConfig) => {
|
|
6
6
|
if (!config.hygraphProjectId) {
|
|
7
|
-
throw new Error('Please provide GC_HYGRAPH_PROJECT_ID in your env file')
|
|
7
|
+
throw new Error('Please provide GC_HYGRAPH_PROJECT_ID in your env file.')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
if (!config.hygraphWriteAccessToken) {
|
|
11
|
-
throw new Error('Please provide GC_HYGRAPH_WRITE_ACCESS_TOKEN in your env file')
|
|
11
|
+
throw new Error('Please provide GC_HYGRAPH_WRITE_ACCESS_TOKEN in your env file.')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const projectId = config.hygraphProjectId
|
|
15
15
|
|
|
16
|
+
if (!config.hygraphManagementApi) {
|
|
17
|
+
throw new Error('Please provide GC_HYGRAPH_MANAGEMENT_API in your env file.')
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
const hygraphClient = new ApolloClient({
|
|
17
21
|
link: new HttpLink({
|
|
18
|
-
uri:
|
|
22
|
+
uri: config.hygraphManagementApi,
|
|
19
23
|
fetch,
|
|
20
24
|
headers: { Authorization: `Bearer ${config.hygraphWriteAccessToken}` },
|
|
21
25
|
}),
|
package/tsconfig.json
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
"exclude": ["**/node_modules", "example", "dist", "**/.*/", "__tests__", "__mocks__"],
|
|
3
3
|
"include": ["**/*.ts", "**/*.tsx"],
|
|
4
4
|
"files": ["src/index.ts"],
|
|
5
|
-
"extends": "@
|
|
5
|
+
"extends": "@tsconfig/node18/tsconfig.json",
|
|
6
6
|
"compilerOptions": {
|
|
7
7
|
"rootDir": "src",
|
|
8
8
|
"noEmit": false,
|
|
9
9
|
"outDir": "dist",
|
|
10
10
|
"sourceMap": false,
|
|
11
11
|
"noLib": false,
|
|
12
|
-
"strict": true
|
|
12
|
+
"strict": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"moduleResolution": "Node",
|
|
15
|
+
"module": "CommonJS"
|
|
13
16
|
}
|
|
14
17
|
}
|