@vrplatform/graphql 1.0.7 → 1.1.1

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.
Files changed (88) hide show
  1. package/build/main/client/headers.d.ts +3 -0
  2. package/build/main/client/headers.js +42 -0
  3. package/build/main/client/index.d.ts +13 -0
  4. package/build/main/client/index.js +103 -0
  5. package/build/main/client/subscription.d.ts +3 -0
  6. package/build/main/client/subscription.js +29 -0
  7. package/build/main/common/account.d.ts +2 -0
  8. package/build/main/common/account.js +7 -0
  9. package/build/main/common/address.d.ts +9 -0
  10. package/build/main/common/address.js +2 -0
  11. package/build/main/common/bank-record.d.ts +2 -0
  12. package/build/main/common/bank-record.js +7 -0
  13. package/build/main/common/index.d.ts +5 -0
  14. package/build/main/common/index.js +21 -0
  15. package/build/main/common/listings.d.ts +4 -0
  16. package/build/main/common/listings.js +99 -0
  17. package/build/main/common/tenant.d.ts +19 -0
  18. package/build/main/common/tenant.js +85 -0
  19. package/build/main/error.d.ts +2 -0
  20. package/build/main/error.js +6 -0
  21. package/build/main/gqty/index.d.ts +7 -0
  22. package/build/main/gqty/index.js +48 -0
  23. package/build/main/gqty/schema.generated.d.ts +39211 -46819
  24. package/build/main/gqty/schema.generated.js +10382 -14191
  25. package/build/main/index.d.ts +4 -14
  26. package/build/main/index.js +7 -78
  27. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  28. package/build/main/types.d.ts +5 -6
  29. package/build/main/wrap.d.ts +12 -0
  30. package/build/main/wrap.js +47 -0
  31. package/build/module/client/headers.d.ts +3 -0
  32. package/build/module/client/headers.js +39 -0
  33. package/build/module/client/index.d.ts +13 -0
  34. package/build/module/client/index.js +98 -0
  35. package/build/module/client/subscription.d.ts +3 -0
  36. package/build/module/client/subscription.js +26 -0
  37. package/build/module/common/account.d.ts +2 -0
  38. package/build/module/common/account.js +4 -0
  39. package/build/module/common/address.d.ts +9 -0
  40. package/build/module/common/address.js +1 -0
  41. package/build/module/common/bank-record.d.ts +2 -0
  42. package/build/module/common/bank-record.js +4 -0
  43. package/build/module/common/index.d.ts +5 -0
  44. package/build/module/common/index.js +5 -0
  45. package/build/module/common/listings.d.ts +4 -0
  46. package/build/module/common/listings.js +93 -0
  47. package/build/module/common/tenant.d.ts +19 -0
  48. package/build/module/common/tenant.js +77 -0
  49. package/build/module/error.d.ts +2 -0
  50. package/build/module/error.js +2 -0
  51. package/build/module/gqty/index.d.ts +7 -0
  52. package/build/module/gqty/index.js +41 -0
  53. package/build/module/gqty/schema.generated.d.ts +39211 -46819
  54. package/build/module/gqty/schema.generated.js +10382 -14191
  55. package/build/module/index.d.ts +4 -14
  56. package/build/module/index.js +4 -75
  57. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  58. package/build/module/types.d.ts +5 -6
  59. package/build/module/wrap.d.ts +12 -0
  60. package/build/module/wrap.js +44 -0
  61. package/package.json +25 -35
  62. package/src/client/headers.ts +51 -0
  63. package/src/client/index.ts +152 -0
  64. package/src/client/subscription.ts +34 -0
  65. package/src/common/account.ts +6 -0
  66. package/src/common/address.ts +9 -0
  67. package/src/common/bank-record.ts +6 -0
  68. package/src/common/index.ts +5 -0
  69. package/src/common/listings.ts +106 -0
  70. package/src/common/tenant.ts +101 -0
  71. package/src/error.ts +1 -0
  72. package/src/gqty/index.ts +62 -0
  73. package/src/gqty/schema.generated.d.ts +39211 -46819
  74. package/src/gqty/schema.generated.js +10421 -14218
  75. package/src/index.ts +9 -97
  76. package/src/types.ts +6 -10
  77. package/src/wrap.ts +67 -0
  78. package/LICENSE +0 -3
  79. package/build/main/create-client.d.ts +0 -6
  80. package/build/main/create-client.js +0 -107
  81. package/build/main/gqty/error.d.ts +0 -6
  82. package/build/main/gqty/error.js +0 -48
  83. package/build/module/create-client.d.ts +0 -6
  84. package/build/module/create-client.js +0 -104
  85. package/build/module/gqty/error.d.ts +0 -6
  86. package/build/module/gqty/error.js +0 -40
  87. package/src/create-client.ts +0 -120
  88. package/src/gqty/error.ts +0 -54
