@stonecrop/graphql-client 0.14.0 → 0.16.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/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@stonecrop/graphql-client",
3
- "version": "0.14.0",
4
- "license": "MIT",
5
- "type": "module",
6
- "author": {
7
- "name": "Tyler Matteson",
8
- "email": "tyler@agritheory.com"
3
+ "version": "0.16.0",
4
+ "description": "GraphQL client integration for Stonecrop",
5
+ "bugs": {
6
+ "url": "https://github.com/agritheory/stonecrop/issues"
9
7
  },
10
8
  "repository": {
11
9
  "type": "git",
12
10
  "url": "https://github.com/agritheory/stonecrop",
13
11
  "directory": "graphql_client"
14
12
  },
15
- "bugs": {
16
- "url": "https://github.com/agritheory/stonecrop/issues"
13
+ "license": "MIT",
14
+ "author": {
15
+ "name": "Tyler Matteson",
16
+ "email": "tyler@agritheory.com"
17
17
  },
18
- "description": "GraphQL client integration for Stonecrop",
19
- "types": "./dist/graphql-client.d.ts",
18
+ "sideEffects": false,
19
+ "type": "module",
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/graphql-client.d.ts",
@@ -24,16 +24,16 @@
24
24
  },
25
25
  "./types": "./dist/src/types/index.d.ts"
26
26
  },
27
+ "types": "./dist/graphql-client.d.ts",
27
28
  "files": [
28
29
  "dist/*",
29
30
  "src/*"
30
31
  ],
31
- "sideEffects": false,
32
32
  "dependencies": {
33
33
  "graphql": "^16.14.0",
34
34
  "pluralize": "^8.0.0",
35
- "@stonecrop/schema": "0.14.0",
36
- "@stonecrop/stonecrop": "0.14.0"
35
+ "@stonecrop/schema": "0.16.0",
36
+ "@stonecrop/stonecrop": "0.16.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@microsoft/api-documenter": "^7.30.5",
@@ -51,15 +51,15 @@
51
51
  "vitest": "^4.1.5",
52
52
  "vue": "^3.5.33",
53
53
  "vue-router": "^5.0.6",
54
- "stonecrop-rig": "0.7.0",
55
- "@stonecrop/graphql-middleware": "0.14.0"
56
- },
57
- "publishConfig": {
58
- "access": "public"
54
+ "@stonecrop/graphql-middleware": "0.16.0",
55
+ "stonecrop-rig": "0.7.0"
59
56
  },
60
57
  "engines": {
61
58
  "node": ">=24.0.0"
62
59
  },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
63
  "scripts": {
64
64
  "_phase:build": "heft build && vite build && rushx docs",
65
65
  "build": "heft build && vite build && rushx docs",
@@ -69,7 +69,7 @@
69
69
  "lint:fix": "oxlint --fix",
70
70
  "preview": "vite preview",
71
71
  "test": "vitest run --coverage.enabled false",
72
- "test:watch": "vitest watch",
73
- "test:coverage": "vitest run --coverage"
72
+ "test:coverage": "vitest run --coverage",
73
+ "test:watch": "vitest watch"
74
74
  }
75
75
  }
