@vrplatform/graphql 1.0.8 → 1.1.2

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 +39464 -46636
  24. package/build/main/gqty/schema.generated.js +10450 -14093
  25. package/build/main/index.d.ts +4 -14
  26. package/build/main/index.js +7 -75
  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 +39464 -46636
  54. package/build/module/gqty/schema.generated.js +10450 -14093
  55. package/build/module/index.d.ts +4 -14
  56. package/build/module/index.js +4 -72
  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 +39464 -46636
  74. package/src/gqty/schema.generated.js +10472 -14099
  75. package/src/index.ts +9 -94
  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,3 @@
1
+ import type { GqlAuthParam, Headers } from '../types';
2
+ export declare function createHeadersFactory(args?: Pick<GqlAuthParam, 'headers' | 'secret' | 'accessToken' | 'auditUserId'>): (base?: Headers) => Promise<Headers>;
3
+ export type HeadersFactory = ReturnType<typeof createHeadersFactory>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHeadersFactory = createHeadersFactory;
4
+ // Create headers factory function
5
+ function createHeadersFactory(args) {
6
+ return async (base) => {
7
+ const result = {};
8
+ // Add static or function headers
9
+ if (args?.headers) {
10
+ if (typeof args.headers === 'function') {
11
+ const functionResult = await args.headers();
12
+ for (const key in functionResult) {
13
+ result[key] = functionResult[key];
14
+ }
15
+ }
16
+ else {
17
+ for (const key in args.headers) {
18
+ result[key] = args.headers[key];
19
+ }
20
+ }
21
+ }
22
+ // Add base headers
23
+ if (base) {
24
+ for (const key in base) {
25
+ result[key] = base[key];
26
+ }
27
+ }
28
+ // Add auth headers
29
+ if (args?.secret) {
30
+ result['x-hasura-admin-secret'] = args.secret;
31
+ }
32
+ else if (args?.accessToken) {
33
+ result.authorization = args.accessToken.startsWith('Bearer ')
34
+ ? args.accessToken
35
+ : `Bearer ${args.accessToken}`;
36
+ }
37
+ if (args?.auditUserId) {
38
+ result['x-hasura-audit-user-id'] = args.auditUserId;
39
+ }
40
+ return result;
41
+ };
42
+ }
@@ -0,0 +1,13 @@
1
+ import { type RetryableFetchParams } from '@finalytic/utils';
2
+ import { type GQtyClient } from 'gqty';
3
+ import { type GeneratedSchema } from '../gqty';
4
+ import type { GqlAuthParam } from '../types';
5
+ export type HasuraClient = ReturnType<typeof useHasuraClient>;
6
+ export declare const defaultAssertHasuraRetryableResponse: RetryableFetchParams['assertResponse'];
7
+ export declare function useHasuraClient({ uri, secret, auditUserId, accessToken, subscriptions, headers, credentials, ...retryableFetchArgs }?: GqlAuthParam & RetryableFetchParams): {
8
+ readonly client: GQtyClient<GeneratedSchema>;
9
+ subscriptionsClient: import("gqty").SubscriptionsClient;
10
+ mutate<T = unknown>(resolved: (sub: import("../gqty").Mutation) => T, options?: import("../wrap").ResolveOptionsWithSession<T>): Promise<T>;
11
+ query<T = unknown>(resolved: (sub: import("../gqty").Query) => T, options?: import("../wrap").ResolveOptionsWithSession<T>): Promise<T>;
12
+ subscribe<T = unknown>(resolved: (sub: import("../gqty").Subscription) => T, onData: (data: T, unsubscribeFn: () => Promise<void>) => void, onError?: (err: Error, unsubscribeFn: () => Promise<void>) => void): () => Promise<void>;
13
+ };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultAssertHasuraRetryableResponse = void 0;
4
+ exports.useHasuraClient = useHasuraClient;
5
+ const utils_1 = require("@finalytic/utils");
6
+ const gqty_1 = require("gqty");
7
+ const constants_1 = require("../constants");
8
+ const gqty_2 = require("../gqty");
9
+ const wrap_1 = require("../wrap");
10
+ const headers_1 = require("./headers");
11
+ const subscription_1 = require("./subscription");
12
+ const retryablesErrors = [
13
+ 'deadlock detected',
14
+ 'fetch failed',
15
+ 'Unexpected token',
16
+ 'operation exceeded the time limit',
17
+ ];
18
+ function isRetryableResponse(json) {
19
+ if (!json || typeof json !== 'object')
20
+ return null;
21
+ const message = JSON.stringify(json.errors || {});
22
+ if (!message)
23
+ return null;
24
+ return retryablesErrors.find((e) => message?.includes(e));
25
+ }
26
+ const defaultAssertHasuraRetryableResponse = async (arg) => {
27
+ const defaultResponse = await (0, utils_1.defaultAssertRetryableResponse)(arg);
28
+ if (defaultResponse && 'retryable' in defaultResponse)
29
+ return defaultResponse;
30
+ const json = await (0, utils_1.formatResponse)(arg.response).catch(() => null);
31
+ arg.response.json = () => json;
32
+ const retryableResponse = isRetryableResponse(json);
33
+ if (retryableResponse) {
34
+ return {
35
+ retryable: true,
36
+ errorMessage: retryableResponse,
37
+ errorDetails: json,
38
+ };
39
+ }
40
+ };
41
+ exports.defaultAssertHasuraRetryableResponse = defaultAssertHasuraRetryableResponse;
42
+ function useHasuraClient({ uri = constants_1.hasuraGraphqlUri, secret, auditUserId, accessToken, subscriptions, headers, credentials, ...retryableFetchArgs } = {}) {
43
+ const getHeaders = (0, headers_1.createHeadersFactory)({
44
+ accessToken,
45
+ auditUserId,
46
+ headers,
47
+ secret,
48
+ });
49
+ // Create the subscriptions client if needed
50
+ const subscriptionsClient = (0, subscription_1.createHasuraSubscriptionsClient)(uri, getHeaders, subscriptions !== false);
51
+ const fetchFn = retryableFetchArgs.fetch || fetch;
52
+ const attempts = retryableFetchArgs.attempts === undefined ? 3 : retryableFetchArgs.attempts;
53
+ const retryableFetch = attempts > 1
54
+ ? (0, utils_1.useRetryableFetch)({
55
+ assertResponse: exports.defaultAssertHasuraRetryableResponse,
56
+ ...retryableFetchArgs,
57
+ attempts,
58
+ })
59
+ : undefined;
60
+ // Create the GQty client
61
+ const client = () => (0, gqty_1.createClient)({
62
+ schema: gqty_2.generatedSchema,
63
+ scalarsEnumsHash: gqty_2.scalarsEnumsHash,
64
+ async queryFetcher(query, variables, fetchOptions) {
65
+ const getRequest = async () => {
66
+ const headers = await getHeaders({
67
+ 'Content-Type': 'application/json',
68
+ });
69
+ if (fetchOptions?.headers) {
70
+ for (const key in fetchOptions.headers) {
71
+ headers[key] = fetchOptions.headers[key];
72
+ }
73
+ }
74
+ const isMutation = query.includes('mutation');
75
+ headers[constants_1.hasuraQueryTypeHeader] = isMutation ? 'mutation' : 'query';
76
+ return new Request(uri, {
77
+ method: 'POST',
78
+ credentials,
79
+ headers,
80
+ body: JSON.stringify({
81
+ query,
82
+ variables,
83
+ }),
84
+ });
85
+ };
86
+ const response = retryableFetch
87
+ ? await retryableFetch(getRequest)
88
+ : await fetchFn(await getRequest());
89
+ const json = await response.json();
90
+ return json;
91
+ },
92
+ subscriptionsClient,
93
+ normalization: false,
94
+ defaults: {
95
+ resolved: {
96
+ noCache: true,
97
+ retry: false, // We're handling retries ourselves in queryFetcher
98
+ },
99
+ },
100
+ retry: { maxRetries: 0 },
101
+ });
102
+ return (0, wrap_1.wrapGraphQLClient)(client, subscriptionsClient);
103
+ }
@@ -0,0 +1,3 @@
1
+ import type { SubscriptionsClient } from 'gqty';
2
+ import type { Headers } from '../types';
3
+ export declare function createHasuraSubscriptionsClient(uri: string, getHeaders: (base?: Headers) => Promise<Headers>, enabled?: boolean): SubscriptionsClient | undefined;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHasuraSubscriptionsClient = createHasuraSubscriptionsClient;
4
+ const subscriptions_1 = require("@gqty/subscriptions");
5
+ const constants_1 = require("../constants");
6
+ // Create subscriptions client
7
+ function createHasuraSubscriptionsClient(uri, getHeaders, enabled = true) {
8
+ // Ensure we strictly check for false, not falsy values
9
+ if (enabled === false) {
10
+ // We must return undefined here, not a client when disabled
11
+ return undefined;
12
+ }
13
+ try {
14
+ const wsUrl = new URL(uri);
15
+ wsUrl.protocol = wsUrl.protocol
16
+ .replace('https', 'wss')
17
+ .replace('http', 'ws');
18
+ return (0, subscriptions_1.createSubscriptionsClient)({
19
+ wsEndpoint: wsUrl.href,
20
+ connectionInitPayload: async () => ({
21
+ headers: await getHeaders({ [constants_1.hasuraQueryTypeHeader]: 'subscription' }),
22
+ }),
23
+ });
24
+ }
25
+ catch (error) {
26
+ console.error('Failed to create subscriptions client:', error);
27
+ return undefined;
28
+ }
29
+ }
@@ -0,0 +1,2 @@
1
+ import type { account_order_by } from '../gqty';
2
+ export declare const defaultAccountOrderBy: account_order_by[];
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultAccountOrderBy = void 0;
4
+ exports.defaultAccountOrderBy = [
5
+ { category: { index: 'asc' } },
6
+ { title: 'asc' },
7
+ ];
@@ -0,0 +1,9 @@
1
+ export type Address = {
2
+ full: string;
3
+ line1: string;
4
+ line2: string | undefined;
5
+ city: string;
6
+ postalCode: string;
7
+ stateCode: string;
8
+ countryCode: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type { bankRecord_order_by } from '../gqty';
2
+ export declare const defaultBankRecordOrderBy: bankRecord_order_by[];
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultBankRecordOrderBy = void 0;
4
+ exports.defaultBankRecordOrderBy = [
5
+ { date: 'desc' },
6
+ { uniqueRef: 'desc' },
7
+ ];
@@ -0,0 +1,5 @@
1
+ export * from './account';
2
+ export * from './address';
3
+ export * from './bank-record';
4
+ export * from './listings';
5
+ export * from './tenant';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account"), exports);
18
+ __exportStar(require("./address"), exports);
19
+ __exportStar(require("./bank-record"), exports);
20
+ __exportStar(require("./listings"), exports);
21
+ __exportStar(require("./tenant"), exports);
@@ -0,0 +1,4 @@
1
+ import type { listing_bool_exp } from '../gqty';
2
+ export declare function whereListingIsActive(): listing_bool_exp;
3
+ export declare function whereGlListingIsActive(where?: listing_bool_exp, date?: string): listing_bool_exp;
4
+ export declare const whereGlListingIsInactive: (where?: listing_bool_exp, date?: string, includeUpcoming?: boolean) => listing_bool_exp;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.whereGlListingIsInactive = void 0;
4
+ exports.whereListingIsActive = whereListingIsActive;
5
+ exports.whereGlListingIsActive = whereGlListingIsActive;
6
+ const utils_1 = require("@finalytic/utils");
7
+ function whereListingIsActive() {
8
+ return {
9
+ _or: [
10
+ {
11
+ // LEGACY teams
12
+ tenant: {
13
+ isGeneralLedger: { _eq: false },
14
+ },
15
+ calculatedStatus: { _eq: 'active' },
16
+ },
17
+ {
18
+ // GL teams
19
+ tenant: {
20
+ isGeneralLedger: { _eq: true },
21
+ },
22
+ ...whereGlListingIsActive(undefined, (0, utils_1.utc)().yyyymmdd()),
23
+ },
24
+ ],
25
+ };
26
+ }
27
+ function whereGlListingIsActive(where, date = (0, utils_1.utc)().yyyymmdd()) {
28
+ const statusWhere = {
29
+ _or: [
30
+ {
31
+ _not: {
32
+ ownershipPeriods: {},
33
+ },
34
+ },
35
+ {
36
+ ownershipPeriods: {
37
+ setListingInactive: { _eq: false },
38
+ _or: [
39
+ {
40
+ startAt: {
41
+ _lt: date,
42
+ },
43
+ endAt: {
44
+ _gte: date,
45
+ },
46
+ },
47
+ {
48
+ startAt: {
49
+ _lt: date,
50
+ },
51
+ endAt: {
52
+ _is_null: true,
53
+ },
54
+ },
55
+ ],
56
+ },
57
+ },
58
+ ],
59
+ };
60
+ if (where)
61
+ return { _and: [statusWhere, where] };
62
+ return statusWhere;
63
+ }
64
+ const whereGlListingIsInactive = (where, date = (0, utils_1.utc)().yyyymmdd(), includeUpcoming = false) => {
65
+ const statusWhere = {
66
+ ownershipPeriods: {
67
+ setListingInactive: { _eq: true },
68
+ _or: [
69
+ includeUpcoming
70
+ ? {
71
+ startAt: {
72
+ _gte: date,
73
+ },
74
+ }
75
+ : undefined,
76
+ {
77
+ startAt: {
78
+ _lt: date,
79
+ },
80
+ endAt: {
81
+ _gte: date,
82
+ },
83
+ },
84
+ {
85
+ startAt: {
86
+ _lt: date,
87
+ },
88
+ endAt: {
89
+ _is_null: true,
90
+ },
91
+ },
92
+ ].filter(utils_1.hasValue),
93
+ },
94
+ };
95
+ if (where)
96
+ return { _and: [statusWhere, where] };
97
+ return statusWhere;
98
+ };
99
+ exports.whereGlListingIsInactive = whereGlListingIsInactive;
@@ -0,0 +1,19 @@
1
+ import type { tenant_bool_exp } from '../gqty';
2
+ export declare const VRP_TENANT_ID = "7bfec41f-aa3f-4602-95d2-f7996e4f0e59";
3
+ export declare const DEMO_TEST_PARTNER_TENANT_ID = "0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa";
4
+ export declare const XIMPLIFI_TENANT_ID = "d6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5";
5
+ export declare function whereTenantActive(where?: tenant_bool_exp): tenant_bool_exp;
6
+ export declare function assertTenantActive(tenant: {
7
+ calculatedStatus?: string;
8
+ calculatedBillingPartner?: {
9
+ calculatedStatus?: string;
10
+ };
11
+ }): void;
12
+ export declare function mapTenantStatus(tenant: {
13
+ calculatedStatus?: string;
14
+ calculatedBillingPartner?: {
15
+ calculatedStatus?: string;
16
+ };
17
+ }): 'active' | 'inactive';
18
+ export declare function whereTenantNotTestTeam(where?: tenant_bool_exp): tenant_bool_exp;
19
+ export declare function whereTenantShouldBePaid(where?: tenant_bool_exp, includePartnerTeams?: boolean): tenant_bool_exp;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XIMPLIFI_TENANT_ID = exports.DEMO_TEST_PARTNER_TENANT_ID = exports.VRP_TENANT_ID = void 0;
4
+ exports.whereTenantActive = whereTenantActive;
5
+ exports.assertTenantActive = assertTenantActive;
6
+ exports.mapTenantStatus = mapTenantStatus;
7
+ exports.whereTenantNotTestTeam = whereTenantNotTestTeam;
8
+ exports.whereTenantShouldBePaid = whereTenantShouldBePaid;
9
+ const utils_1 = require("@finalytic/utils");
10
+ const error_1 = require("../error");
11
+ // Tenants
12
+ exports.VRP_TENANT_ID = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59';
13
+ exports.DEMO_TEST_PARTNER_TENANT_ID = '0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa';
14
+ exports.XIMPLIFI_TENANT_ID = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5';
15
+ function whereTenantActive(where) {
16
+ const statusWhere = {
17
+ calculatedStatus: { _eq: 'active' },
18
+ _or: [
19
+ {
20
+ calculatedBillingPartner: { calculatedStatus: { _eq: 'active' } },
21
+ },
22
+ {
23
+ calculatedBillingPartnerId: { _is_null: true },
24
+ },
25
+ ],
26
+ };
27
+ if (where)
28
+ return { _and: [statusWhere, where] };
29
+ return statusWhere;
30
+ }
31
+ function assertTenantActive(tenant) {
32
+ if (tenant.calculatedStatus !== 'active' ||
33
+ tenant.calculatedBillingPartner?.calculatedStatus !== 'active')
34
+ throw new error_1.HasuraError('Tenant or billing partner are not active');
35
+ }
36
+ function mapTenantStatus(tenant) {
37
+ const status = tenant.calculatedStatus === 'active';
38
+ const partnerStatus = tenant.calculatedBillingPartner?.calculatedStatus;
39
+ return status && partnerStatus === 'active' ? 'active' : 'inactive';
40
+ }
41
+ function whereTenantNotTestTeam(where) {
42
+ const statusWhere = {
43
+ id: { _nin: [exports.VRP_TENANT_ID, exports.DEMO_TEST_PARTNER_TENANT_ID] },
44
+ partnerId: {
45
+ _neq: exports.DEMO_TEST_PARTNER_TENANT_ID,
46
+ },
47
+ _or: [
48
+ { billingPartnerId: { _neq: exports.DEMO_TEST_PARTNER_TENANT_ID } },
49
+ { billingPartnerId: { _is_null: true } },
50
+ ],
51
+ };
52
+ if (where)
53
+ return { _and: [statusWhere, where] };
54
+ return statusWhere;
55
+ }
56
+ function whereTenantShouldBePaid(where, includePartnerTeams = false) {
57
+ let statusWhere = {
58
+ isOnboarding: {
59
+ _eq: false, // has left onboarding
60
+ },
61
+ // tenant has no trial or trial ended
62
+ _or: [
63
+ {
64
+ trialUntil: {
65
+ _lt: (0, utils_1.utc)().yyyymmdd(),
66
+ },
67
+ },
68
+ {
69
+ trialUntil: {
70
+ _is_null: true,
71
+ },
72
+ },
73
+ ],
74
+ };
75
+ if (!includePartnerTeams)
76
+ statusWhere = {
77
+ ...statusWhere,
78
+ calculatedIsBillable: {
79
+ _eq: true, // no partner teams
80
+ },
81
+ };
82
+ if (where)
83
+ statusWhere = { _and: [statusWhere, where] };
84
+ return whereTenantActive(statusWhere);
85
+ }
@@ -0,0 +1,2 @@
1
+ export declare class HasuraError extends Error {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasuraError = void 0;
4
+ class HasuraError extends Error {
5
+ }
6
+ exports.HasuraError = HasuraError;
@@ -1 +1,8 @@
1
+ /**
2
+ * GQTY: You can safely modify this file and Query Fetcher based on your needs
3
+ */
4
+ import type { GeneratedSchema } from './schema.generated';
5
+ export declare const client: import("gqty").GQtyClient<GeneratedSchema>;
6
+ declare const query: import("./schema.generated").Query, mutation: import("./schema.generated").Mutation, mutate: import("gqty").Mutate<GeneratedSchema>, subscription: import("./schema.generated").Subscription, resolved: import("gqty").Resolved, refetch: import("gqty").Refetch, track: import("gqty/Helpers/track").Track;
7
+ export { query, mutation, mutate, subscription, resolved, refetch, track };
1
8
  export * from './schema.generated';
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /**
3
+ * GQTY: You can safely modify this file and Query Fetcher based on your needs
4
+ */
2
5
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
6
  if (k2 === undefined) k2 = k;
4
7
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,4 +17,49 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
17
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
18
  };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.track = exports.refetch = exports.resolved = exports.subscription = exports.mutate = exports.mutation = exports.query = exports.client = void 0;
21
+ const subscriptions_1 = require("@gqty/subscriptions");
22
+ const gqty_1 = require("gqty");
23
+ const schema_generated_1 = require("./schema.generated");
24
+ const queryFetcher = async (query, variables, fetchOptions) => {
25
+ // Modify "/api/graphql" if needed
26
+ const response = await fetch('/api/graphql', {
27
+ method: 'POST',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ body: JSON.stringify({
32
+ query,
33
+ variables,
34
+ }),
35
+ mode: 'cors',
36
+ ...fetchOptions,
37
+ });
38
+ const json = await response.json();
39
+ return json;
40
+ };
41
+ const subscriptionsClient = typeof window !== 'undefined'
42
+ ? (0, subscriptions_1.createSubscriptionsClient)({
43
+ wsEndpoint: () => {
44
+ // Modify if needed
45
+ const url = new URL('/api/graphql', window.location.href);
46
+ url.protocol = url.protocol.replace('http', 'ws');
47
+ return url.href;
48
+ },
49
+ })
50
+ : undefined;
51
+ exports.client = (0, gqty_1.createClient)({
52
+ schema: schema_generated_1.generatedSchema,
53
+ scalarsEnumsHash: schema_generated_1.scalarsEnumsHash,
54
+ queryFetcher,
55
+ subscriptionsClient,
56
+ });
57
+ const { query, mutation, mutate, subscription, resolved, refetch, track } = exports.client;
58
+ exports.query = query;
59
+ exports.mutation = mutation;
60
+ exports.mutate = mutate;
61
+ exports.subscription = subscription;
62
+ exports.resolved = resolved;
63
+ exports.refetch = refetch;
64
+ exports.track = track;
17
65
  __exportStar(require("./schema.generated"), exports);