@trackunit/iris-app 2.3.6 → 2.3.9-alpha-90b6c9b97dd.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.
- package/CHANGELOG.md +0 -43
- package/README.md +0 -18
- package/package.json +3 -5
- package/src/executors/submit/executor.js +22 -115
- package/src/generators/create/generator.js +11 -8
- package/src/generators/extend/generator.d.ts +0 -11
- package/src/generators/extend/generator.js +1 -53
- package/src/generators/extend/schema.d.ts +0 -1
- package/src/generators/extend/schema.json +0 -5
- package/src/generators/extend/files/SERVERSIDE_API_EXTENSION_GRAPHQL/src/graphql/asset-by-id.graphql__template__ +0 -6
- package/src/generators/extend/files/SERVERSIDE_API_EXTENSION_GRAPHQL/src/index.ts__template__ +0 -31
- package/src/generators/utils/get-package-manifest.d.ts +0 -5
- package/src/generators/utils/get-package-manifest.js +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
## 2.3.6 (2026-08-05)
|
|
2
|
-
|
|
3
|
-
### 🧱 Updated Dependencies
|
|
4
|
-
|
|
5
|
-
- Updated iris-app-build-utilities to 2.2.5
|
|
6
|
-
- Updated iris-app-api to 2.2.5
|
|
7
|
-
- Updated react-vite-test-setup to 0.0.91
|
|
8
|
-
- Updated react-graphql-tools to 1.14.92
|
|
9
|
-
- Updated shared-utils to 1.15.93
|
|
10
|
-
|
|
11
|
-
## 2.3.5 (2026-08-04)
|
|
12
|
-
|
|
13
|
-
### 🧱 Updated Dependencies
|
|
14
|
-
|
|
15
|
-
- Updated iris-app-build-utilities to 2.2.4
|
|
16
|
-
- Updated iris-app-api to 2.2.4
|
|
17
|
-
- Updated react-vite-test-setup to 0.0.90
|
|
18
|
-
- Updated react-graphql-tools to 1.14.91
|
|
19
|
-
- Updated shared-utils to 1.15.92
|
|
20
|
-
|
|
21
|
-
## 2.3.4 (2026-08-04)
|
|
22
|
-
|
|
23
|
-
This was a version bump only for iris-app to align it with other projects, there were no code changes.
|
|
24
|
-
|
|
25
|
-
## 2.3.3 (2026-08-04)
|
|
26
|
-
|
|
27
|
-
### 🧱 Updated Dependencies
|
|
28
|
-
|
|
29
|
-
- Updated iris-app-build-utilities to 2.2.3
|
|
30
|
-
- Updated iris-app-api to 2.2.3
|
|
31
|
-
- Updated react-vite-test-setup to 0.0.89
|
|
32
|
-
- Updated react-graphql-tools to 1.14.90
|
|
33
|
-
- Updated shared-utils to 1.15.91
|
|
34
|
-
|
|
35
|
-
## 2.3.2 (2026-08-03)
|
|
36
|
-
|
|
37
|
-
### 🧱 Updated Dependencies
|
|
38
|
-
|
|
39
|
-
- Updated iris-app-build-utilities to 2.2.2
|
|
40
|
-
- Updated iris-app-api to 2.2.2
|
|
41
|
-
- Updated react-vite-test-setup to 0.0.88
|
|
42
|
-
- Updated shared-utils to 1.15.90
|
|
43
|
-
|
|
44
1
|
## 2.3.1 (2026-08-03)
|
|
45
2
|
|
|
46
3
|
### 🧱 Updated Dependencies
|
package/README.md
CHANGED
|
@@ -11,24 +11,6 @@ For more info and a full guide on Iris App SDK Development, please visit our [De
|
|
|
11
11
|
|
|
12
12
|
Run through the easy getting started guide here: [Getting Started](https://developers.trackunit.com/docs/getting-started)
|
|
13
13
|
|
|
14
|
-
## Serverside GraphQL scaffolding
|
|
15
|
-
|
|
16
|
-
Typed access to the Trackunit public GraphQL API is optional for serverside API extensions:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npx nx generate @trackunit/iris-app:extend \
|
|
20
|
-
--type=SERVERSIDE_API_EXTENSION \
|
|
21
|
-
--graphql
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The option is off by default. It reuses the standard `graphql-hooks` target, configures React-free code generation against the public schema, and adds a named typed asset query example. Regenerate documents after editing `.graphql` files:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npx nx run <project>:graphql-hooks
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Local requests must include a user bearer token. Set `SDK_ENVIRONMENT=DEV` or `STAGE` in the extension's `.env` to target a non-production public API; unset defaults to production.
|
|
31
|
-
|
|
32
14
|
## Testing Local Changes
|
|
33
15
|
|
|
34
16
|
To test changes to the SDK generators locally, you can verify them in a full, temporary workspace environment.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.9-alpha-90b6c9b97dd.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -23,10 +23,8 @@
|
|
|
23
23
|
"@nx/react": "23.1.0",
|
|
24
24
|
"@npmcli/arborist": "^9.1.9",
|
|
25
25
|
"win-ca": "^3.5.1",
|
|
26
|
-
"@trackunit/
|
|
27
|
-
"@trackunit/
|
|
28
|
-
"@trackunit/shared-utils": "1.15.93",
|
|
29
|
-
"@trackunit/iris-app-api": "2.2.5",
|
|
26
|
+
"@trackunit/shared-utils": "1.15.95-alpha-90b6c9b97dd.0",
|
|
27
|
+
"@trackunit/iris-app-api": "2.2.7-alpha-90b6c9b97dd.0",
|
|
30
28
|
"tslib": "^2.6.2",
|
|
31
29
|
"@clack/prompts": "^1.0.0",
|
|
32
30
|
"@npm/types": "^1.0.2",
|
|
@@ -15,81 +15,12 @@ const irisAppServerSettings_1 = require("../utils/irisAppServerSettings");
|
|
|
15
15
|
class NpmConflictError extends Error {
|
|
16
16
|
}
|
|
17
17
|
class NpmGeneralError extends Error {
|
|
18
|
-
constructor(message, statusCode, code, type) {
|
|
19
|
-
super(message);
|
|
20
|
-
this.statusCode = statusCode;
|
|
21
|
-
this.code = code;
|
|
22
|
-
this.type = type;
|
|
23
|
-
}
|
|
24
18
|
}
|
|
25
19
|
class ApproveError extends Error {
|
|
26
|
-
constructor(message, statusCode, code) {
|
|
27
|
-
super(message);
|
|
28
|
-
this.statusCode = statusCode;
|
|
29
|
-
this.code = code;
|
|
30
|
-
}
|
|
31
20
|
}
|
|
32
21
|
function sleep(time) {
|
|
33
22
|
return new Promise(resolve => setTimeout(resolve, time));
|
|
34
23
|
}
|
|
35
|
-
// Errno-style codes that indicate the request never reached the registry at all
|
|
36
|
-
// (DNS/connection/timeout failures at the transport layer), as opposed to local
|
|
37
|
-
// validation errors (e.g. libnpmpublish's EPRIVATE/EBADSEMVER/EUSAGE) which carry
|
|
38
|
-
// a code but are permanent and can never succeed on retry. Kept aligned with
|
|
39
|
-
// make-fetch-happen's own RETRY_ERRORS list (used by the submit path) plus the
|
|
40
|
-
// undici error codes doApproveApp's native fetch can raise.
|
|
41
|
-
//
|
|
42
|
-
// ENOTFOUND (DNS failure) is deliberately included even though make-fetch-happen
|
|
43
|
-
// itself excludes it as "bad hostname, or offline" - a DNS blip during a VPN/
|
|
44
|
-
// network transition is common enough in practice that failing fast here would
|
|
45
|
-
// trade one wasted-wait problem for developers hitting spurious permanent
|
|
46
|
-
// failures on flaky networks. This is a judgment call, not a clear-cut default.
|
|
47
|
-
const RETRYABLE_TRANSPORT_CODES = new Set([
|
|
48
|
-
"ENOTFOUND",
|
|
49
|
-
"ECONNRESET",
|
|
50
|
-
"ECONNREFUSED",
|
|
51
|
-
"ETIMEDOUT",
|
|
52
|
-
"EAI_AGAIN",
|
|
53
|
-
"ERR_SOCKET_TIMEOUT",
|
|
54
|
-
"EADDRINUSE",
|
|
55
|
-
// from @npmcli/agent, surfaced through make-fetch-happen
|
|
56
|
-
"ECONNECTIONTIMEOUT",
|
|
57
|
-
"EIDLETIMEOUT",
|
|
58
|
-
"ERESPONSETIMEOUT",
|
|
59
|
-
"ETRANSFERTIMEOUT",
|
|
60
|
-
// doApproveApp uses Node's native fetch (undici), which raises its own
|
|
61
|
-
// codes distinct from the classic Node errno codes above.
|
|
62
|
-
"UND_ERR_CONNECT_TIMEOUT",
|
|
63
|
-
"UND_ERR_HEADERS_TIMEOUT",
|
|
64
|
-
"UND_ERR_BODY_TIMEOUT",
|
|
65
|
-
"UND_ERR_SOCKET", // e.g. "other side closed" on a reused keep-alive connection
|
|
66
|
-
]);
|
|
67
|
-
/**
|
|
68
|
-
* Decide whether a failed submit/approve attempt is worth retrying.
|
|
69
|
-
*
|
|
70
|
-
* This is an allowlist, not a denylist: only failures with a real chance of
|
|
71
|
-
* succeeding on a later attempt are retried - 5xx responses, 408/429 (timeout/
|
|
72
|
-
* rate-limited), a transport-level failure that never reached the registry at
|
|
73
|
-
* all (identified by a known transient errno code), or a minipass-fetch request
|
|
74
|
-
* timeout (which surfaces with the generic code FETCH_ERROR, distinguishable
|
|
75
|
-
* only via its `type: "request-timeout"`). Everything else - permanent 4xx
|
|
76
|
-
* errors, local validation errors with an unrelated code (e.g. EBADSEMVER), or
|
|
77
|
-
* any other unrecognized error shape - is treated as non-retryable by default.
|
|
78
|
-
*
|
|
79
|
-
* @param {number} [statusCode] The HTTP status code of the failed attempt, if any.
|
|
80
|
-
* @param {string} [code] The error's errno-style code, if any (no statusCode implies no HTTP response was received).
|
|
81
|
-
* @param {string} [type] The error's `type` field, if any. Only consulted when `code === "FETCH_ERROR"`, since that's the one code minipass-fetch's FetchError uses generically for several failure kinds - `type` is what distinguishes a timeout from the others.
|
|
82
|
-
* @returns {boolean} Whether the attempt should be retried.
|
|
83
|
-
*/
|
|
84
|
-
function isRetryableError(statusCode, code, type) {
|
|
85
|
-
if (statusCode !== undefined) {
|
|
86
|
-
return statusCode >= 500 || statusCode === 408 || statusCode === 429;
|
|
87
|
-
}
|
|
88
|
-
if (code === undefined) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return RETRYABLE_TRANSPORT_CODES.has(code) || (code === "FETCH_ERROR" && type === "request-timeout");
|
|
92
|
-
}
|
|
93
24
|
/**
|
|
94
25
|
* Submit the package to the npm registry.
|
|
95
26
|
*
|
|
@@ -141,24 +72,16 @@ async function doUploadAppWithRetry(accessToken, manifest, tarData, settings, re
|
|
|
141
72
|
console.error("❌ Unable to ship app package. Cannot submit over existing version.");
|
|
142
73
|
return { success: false };
|
|
143
74
|
}
|
|
144
|
-
if (!(e instanceof NpmGeneralError)) {
|
|
145
|
-
// An error shape we don't recognize (e.g. a bug elsewhere in this function) -
|
|
146
|
-
// log the full error/stack rather than a bare message so it stays debuggable.
|
|
147
|
-
console.error("❌ Unable to ship app package. Got error from Iris App SDK repository.", e);
|
|
148
|
-
return { success: false };
|
|
149
|
-
}
|
|
150
|
-
if (!isRetryableError(e.statusCode, e.code, e.type)) {
|
|
151
|
-
console.error("❌ Unable to ship app package.", e.message);
|
|
152
|
-
return { success: false };
|
|
153
|
-
}
|
|
154
|
-
if (retryCount > 1) {
|
|
155
|
-
console.error("⚠️ Unable to ship app package. Got error from Iris App SDK repository. Retrying submit...", e.message);
|
|
156
|
-
await sleep(30000);
|
|
157
|
-
return await doUploadAppWithRetry(accessToken, manifest, tarData, settings, retryCount - 1);
|
|
158
|
-
}
|
|
159
75
|
else {
|
|
160
|
-
|
|
161
|
-
|
|
76
|
+
if (retryCount > 1) {
|
|
77
|
+
console.error("⚠️ Unable to ship app package. Got error from Iris App SDK repository. Retrying submit...", e);
|
|
78
|
+
await sleep(30000);
|
|
79
|
+
return await doUploadAppWithRetry(accessToken, manifest, tarData, settings, retryCount - 1);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.error("❌ Unable to ship app package. Got error from Iris App SDK repository.", e);
|
|
83
|
+
return { success: false };
|
|
84
|
+
}
|
|
162
85
|
}
|
|
163
86
|
}
|
|
164
87
|
}
|
|
@@ -179,9 +102,6 @@ async function doUploadApp(accessToken, manifest, tarData, settings) {
|
|
|
179
102
|
else {
|
|
180
103
|
return {
|
|
181
104
|
ok: false,
|
|
182
|
-
statusCode: err.statusCode,
|
|
183
|
-
code: err.code,
|
|
184
|
-
type: err.type,
|
|
185
105
|
headers: new Headers(err.headers),
|
|
186
106
|
statusText: `Error`,
|
|
187
107
|
text: () => Promise.resolve(`${err.name} ${err.message}`),
|
|
@@ -210,7 +130,7 @@ async function doUploadApp(accessToken, manifest, tarData, settings) {
|
|
|
210
130
|
" " +
|
|
211
131
|
(await submitResult.text()) +
|
|
212
132
|
". Trace ID: " +
|
|
213
|
-
submitResult.headers.get("trace-id")
|
|
133
|
+
submitResult.headers.get("trace-id"));
|
|
214
134
|
}
|
|
215
135
|
}
|
|
216
136
|
async function promptUserForInput(query) {
|
|
@@ -230,21 +150,19 @@ async function doApproveAppWithRetry(token, manifest, settings, retryCount) {
|
|
|
230
150
|
return await doApproveApp(token, manifest, settings);
|
|
231
151
|
}
|
|
232
152
|
catch (e) {
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
await sleep(30000);
|
|
244
|
-
return await doApproveAppWithRetry(token, manifest, settings, retryCount - 1);
|
|
153
|
+
if (e instanceof ApproveError) {
|
|
154
|
+
if (retryCount > 1) {
|
|
155
|
+
console.error("⚠️ Unable to approve app package. Got approve error from Iris App SDK repository. Retrying approve...", e);
|
|
156
|
+
await sleep(30000);
|
|
157
|
+
return await doApproveAppWithRetry(token, manifest, settings, retryCount - 1);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
console.error("❌ Unable to approve app package. Got approve error from Iris App SDK repository.", e);
|
|
161
|
+
return { success: false };
|
|
162
|
+
}
|
|
245
163
|
}
|
|
246
164
|
else {
|
|
247
|
-
console.error("❌ Unable to approve app package. Got
|
|
165
|
+
console.error("❌ Unable to approve app package. Got error from Iris App SDK repository.", e);
|
|
248
166
|
return { success: false };
|
|
249
167
|
}
|
|
250
168
|
}
|
|
@@ -252,29 +170,18 @@ async function doApproveAppWithRetry(token, manifest, settings, retryCount) {
|
|
|
252
170
|
async function doApproveApp(token, manifest, settings) {
|
|
253
171
|
if (process.env.TU_APPROVE === "true") {
|
|
254
172
|
console.log(`🖋️ Approving the app...`);
|
|
255
|
-
// A rejection here (e.g. DNS/connection/timeout failure) never produced an HTTP
|
|
256
|
-
// response, so it's re-thrown as an ApproveError with no statusCode - carrying
|
|
257
|
-
// the underlying cause's errno code (if any) so isRetryableError can recognize
|
|
258
|
-
// genuine transport failures, and the cause's message so the log doesn't just
|
|
259
|
-
// say "fetch failed" with no indication of what actually broke.
|
|
260
173
|
const approveResult = await fetch(new URL(`${manifest.name}@${manifest.version}`, settings.approvalUrl), {
|
|
261
174
|
method: "PUT",
|
|
262
175
|
headers: {
|
|
263
176
|
Authorization: `Bearer ${token}`,
|
|
264
177
|
},
|
|
265
|
-
}).catch((err) => {
|
|
266
|
-
const cause = err.cause instanceof Error ? err.cause : undefined;
|
|
267
|
-
const causeCode = cause && "code" in cause ? cause.code : undefined;
|
|
268
|
-
const code = typeof causeCode === "string" ? causeCode : undefined;
|
|
269
|
-
const reason = cause ? `${err.message}: ${cause.message}` : err.message;
|
|
270
|
-
throw new ApproveError(reason, undefined, code);
|
|
271
178
|
});
|
|
272
179
|
if (approveResult.ok) {
|
|
273
180
|
console.log(`✅ Approved version ${manifest.version} of ${manifest.name}.`);
|
|
274
181
|
return { success: true };
|
|
275
182
|
}
|
|
276
183
|
else {
|
|
277
|
-
throw new ApproveError(`${approveResult.statusText}, ${await approveResult.text()}, Trace ID: ${approveResult.headers.get("trace-id")}
|
|
184
|
+
throw new ApproveError(`${approveResult.statusText}, ${await approveResult.text()}, Trace ID: ${approveResult.headers.get("trace-id")}`);
|
|
278
185
|
}
|
|
279
186
|
}
|
|
280
187
|
else {
|
|
@@ -4,8 +4,8 @@ exports.IrisAppGenerator = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const internal_1 = require("@nx/js/internal");
|
|
7
|
+
const pacote = tslib_1.__importStar(require("pacote"));
|
|
7
8
|
const path = tslib_1.__importStar(require("path"));
|
|
8
|
-
const get_package_manifest_1 = require("../utils/get-package-manifest");
|
|
9
9
|
function normalizeOptions(tree, options) {
|
|
10
10
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
11
11
|
const projectDirectory = options.directory ? path.join(options.directory, name) : name;
|
|
@@ -36,6 +36,9 @@ function addFiles(tree, options, packageJson) {
|
|
|
36
36
|
};
|
|
37
37
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, "files"), options.projectRoot, templateOptions);
|
|
38
38
|
}
|
|
39
|
+
const getManifest = (packageName) => {
|
|
40
|
+
return pacote.manifest(packageName, process.env.TU_NPM_REGISTRY ? { registry: process.env.TU_NPM_REGISTRY } : undefined);
|
|
41
|
+
};
|
|
39
42
|
/**
|
|
40
43
|
* Iris App Generator.
|
|
41
44
|
* This generator will create a new iris app, you can call this from your own generator.
|
|
@@ -46,24 +49,24 @@ function addFiles(tree, options, packageJson) {
|
|
|
46
49
|
*/
|
|
47
50
|
const IrisAppGenerator = async function (tree, options) {
|
|
48
51
|
const normalizedOptions = normalizeOptions(tree, options);
|
|
49
|
-
const packageJsonFromNpm = await (
|
|
52
|
+
const packageJsonFromNpm = await getManifest("@trackunit/iris-app");
|
|
50
53
|
const packageJsonLocally = (0, devkit_1.readJsonFile)(path.join(__dirname, "..", "..", "..", "package.json"));
|
|
51
54
|
if (options.updatePackageJson) {
|
|
52
55
|
if (packageJsonFromNpm.version !== packageJsonLocally.version) {
|
|
53
56
|
// eslint-disable-next-line no-console
|
|
54
57
|
console.warn(`⚠️ This version of the iris-app package does not match the version of the iris-app package from NPM JS. Please update using: npm i @trackunit/iris-app@${packageJsonFromNpm.version}`);
|
|
55
58
|
}
|
|
56
|
-
const reactComponentsPackageJsonFromNpm = (
|
|
57
|
-
const reactCoreContextsPackageJsonFromNpm = (
|
|
58
|
-
const cssCorePackageJsonFromNpm = (
|
|
59
|
+
const reactComponentsPackageJsonFromNpm = getManifest("@trackunit/react-components");
|
|
60
|
+
const reactCoreContextsPackageJsonFromNpm = getManifest("@trackunit/react-core-contexts");
|
|
61
|
+
const cssCorePackageJsonFromNpm = getManifest("@trackunit/css-core");
|
|
59
62
|
const tuDependencies = {
|
|
60
63
|
"@trackunit/react-components": (await reactComponentsPackageJsonFromNpm).version,
|
|
61
64
|
"@trackunit/react-core-contexts": (await reactCoreContextsPackageJsonFromNpm).version,
|
|
62
65
|
"@trackunit/css-core": (await cssCorePackageJsonFromNpm).version,
|
|
63
66
|
};
|
|
64
|
-
const irisAppSdkVitePackageJsonFromNpm = (
|
|
65
|
-
const reactCoreContextsTestPackageJsonFromNpm = (
|
|
66
|
-
const reactTestSetupPackageJsonFromNpm = (
|
|
67
|
+
const irisAppSdkVitePackageJsonFromNpm = getManifest("@trackunit/iris-app-sdk-vite");
|
|
68
|
+
const reactCoreContextsTestPackageJsonFromNpm = getManifest("@trackunit/react-core-contexts-test");
|
|
69
|
+
const reactTestSetupPackageJsonFromNpm = getManifest("@trackunit/react-test-setup");
|
|
67
70
|
const tuDevDependencies = {
|
|
68
71
|
"@trackunit/iris-app-sdk-vite": (await irisAppSdkVitePackageJsonFromNpm).version,
|
|
69
72
|
"@trackunit/react-core-contexts-test": (await reactCoreContextsTestPackageJsonFromNpm).version,
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { Tree } from "@nx/devkit";
|
|
2
2
|
import { IrisAppExtensionGeneratorSchema } from "./schema";
|
|
3
|
-
type ServersideGraphqlOptions = {
|
|
4
|
-
readonly projectName: string;
|
|
5
|
-
readonly projectRoot: string;
|
|
6
|
-
readonly className: string;
|
|
7
|
-
readonly serversideUtilsVersion: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Adds public-schema codegen and a typed Hono example to a generated serverside extension.
|
|
11
|
-
*/
|
|
12
|
-
export declare const addServersideGraphql: (tree: Tree, options: ServersideGraphqlOptions) => Promise<void>;
|
|
13
3
|
/**
|
|
14
4
|
* Ensures that jest.preset.js exists and includes the required @trackunit/react-test-setup preset.
|
|
15
5
|
* If the file doesn't exist, creates it. If it exists but doesn't include the preset, updates it.
|
|
@@ -23,4 +13,3 @@ export declare function ensureJestPresetConfiguration(tree: Tree, templateOption
|
|
|
23
13
|
* @returns { Promise<void> } void
|
|
24
14
|
*/
|
|
25
15
|
export declare const IrisAppExtensionGenerator: (tree: Tree, options: IrisAppExtensionGeneratorSchema) => Promise<() => void>;
|
|
26
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IrisAppExtensionGenerator =
|
|
3
|
+
exports.IrisAppExtensionGenerator = void 0;
|
|
4
4
|
exports.ensureJestPresetConfiguration = ensureJestPresetConfiguration;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
@@ -9,53 +9,12 @@ const js_1 = require("@nx/js");
|
|
|
9
9
|
const internal_1 = require("@nx/js/internal");
|
|
10
10
|
const react_1 = require("@nx/react");
|
|
11
11
|
const iris_app_api_1 = require("@trackunit/iris-app-api");
|
|
12
|
-
const react_graphql_tools_1 = require("@trackunit/react-graphql-tools");
|
|
13
12
|
const fs = tslib_1.__importStar(require("fs"));
|
|
14
13
|
const path = tslib_1.__importStar(require("path"));
|
|
15
14
|
const string_ts_1 = require("string-ts");
|
|
16
15
|
const ts_morph_1 = require("ts-morph");
|
|
17
16
|
const astUtils_1 = require("../../utils/ast/astUtils");
|
|
18
|
-
const get_package_manifest_1 = require("../utils/get-package-manifest");
|
|
19
17
|
const dependencies_1 = require("./dependencies");
|
|
20
|
-
const addGraphqlDependency = (target) => {
|
|
21
|
-
if (!target) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const dependsOn = target.dependsOn ?? [];
|
|
25
|
-
if (!dependsOn.includes("graphql-hooks")) {
|
|
26
|
-
target.dependsOn = [...dependsOn, "graphql-hooks"];
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Adds public-schema codegen and a typed Hono example to a generated serverside extension.
|
|
31
|
-
*/
|
|
32
|
-
const addServersideGraphql = async (tree, options) => {
|
|
33
|
-
await (0, react_graphql_tools_1.addGraphqlGenerator)(tree, {
|
|
34
|
-
project: options.projectName,
|
|
35
|
-
schemaSource: "public",
|
|
36
|
-
generateMocks: false,
|
|
37
|
-
});
|
|
38
|
-
(0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", "SERVERSIDE_API_EXTENSION_GRAPHQL"), options.projectRoot, {
|
|
39
|
-
...options,
|
|
40
|
-
template: "",
|
|
41
|
-
});
|
|
42
|
-
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, "project.json"), projectJson => {
|
|
43
|
-
addGraphqlDependency(projectJson.targets.build);
|
|
44
|
-
addGraphqlDependency(projectJson.targets.test);
|
|
45
|
-
addGraphqlDependency(projectJson.targets.serve);
|
|
46
|
-
addGraphqlDependency(projectJson.targets["tsc-validate"]);
|
|
47
|
-
return projectJson;
|
|
48
|
-
});
|
|
49
|
-
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, "package.json"), packageJson => {
|
|
50
|
-
packageJson.dependencies = {
|
|
51
|
-
...packageJson.dependencies,
|
|
52
|
-
"@trackunit/serverside-utils": options.serversideUtilsVersion,
|
|
53
|
-
};
|
|
54
|
-
return packageJson;
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
exports.addServersideGraphql = addServersideGraphql;
|
|
58
|
-
const getPackageVersion = async (packageName) => (await (0, get_package_manifest_1.getPackageManifest)(packageName)).version;
|
|
59
18
|
function normalizeOptions(tree, options) {
|
|
60
19
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
61
20
|
const projectDirectory = options.directory ? `${(0, devkit_1.names)(options.directory).fileName}/${name}` : name;
|
|
@@ -127,9 +86,6 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
127
86
|
template: "",
|
|
128
87
|
};
|
|
129
88
|
const irisAppExtensionType = normalizedOptions.type;
|
|
130
|
-
if (normalizedOptions.graphql && irisAppExtensionType !== "SERVERSIDE_API_EXTENSION") {
|
|
131
|
-
throw new Error("GraphQL setup is only supported for SERVERSIDE_API_EXTENSION");
|
|
132
|
-
}
|
|
133
89
|
if (!tree.exists(`${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${normalizedOptions.app}`)) {
|
|
134
90
|
throw new Error(`The app does not exist: ${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${normalizedOptions.app} make sure you enter the right app name`);
|
|
135
91
|
}
|
|
@@ -237,14 +193,6 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
237
193
|
return projectJson;
|
|
238
194
|
});
|
|
239
195
|
}
|
|
240
|
-
if (normalizedOptions.graphql) {
|
|
241
|
-
await (0, exports.addServersideGraphql)(tree, {
|
|
242
|
-
projectName: normalizedOptions.projectName,
|
|
243
|
-
projectRoot: normalizedOptions.projectRoot,
|
|
244
|
-
className: (0, devkit_1.names)(normalizedOptions.name).className,
|
|
245
|
-
serversideUtilsVersion: await getPackageVersion("@trackunit/serverside-utils"),
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
196
|
//TODO: Change the following to update the manifest in the virtual Tree - not on the file system.
|
|
249
197
|
const project = new ts_morph_1.Project({
|
|
250
198
|
tsConfigFilePath: `${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${normalizedOptions.app}/tsconfig.app.json`,
|
|
@@ -64,11 +64,6 @@
|
|
|
64
64
|
"type": "boolean",
|
|
65
65
|
"description": "If the root jest.preset.js should be extended with the Iris app preset",
|
|
66
66
|
"default": true
|
|
67
|
-
},
|
|
68
|
-
"graphql": {
|
|
69
|
-
"type": "boolean",
|
|
70
|
-
"description": "Add typed Trackunit public GraphQL support (SERVERSIDE_API_EXTENSION only)",
|
|
71
|
-
"default": false
|
|
72
67
|
}
|
|
73
68
|
},
|
|
74
69
|
"required": ["name", "directory", "type"]
|
package/src/generators/extend/files/SERVERSIDE_API_EXTENSION_GRAPHQL/src/index.ts__template__
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createTrackunitGraphqlClient, getUserToken } from "@trackunit/serverside-utils";
|
|
2
|
-
import { Hono } from "hono";
|
|
3
|
-
import { <%= className %>AssetByIdDocument } from "./generated/graphql-api/graphql";
|
|
4
|
-
|
|
5
|
-
const app = new Hono();
|
|
6
|
-
|
|
7
|
-
app.get("/health", c => {
|
|
8
|
-
return c.json({
|
|
9
|
-
status: "ok",
|
|
10
|
-
timestamp: new Date().toISOString(),
|
|
11
|
-
service: "<%= projectName %>",
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
app.get("/assets/:id", async c => {
|
|
16
|
-
const token = getUserToken({ context: c });
|
|
17
|
-
if (!token) {
|
|
18
|
-
return c.json({ error: "Unauthorized" }, 401);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const client = createTrackunitGraphqlClient({ context: c });
|
|
22
|
-
const data = await client.request({
|
|
23
|
-
document: <%= className %>AssetByIdDocument,
|
|
24
|
-
variables: { id: c.req.param("id") },
|
|
25
|
-
signal: c.req.raw.signal,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return c.json(data);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default app.fetch;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPackageManifest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pacote = tslib_1.__importStar(require("pacote"));
|
|
6
|
-
/**
|
|
7
|
-
* Keeps Trackunit registry overrides consistent across package-consuming generators.
|
|
8
|
-
*/
|
|
9
|
-
const getPackageManifest = (packageName) => pacote.manifest(packageName, process.env.TU_NPM_REGISTRY ? { registry: process.env.TU_NPM_REGISTRY } : undefined);
|
|
10
|
-
exports.getPackageManifest = getPackageManifest;
|
|
11
|
-
//# sourceMappingURL=get-package-manifest.js.map
|