@simtlix/simfinity-js-client 1.0.6 → 3.19.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/README.md +121 -3
- package/package.json +17 -6
- package/src/SimfinityClient.js +286 -392
- package/src/inputs.js +106 -0
- package/src/metadata.js +104 -0
- package/src/selection.js +88 -0
- package/types/index.d.ts +91 -0
- package/IMPLEMENTATION_PROMPT.md +0 -1137
- package/examples/demo.js +0 -350
- package/simtlix-simfinity-js-client-1.0.0.tgz +0 -0
- package/simtlix-simfinity-js-client-1.0.1.tgz +0 -0
- package/simtlix-simfinity-js-client-1.0.3.tgz +0 -0
- package/simtlix-simfinity-js-client-1.0.4.tgz +0 -0
- package/simtlix-simfinity-js-client-1.0.5.tgz +0 -0
package/README.md
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Introspection-driven GraphQL client for [simfinity-js](https://github.com/simtlix/simfinity.js) APIs. It discovers your schema at runtime via introspection and exposes a chainable query builder, CRUD helpers, aggregate queries, state-machine transitions, schema metadata access, mutation input transformation, and more — no code generation required.
|
|
4
4
|
|
|
5
|
+
> Since 3.19.0, the client is maintained in the Simfinity monorepo and follows its aligned release version. Existing valid 1.1 JavaScript calls remain supported.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install @simtlix/simfinity-js-client
|
|
10
|
+
npm install @simtlix/simfinity-js-client@3.19.0
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Quick Start
|
|
@@ -41,7 +43,7 @@ Creates a new client instance pointing at the given GraphQL endpoint.
|
|
|
41
43
|
|
|
42
44
|
### `client.init()`
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
By default, runs an extended introspection query against the endpoint and builds internal registries of types, queries, and mutations — including Simfinity-specific field extensions (relation metadata, state machine flags, read-only markers). **Must be called before any other method.**
|
|
45
47
|
|
|
46
48
|
### Schema Inspection
|
|
47
49
|
|
|
@@ -71,7 +73,7 @@ const results = await client.find('serie')
|
|
|
71
73
|
|
|
72
74
|
#### `.where(field, operator, value [, value2])`
|
|
73
75
|
|
|
74
|
-
Filter by a scalar field. Supported operators depend on the server schema (e.g. `EQ`, `NE`, `GT`, `LT`, `GTE`, `LTE`, `
|
|
76
|
+
Filter by a scalar field. Supported operators depend on the server schema (e.g. `EQ`, `NE`, `GT`, `LT`, `GTE`, `LTE`, `BTW`, `LIKE`, `NIN`).
|
|
75
77
|
|
|
76
78
|
#### `.where(field, terms)`
|
|
77
79
|
|
|
@@ -83,6 +85,106 @@ Filter by a collection field using an array of term objects:
|
|
|
83
85
|
])
|
|
84
86
|
```
|
|
85
87
|
|
|
88
|
+
#### `.or(groups)` / `.and(groups)`
|
|
89
|
+
|
|
90
|
+
Add AND/OR logical filter groups for complex boolean conditions. Each method accepts an array of `QLFilterGroup` objects and can be called multiple times (groups accumulate). These combine with existing flat `.where()` filters via AND at the top level.
|
|
91
|
+
|
|
92
|
+
A `QLFilterGroup` is a plain object with optional `AND`, `OR`, and `conditions` fields:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
{
|
|
96
|
+
conditions: [{ field: 'category', operator: 'EQ', value: 'Drama' }],
|
|
97
|
+
AND: [/* nested QLFilterGroup objects */],
|
|
98
|
+
OR: [/* nested QLFilterGroup objects */],
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Simple OR** -- return series in either Drama or Comedy:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
const results = await client.find('serie')
|
|
106
|
+
.or([
|
|
107
|
+
SimfinityClient.condition('categories', 'EQ', 'Drama'),
|
|
108
|
+
SimfinityClient.condition('categories', 'EQ', 'Comedy'),
|
|
109
|
+
])
|
|
110
|
+
.fields('id name categories')
|
|
111
|
+
.exec();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Flat filters combined with OR** -- flat `.where()` is ANDed with the OR group:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
const results = await client.find('serie')
|
|
118
|
+
.where('categories', 'NE', 'Horror')
|
|
119
|
+
.or([
|
|
120
|
+
SimfinityClient.condition('name', 'LIKE', 'Breaking'),
|
|
121
|
+
SimfinityClient.condition('name', 'LIKE', 'Game'),
|
|
122
|
+
])
|
|
123
|
+
.fields('id name categories')
|
|
124
|
+
.exec();
|
|
125
|
+
// Equivalent to: categories != "Horror" AND (name LIKE "Breaking" OR name LIKE "Game")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Nested AND inside OR**:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
const results = await client.find('serie')
|
|
132
|
+
.or([
|
|
133
|
+
{ AND: [
|
|
134
|
+
SimfinityClient.condition('categories', 'EQ', 'Drama'),
|
|
135
|
+
SimfinityClient.condition('year', 'GTE', 2020),
|
|
136
|
+
]},
|
|
137
|
+
{ AND: [
|
|
138
|
+
SimfinityClient.condition('categories', 'EQ', 'Comedy'),
|
|
139
|
+
SimfinityClient.condition('year', 'GTE', 2015),
|
|
140
|
+
]},
|
|
141
|
+
])
|
|
142
|
+
.exec();
|
|
143
|
+
// Equivalent to: (categories = "Drama" AND year >= 2020) OR (categories = "Comedy" AND year >= 2015)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**AND with nested OR groups**:
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
const results = await client.find('serie')
|
|
150
|
+
.where('year', 'GTE', 2000)
|
|
151
|
+
.and([
|
|
152
|
+
{ OR: [
|
|
153
|
+
SimfinityClient.condition('categories', 'EQ', 'Drama'),
|
|
154
|
+
SimfinityClient.condition('categories', 'EQ', 'Comedy'),
|
|
155
|
+
]},
|
|
156
|
+
{ OR: [
|
|
157
|
+
SimfinityClient.condition('director', 'EQ', 'UK', 'country'),
|
|
158
|
+
SimfinityClient.condition('director', 'EQ', 'US', 'country'),
|
|
159
|
+
]},
|
|
160
|
+
])
|
|
161
|
+
.exec();
|
|
162
|
+
// Equivalent to: year >= 2000 AND (Drama OR Comedy) AND (UK OR US director)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Relationship path filtering** -- use the `path` parameter for object field conditions:
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
.or([
|
|
169
|
+
SimfinityClient.condition('director', 'LIKE', 'Adams', 'name'),
|
|
170
|
+
SimfinityClient.condition('director', 'LIKE', 'Nolan', 'name'),
|
|
171
|
+
])
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The Aggregate Builder also supports `.or()` and `.and()` with identical behavior. The server enforces a maximum nesting depth of 5 levels.
|
|
175
|
+
|
|
176
|
+
#### `SimfinityClient.condition(field, operator, value [, path])`
|
|
177
|
+
|
|
178
|
+
Static convenience factory for creating a filter group with a single condition. Returns a `QLFilterGroup` object:
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
SimfinityClient.condition('category', 'EQ', 'Drama')
|
|
182
|
+
// Equivalent to: { conditions: [{ field: 'category', operator: 'EQ', value: 'Drama' }] }
|
|
183
|
+
|
|
184
|
+
SimfinityClient.condition('author', 'LIKE', 'Adams', 'name')
|
|
185
|
+
// Equivalent to: { conditions: [{ field: 'author', operator: 'LIKE', value: 'Adams', path: 'name' }] }
|
|
186
|
+
```
|
|
187
|
+
|
|
86
188
|
#### `.joinObject(path, fields)`
|
|
87
189
|
|
|
88
190
|
Include a related object's fields in the selection.
|
|
@@ -389,3 +491,19 @@ GRAPHQL_ENDPOINT=http://localhost:3000/graphql npm run demo
|
|
|
389
491
|
## License
|
|
390
492
|
|
|
391
493
|
[Apache-2.0](LICENSE)
|
|
494
|
+
|
|
495
|
+
## Source provenance
|
|
496
|
+
|
|
497
|
+
Imported from simtlix/simfinity-js-client commit `32d9c5bf7264cd3ecddcd3441bffea3b21566cb0` (1.1.0), under its Apache-2.0 license.
|
|
498
|
+
|
|
499
|
+
## Monorepo additions
|
|
500
|
+
|
|
501
|
+
See the [JavaScript client guide](https://simtlix.github.io/simfinity.js/guide/client) for the complete current API and both-engine setup. The client remains dependency-free and browser compatible.
|
|
502
|
+
|
|
503
|
+
- Constructor options add mutually exclusive `descriptor` and `descriptorEndpoint`, injected `fetch`, `introspection: 'extended' | 'standard'`, and asynchronous `prepareHeaders`. Descriptor mode never introspects; use it when the server disables introspection. `getDescriptor()` returns the loaded descriptor or null.
|
|
504
|
+
- `query(name, args?, fields?)` executes exact query roots, including scalar and abstract outputs. `findView(name, params?)` returns a normal list builder, while `getViews(typeName?)` lists descriptor-classified views. Canonical lists are not replaced by views.
|
|
505
|
+
- List and aggregate builders accept `.where(field, filterObject)` and `.filter(group)` for `valuePath`, `ANY`/`ALL`/`NONE` and `$parent`. Operators come from the schema, including text, emptiness, `CONTAINS_ALL` and `IIN`; the server still gates engine support. `collectionArgs(path, args)` applies variables to selected nested collections, separately from legacy parent filtering. Aliased paths use response names.
|
|
506
|
+
- Transformed updates/actions preserve required managed versions. `delete(type, id, fields?, { version })` supplies the protected delete precondition. `transformInput` adds `preserveEmpty`, `includeCollections` and concrete `inputType` opt-ins. Collection delta transformation keeps `{ id, version }` for protected deletions and IDs for unprotected deletions.
|
|
507
|
+
- `transaction(operations, fields?, { name }?)` sends one generated transaction mutation, preserving reference tokens and explicit versions. Descriptor mode discovers its root; introspection mode requires the exact configured name. Errors preserve all `graphQLErrors` extensions, including transaction positions. Writes are never retried by this client.
|
|
508
|
+
|
|
509
|
+
Version 3.19.0 starts the client's aligned monorepo release policy, preserving the package name and existing valid 1.1 JavaScript calls. Releases use this repository's Release Simfinity workflow with npm Trusted Publishing and verified archives in both registries.
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simtlix/simfinity-js-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "Introspection-driven GraphQL client for simfinity-js APIs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "src/SimfinityClient.js",
|
|
6
|
+
"main": "./src/SimfinityClient.js",
|
|
7
7
|
"exports": {
|
|
8
|
-
".":
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
|
+
"default": "./src/SimfinityClient.js"
|
|
11
|
+
}
|
|
9
12
|
},
|
|
10
13
|
"scripts": {
|
|
11
14
|
"demo": "node examples/demo.js"
|
|
@@ -21,9 +24,17 @@
|
|
|
21
24
|
"license": "Apache-2.0",
|
|
22
25
|
"repository": {
|
|
23
26
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/simtlix/simfinity
|
|
27
|
+
"url": "https://github.com/simtlix/simfinity.js",
|
|
28
|
+
"directory": "packages/client"
|
|
25
29
|
},
|
|
26
30
|
"engines": {
|
|
27
|
-
"node": ">=18.
|
|
28
|
-
}
|
|
31
|
+
"node": ">=18.18.0"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"types",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"types": "./types/index.d.ts"
|
|
29
40
|
}
|