stigg-api-client 0.457.0 → 0.458.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/stigg/generated/operations.rb +1286 -0
- data/lib/stigg/generated/schema.json +64336 -0
- data/lib/stigg/version.rb +1 -1
- data/stigg-api-client.gemspec +2 -2
- metadata +4 -5
- data/scripts/generate-operations.mjs +0 -99
- data/scripts/generate.sh +0 -17
- data/scripts/publish.sh +0 -31
data/lib/stigg/version.rb
CHANGED
data/stigg-api-client.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
20
|
spec.files = Dir.chdir(__dir__) do
|
21
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
22
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
21
|
+
`git ls-files -z ; find lib/stigg/generated -print0`.split("\x0").reject do |f|
|
22
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|scripts)/|\.(?:git|travis|circleci)|appveyor)})
|
23
23
|
end
|
24
24
|
end
|
25
25
|
spec.bindir = "exe"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stigg-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.458.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stigg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphlient
|
@@ -40,11 +40,10 @@ files:
|
|
40
40
|
- Rakefile
|
41
41
|
- lib/stigg.rb
|
42
42
|
- lib/stigg/client.rb
|
43
|
+
- lib/stigg/generated/operations.rb
|
44
|
+
- lib/stigg/generated/schema.json
|
43
45
|
- lib/stigg/version.rb
|
44
46
|
- project.json
|
45
|
-
- scripts/generate-operations.mjs
|
46
|
-
- scripts/generate.sh
|
47
|
-
- scripts/publish.sh
|
48
47
|
- stigg-api-client.gemspec
|
49
48
|
homepage: https://stigg.io
|
50
49
|
licenses:
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import * as gql from 'graphql';
|
2
|
-
import fs from 'fs';
|
3
|
-
|
4
|
-
const schema = fs.readFileSync(
|
5
|
-
'../api-client-schema/src/generated/schema.graphql',
|
6
|
-
'utf8'
|
7
|
-
);
|
8
|
-
|
9
|
-
const operations = fs.readFileSync('operations.graphql', 'utf8');
|
10
|
-
|
11
|
-
const gqlSchema = gql.buildSchema(schema);
|
12
|
-
|
13
|
-
const gqlOperations = gql.parse(operations);
|
14
|
-
|
15
|
-
function generateOperationsModule() {
|
16
|
-
const typeInfo = new gql.TypeInfo(gqlSchema);
|
17
|
-
const outputProgram = gql.visit(
|
18
|
-
gqlOperations,
|
19
|
-
gql.visitWithTypeInfo(typeInfo, visitor(gqlSchema, typeInfo))
|
20
|
-
);
|
21
|
-
|
22
|
-
const modules = ['Fragment', 'Mutation', 'Query']
|
23
|
-
.map(
|
24
|
-
(moduleName) =>
|
25
|
-
`module ${moduleName}\n${outputProgram
|
26
|
-
.filter((x) => x.moduleName === moduleName)
|
27
|
-
.map((x) => x.element)
|
28
|
-
.join('\n\n')}\nend`
|
29
|
-
)
|
30
|
-
.join('\n');
|
31
|
-
|
32
|
-
return `# frozen_string_literal: true\n\nmodule Stigg\n${modules}\nend`;
|
33
|
-
}
|
34
|
-
|
35
|
-
function findFragments(node, results = new Set()) {
|
36
|
-
if (node.kind === 'FragmentSpread') {
|
37
|
-
results.add(node.name.value);
|
38
|
-
gqlOperations.definitions.find((def) => {
|
39
|
-
if (
|
40
|
-
def.kind === 'FragmentDefinition' &&
|
41
|
-
def.name.value === node.name.value
|
42
|
-
) {
|
43
|
-
findFragments(def, results);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
}
|
47
|
-
node.selectionSet?.selections?.forEach((node) =>
|
48
|
-
findFragments(node, results)
|
49
|
-
);
|
50
|
-
return results;
|
51
|
-
}
|
52
|
-
|
53
|
-
function visitor(schema, typeInfo) {
|
54
|
-
return {
|
55
|
-
enter(node) {
|
56
|
-
typeInfo.enter(node);
|
57
|
-
},
|
58
|
-
leave(node) {
|
59
|
-
typeInfo.leave(node);
|
60
|
-
switch (node.kind) {
|
61
|
-
case 'Document':
|
62
|
-
return node.definitions;
|
63
|
-
case 'OperationDefinition': {
|
64
|
-
const results = findFragments(node);
|
65
|
-
const rawQuery = node.loc.source.body.substring(
|
66
|
-
node.loc.start,
|
67
|
-
node.loc.end
|
68
|
-
);
|
69
|
-
const namelessQuery = rawQuery.replace(
|
70
|
-
`${node.operation} ${node.name.value}`,
|
71
|
-
`${node.operation} `
|
72
|
-
);
|
73
|
-
const includedFragments = [...results]
|
74
|
-
.map((x) => `#{Fragment::${x}}\n`)
|
75
|
-
.join('');
|
76
|
-
const constantName =
|
77
|
-
node.name.value[0].toUpperCase() + node.name.value.slice(1);
|
78
|
-
return {
|
79
|
-
moduleName: node.operation === 'mutation' ? 'Mutation' : 'Query',
|
80
|
-
element: `${constantName} = <<-GRAPHQL\n${namelessQuery}\n${includedFragments}GRAPHQL`,
|
81
|
-
};
|
82
|
-
}
|
83
|
-
case 'FragmentDefinition': {
|
84
|
-
const querySource = node.loc.source.body.substring(
|
85
|
-
node.loc.start,
|
86
|
-
node.loc.end
|
87
|
-
);
|
88
|
-
return {
|
89
|
-
moduleName: 'Fragment',
|
90
|
-
element: `${node.name.value} = <<-GRAPHQL\n${querySource}\nGRAPHQL`,
|
91
|
-
};
|
92
|
-
}
|
93
|
-
}
|
94
|
-
},
|
95
|
-
};
|
96
|
-
}
|
97
|
-
|
98
|
-
const module = generateOperationsModule();
|
99
|
-
fs.writeFileSync('lib/stigg/generated/operations.rb', module);
|
data/scripts/generate.sh
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
# stitch the operation files together
|
4
|
-
cat ../api-client-schema/src/operations/*.graphql > operations.graphql
|
5
|
-
|
6
|
-
mkdir -p lib/stigg/generated/
|
7
|
-
|
8
|
-
cat <<-EOF > lib/stigg/generated/schema.json
|
9
|
-
$(echo { \"data\": ) $(cat ../api-client-schema/src/generated/schema.json) $(echo })
|
10
|
-
EOF
|
11
|
-
|
12
|
-
node scripts/generate-operations.mjs
|
13
|
-
rm operations.graphql
|
14
|
-
|
15
|
-
bundle exec rubocop -a lib/stigg/generated/operations.rb
|
16
|
-
|
17
|
-
printf "api-client-ruby generated!\n"
|
data/scripts/publish.sh
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
VERSION=$1
|
4
|
-
|
5
|
-
if [ -z "$VERSION" ]; then
|
6
|
-
echo "Usage: ./scripts/publish.sh <version>"
|
7
|
-
exit 1
|
8
|
-
fi
|
9
|
-
|
10
|
-
bundle config unset deployment
|
11
|
-
|
12
|
-
bundle exec bump set "${VERSION}" --no-commit --no-bundle
|
13
|
-
git diff
|
14
|
-
|
15
|
-
echo "Building..."
|
16
|
-
bundle exec rake build
|
17
|
-
|
18
|
-
# create a temporary commit, since it's not possible to
|
19
|
-
# release with a dirty working directory
|
20
|
-
TAG="v${VERSION}"
|
21
|
-
echo "Creating temporary commit and tag (${TAG})..."
|
22
|
-
git add .
|
23
|
-
git commit --no-verify -m "tmp commit for ruby release"
|
24
|
-
git tag "${TAG}"
|
25
|
-
|
26
|
-
echo "Releasing..."
|
27
|
-
bundle exec rake release -v || (git tag -d "${TAG}" ; git reset --soft HEAD~1 ; exit 1)
|
28
|
-
git tag -d "${TAG}"
|
29
|
-
git reset --soft HEAD~1
|
30
|
-
|
31
|
-
echo "api-client-ruby published!"
|