refactor: separate out data structures into hoppscotch-data

This commit is contained in:
Andrew Bastin
2021-11-24 01:20:07 +05:30
parent 2884854aab
commit 38755bf3e3
47 changed files with 820 additions and 74 deletions

View File

@@ -59,7 +59,7 @@
<script setup lang="ts">
import { reactive, ref, watch } from "@nuxtjs/composition-api"
import { isHoppRESTRequest } from "~/helpers/types/HoppRESTRequest"
import { HoppGQLRequest, isHoppRESTRequest } from "@hoppscotch/data"
import {
editGraphqlRequest,
editRESTRequest,
@@ -74,7 +74,6 @@ import {
} from "~/newstore/RESTSession"
import * as teamUtils from "~/helpers/teams/utils"
import { apolloClient } from "~/helpers/apollo"
import { HoppGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { useI18n, useToast } from "~/helpers/utils/composables"
const t = useI18n()

View File

@@ -34,7 +34,7 @@
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api"
import { HoppGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { HoppGQLRequest } from "@hoppscotch/data"
import { addGraphqlCollection, makeCollection } from "~/newstore/collections"
export default defineComponent({

View File

@@ -38,7 +38,7 @@
<script lang="ts">
import { defineComponent, PropType } from "@nuxtjs/composition-api"
import { HoppGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { HoppGQLRequest } from "@hoppscotch/data"
import { editGraphqlRequest } from "~/newstore/collections"
export default defineComponent({

View File

@@ -102,7 +102,7 @@
<script lang="ts">
import { defineComponent, PropType } from "@nuxtjs/composition-api"
import { HoppGQLRequest, makeGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { HoppGQLRequest, makeGQLRequest } from "@hoppscotch/data"
import { removeGraphqlRequest } from "~/newstore/collections"
import { setGQLSession } from "~/newstore/GQLSession"

View File

@@ -116,7 +116,7 @@
<script>
import { defineComponent } from "@nuxtjs/composition-api"
import { translateToNewRequest } from "~/helpers/types/HoppRESTRequest"
import { translateToNewRequest } from "@hoppscotch/data"
import { useReadonlyStream } from "~/helpers/utils/composables"
import {
restSaveContext$,

View File

@@ -93,7 +93,7 @@
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api"
import { translateToNewRequest } from "~/helpers/types/HoppRESTRequest"
import { translateToNewRequest } from "@hoppscotch/data"
import { useReadonlyStream } from "~/helpers/utils/composables"
import {
restSaveContext$,

View File

@@ -235,6 +235,7 @@
import { onMounted, ref, watch } from "@nuxtjs/composition-api"
import clone from "lodash/clone"
import * as gql from "graphql"
import { GQLHeader, makeGQLRequest } from "@hoppscotch/data"
import { copyToClipboard } from "~/helpers/utils/clipboard"
import {
useNuxt,
@@ -262,7 +263,6 @@ import { GQLConnection } from "~/helpers/GQLConnection"
import { makeGQLHistoryEntry, addGraphqlHistoryEntry } from "~/newstore/history"
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
import { getCurrentStrategyID } from "~/helpers/network"
import { GQLHeader, makeGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { useCodemirror } from "~/helpers/editor/codemirror"
import jsonLinter from "~/helpers/editor/linting/json"
import { createGQLQueryLinter } from "~/helpers/editor/linting/gqlQuery"

View File

@@ -200,9 +200,9 @@
import { computed, nextTick, reactive, ref } from "@nuxtjs/composition-api"
import { GraphQLField, GraphQLType } from "graphql"
import { map } from "rxjs/operators"
import { GQLHeader } from "@hoppscotch/data"
import { useCodemirror } from "~/helpers/editor/codemirror"
import { GQLConnection } from "~/helpers/GQLConnection"
import { GQLHeader } from "~/helpers/types/HoppGQLRequest"
import { copyToClipboard } from "~/helpers/utils/clipboard"
import {
useReadonlyStream,

View File

@@ -56,7 +56,7 @@ import {
PropType,
ref,
} from "@nuxtjs/composition-api"
import { makeGQLRequest } from "~/helpers/types/HoppGQLRequest"
import { makeGQLRequest } from "@hoppscotch/data"
import { setGQLSession } from "~/newstore/GQLSession"
import { GQLHistoryEntry } from "~/newstore/history"

View File

@@ -202,7 +202,7 @@ import {
HoppRESTAuthBasic,
HoppRESTAuthBearer,
HoppRESTAuthOAuth2,
} from "~/helpers/types/HoppRESTAuth"
} from "@hoppscotch/data"
import { pluckRef, useStream } from "~/helpers/utils/composables"
import { restAuth$, setRESTAuth } from "~/newstore/RESTSession"
import { useSetting } from "~/newstore/settings"

View File

@@ -165,7 +165,7 @@
<script lang="ts">
import { defineComponent, onMounted, Ref, watch } from "@nuxtjs/composition-api"
import { FormDataKeyValue } from "~/helpers/types/HoppRESTRequest"
import { FormDataKeyValue } from "@hoppscotch/data"
import { pluckRef } from "~/helpers/utils/composables"
import {
addFormDataEntry,

View File

@@ -150,6 +150,7 @@
<script setup lang="ts">
import { onBeforeUpdate, ref, watch } from "@nuxtjs/composition-api"
import { HoppRESTHeader } from "@hoppscotch/data"
import { useCodemirror } from "~/helpers/editor/codemirror"
import {
addRESTHeader,
@@ -165,7 +166,6 @@ import {
useI18n,
useToast,
} from "~/helpers/utils/composables"
import { HoppRESTHeader } from "~/helpers/types/HoppRESTRequest"
const t = useI18n()

View File

@@ -22,13 +22,13 @@
<script setup lang="ts">
import { ref } from "@nuxtjs/composition-api"
import parseCurlCommand from "~/helpers/curlparser"
import { useCodemirror } from "~/helpers/editor/codemirror"
import {
HoppRESTHeader,
HoppRESTParam,
makeRESTRequest,
} from "~/helpers/types/HoppRESTRequest"
} from "@hoppscotch/data"
import parseCurlCommand from "~/helpers/curlparser"
import { useCodemirror } from "~/helpers/editor/codemirror"
import { setRESTRequest } from "~/newstore/RESTSession"
import { useI18n, useToast } from "~/helpers/utils/composables"

View File

@@ -57,13 +57,13 @@
<script lang="ts">
import { Ref } from "@nuxtjs/composition-api"
import { HoppRESTAuthOAuth2 } from "@hoppscotch/data"
import {
pluckRef,
useI18n,
useStream,
useToast,
} from "~/helpers/utils/composables"
import { HoppRESTAuthOAuth2 } from "~/helpers/types/HoppRESTAuth"
import { restAuth$, setRESTAuth } from "~/newstore/RESTSession"
import { tokenRequest } from "~/helpers/oauth"

View File

@@ -143,8 +143,8 @@
<script setup lang="ts">
import { ref, watch, onBeforeUpdate } from "@nuxtjs/composition-api"
import { HoppRESTParam } from "@hoppscotch/data"
import { useCodemirror } from "~/helpers/editor/codemirror"
import { HoppRESTParam } from "~/helpers/types/HoppRESTRequest"
import {
useReadonlyStream,
useI18n,

View File

@@ -42,7 +42,7 @@
<script setup lang="ts">
import { ref } from "@nuxtjs/composition-api"
import { HoppRESTHeader } from "~/helpers/types/HoppRESTRequest"
import { HoppRESTHeader } from "@hoppscotch/data"
import { copyToClipboard } from "~/helpers/utils/clipboard"
import { useI18n, useToast } from "~/helpers/utils/composables"

View File

@@ -10,8 +10,8 @@ import {
GraphQLInterfaceType,
} from "graphql"
import { distinctUntilChanged, map } from "rxjs/operators"
import { GQLHeader } from "@hoppscotch/data"
import { sendNetworkRequest } from "./network"
import { GQLHeader } from "./types/HoppGQLRequest"
const GQL_SCHEMA_POLL_INTERVAL = 7000

View File

@@ -1,5 +1,5 @@
import clone from "lodash/clone"
import { FormDataKeyValue, HoppRESTRequest } from "./types/HoppRESTRequest"
import { FormDataKeyValue, HoppRESTRequest } from "@hoppscotch/data"
import { isJSONContentType } from "./utils/contenttypes"
import { defaultRESTRequest } from "~/newstore/RESTSession"

View File

@@ -5,6 +5,7 @@ import { pipe } from "fp-ts/function"
import * as O from "fp-ts/Option"
import { runTestScript, TestDescriptor } from "@hoppscotch/js-sandbox"
import { isRight } from "fp-ts/Either"
import { isJSONContentType } from "@hoppscotch/data"
import {
getCombinedEnvVariables,
getFinalEnvsFromPreRequest,
@@ -13,7 +14,6 @@ import { getEffectiveRESTRequest } from "./utils/EffectiveURL"
import { HoppRESTResponse } from "./types/HoppRESTResponse"
import { createRESTNetworkRequestStream } from "./network"
import { HoppTestData, HoppTestResult } from "./types/HoppTestResult"
import { isJSONContentType } from "./utils/contenttypes"
import { getRESTRequest, setRESTTestResults } from "~/newstore/RESTSession"
const getTestableBody = (res: HoppRESTResponse & { type: "success" }) => {

View File

@@ -1,10 +1,10 @@
import { HoppRESTRequest } from "@hoppscotch/data"
import { runMutation } from "../GQLClient"
import {
CreateShortcodeDocument,
CreateShortcodeMutation,
CreateShortcodeMutationVariables,
} from "../graphql"
import { HoppRESTRequest } from "~/helpers/types/HoppRESTRequest"
export const createShortcode = (request: HoppRESTRequest) =>
runMutation<CreateShortcodeMutation, CreateShortcodeMutationVariables, "">(

View File

@@ -2,7 +2,7 @@ import {
FormDataKeyValue,
HoppRESTHeader,
HoppRESTParam,
} from "../types/HoppRESTRequest"
} from "@hoppscotch/data"
import { EffectiveHoppRESTRequest } from "../utils/EffectiveURL"
import { CLibcurlCodegen } from "./generators/c-libcurl"
import { CsRestsharpCodegen } from "./generators/cs-restsharp"

View File

@@ -11,7 +11,7 @@ import {
query,
updateDoc,
} from "firebase/firestore"
import { FormDataKeyValue } from "../types/HoppRESTRequest"
import { FormDataKeyValue } from "@hoppscotch/data"
import { currentUser$ } from "./auth"
import { settingsStore } from "~/newstore/settings"
import {

View File

@@ -9,10 +9,7 @@ import {
} from "rxjs"
import { doc, getDoc, getFirestore, setDoc } from "firebase/firestore"
import cloneDeep from "lodash/cloneDeep"
import {
HoppRESTRequest,
translateToNewRequest,
} from "../types/HoppRESTRequest"
import { HoppRESTRequest, translateToNewRequest } from "@hoppscotch/data"
import { currentUser$, HoppUser } from "./auth"
import { restRequest$ } from "~/newstore/RESTSession"

View File

@@ -2,7 +2,7 @@ import { BehaviorSubject } from "rxjs"
import { gql } from "graphql-tag"
import pull from "lodash/pull"
import remove from "lodash/remove"
import { translateToNewRequest } from "../types/HoppRESTRequest"
import { translateToNewRequest } from "@hoppscotch/data"
import { TeamCollection } from "./TeamCollection"
import { TeamRequest } from "./TeamRequest"
import {

View File

@@ -1,4 +1,4 @@
import { HoppRESTRequest } from "../types/HoppRESTRequest"
import { HoppRESTRequest } from "@hoppscotch/data"
/**
* Defines how a Teams request is represented in TeamCollectionAdapter

View File

@@ -1,4 +1,4 @@
import { HoppRESTRequest } from "./HoppRESTRequest"
import { HoppRESTRequest } from "@hoppscotch/data"
export type HoppRESTResponse =
| { type: "loading"; req: HoppRESTRequest }

View File

@@ -1,6 +1,6 @@
import { combineLatest, Observable } from "rxjs"
import { map } from "rxjs/operators"
import { FormDataKeyValue, HoppRESTRequest } from "../types/HoppRESTRequest"
import { FormDataKeyValue, HoppRESTRequest } from "@hoppscotch/data"
import { parseTemplateString, parseBodyEnvVariables } from "../templating"
import { Environment, getGlobalVariables } from "~/newstore/environments"

View File

@@ -1,4 +1,8 @@
export const knownContentTypes = {
import { ValidContentTypes } from "@hoppscotch/data"
export type Content = "json" | "xml" | "multipart" | "html" | "plain"
export const knownContentTypes: Record<ValidContentTypes, Content> = {
"application/json": "json",
"application/ld+json": "json",
"application/hal+json": "json",
@@ -10,8 +14,6 @@ export const knownContentTypes = {
"text/plain": "plain",
}
export type ValidContentTypes = keyof typeof knownContentTypes
export function isJSONContentType(contentType: string) {
return /\bjson\b/i.test(contentType)
}

View File

@@ -1,11 +1,7 @@
import { distinctUntilChanged, pluck } from "rxjs/operators"
import { GQLHeader, HoppGQLRequest, makeGQLRequest } from "@hoppscotch/data"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { useStream } from "~/helpers/utils/composables"
import {
GQLHeader,
HoppGQLRequest,
makeGQLRequest,
} from "~/helpers/types/HoppGQLRequest"
type GQLSession = {
request: HoppGQLRequest

View File

@@ -1,6 +1,5 @@
import { pluck, distinctUntilChanged, map, filter } from "rxjs/operators"
import { Ref } from "@nuxtjs/composition-api"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import {
FormDataKeyValue,
HoppRESTHeader,
@@ -8,12 +7,13 @@ import {
HoppRESTReqBody,
HoppRESTRequest,
RESTReqSchemaVersion,
} from "~/helpers/types/HoppRESTRequest"
HoppRESTAuth,
ValidContentTypes,
} from "@hoppscotch/data"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"
import { useStream } from "~/helpers/utils/composables"
import { HoppTestResult } from "~/helpers/types/HoppTestResult"
import { HoppRESTAuth } from "~/helpers/types/HoppRESTAuth"
import { ValidContentTypes } from "~/helpers/utils/contenttypes"
import { HoppRequestSaveContext } from "~/helpers/types/HoppRequestSaveContext"
type RESTSession = {

View File

@@ -1,14 +1,12 @@
import { pluck } from "rxjs/operators"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { getRESTSaveContext, setRESTSaveContext } from "./RESTSession"
import {
HoppRESTRequest,
translateToNewRequest,
} from "~/helpers/types/HoppRESTRequest"
import {
HoppGQLRequest,
translateToGQLRequest,
} from "~/helpers/types/HoppGQLRequest"
HoppRESTRequest,
translateToNewRequest,
} from "@hoppscotch/data"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { getRESTSaveContext, setRESTSaveContext } from "./RESTSession"
export interface Collection<T extends HoppRESTRequest | HoppGQLRequest> {
v: number

View File

@@ -1,15 +1,13 @@
import eq from "lodash/eq"
import { pluck } from "rxjs/operators"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { completedRESTResponse$ } from "./RESTSession"
import {
HoppRESTRequest,
translateToNewRequest,
} from "~/helpers/types/HoppRESTRequest"
import {
HoppGQLRequest,
translateToGQLRequest,
} from "~/helpers/types/HoppGQLRequest"
} from "@hoppscotch/data"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { completedRESTResponse$ } from "./RESTSession"
export type RESTHistoryEntry = {
v: number

View File

@@ -5,6 +5,7 @@ import assign from "lodash/assign"
import isEmpty from "lodash/isEmpty"
import * as O from "fp-ts/Option"
import { pipe } from "fp-ts/function"
import { translateToNewRequest } from "@hoppscotch/data"
import {
settingsStore,
bulkApplySettings,
@@ -44,7 +45,6 @@ import { WSRequest$, setWSRequest } from "./WebSocketSession"
import { SIORequest$, setSIORequest } from "./SocketIOSession"
import { SSERequest$, setSSERequest } from "./SSESession"
import { MQTTRequest$, setMQTTRequest } from "./MQTTSession"
import { translateToNewRequest } from "~/helpers/types/HoppRESTRequest"
function checkAndMigrateOldSettings() {
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")

View File

@@ -53,6 +53,7 @@
"@codemirror/text": "^0.19.5",
"@codemirror/view": "^0.19.21",
"@hoppscotch/codemirror-lang-graphql": "workspace:^0.1.0",
"@hoppscotch/data": "workspace:^0.1.0",
"@hoppscotch/js-sandbox": "workspace:^1.0.0",
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/composition-api": "^0.30.0",

View File

@@ -120,6 +120,7 @@ import "splitpanes/dist/splitpanes.css"
import { map } from "rxjs/operators"
import { Subscription } from "rxjs"
import isEqual from "lodash/isEqual"
import { HoppRESTRequest, HoppRESTAuthOAuth2 } from "@hoppscotch/data"
import { useSetting } from "~/newstore/settings"
import {
restActiveParamsCount$,
@@ -137,9 +138,7 @@ import {
} from "~/helpers/utils/composables"
import { loadRequestFromSync, startRequestSync } from "~/helpers/fb/request"
import { onLoggedIn } from "~/helpers/fb/auth"
import { HoppRESTRequest } from "~/helpers/types/HoppRESTRequest"
import { oauthRedirect } from "~/helpers/oauth"
import { HoppRESTAuthOAuth2 } from "~/helpers/types/HoppRESTAuth"
import useWindowSize from "~/helpers/utils/useWindowSize"
function bindRequestToURLParams() {

View File

@@ -63,13 +63,13 @@ import {
watch,
} from "@nuxtjs/composition-api"
import * as E from "fp-ts/Either"
import { makeRESTRequest } from "@hoppscotch/data"
import { useGQLQuery } from "~/helpers/backend/GQLClient"
import {
ResolveShortcodeDocument,
ResolveShortcodeQuery,
ResolveShortcodeQueryVariables,
} from "~/helpers/backend/graphql"
import { makeRESTRequest } from "~/helpers/types/HoppRESTRequest"
import { setRESTRequest } from "~/newstore/RESTSession"
export default defineComponent({

356
packages/hoppscotch-data/package-lock.json generated Normal file
View File

@@ -0,0 +1,356 @@
{
"name": "@hoppscotch/data",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@hoppscotch/data",
"version": "0.1.0",
"license": "MIT",
"dependencies": {
"fp-ts": "^2.11.5",
"io-ts": "^2.2.16"
},
"devDependencies": {
"esbuild": "^0.13.15",
"rollup": "^2.60.0",
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-esbuild": "^4.7.2"
}
},
"../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild": {
"version": "0.13.15",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"optionalDependencies": {
"esbuild-android-arm64": "0.13.15",
"esbuild-darwin-64": "0.13.15",
"esbuild-darwin-arm64": "0.13.15",
"esbuild-freebsd-64": "0.13.15",
"esbuild-freebsd-arm64": "0.13.15",
"esbuild-linux-32": "0.13.15",
"esbuild-linux-64": "0.13.15",
"esbuild-linux-arm": "0.13.15",
"esbuild-linux-arm64": "0.13.15",
"esbuild-linux-mips64le": "0.13.15",
"esbuild-linux-ppc64le": "0.13.15",
"esbuild-netbsd-64": "0.13.15",
"esbuild-openbsd-64": "0.13.15",
"esbuild-sunos-64": "0.13.15",
"esbuild-windows-32": "0.13.15",
"esbuild-windows-64": "0.13.15",
"esbuild-windows-arm64": "0.13.15"
}
},
"../../node_modules/.pnpm/rollup-plugin-dts@4.0.1_rollup@2.60.0/node_modules/rollup-plugin-dts": {
"version": "4.0.1",
"dev": true,
"license": "LGPL-3.0",
"dependencies": {
"magic-string": "^0.25.7"
},
"devDependencies": {
"@types/babel__code-frame": "^7.0.3",
"@types/d3-drag": "^3.0.1",
"@types/estree": "0.0.50",
"@types/fs-extra": "^9.0.12",
"@types/node": "^16.7.5",
"@types/react": "^17.0.20",
"c8": "^7.8.0",
"fs-extra": "^10.0.0",
"rimraf": "^3.0.2",
"rollup": "2.56.3",
"typescript": "4.4.2"
},
"engines": {
"node": ">=v12.22.6"
},
"funding": {
"url": "https://github.com/sponsors/Swatinem"
},
"optionalDependencies": {
"@babel/code-frame": "^7.14.5"
},
"peerDependencies": {
"rollup": "^2.56.3",
"typescript": "^4.4.2"
}
},
"../../node_modules/.pnpm/rollup-plugin-esbuild@4.7.2_esbuild@0.13.15+rollup@2.60.0/node_modules/rollup-plugin-esbuild": {
"version": "4.7.2",
"dev": true,
"license": "MIT",
"dependencies": {
"@rollup/pluginutils": "^4.1.1",
"joycon": "^3.0.1",
"jsonc-parser": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^27.0.2",
"@types/node": "14.14.37",
"esbuild": "^0.13.13",
"jest": "^27.3.1",
"prettier": "^2.4.1",
"rollup": "^2.59.0",
"ts-jest": "^27.0.7",
"tsup": "^5.7.2",
"typescript": "^4.4.4"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"esbuild": ">=0.10.1",
"rollup": "^1.20.0 || ^2.0.0"
}
},
"../../node_modules/.pnpm/rollup@2.60.0/node_modules/rollup": {
"version": "2.60.0",
"dev": true,
"license": "MIT",
"bin": {
"rollup": "dist/bin/rollup"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.5",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-typescript": "^8.2.5",
"@rollup/pluginutils": "^4.1.1",
"@types/node": "^10.17.60",
"@types/require-relative": "^0.8.0",
"@types/signal-exit": "^3.0.1",
"@types/yargs-parser": "^20.2.1",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"acorn": "^8.5.0",
"acorn-jsx": "^5.3.2",
"acorn-walk": "^8.2.0",
"buble": "^0.20.0",
"chokidar": "^3.5.2",
"colorette": "^1.4.0",
"core-js": "^3.18.0",
"date-time": "^4.0.0",
"es5-shim": "^4.6.2",
"es6-shim": "^0.35.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-prettier": "^3.4.1",
"execa": "^5.1.1",
"fixturify": "^2.1.1",
"hash.js": "^1.1.7",
"husky": "^6.0.0",
"is-reference": "^3.0.0",
"lint-staged": "^10.5.4",
"locate-character": "^2.0.5",
"magic-string": "^0.25.7",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"pinst": "^2.1.6",
"prettier": "^2.4.1",
"pretty-bytes": "^5.6.0",
"pretty-ms": "^7.0.1",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^2.57.0",
"rollup-plugin-license": "^2.5.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-thatworks": "^1.0.4",
"sander": "^0.6.0",
"shx": "^0.3.3",
"signal-exit": "^3.0.5",
"source-map": "^0.7.3",
"source-map-support": "^0.5.20",
"sourcemap-codec": "^1.4.8",
"systemjs": "^6.10.3",
"terser": "^5.9.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"weak-napi": "^2.0.2",
"yargs-parser": "^20.2.9"
},
"engines": {
"node": ">=10.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/esbuild": {
"resolved": "../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild",
"link": true
},
"node_modules/fp-ts": {
"version": "2.11.5",
"resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.11.5.tgz",
"integrity": "sha512-OqlwJq1BdpB83BZXTqI+dNcA6uYk6qk4u9Cgnt64Y+XS7dwdbp/mobx8S2KXf2AXH+scNmA/UVK3SEFHR3vHZA=="
},
"node_modules/io-ts": {
"version": "2.2.16",
"resolved": "https://registry.npmjs.org/io-ts/-/io-ts-2.2.16.tgz",
"integrity": "sha512-y5TTSa6VP6le0hhmIyN0dqEXkrZeJLeC5KApJq6VLci3UEKF80lZ+KuoUs02RhBxNWlrqSNxzfI7otLX1Euv8Q==",
"peerDependencies": {
"fp-ts": "^2.5.0"
}
},
"node_modules/rollup": {
"resolved": "../../node_modules/.pnpm/rollup@2.60.0/node_modules/rollup",
"link": true
},
"node_modules/rollup-plugin-dts": {
"resolved": "../../node_modules/.pnpm/rollup-plugin-dts@4.0.1_rollup@2.60.0/node_modules/rollup-plugin-dts",
"link": true
},
"node_modules/rollup-plugin-esbuild": {
"resolved": "../../node_modules/.pnpm/rollup-plugin-esbuild@4.7.2_esbuild@0.13.15+rollup@2.60.0/node_modules/rollup-plugin-esbuild",
"link": true
}
},
"dependencies": {
"esbuild": {
"version": "file:../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild",
"requires": {
"esbuild-android-arm64": "0.13.15",
"esbuild-darwin-64": "0.13.15",
"esbuild-darwin-arm64": "0.13.15",
"esbuild-freebsd-64": "0.13.15",
"esbuild-freebsd-arm64": "0.13.15",
"esbuild-linux-32": "0.13.15",
"esbuild-linux-64": "0.13.15",
"esbuild-linux-arm": "0.13.15",
"esbuild-linux-arm64": "0.13.15",
"esbuild-linux-mips64le": "0.13.15",
"esbuild-linux-ppc64le": "0.13.15",
"esbuild-netbsd-64": "0.13.15",
"esbuild-openbsd-64": "0.13.15",
"esbuild-sunos-64": "0.13.15",
"esbuild-windows-32": "0.13.15",
"esbuild-windows-64": "0.13.15",
"esbuild-windows-arm64": "0.13.15"
}
},
"fp-ts": {
"version": "2.11.5",
"resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.11.5.tgz",
"integrity": "sha512-OqlwJq1BdpB83BZXTqI+dNcA6uYk6qk4u9Cgnt64Y+XS7dwdbp/mobx8S2KXf2AXH+scNmA/UVK3SEFHR3vHZA=="
},
"io-ts": {
"version": "2.2.16",
"resolved": "https://registry.npmjs.org/io-ts/-/io-ts-2.2.16.tgz",
"integrity": "sha512-y5TTSa6VP6le0hhmIyN0dqEXkrZeJLeC5KApJq6VLci3UEKF80lZ+KuoUs02RhBxNWlrqSNxzfI7otLX1Euv8Q==",
"requires": {}
},
"rollup": {
"version": "file:../../node_modules/.pnpm/rollup@2.60.0/node_modules/rollup",
"requires": {
"@rollup/plugin-alias": "^3.1.5",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-typescript": "^8.2.5",
"@rollup/pluginutils": "^4.1.1",
"@types/node": "^10.17.60",
"@types/require-relative": "^0.8.0",
"@types/signal-exit": "^3.0.1",
"@types/yargs-parser": "^20.2.1",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"acorn": "^8.5.0",
"acorn-jsx": "^5.3.2",
"acorn-walk": "^8.2.0",
"buble": "^0.20.0",
"chokidar": "^3.5.2",
"colorette": "^1.4.0",
"core-js": "^3.18.0",
"date-time": "^4.0.0",
"es5-shim": "^4.6.2",
"es6-shim": "^0.35.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-prettier": "^3.4.1",
"execa": "^5.1.1",
"fixturify": "^2.1.1",
"fsevents": "~2.3.2",
"hash.js": "^1.1.7",
"husky": "^6.0.0",
"is-reference": "^3.0.0",
"lint-staged": "^10.5.4",
"locate-character": "^2.0.5",
"magic-string": "^0.25.7",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"pinst": "^2.1.6",
"prettier": "^2.4.1",
"pretty-bytes": "^5.6.0",
"pretty-ms": "^7.0.1",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^2.57.0",
"rollup-plugin-license": "^2.5.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-thatworks": "^1.0.4",
"sander": "^0.6.0",
"shx": "^0.3.3",
"signal-exit": "^3.0.5",
"source-map": "^0.7.3",
"source-map-support": "^0.5.20",
"sourcemap-codec": "^1.4.8",
"systemjs": "^6.10.3",
"terser": "^5.9.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"weak-napi": "^2.0.2",
"yargs-parser": "^20.2.9"
}
},
"rollup-plugin-dts": {
"version": "file:../../node_modules/.pnpm/rollup-plugin-dts@4.0.1_rollup@2.60.0/node_modules/rollup-plugin-dts",
"requires": {
"@babel/code-frame": "^7.14.5",
"@types/babel__code-frame": "^7.0.3",
"@types/d3-drag": "^3.0.1",
"@types/estree": "0.0.50",
"@types/fs-extra": "^9.0.12",
"@types/node": "^16.7.5",
"@types/react": "^17.0.20",
"c8": "^7.8.0",
"fs-extra": "^10.0.0",
"magic-string": "^0.25.7",
"rimraf": "^3.0.2",
"rollup": "2.56.3",
"typescript": "4.4.2"
}
},
"rollup-plugin-esbuild": {
"version": "file:../../node_modules/.pnpm/rollup-plugin-esbuild@4.7.2_esbuild@0.13.15+rollup@2.60.0/node_modules/rollup-plugin-esbuild",
"requires": {
"@rollup/pluginutils": "^4.1.1",
"@types/jest": "^27.0.2",
"@types/node": "14.14.37",
"esbuild": "^0.13.13",
"jest": "^27.3.1",
"joycon": "^3.0.1",
"jsonc-parser": "^3.0.0",
"prettier": "^2.4.1",
"rollup": "^2.59.0",
"ts-jest": "^27.0.7",
"tsup": "^5.7.2",
"typescript": "^4.4.4"
}
}
}
}

View File

@@ -0,0 +1,32 @@
{
"name": "@hoppscotch/data",
"version": "0.1.0",
"description": "Data Types, Validations and Migrations for Hoppscotch Public Data Structures",
"main": "dist/index.js",
"module": "true",
"files": [
"dist"
],
"scripts": {
"build": "tsup src --dts",
"prepare": "tsup src --dts"
},
"exports": {
".": "./dist/index.js",
"./graphql": "./dist/graphql/index.js",
"./rest": "./dist/rest/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hoppscotch/hoppscotch.git"
},
"author": "The Hoppscotch Team <support@hoppscotch.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/hoppscotch/hoppscotch/issues"
},
"homepage": "https://github.com/hoppscotch/hoppscotch#readme",
"devDependencies": {
"tsup": "^5.9.0"
}
}

View File

@@ -0,0 +1,36 @@
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import multi from '@rollup/plugin-multi-entry'
const name = require('./package.json').main.replace(/\.js$/, '')
const bundle = config => ({
...config,
input: 'src/**/*.ts',
external: id => !/^[./]/.test(id),
})
export default [
bundle({
plugins: [multi(), esbuild()],
output: [
{
file: `${name}.js`,
format: 'cjs',
sourcemap: true,
},
{
file: `${name}.mjs`,
format: 'es',
sourcemap: true,
},
],
}),
bundle({
plugins: [dts()],
output: {
file: `${name}.d.ts`,
format: 'es',
},
}),
]

View File

@@ -38,4 +38,4 @@ export function makeGQLRequest(x: Omit<HoppGQLRequest, "v">) {
v: 1,
...x,
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./rest"
export * from "./graphql"

View File

@@ -31,4 +31,4 @@ export type HoppRESTAuth = { authActive: boolean } & (
| HoppRESTAuthBasic
| HoppRESTAuthBearer
| HoppRESTAuthOAuth2
)
)

View File

@@ -0,0 +1,13 @@
export const knownContentTypes = {
"application/json": "json",
"application/ld+json": "json",
"application/hal+json": "json",
"application/vnd.api+json": "json",
"application/xml": "xml",
"application/x-www-form-urlencoded": "multipart",
"multipart/form-data": "multipart",
"text/html": "html",
"text/plain": "plain",
}
export type ValidContentTypes = keyof typeof knownContentTypes

View File

@@ -1,6 +1,9 @@
import { ValidContentTypes } from "../utils/contenttypes"
import { ValidContentTypes } from "./content-types"
import { HoppRESTAuth } from "./HoppRESTAuth"
export * from "./content-types"
export * from "./HoppRESTAuth"
export const RESTReqSchemaVersion = "1"
export type HoppRESTParam = {

View File

@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es2017",
"module": "esnext",
"lib": ["esnext"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"strictNullChecks": true,
"resolveJsonModule": true
}
}

View File

@@ -0,0 +1,18 @@
import { Options } from 'tsup'
const options: Options = {
format: [
'cjs',
// loading Babel in ESM is tricky, since Babel itself it CJS only
// we decided to drop ESM support until Babel supports native ESM
// 'esm',
],
clean: true,
splitting: true,
dts: true,
entryPoints: [
'src/**/*.ts',
],
}
export default options