Skip to content

Commit

Permalink
DeepLinks is now ES Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed May 28, 2023
1 parent af3193f commit 561bfb6
Show file tree
Hide file tree
Showing 46 changed files with 163 additions and 147 deletions.
4 changes: 2 additions & 2 deletions benchmarks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { Suite } from 'benchmark';
import { DeepClient } from '../imports/client';
import { DeepClient } from '../imports/client.js';
import _ from 'lodash';
import Debug from 'debug';

Expand Down
8 changes: 4 additions & 4 deletions imports/bool_exp_to_sql.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Debug from 'debug';
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { HasuraApi } from "@deep-foundation/hasura/api";
import { generateMutation, generateSerial } from './gql';
import { DeepClient } from './client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
import { generateMutation, generateSerial } from './gql/index.js';
import { DeepClient } from './client.js';

const debug = Debug('deeplinks:bool_exp');
const log = debug.extend('log');
Expand Down
5 changes: 3 additions & 2 deletions imports/client-handler.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DeepClient } from "./client";
import { gql } from '@apollo/client';
import { DeepClient } from './client.js';
import apolloModule from '@apollo/client';
const { gql} = apolloModule;

export async function evalClientHandler({
value,
Expand Down
22 changes: 12 additions & 10 deletions imports/client.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import atob from 'atob';
import { ApolloClient, ApolloError, ApolloQueryResult, useApolloClient, gql, useQuery, useSubscription, FetchResult } from "@apollo/client";
import { generateApolloClient, IApolloClient } from "@deep-foundation/hasura/client";
import { useLocalStore } from "@deep-foundation/store/local";
import apolloModule from '@apollo/client';
import type { ApolloQueryResult } from '@apollo/client';
const { gql, useQuery, useSubscription, useApolloClient } = apolloModule;
import { generateApolloClient, IApolloClient } from '@deep-foundation/hasura/client.js';
import { useLocalStore } from '@deep-foundation/store/local.js';
import React, { createContext, useContext, useEffect, useMemo, useState } from "react";
import { deprecate, inherits, inspect } from "util";
import { deleteMutation, generateMutation, generateQuery, generateQueryData, generateSerial, IGenerateMutationBuilder, IGenerateMutationOptions, insertMutation, ISerialResult, updateMutation } from "./gql";
import { Link, MinilinkCollection, minilinks, MinilinksInstance, MinilinksResult, useMinilinksApply, useMinilinksQuery, useMinilinksSubscription } from "./minilinks";
import { awaitPromise } from "./promise";
import { useTokenController } from "./react-token";
import { reserve } from "./reserve";
import { deleteMutation, generateMutation, generateQuery, generateQueryData, generateSerial, IGenerateMutationBuilder, IGenerateMutationOptions, insertMutation, ISerialResult, updateMutation } from './gql/index.js';
import { Link, MinilinkCollection, minilinks, MinilinksInstance, MinilinksResult, useMinilinksApply, useMinilinksQuery, useMinilinksSubscription } from './minilinks.js';
import { awaitPromise } from './promise.js';
import { useTokenController } from './react-token.js';
import { reserve } from './reserve.js';
import Debug from 'debug';
import { corePckg } from './core';
import { BoolExpCan, BoolExpHandler, QueryLink, BoolExpSelector, BoolExpTree, BoolExpValue, MutationInputLink, MutationInputLinkPlain, MutationInputValue } from './client_types';
import { corePckg } from './core.js';
import { BoolExpCan, BoolExpHandler, QueryLink, BoolExpSelector, BoolExpTree, BoolExpValue, MutationInputLink, MutationInputLinkPlain, MutationInputValue } from './client_types.js';

const debug = Debug('deeplinks:client');
const log = debug.extend('log');
Expand Down
2 changes: 1 addition & 1 deletion imports/core-symbols.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packager, Package } from './packager';
import { Packager, Package } from './packager.js';

export const coreSymbolsPckg: Package = {
package: {
Expand Down
2 changes: 1 addition & 1 deletion imports/core.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packager, Package } from './packager';
import { Packager, Package } from './packager.js';

export const corePckg: Package = {
package: {
Expand Down
6 changes: 3 additions & 3 deletions imports/gql/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';

export * from './mutation';
export * from './query';
export * from './serial';
export * from './mutation.js';
export * from './query.js';
export * from './serial.js';
2 changes: 1 addition & 1 deletion imports/gql/serial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Debug from 'debug';
import gql from 'graphql-tag';
import { SerialOperationType, Table, SerialOperation, SerialOperationDetails } from '../client';
import { SerialOperationType, Table, SerialOperation, SerialOperationDetails } from '../client.js';

const debug = Debug('deeplinks:gql:serial');
const log = debug.extend('log');
Expand Down
4 changes: 2 additions & 2 deletions imports/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { generateApolloClient } from "@deep-foundation/hasura/client";
import { DeepClient } from "./client";
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { DeepClient } from './client.js';
import _ from 'lodash';

const apolloClient = generateApolloClient({
Expand Down
2 changes: 1 addition & 1 deletion imports/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import JWT from 'jsonwebtoken';

export interface Options {
Expand Down
6 changes: 3 additions & 3 deletions imports/minilinks-query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _serialize, _boolExpFields, serializeWhere, serializeQuery } from "./client";
import { BoolExpLink, ComparasionType, QueryLink } from "./client_types";
import { MinilinkCollection, MinilinksGeneratorOptions, Link } from "./minilinks";
import { _serialize, _boolExpFields, serializeWhere, serializeQuery } from './client.js';
import { BoolExpLink, ComparasionType, QueryLink } from './client_types.js';
import { MinilinkCollection, MinilinksGeneratorOptions, Link } from './minilinks.js';

export interface BoolExpLinkMinilinks extends BoolExpLink {
_applies?: ComparasionType<number>;
Expand Down
10 changes: 5 additions & 5 deletions imports/minilinks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _remove from 'lodash/remove';
import _isEqual from 'lodash/isEqual';
import _isEqualWith from 'lodash/isEqualWith';
import _remove from 'lodash/remove.js';
import _isEqual from 'lodash/isEqual.js';
import _isEqualWith from 'lodash/isEqualWith.js';
import EventEmitter from 'events';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import Debug from 'debug';
import { inherits } from 'util';
import { minilinksQuery, minilinksQueryIs } from './minilinks-query';
import { QueryLink } from './client_types';
import { minilinksQuery, minilinksQueryIs } from './minilinks-query.js';
import { QueryLink } from './client_types.js';

const debug = Debug('deeplinks:minilinks');
const log = debug.extend('log');
Expand Down
6 changes: 3 additions & 3 deletions imports/packager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Debug from 'debug';
import { DeepClient } from './client';
import type { DeepSerialOperation } from './client';
import { Link, minilinks, MinilinksResult } from './minilinks';
import { DeepClient } from './client.js';
import type { DeepSerialOperation } from './client.js';
import { Link, minilinks, MinilinksResult } from './minilinks.js';

const debug = Debug('deeplinks:packager');
const log = debug.extend('log');
Expand Down
2 changes: 1 addition & 1 deletion imports/permission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HasuraApi } from "@deep-foundation/hasura/api";
import { HasuraApi } from '@deep-foundation/hasura/api.js';

export const permissions = async (api: HasuraApi, table: string | { name: string; schema: string; }, actions: {
role: string;
Expand Down
4 changes: 2 additions & 2 deletions imports/promise.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloClient } from "@apollo/client";
import type { ApolloClient } from '@apollo/client';
import Debug from 'debug';
import { generateQuery, generateQueryData, generateSerial, insertMutation } from "./gql";
import { generateQuery, generateQueryData, generateSerial, insertMutation } from './gql/index.js';


const debug = Debug('deeplinks:promise');
Expand Down
4 changes: 2 additions & 2 deletions imports/react-token.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import uniqid from 'uniqid';
import { TokenContext } from '@deep-foundation/react-hasura/token-context';
import { useLocalStore } from '@deep-foundation/store/local';
import { TokenContext } from '@deep-foundation/react-hasura/token-context.js';
import { useLocalStore } from '@deep-foundation/store/local.js';

export function useTokenController() {
return useLocalStore('dc-dg-token', '');
Expand Down
6 changes: 4 additions & 2 deletions imports/reserve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ApolloClient, gql } from "@apollo/client";
import { generateQuery, generateQueryData, generateSerial, insertMutation } from "./gql";
import apolloModule from '@apollo/client';
import type { ApolloClient } from '@apollo/client';
const { gql } = apolloModule;
import { generateQuery, generateQueryData, generateSerial, insertMutation } from './gql/index.js';

export interface ReservedOptions {
count: number;
Expand Down
7 changes: 5 additions & 2 deletions imports/reserved.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ApolloClient, gql } from "@apollo/client";
import { generateQuery, generateQueryData } from "./gql";
import apolloModule from '@apollo/client';
import type { ApolloClient } from '@apollo/client';
const { gql } = apolloModule;

import { generateQuery, generateQueryData } from './gql/index.js';

export interface ReseveOptions {
count: number;
Expand Down
8 changes: 4 additions & 4 deletions imports/router/authorization.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { jwt } from '../jwt';
import { generateRemoteSchema } from '@deep-foundation/hasura/remote-schema';
import { jwt } from '../jwt.js';
import { generateRemoteSchema } from '@deep-foundation/hasura/remote-schema.js';
import gql from 'graphql-tag';
import { ApolloServer } from 'apollo-server-express';
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { DeepClient } from '../client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { DeepClient } from '../client.js';
import Chance from 'chance';

const chance = new Chance();
Expand Down
8 changes: 4 additions & 4 deletions imports/router/guest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { jwt } from '../jwt';
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { jwt } from '../jwt.js';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import gql from 'graphql-tag';
import { generateSerial, insertMutation } from '../gql';
import { generateSerial, insertMutation } from '../gql/index.js';
import { ApolloServer } from 'apollo-server-express';
import { DeepClient } from '../client';
import { DeepClient } from '../client.js';
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';

const JWT_SECRET = process.env.JWT_SECRET;
Expand Down
12 changes: 6 additions & 6 deletions imports/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import express from 'express';
import links from './links';
import values from './values';
import reservedCleaner from './reserved-cleaner';
import reserved from './reserved';
import healthz from './healthz';
import scheduler from './scheduler';
import links from './links.js';
import values from './values.js';
import reservedCleaner from './reserved-cleaner.js';
import reserved from './reserved.js';
import healthz from './healthz.js';
import scheduler from './scheduler.js';

const router:express.IRouter = express.Router();

Expand Down
8 changes: 4 additions & 4 deletions imports/router/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { jwt } from '../jwt';
import { generateRemoteSchema } from '@deep-foundation/hasura/remote-schema';
import { jwt } from '../jwt.js';
import { generateRemoteSchema } from '@deep-foundation/hasura/remote-schema.js';
import gql from 'graphql-tag';
import { ApolloServer } from 'apollo-server-express';
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { DeepClient } from '../client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { DeepClient } from '../client.js';

const apolloClient = generateApolloClient({
path: `${process.env.DEEPLINKS_HASURA_PATH}/v1/graphql`,
Expand Down
19 changes: 10 additions & 9 deletions imports/router/links.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Debug from 'debug';

import { HasuraApi } from "@deep-foundation/hasura/api";
import { generateApolloClient } from '@deep-foundation/hasura/client';
// import { sql } from '@deep-foundation/hasura/sql';
import { gql } from '@apollo/client';

import { DeepClient } from '../client';
import { ContainerController } from '../container-controller';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids';
import { findPromiseLink, reject, resolve } from '../promise';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
// import { sql } from '@deep-foundation/hasura/sql.js';
import apolloModule from '@apollo/client';
const { gql} = apolloModule;

import { DeepClient } from '../client.js';
import { ContainerController } from '../container-controller.js';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids.js';
import { findPromiseLink, reject, resolve } from '../promise.js';
import { promisify } from 'util';
import {exec} from 'child_process';
import waitOn from 'wait-on';
Expand Down
12 changes: 6 additions & 6 deletions imports/router/packager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';
import { ApolloServer } from 'apollo-server-express';
import Gists from 'gists';
import gql from 'graphql-tag';
import { isEmpty } from 'lodash';
import _ from 'lodash';
import os from 'os';
import path from 'path';
import url from 'url';
import { DeepClient } from '../client';
import { Packager } from '../packager';
import { DeepClient } from '../client.js';
import { Packager } from '../packager.js';

const tmpdir = os.tmpdir();

Expand Down Expand Up @@ -141,10 +141,10 @@ export const packagerPublishCore = async (errors = [], address: string, id: numb
if (deepPckgContent?.errors?.length) {
errors.push(...deepPckgContent.errors);
}
if (isEmpty(deepPckgContent?.package)) {
if (_.isEmpty(deepPckgContent?.package)) {
errors.push('!package');
}
if (isEmpty(deepPckgContent?.data)) {
if (_.isEmpty(deepPckgContent?.data)) {
errors.push('!data');
}
if (errors.length) return { errors };
Expand Down
6 changes: 3 additions & 3 deletions imports/router/reserved-cleaner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateQuery, generateQueryData } from '../gql';
import { HasuraApi } from '@deep-foundation/hasura/api';
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { generateQuery, generateQueryData } from '../gql/index.js';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';

const RESERVED_LIFETIME_MS = +process.env.RESERVED_LIFETIME || 24 * 60 * 60 * 1000;

Expand Down
6 changes: 3 additions & 3 deletions imports/router/reserved.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateApolloClient } from '@deep-foundation/hasura/client';
import { HasuraApi } from "@deep-foundation/hasura/api";
import { generateMutation, generateSerial, insertMutation } from '../gql';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
import { generateMutation, generateSerial, insertMutation } from '../gql/index.js';
import Debug from 'debug';

const debug = Debug('deeplinks:eh:reserved');
Expand Down
23 changes: 12 additions & 11 deletions imports/router/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import Debug from 'debug';

import { generateApolloClient } from '@deep-foundation/hasura/client';
import { HasuraApi } from "@deep-foundation/hasura/api";
// import { sql } from '@deep-foundation/hasura/sql';
import { gql } from '@apollo/client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
// import { sql } from '@deep-foundation/hasura/sql.js';
import apolloModule from '@apollo/client';
const { gql} = apolloModule;
import vm from 'vm';

import { permissions } from '../permission';
import { findPromiseLink, reject, resolve } from '../promise';
import { DeepClient } from '../client';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids';
import { permissions } from '../permission.js';
import { findPromiseLink, reject, resolve } from '../promise.js';
import { DeepClient } from '../client.js';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids.js';
import axios from 'axios';
import crypto from 'crypto';
import {
handleOperation,
} from './links';
import { boolExpToSQL } from '../bool_exp_to_sql';
import { useRunner, processPromises } from './links';
} from './links.js';
import { boolExpToSQL } from '../bool_exp_to_sql.js';
import { useRunner, processPromises } from './links.js';

const SCHEMA = 'public';

Expand Down
21 changes: 11 additions & 10 deletions imports/router/values.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import Debug from 'debug';

import { generateApolloClient } from '@deep-foundation/hasura/client';
import { HasuraApi } from "@deep-foundation/hasura/api";
// import { sql } from '@deep-foundation/hasura/sql';
import { gql } from '@apollo/client';
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import { HasuraApi } from '@deep-foundation/hasura/api.js';
// import { sql } from '@deep-foundation/hasura/sql.js';
import apolloModule from '@apollo/client';
const { gql} = apolloModule;
import vm from 'vm';

import { permissions } from '../permission';
import { findPromiseLink, reject, resolve } from '../promise';
import { DeepClient } from '../client';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids';
import { permissions } from '../permission.js';
import { findPromiseLink, reject, resolve } from '../promise.js';
import { DeepClient } from '../client.js';
import { ALLOWED_IDS, DENIED_IDS } from '../global-ids.js';
import axios from 'axios';
import crypto from 'crypto';
import {
handleOperation,
handleSelectorOperation,
} from './links';
import { boolExpToSQL } from '../bool_exp_to_sql';
} from './links.js';
import { boolExpToSQL } from '../bool_exp_to_sql.js';

const SCHEMA = 'public';

Expand Down
Loading

0 comments on commit 561bfb6

Please sign in to comment.