@@ -0,0 +1,101 @@
1
+ import { utc } from '@finalytic/utils';
2
+ import { HasuraError } from '../error';
3
+ import type { tenant_bool_exp } from '../gqty';
4
+
5
+ // Tenants
6
+ export const VRP_TENANT_ID = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59';
7
+ export const DEMO_TEST_PARTNER_TENANT_ID =
8
+ '0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa';
9
+ export const XIMPLIFI_TENANT_ID = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5';
10
+
11
+ export function whereTenantActive(where?: tenant_bool_exp) {
12
+ const statusWhere: tenant_bool_exp = {
13
+ calculatedStatus: { _eq: 'active' },
14
+ _or: [
15
+ {
16
+ calculatedBillingPartner: { calculatedStatus: { _eq: 'active' } },
17
+ },
18
+ {
19
+ calculatedBillingPartnerId: { _is_null: true },
20
+ },
21
+ ],
22
+ };
23
+
24
+ if (where) return { _and: [statusWhere, where] };
25
+
26
+ return statusWhere;
27
+ }
28
+
29
+ export function assertTenantActive(tenant: {
30
+ calculatedStatus?: string;
31
+ calculatedBillingPartner?: { calculatedStatus?: string };
32
+ }) {
33
+ if (
34
+ tenant.calculatedStatus !== 'active' ||
35
+ tenant.calculatedBillingPartner?.calculatedStatus !== 'active'
36
+ )
37
+ throw new HasuraError('Tenant or billing partner are not active');
38
+ }
39
+
40
+ export function mapTenantStatus(tenant: {
41
+ calculatedStatus?: string;
42
+ calculatedBillingPartner?: { calculatedStatus?: string };
43
+ }): 'active' | 'inactive' {
44
+ const status = tenant.calculatedStatus === 'active';
45
+ const partnerStatus = tenant.calculatedBillingPartner?.calculatedStatus;
46
+
47
+ return status && partnerStatus === 'active' ? 'active' : 'inactive';
48
+ }
49
+
50
+ export function whereTenantNotTestTeam(where?: tenant_bool_exp) {
51
+ const statusWhere: tenant_bool_exp = {
52
+ id: { _nin: [VRP_TENANT_ID, DEMO_TEST_PARTNER_TENANT_ID] },
53
+ partnerId: {
54
+ _neq: DEMO_TEST_PARTNER_TENANT_ID,
55
+ },
56
+ _or: [
57
+ { billingPartnerId: { _neq: DEMO_TEST_PARTNER_TENANT_ID } },
58
+ { billingPartnerId: { _is_null: true } },
59
+ ],
60
+ };
61
+
62
+ if (where) return { _and: [statusWhere, where] };
63
+
64
+ return statusWhere;
65
+ }
66
+
67
+ export function whereTenantShouldBePaid(
68
+ where?: tenant_bool_exp,
69
+ includePartnerTeams = false
70
+ ) {
71
+ let statusWhere: tenant_bool_exp = {
72
+ isOnboarding: {
73
+ _eq: false, // has left onboarding
74
+ },
75
+ // tenant has no trial or trial ended
76
+ _or: [
77
+ {
78
+ trialUntil: {
79
+ _lt: utc().yyyymmdd(),
80
+ },
81
+ },
82
+ {
83
+ trialUntil: {
84
+ _is_null: true,
85
+ },
86
+ },
87
+ ],
88
+ };
89
+
90
+ if (!includePartnerTeams)
91
+ statusWhere = {
92
+ ...statusWhere,
93
+ calculatedIsBillable: {
94
+ _eq: true, // no partner teams
95
+ },
96
+ };
97
+
98
+ if (where) statusWhere = { _and: [statusWhere, where] };
99
+
100
+ return whereTenantActive(statusWhere);
101
+ }
package/src/error.ts ADDED
@@ -0,0 +1 @@
1
+ export class HasuraError extends Error {}
package/src/gqty/index.ts CHANGED
@@ -1 +1,63 @@
1
+ /**
2
+ * GQTY: You can safely modify this file and Query Fetcher based on your needs
3
+ */
4
+
5
+ import { createSubscriptionsClient } from '@gqty/subscriptions';
6
+ import type { QueryFetcher } from 'gqty';
7
+ import { createClient } from 'gqty';
8
+ import type {
9
+ GeneratedSchema,
10
+ SchemaObjectTypes,
11
+ SchemaObjectTypesNames,
12
+ } from './schema.generated';
13
+ import { generatedSchema, scalarsEnumsHash } from './schema.generated';
14
+
15
+ const queryFetcher: QueryFetcher = async (query, variables, fetchOptions) => {
16
+ // Modify "/api/graphql" if needed
17
+ const response = await fetch('/api/graphql', {
18
+ method: 'POST',
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ body: JSON.stringify({
23
+ query,
24
+ variables,
25
+ }),
26
+ mode: 'cors',
27
+ ...fetchOptions,
28
+ });
29
+
30
+ const json = await response.json();
31
+
32
+ return json;
33
+ };
34
+
35
+ const subscriptionsClient =
36
+ typeof window !== 'undefined'
37
+ ? createSubscriptionsClient({
38
+ wsEndpoint: () => {
39
+ // Modify if needed
40
+ const url = new URL('/api/graphql', window.location.href);
41
+ url.protocol = url.protocol.replace('http', 'ws');
42
+ return url.href;
43
+ },
44
+ })
45
+ : undefined;
46
+
47
+ export const client = createClient<
48
+ GeneratedSchema,
49
+ SchemaObjectTypesNames,
50
+ SchemaObjectTypes
51
+ >({
52
+ schema: generatedSchema,
53
+ scalarsEnumsHash,
54
+ queryFetcher,
55
+ subscriptionsClient,
56
+ });
57
+
58
+ const { query, mutation, mutate, subscription, resolved, refetch, track } =
59
+ client;
60
+
61
+ export { query, mutation, mutate, subscription, resolved, refetch, track };
62
+
1
63
  export * from './schema.generated';