@stonecrop/rockfoil 0.14.0 → 0.15.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/dist/rockfoil.js +10005 -9962
- package/dist/rockfoil.js.map +1 -1
- package/package.json +16 -16
- package/dist/index.js +0 -2
- package/dist/middleware/postgraphile.js +0 -50
- package/dist/tests/postgraphile.test.d.ts +0 -2
- package/dist/tests/postgraphile.test.d.ts.map +0 -1
- package/dist/tests/postgraphile.test.js +0 -58
- package/dist/types/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/rockfoil",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"type": "module",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "Tyler Matteson",
|
|
8
|
-
"email": "tyler@agritheory.com"
|
|
9
|
-
},
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "PostGraphile plugin for Stonecrop schema integration",
|
|
10
5
|
"homepage": "https://github.com/agritheory/rockfoil#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/agritheory/stonecrop/issues"
|
|
8
|
+
},
|
|
11
9
|
"repository": {
|
|
12
10
|
"type": "git",
|
|
13
11
|
"url": "https://github.com/agritheory/stonecrop",
|
|
14
12
|
"directory": "rockfoil"
|
|
15
13
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Tyler Matteson",
|
|
17
|
+
"email": "tyler@agritheory.com"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
20
23
|
"exports": {
|
|
21
24
|
".": {
|
|
22
25
|
"types": "./dist/rockfoil.d.ts",
|
|
@@ -25,14 +28,11 @@
|
|
|
25
28
|
"./styles": "./dist/assets/index.css",
|
|
26
29
|
"./types": "./dist/src/types/index.d.ts"
|
|
27
30
|
},
|
|
31
|
+
"types": "./dist/rockfoil.d.ts",
|
|
28
32
|
"files": [
|
|
29
33
|
"dist/*",
|
|
30
34
|
"src/*"
|
|
31
35
|
],
|
|
32
|
-
"description": "PostGraphile plugin for Stonecrop schema integration",
|
|
33
|
-
"sideEffects": [
|
|
34
|
-
"**/*.css"
|
|
35
|
-
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"graphql": "^16.14.0",
|
|
38
38
|
"postgraphile": "^5.0.3"
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"lint:fix": "oxlint --fix",
|
|
65
65
|
"preview": "vite preview",
|
|
66
66
|
"test": "vitest run --coverage.enabled false",
|
|
67
|
-
"test:watch": "vitest watch",
|
|
68
67
|
"test:coverage": "vitest run --coverage",
|
|
69
|
-
"test:ui": "vitest --ui"
|
|
68
|
+
"test:ui": "vitest --ui",
|
|
69
|
+
"test:watch": "vitest watch"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/dist/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { wrapPlans } from 'postgraphile/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a PostGraphile plugin that wraps GraphQL query and mutation plans with before/after hooks
|
|
4
|
-
* @param hookMap - Configuration mapping field names to before/after hook functions
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export const createPglRockfoilPlugin = (hookMap) => {
|
|
8
|
-
const queryPlans = {};
|
|
9
|
-
const mutationPlans = {};
|
|
10
|
-
for (const [fieldname, plans] of Object.entries(hookMap)) {
|
|
11
|
-
if (plans.beforeQuery || plans.afterQuery) {
|
|
12
|
-
queryPlans[fieldname] = {
|
|
13
|
-
plan: (plan, $source, fieldArgs, info) => {
|
|
14
|
-
// Process before query hooks
|
|
15
|
-
if (plans.beforeQuery) {
|
|
16
|
-
plans.beforeQuery(plan, $source, fieldArgs, info);
|
|
17
|
-
}
|
|
18
|
-
// Execute the query plan
|
|
19
|
-
let $result = plan();
|
|
20
|
-
// Process after query hooks
|
|
21
|
-
if (plans.afterQuery) {
|
|
22
|
-
$result = plans.afterQuery($result, plan, $source, fieldArgs, info);
|
|
23
|
-
}
|
|
24
|
-
return $result;
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (plans.beforeMutation || plans.afterMutation) {
|
|
29
|
-
mutationPlans[fieldname] = {
|
|
30
|
-
plan: (plan, $source, fieldArgs, info) => {
|
|
31
|
-
// Process before mutation hooks
|
|
32
|
-
if (plans.beforeMutation) {
|
|
33
|
-
plans.beforeMutation(plan, $source, fieldArgs, info);
|
|
34
|
-
}
|
|
35
|
-
// Execute the mutation plan
|
|
36
|
-
let $result = plan();
|
|
37
|
-
// Process after mutation hooks
|
|
38
|
-
if (plans.afterMutation) {
|
|
39
|
-
$result = plans.afterMutation($result, plan, $source, fieldArgs, info);
|
|
40
|
-
}
|
|
41
|
-
return $result;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return wrapPlans({
|
|
47
|
-
Query: queryPlans,
|
|
48
|
-
Mutation: mutationPlans,
|
|
49
|
-
});
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgraphile.test.d.ts","sourceRoot":"","sources":["../../tests/postgraphile.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
// Mock postgraphile/utils with a simple implementation
|
|
3
|
-
vi.mock('postgraphile/utils', () => ({
|
|
4
|
-
wrapPlans: (config) => ({
|
|
5
|
-
name: 'TestPlugin',
|
|
6
|
-
version: '1.0.0',
|
|
7
|
-
_config: config, // Store config for testing
|
|
8
|
-
}),
|
|
9
|
-
}));
|
|
10
|
-
import { createPglRockfoilPlugin } from '../src/middleware/postgraphile';
|
|
11
|
-
describe('Rockfoil PostGraphile Plugin', () => {
|
|
12
|
-
describe('createPglRockfoilPlugin', () => {
|
|
13
|
-
it('should create a valid plugin with empty hook map', () => {
|
|
14
|
-
const plugin = createPglRockfoilPlugin({});
|
|
15
|
-
expect(plugin).toBeDefined();
|
|
16
|
-
expect(plugin.name).toBe('TestPlugin');
|
|
17
|
-
expect(plugin.version).toBe('1.0.0');
|
|
18
|
-
});
|
|
19
|
-
it('should create a plugin with query hooks', () => {
|
|
20
|
-
const hookMap = {
|
|
21
|
-
testField: {
|
|
22
|
-
beforeQuery: vi.fn(),
|
|
23
|
-
afterQuery: vi.fn(),
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
const plugin = createPglRockfoilPlugin(hookMap);
|
|
27
|
-
expect(plugin).toBeDefined();
|
|
28
|
-
expect(plugin.name).toBe('TestPlugin');
|
|
29
|
-
});
|
|
30
|
-
it('should create a plugin with mutation hooks', () => {
|
|
31
|
-
const hookMap = {
|
|
32
|
-
createTest: {
|
|
33
|
-
beforeMutation: vi.fn(),
|
|
34
|
-
afterMutation: vi.fn(),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const plugin = createPglRockfoilPlugin(hookMap);
|
|
38
|
-
expect(plugin).toBeDefined();
|
|
39
|
-
expect(plugin.name).toBe('TestPlugin');
|
|
40
|
-
});
|
|
41
|
-
it('should handle complex hook map', () => {
|
|
42
|
-
const hookMap = {
|
|
43
|
-
field1: {
|
|
44
|
-
beforeQuery: vi.fn(),
|
|
45
|
-
},
|
|
46
|
-
field2: {
|
|
47
|
-
afterQuery: vi.fn(),
|
|
48
|
-
},
|
|
49
|
-
field3: {
|
|
50
|
-
beforeMutation: vi.fn(),
|
|
51
|
-
afterMutation: vi.fn(),
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
const plugin = createPglRockfoilPlugin(hookMap);
|
|
55
|
-
expect(plugin).toBeDefined();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/dist/types/index.js
DELETED
|
File without changes
|