@trackunit/react-graphql-tools 1.17.7 → 1.17.8
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 +16 -0
- package/package.json +2 -2
- package/src/executors/createHooks/collectPermissions.d.ts +6 -0
- package/src/executors/createHooks/collectPermissions.js +4 -3
- package/src/executors/createHooks/collectProjectScopes.d.ts +17 -0
- package/src/executors/createHooks/collectProjectScopes.js +49 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 1.17.8 (2026-08-31)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **react-graphql-tools:** narrow the scope-audit exports on the published barrel ([#25190](https://github.com/Trackunit/manager/issues/25190))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated iris-app-build-utilities to 2.4.28
|
|
10
|
+
- Updated react-vite-test-setup to 0.0.117
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- Cursor @cursoragent
|
|
15
|
+
- Mikkel Thorbjørn Andersen
|
|
16
|
+
|
|
1
17
|
## 1.17.7 (2026-08-31)
|
|
2
18
|
|
|
3
19
|
### 🧱 Updated Dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-graphql-tools",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.8",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"executors": "./executors.json",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"tslib": "^2.6.2",
|
|
20
20
|
"@nx/devkit": "23.1.0",
|
|
21
21
|
"@nx/js": "23.1.0",
|
|
22
|
-
"@trackunit/iris-app-build-utilities": "2.4.
|
|
22
|
+
"@trackunit/iris-app-build-utilities": "2.4.28",
|
|
23
23
|
"graphql": "^16.10.0"
|
|
24
24
|
},
|
|
25
25
|
"migrations": "./migrations.json",
|
|
@@ -7,6 +7,12 @@ import { GraphQLSchema } from "graphql";
|
|
|
7
7
|
* disk) or the schema file is missing (e.g. isolated test workspaces).
|
|
8
8
|
*/
|
|
9
9
|
export declare const loadAuthSchema: (nxRoot: string) => GraphQLSchema | null;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively reads every `.graphql` source document under a directory, skipping generated output.
|
|
12
|
+
* `*-manager.graphql` is excluded to match codegen's default document globs, so an operation that was
|
|
13
|
+
* never generated can't shadow a generated one of the same name.
|
|
14
|
+
*/
|
|
15
|
+
export declare const readGraphqlDocuments: (directory: string) => Array<string>;
|
|
10
16
|
/**
|
|
11
17
|
* Builds a map of operation name -> sorted, de-duplicated authorization scopes required by that
|
|
12
18
|
* operation, from raw GraphQL operation/fragment source documents.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectOperationPermissions = exports.collectPermissionsFromDocuments = exports.loadAuthSchema = void 0;
|
|
3
|
+
exports.collectOperationPermissions = exports.collectPermissionsFromDocuments = exports.readGraphqlDocuments = exports.loadAuthSchema = void 0;
|
|
4
4
|
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const graphql_1 = require("graphql");
|
|
@@ -133,7 +133,7 @@ const readGraphqlDocuments = (directory) => {
|
|
|
133
133
|
if (entry.isDirectory()) {
|
|
134
134
|
if (entry.name === "generated" || entry.name === "node_modules")
|
|
135
135
|
continue;
|
|
136
|
-
documents.push(...readGraphqlDocuments(fullPath));
|
|
136
|
+
documents.push(...(0, exports.readGraphqlDocuments)(fullPath));
|
|
137
137
|
}
|
|
138
138
|
else if (entry.name.endsWith(".graphql") && !entry.name.endsWith("-manager.graphql")) {
|
|
139
139
|
documents.push((0, fs_1.readFileSync)(fullPath, { encoding: "utf-8" }));
|
|
@@ -141,6 +141,7 @@ const readGraphqlDocuments = (directory) => {
|
|
|
141
141
|
}
|
|
142
142
|
return documents;
|
|
143
143
|
};
|
|
144
|
+
exports.readGraphqlDocuments = readGraphqlDocuments;
|
|
144
145
|
/**
|
|
145
146
|
* Builds a map of operation name -> sorted, de-duplicated authorization scopes required by that
|
|
146
147
|
* operation, from raw GraphQL operation/fragment source documents.
|
|
@@ -194,7 +195,7 @@ exports.collectPermissionsFromDocuments = collectPermissionsFromDocuments;
|
|
|
194
195
|
const collectOperationPermissions = (schema, generatedFilePath) => {
|
|
195
196
|
// <lib>/src/generated/graphql-api/graphql.ts -> <lib>/src
|
|
196
197
|
const documentsDirectory = (0, path_1.join)((0, path_1.dirname)(generatedFilePath), "..", "..");
|
|
197
|
-
return (0, exports.collectPermissionsFromDocuments)(schema, readGraphqlDocuments(documentsDirectory));
|
|
198
|
+
return (0, exports.collectPermissionsFromDocuments)(schema, (0, exports.readGraphqlDocuments)(documentsDirectory));
|
|
198
199
|
};
|
|
199
200
|
exports.collectOperationPermissions = collectOperationPermissions;
|
|
200
201
|
//# sourceMappingURL=collectPermissions.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GraphQLSchema } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Drops the memoised per-project scopes. Exposed for tests, which build a fresh schema per case.
|
|
4
|
+
*/
|
|
5
|
+
export declare const clearProjectScopesCache: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the authorization scopes every GraphQL operation in a project requires, as one sorted,
|
|
8
|
+
* de-duplicated list.
|
|
9
|
+
*
|
|
10
|
+
* A project requiring no scopes and a project with no GraphQL at all both yield an empty list —
|
|
11
|
+
* callers that need to tell those apart should inspect the project's documents themselves.
|
|
12
|
+
*
|
|
13
|
+
* @param schema The authorization-annotated schema to resolve field directives against.
|
|
14
|
+
* @param projectRoot Absolute path to the project whose `.graphql` documents should be scanned.
|
|
15
|
+
* @returns {Array<string>} Sorted, de-duplicated scopes required by the project.
|
|
16
|
+
*/
|
|
17
|
+
export declare const collectProjectScopes: (schema: GraphQLSchema, projectRoot: string) => Array<string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectProjectScopes = exports.clearProjectScopesCache = void 0;
|
|
4
|
+
const collectPermissions_1 = require("./collectPermissions");
|
|
5
|
+
/**
|
|
6
|
+
* A workspace-wide scan asks the same library for its scopes once per app that depends on it,
|
|
7
|
+
* so results are cached per project root. The cache is only valid for the schema that produced
|
|
8
|
+
* it; a different schema resets it rather than returning stale answers.
|
|
9
|
+
*/
|
|
10
|
+
let cachedSchema;
|
|
11
|
+
const scopesByProjectRoot = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Drops the memoised per-project scopes. Exposed for tests, which build a fresh schema per case.
|
|
14
|
+
*/
|
|
15
|
+
const clearProjectScopesCache = () => {
|
|
16
|
+
cachedSchema = undefined;
|
|
17
|
+
scopesByProjectRoot.clear();
|
|
18
|
+
};
|
|
19
|
+
exports.clearProjectScopesCache = clearProjectScopesCache;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the authorization scopes every GraphQL operation in a project requires, as one sorted,
|
|
22
|
+
* de-duplicated list.
|
|
23
|
+
*
|
|
24
|
+
* A project requiring no scopes and a project with no GraphQL at all both yield an empty list —
|
|
25
|
+
* callers that need to tell those apart should inspect the project's documents themselves.
|
|
26
|
+
*
|
|
27
|
+
* @param schema The authorization-annotated schema to resolve field directives against.
|
|
28
|
+
* @param projectRoot Absolute path to the project whose `.graphql` documents should be scanned.
|
|
29
|
+
* @returns {Array<string>} Sorted, de-duplicated scopes required by the project.
|
|
30
|
+
*/
|
|
31
|
+
const collectProjectScopes = (schema, projectRoot) => {
|
|
32
|
+
if (cachedSchema !== schema) {
|
|
33
|
+
cachedSchema = schema;
|
|
34
|
+
scopesByProjectRoot.clear();
|
|
35
|
+
}
|
|
36
|
+
const cached = scopesByProjectRoot.get(projectRoot);
|
|
37
|
+
if (cached !== undefined)
|
|
38
|
+
return cached;
|
|
39
|
+
const permissionsByOperation = (0, collectPermissions_1.collectPermissionsFromDocuments)(schema, (0, collectPermissions_1.readGraphqlDocuments)(projectRoot));
|
|
40
|
+
const scopes = new Set();
|
|
41
|
+
for (const operationScopes of permissionsByOperation.values()) {
|
|
42
|
+
operationScopes.forEach(scope => scopes.add(scope));
|
|
43
|
+
}
|
|
44
|
+
const sorted = [...scopes].sort();
|
|
45
|
+
scopesByProjectRoot.set(projectRoot, sorted);
|
|
46
|
+
return sorted;
|
|
47
|
+
};
|
|
48
|
+
exports.collectProjectScopes = collectProjectScopes;
|
|
49
|
+
//# sourceMappingURL=collectProjectScopes.js.map
|
package/src/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export type { CreateGraphqlHooksExecutorSchema } from "./executors/createHooks/s
|
|
|
2
2
|
export type { AddGraphqlGeneratorSchema } from "./generators/add-graphql/schema";
|
|
3
3
|
export { CreateGraphqlHooks } from "./executors/createHooks/executor";
|
|
4
4
|
export { addGraphqlGenerator } from "./generators/add-graphql/generator";
|
|
5
|
+
export { collectPermissionsFromDocuments, loadAuthSchema } from "./executors/createHooks/collectPermissions";
|
|
6
|
+
export { collectProjectScopes } from "./executors/createHooks/collectProjectScopes";
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addGraphqlGenerator = exports.CreateGraphqlHooks = void 0;
|
|
3
|
+
exports.collectProjectScopes = exports.loadAuthSchema = exports.collectPermissionsFromDocuments = exports.addGraphqlGenerator = exports.CreateGraphqlHooks = void 0;
|
|
4
4
|
var executor_1 = require("./executors/createHooks/executor");
|
|
5
5
|
Object.defineProperty(exports, "CreateGraphqlHooks", { enumerable: true, get: function () { return executor_1.CreateGraphqlHooks; } });
|
|
6
6
|
var generator_1 = require("./generators/add-graphql/generator");
|
|
7
7
|
Object.defineProperty(exports, "addGraphqlGenerator", { enumerable: true, get: function () { return generator_1.addGraphqlGenerator; } });
|
|
8
|
+
var collectPermissions_1 = require("./executors/createHooks/collectPermissions");
|
|
9
|
+
Object.defineProperty(exports, "collectPermissionsFromDocuments", { enumerable: true, get: function () { return collectPermissions_1.collectPermissionsFromDocuments; } });
|
|
10
|
+
Object.defineProperty(exports, "loadAuthSchema", { enumerable: true, get: function () { return collectPermissions_1.loadAuthSchema; } });
|
|
11
|
+
var collectProjectScopes_1 = require("./executors/createHooks/collectProjectScopes");
|
|
12
|
+
Object.defineProperty(exports, "collectProjectScopes", { enumerable: true, get: function () { return collectProjectScopes_1.collectProjectScopes; } });
|
|
8
13
|
//# sourceMappingURL=index.js.map
|