package/dist/client.js DELETED
@@ -1,247 +0,0 @@
1
- /**
2
- * Client for interacting with Stonecrop GraphQL API.
3
- *
4
- * Acts as a transport layer — it passes requests to the middleware and returns
5
- * merged results. Does not construct queries itself.
6
- *
7
- * @public
8
- */
9
- export class StonecropClient {
10
- endpoint;
11
- headers;
12
- metaCache = new Map();
13
- constructor(options) {
14
- this.endpoint = options.endpoint;
15
- this.headers = {
16
- 'Content-Type': 'application/json',
17
- ...options.headers,
18
- };
19
- }
20
- /**
21
- * Execute a GraphQL query against the configured endpoint.
22
- *
23
- * @param query - GraphQL query string
24
- * @param variables - Query variables
25
- * @throws Error if the GraphQL response contains errors
26
- */
27
- async query(query, variables) {
28
- const response = await fetch(this.endpoint, {
29
- method: 'POST',
30
- headers: this.headers,
31
- body: JSON.stringify({ query, variables }),
32
- });
33
- const json = (await response.json());
34
- if (json.errors?.length) {
35
- throw new Error(json.errors[0].message);
36
- }
37
- return json.data;
38
- }
39
- /**
40
- * Execute a GraphQL mutation. Delegates to query() since both use POST.
41
- *
42
- * @param mutation - GraphQL mutation string
43
- * @param variables - Mutation variables
44
- */
45
- async mutate(mutation, variables) {
46
- return this.query(mutation, variables);
47
- }
48
- /**
49
- * Get doctype metadata
50
- * @param context - Doctype context containing doctype name
51
- */
52
- async getMeta(context) {
53
- const cached = this.metaCache.get(context.doctype);
54
- if (cached)
55
- return cached;
56
- const result = await this.query(`
57
- query GetMeta($doctype: String!) {
58
- stonecropMeta(doctype: $doctype) {
59
- name
60
- slug
61
- tableName
62
- fields {
63
- fieldname
64
- fieldtype
65
- component
66
- label
67
- width
68
- align
69
- required
70
- readOnly
71
- edit
72
- hidden
73
- default
74
- options
75
- mask
76
- precision
77
- scale
78
- mode
79
- validation
80
- }
81
- workflow {
82
- states
83
- actions {
84
- label
85
- handler
86
- requiredFields
87
- allowedStates
88
- confirm
89
- args
90
- }
91
- }
92
- inherits
93
- }
94
- }
95
- `, { doctype: context.doctype });
96
- if (result.stonecropMeta) {
97
- this.metaCache.set(context.doctype, result.stonecropMeta);
98
- }
99
- return result.stonecropMeta;
100
- }
101
- /**
102
- * Get all doctype metadata
103
- */
104
- async getAllMeta() {
105
- const result = await this.query(`
106
- query GetAllMeta {
107
- stonecropAllMeta {
108
- name
109
- slug
110
- tableName
111
- fields {
112
- fieldname
113
- fieldtype
114
- component
115
- label
116
- width
117
- align
118
- required
119
- readOnly
120
- edit
121
- hidden
122
- default
123
- options
124
- mask
125
- precision
126
- scale
127
- mode
128
- validation
129
- }
130
- workflow {
131
- states
132
- actions {
133
- label
134
- handler
135
- requiredFields
136
- allowedStates
137
- confirm
138
- args
139
- }
140
- }
141
- inherits
142
- }
143
- }
144
- `);
145
- for (const meta of result.stonecropAllMeta) {
146
- this.metaCache.set(meta.name, meta);
147
- }
148
- return result.stonecropAllMeta;
149
- }
150
- /**
151
- * Get a single record by ID.
152
- *
153
- * Routes through the stonecropRecord resolver which handles nested data
154
- * fetching based on the includeNested option.
155
- *
156
- * @param doctype - Doctype reference (name and optional slug)
157
- * @param recordId - Record ID to fetch
158
- * @param options - Query options (includeNested, maxDepth)
159
- */
160
- async getRecord(doctype, recordId, options) {
161
- const result = await this.query(`query GetRecord($doctype: String!, $id: String!, $options: JSON) {
162
- stonecropRecord(doctype: $doctype, id: $id, options: $options) {
163
- data
164
- unknownLinks
165
- }
166
- }`, {
167
- doctype: doctype.name,
168
- id: recordId,
169
- options: options?.includeNested
170
- ? {
171
- includeNested: options.includeNested,
172
- maxDepth: options.maxDepth,
173
- }
174
- : undefined,
175
- });
176
- return {
177
- record: result.stonecropRecord?.data ?? null,
178
- unknownLinks: result.stonecropRecord?.unknownLinks,
179
- };
180
- }
181
- /**
182
- * Get multiple records with optional filtering and pagination.
183
- *
184
- * Returns flat arrays — the middleware merges connection format (\{ nodes: [...] \})
185
- * into plain arrays before returning.
186
- *
187
- * @param doctype - Doctype reference (name and optional slug)
188
- * @param options - Query options (filters, orderBy, limit, offset)
189
- */
190
- async getRecords(doctype, options) {
191
- const result = await this.query(`
192
- query GetRecords(
193
- $doctype: String!
194
- $filters: JSON
195
- $orderBy: String
196
- $limit: Int
197
- $offset: Int
198
- ) {
199
- stonecropRecords(
200
- doctype: $doctype
201
- filters: $filters
202
- orderBy: $orderBy
203
- limit: $limit
204
- offset: $offset
205
- ) {
206
- data
207
- count
208
- }
209
- }
210
- `, {
211
- doctype: doctype.name,
212
- ...options,
213
- });
214
- return result.stonecropRecords.data;
215
- }
216
- /**
217
- * Execute a doctype action
218
- * @param doctype - Doctype reference (name and optional slug)
219
- * @param action - Action name to execute
220
- * @param args - Action arguments
221
- */
222
- async runAction(doctype, action, args) {
223
- const result = await this.query(`
224
- mutation RunAction($doctype: String!, $action: String!, $args: JSON) {
225
- stonecropAction(doctype: $doctype, action: $action, args: $args) {
226
- success
227
- data
228
- error
229
- }
230
- }
231
- `, {
232
- doctype: doctype.name,
233
- action,
234
- args,
235
- });
236
- return result.stonecropAction;
237
- }
238
- /**
239
- * Clear the cached doctype metadata.
240
- *
241
- * Call this if the server-side doctype schema has changed and you need
242
- * to fetch fresh metadata (e.g., after adding a new field).
243
- */
244
- clearMetaCache() {
245
- this.metaCache.clear();
246
- }
247
- }
@@ -1,53 +0,0 @@
1
- import { gql } from 'graphql-request';
2
- /**
3
- * This is the schema for the GraphQL API.
4
- * @public
5
- */
6
- const typeDefs = gql `
7
- type Doctype {
8
- id: ID!
9
- name: String!
10
- workflow: String!
11
- schema: String!
12
- actions: String!
13
- }
14
-
15
- type DoctypeField {
16
- id: ID!
17
- label: String!
18
- fieldtype: String
19
- component: String
20
- required: Boolean
21
- readonly: Boolean
22
- }
23
-
24
- type DoctypeWorkflow {
25
- name: String!
26
- machine: StateMachine!
27
- }
28
-
29
- type StateMachine {
30
- id: ID!
31
- }
32
-
33
- type DoctypeAction {
34
- eventName: String!
35
- callback: String
36
- }
37
-
38
- type Query {
39
- getMeta(doctype: String!): Doctype # ∪ error
40
- getRecords(doctype: String!, filters: [String]): [String] # ∪ error
41
- getRecord(doctype: String!, id: ID!): String # ∪ error
42
- }
43
-
44
- type Mutation {
45
- runAction(doctype: String!, id: [ID!]!, functionName: String!): [String!]! # ∪ error
46
- }
47
-
48
- schema {
49
- query: Query
50
- mutation: Mutation
51
- }
52
- `;
53
- export default typeDefs;