quill-sql 0.1.8 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/client_token.rb +43 -0
- data/lib/db/bigquery.rb +1346 -0
- data/lib/db/cached_connection.rb +187 -17
- data/lib/db/civil_time.rb +60 -0
- data/lib/db/clickhouse.rb +164 -48
- data/lib/db/databricks.rb +498 -61
- data/lib/db/db_helper.rb +112 -2
- data/lib/db/mssql.rb +917 -0
- data/lib/db/mysql.rb +934 -0
- data/lib/db/postgres.rb +222 -47
- data/lib/db/redshift.rb +164 -0
- data/lib/db/snowflake.rb +1167 -0
- data/lib/models/filters.rb +1 -1
- data/lib/quill-sql.rb +468 -100
- data/lib/utils/pivot_template.rb +457 -0
- data/lib/utils/report_error.rb +169 -0
- data/lib/utils/run_query_processes.rb +26 -4
- metadata +128 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f44056690bfd0eeb66ee964d0d70d15478edae129526f91e13d74bd7ad2c0375
|
|
4
|
+
data.tar.gz: db68d2447e11d6329ded6986fd8252c70018d1981f18c2e290170d9d65740d45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7eb646e4e48d04af8a09e4e906a9f1574e20cda8a55d82f7e5ede37f7eb83341d929b188e3e32892af52eec9d00f8e10d17ad218102acf4aae898622e103f700
|
|
7
|
+
data.tar.gz: 3bae53ffe256841b643de2eb15592cd178ed748d68dea5e029fbad3d881d2e337158f2d41c009fa42601fde7a97ec691e3432d0c8d34c7a7ee6c4369b321befb
|
data/README.md
CHANGED
|
@@ -43,7 +43,7 @@ post '/quill' do
|
|
|
43
43
|
headers 'Access-Control-Allow-Origin' => '*'
|
|
44
44
|
metadata = JSON.parse(request.body.read)['metadata']
|
|
45
45
|
result = quill.query(
|
|
46
|
-
tenants: [
|
|
46
|
+
tenants: [{ 'tenantField' => 'organization_id', 'tenantIds' => [current_user.organization_id] }],
|
|
47
47
|
metadata: metadata
|
|
48
48
|
)
|
|
49
49
|
result.to_json
|
|
@@ -57,6 +57,10 @@ options '/quill' do
|
|
|
57
57
|
end
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
## Upgrading
|
|
61
|
+
|
|
62
|
+
- `query` no longer accepts an empty `tenants` or `flags` array. It returns `status: "error"` with `Quill SDK: You may not pass an empty tenants array.` or `Quill SDK: You may not pass an empty flags array.` Leave `flags` out when there are none.
|
|
63
|
+
|
|
60
64
|
## For local testing (dev purposes only)
|
|
61
65
|
|
|
62
66
|
Create a `.env` file in your project root with the following key-value pairs:
|
data/lib/client_token.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
class Quill
|
|
6
|
+
# Mint a short-lived, signed client token for the browser.
|
|
7
|
+
#
|
|
8
|
+
# +tenants+ is an array of <tt>{ tenantField:, tenantIds: }</tt> hashes, the
|
|
9
|
+
# same shape the React SDK's +tenants+ prop takes. The server validates it
|
|
10
|
+
# against the client's tenant configuration (one tenantField per token, ids
|
|
11
|
+
# coerced to the field's type, no reserved sentinels). A database-level
|
|
12
|
+
# tenant scopes to +QUILL_SINGLE_TENANT+.
|
|
13
|
+
#
|
|
14
|
+
# +flags+ is optional: an array of flag names, or of
|
|
15
|
+
# <tt>{ tenantField:, flags: }</tt> hashes.
|
|
16
|
+
#
|
|
17
|
+
# +public_key+ is the environment's public key; +client_id+ is its old name.
|
|
18
|
+
def generate_client_token(tenants:, expiration:, public_key: nil, flags: nil, client_id: nil)
|
|
19
|
+
public_key ||= client_id
|
|
20
|
+
failure = ->(origin, err) { ReportError.report_request(origin, 'generate-client-token', err) }
|
|
21
|
+
raise failure.call('sdk', 'public_key is required') if public_key.nil? || public_key.to_s.empty?
|
|
22
|
+
unless expiration.is_a?(Integer) && expiration > (Time.now.to_f * 1000).to_i
|
|
23
|
+
raise failure.call('sdk', 'expiration must be a future millisecond timestamp')
|
|
24
|
+
end
|
|
25
|
+
if !tenants.is_a?(Array) || tenants.empty?
|
|
26
|
+
raise failure.call('sdk', 'tenants must be a non-empty array of { tenantField, tenantIds }')
|
|
27
|
+
end
|
|
28
|
+
if !flags.nil? && (!flags.is_a?(Array) || flags.empty?)
|
|
29
|
+
raise failure.call('sdk', 'flags must be a non-empty array when given')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
body = { clientId: public_key, tenants: tenants, expiration: expiration, adminEnabled: true }
|
|
33
|
+
body[:flags] = flags unless flags.nil?
|
|
34
|
+
|
|
35
|
+
response = post_sdk('generate-client-token', body)
|
|
36
|
+
token = JSON.parse(response.body).dig('metadata', 'token') if response.is_a?(Net::HTTPSuccess)
|
|
37
|
+
raise failure.call('metadata', response) unless token.is_a?(String) && !token.empty?
|
|
38
|
+
|
|
39
|
+
token
|
|
40
|
+
rescue StandardError => e
|
|
41
|
+
raise failure.call('metadata', e)
|
|
42
|
+
end
|
|
43
|
+
end
|