houdini 2.0.0-next.9 → 2.0.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.
- package/build/adapter/index.d.ts +2 -2
- package/build/adapter/index.js +6 -0
- package/build/cmd/generate.d.ts +5 -0
- package/build/cmd/generate.js +77 -0
- package/build/cmd/index.js +32 -0
- package/build/cmd/init.js +565 -0
- package/build/cmd/pullSchema.js +26 -0
- package/build/lib/ast.js +71 -0
- package/build/lib/codegen.d.ts +57 -0
- package/build/lib/codegen.js +617 -0
- package/build/lib/config.d.ts +240 -177
- package/build/lib/config.js +143 -0
- package/build/lib/constants.js +14 -0
- package/build/lib/database.d.ts +7 -0
- package/build/lib/database.js +624 -0
- package/build/lib/db.d.ts +13 -0
- package/build/lib/db.js +135 -0
- package/build/lib/deepMerge.js +23 -0
- package/build/lib/error.d.ts +16 -0
- package/build/lib/error.js +115 -0
- package/build/lib/fs.d.ts +9 -11
- package/build/lib/fs.js +245 -0
- package/build/lib/graphql.d.ts +5 -32
- package/build/lib/graphql.js +36 -0
- package/build/lib/imports.d.ts +29 -14
- package/build/lib/imports.js +66 -0
- package/build/lib/index.d.ts +17 -24
- package/build/lib/index.js +21 -0
- package/build/lib/logger.d.ts +12 -0
- package/build/lib/logger.js +45 -0
- package/build/lib/parse.d.ts +1 -2
- package/build/lib/parse.js +32 -0
- package/build/lib/path.d.ts +0 -1
- package/build/lib/path.js +44 -0
- package/build/lib/pipeline.d.ts +1 -1
- package/build/lib/pipeline.js +8 -0
- package/build/lib/plugins.d.ts +4 -0
- package/build/lib/plugins.js +88 -0
- package/build/lib/project.d.ts +19 -0
- package/build/lib/project.js +296 -0
- package/build/lib/schema.d.ts +1 -0
- package/build/lib/schema.js +61 -0
- package/build/lib/sleep.d.ts +1 -0
- package/build/lib/sleep.js +8 -0
- package/build/lib/types.d.ts +92 -303
- package/build/lib/types.js +37 -0
- package/build/lib/walk.d.ts +11 -6
- package/build/lib/walk.js +138 -0
- package/build/node/index.d.ts +44 -0
- package/build/node/index.js +402 -0
- package/build/oauth/index.d.ts +41 -0
- package/build/oauth/index.js +108 -0
- package/build/package.json +212 -0
- package/build/router/auth-token.d.ts +29 -0
- package/build/router/auth-token.js +168 -0
- package/build/{lib/router → router}/conventions.d.ts +10 -1
- package/build/router/conventions.js +165 -0
- package/build/{runtime-esm/router → router}/cookies.js +21 -21
- package/build/{runtime-esm/router → router}/jwt.js +8 -6
- package/build/{lib/router → router}/manifest.d.ts +2 -2
- package/build/router/manifest.js +279 -0
- package/build/{runtime/router → router}/match.d.ts +10 -10
- package/build/router/match.js +219 -0
- package/build/router/server.d.ts +57 -0
- package/build/router/server.js +500 -0
- package/build/{runtime/router → router}/session.d.ts +8 -3
- package/build/router/session.js +338 -0
- package/build/router/types.d.ts +44 -0
- package/build/runtime/cache/benchmarks/cache.bench.d.ts +1 -0
- package/build/runtime/cache/benchmarks/cache.bench.js +943 -0
- package/build/runtime/cache/gc.d.ts +2 -1
- package/build/{runtime-esm → runtime}/cache/gc.js +4 -1
- package/build/runtime/cache/index.d.ts +173 -3
- package/build/{runtime-esm/cache/cache.js → runtime/cache/index.js} +197 -70
- package/build/runtime/cache/lists.d.ts +9 -4
- package/build/{runtime-esm → runtime}/cache/lists.js +116 -27
- package/build/runtime/cache/staleManager.d.ts +2 -1
- package/build/{runtime-esm → runtime}/cache/staleManager.js +6 -2
- package/build/runtime/cache/storage.d.ts +5 -2
- package/build/{runtime-esm → runtime}/cache/storage.js +126 -54
- package/build/{runtime-esm → runtime}/cache/stuff.js +4 -3
- package/build/runtime/cache/subscription.d.ts +23 -9
- package/build/{runtime-esm → runtime}/cache/subscription.js +103 -65
- package/build/runtime/{client/index.d.ts → client.d.ts} +15 -22
- package/build/runtime/client.js +86 -0
- package/build/runtime/coerce.d.ts +4 -0
- package/build/runtime/coerce.js +31 -0
- package/build/runtime/config.d.ts +20 -0
- package/build/runtime/config.js +88 -0
- package/build/runtime/{lib/constants.d.ts → constants.d.ts} +1 -1
- package/build/runtime/{client/documentStore.d.ts → documentStore.d.ts} +18 -11
- package/build/{runtime-esm/client → runtime}/documentStore.js +53 -56
- package/build/runtime/endpoint.d.ts +14 -0
- package/build/runtime/endpoint.js +29 -0
- package/build/{runtime-cjs/lib → runtime}/flatten.d.ts +1 -1
- package/build/runtime/formData.d.ts +24 -0
- package/build/runtime/formData.js +93 -0
- package/build/runtime/index.d.ts +16 -8
- package/build/runtime/index.js +54 -0
- package/build/{runtime-cjs/lib → runtime}/key.d.ts +1 -1
- package/build/{runtime-esm/lib → runtime}/key.js +4 -4
- package/build/{runtime-esm/lib → runtime}/log.js +3 -3
- package/build/runtime/multipart.d.ts +8 -0
- package/build/runtime/multipart.js +49 -0
- package/build/{runtime-cjs/lib → runtime}/pageInfo.d.ts +3 -3
- package/build/{runtime-esm/lib → runtime}/pageInfo.js +2 -2
- package/build/{runtime-cjs/lib → runtime}/pagination.d.ts +12 -8
- package/build/{runtime-esm/lib → runtime}/pagination.js +157 -21
- package/build/{runtime-cjs/lib → runtime}/scalars.d.ts +6 -6
- package/build/{runtime-esm/lib → runtime}/scalars.js +10 -43
- package/build/{runtime-cjs/lib → runtime}/selection.d.ts +1 -1
- package/build/{runtime-esm/lib → runtime}/selection.js +17 -2
- package/build/runtime/{lib/store.d.ts → store.d.ts} +1 -1
- package/build/{runtime-esm/lib → runtime}/store.js +2 -3
- package/build/runtime/{lib/types.d.ts → types.d.ts} +102 -101
- package/build/{runtime-esm/lib → runtime}/types.js +9 -14
- package/build/test/index.d.ts +6 -25
- package/build/test/index.js +329 -0
- package/build/test/package.json +1 -0
- package/build/vite/hmr.d.ts +26 -3
- package/build/vite/hmr.js +431 -0
- package/build/vite/houdini.d.ts +4 -10
- package/build/vite/houdini.js +134 -0
- package/build/vite/index.d.ts +13 -7
- package/build/vite/index.js +104 -0
- package/build/vite/package.json +1 -0
- package/build/vite/schema.d.ts +5 -3
- package/build/vite/schema.js +193 -0
- package/package.json +148 -57
- package/build/adapter-cjs/index.js +0 -33
- package/build/adapter-cjs/package.json +0 -1
- package/build/adapter-esm/index.js +0 -9
- package/build/cmd-cjs/index.js +0 -89299
- package/build/cmd-cjs/package.json +0 -1
- package/build/cmd-esm/index.js +0 -89303
- package/build/codegen/generators/artifacts/fieldKey.d.ts +0 -3
- package/build/codegen/generators/artifacts/index.d.ts +0 -17
- package/build/codegen/generators/artifacts/indexFile.d.ts +0 -2
- package/build/codegen/generators/artifacts/inputs.d.ts +0 -4
- package/build/codegen/generators/artifacts/operations.d.ts +0 -11
- package/build/codegen/generators/artifacts/selection.d.ts +0 -20
- package/build/codegen/generators/artifacts/utils.d.ts +0 -8
- package/build/codegen/generators/comments/jsdoc.d.ts +0 -2
- package/build/codegen/generators/definitions/enums.d.ts +0 -2
- package/build/codegen/generators/definitions/index.d.ts +0 -2
- package/build/codegen/generators/index.d.ts +0 -6
- package/build/codegen/generators/indexFile/index.d.ts +0 -2
- package/build/codegen/generators/persistedQueries/index.d.ts +0 -2
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +0 -2
- package/build/codegen/generators/runtime/index.d.ts +0 -3
- package/build/codegen/generators/runtime/injectPlugins.d.ts +0 -7
- package/build/codegen/generators/runtime/pluginIndex.d.ts +0 -5
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +0 -15
- package/build/codegen/generators/runtime/runtimeConfig.d.ts +0 -7
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +0 -4
- package/build/codegen/generators/typescript/documentTypes.d.ts +0 -2
- package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +0 -2
- package/build/codegen/generators/typescript/index.d.ts +0 -2
- package/build/codegen/generators/typescript/inlineType.d.ts +0 -29
- package/build/codegen/generators/typescript/loadingState.d.ts +0 -8
- package/build/codegen/index.d.ts +0 -8
- package/build/codegen/transforms/addFields.d.ts +0 -2
- package/build/codegen/transforms/collectDefinitions.d.ts +0 -9
- package/build/codegen/transforms/componentFields.d.ts +0 -8
- package/build/codegen/transforms/fragmentVariables.d.ts +0 -17
- package/build/codegen/transforms/index.d.ts +0 -9
- package/build/codegen/transforms/list.d.ts +0 -9
- package/build/codegen/transforms/paginate.d.ts +0 -4
- package/build/codegen/transforms/runtimeScalars.d.ts +0 -2
- package/build/codegen/transforms/schema.d.ts +0 -2
- package/build/codegen/transforms/typename.d.ts +0 -2
- package/build/codegen/utils/commonjs.d.ts +0 -5
- package/build/codegen/utils/flattenSelections.d.ts +0 -11
- package/build/codegen/utils/index.d.ts +0 -4
- package/build/codegen/utils/moduleExport.d.ts +0 -4
- package/build/codegen/utils/murmur.d.ts +0 -9
- package/build/codegen/utils/objectIdentificationSelection.d.ts +0 -3
- package/build/codegen/utils/stripLoc.d.ts +0 -3
- package/build/codegen/validators/componentFields.d.ts +0 -2
- package/build/codegen/validators/index.d.ts +0 -5
- package/build/codegen/validators/noIDAlias.d.ts +0 -2
- package/build/codegen/validators/plugins.d.ts +0 -3
- package/build/codegen/validators/typeCheck.d.ts +0 -5
- package/build/codegen/validators/uniqueNames.d.ts +0 -2
- package/build/codegen-cjs/index.js +0 -74656
- package/build/codegen-cjs/package.json +0 -1
- package/build/codegen-esm/index.js +0 -74655
- package/build/lib/cleanupFiles.d.ts +0 -1
- package/build/lib/detectTools.d.ts +0 -16
- package/build/lib/introspection.d.ts +0 -3
- package/build/lib/plugin.d.ts +0 -2
- package/build/lib/router/index.d.ts +0 -9
- package/build/lib/router/server.d.ts +0 -7
- package/build/lib/router/types.d.ts +0 -23
- package/build/lib/typescript.d.ts +0 -20
- package/build/lib/watchAndRun.d.ts +0 -61
- package/build/lib-cjs/index.js +0 -79739
- package/build/lib-cjs/package.json +0 -1
- package/build/lib-esm/index.js +0 -79648
- package/build/runtime/cache/cache.d.ts +0 -169
- package/build/runtime/client/plugins/cache.d.ts +0 -9
- package/build/runtime/client/plugins/fetch.d.ts +0 -38
- package/build/runtime/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime/client/plugins/fragment.d.ts +0 -2
- package/build/runtime/client/plugins/index.d.ts +0 -9
- package/build/runtime/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime/client/plugins/mutation.d.ts +0 -2
- package/build/runtime/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime/client/plugins/query.d.ts +0 -2
- package/build/runtime/client/plugins/subscription.d.ts +0 -20
- package/build/runtime/client/plugins/test.d.ts +0 -15
- package/build/runtime/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime/client/utils/index.d.ts +0 -1
- package/build/runtime/generated.d.ts +0 -5
- package/build/runtime/imports/config.d.ts +0 -3
- package/build/runtime/imports/pluginConfig.d.ts +0 -3
- package/build/runtime/lib/config.d.ts +0 -216
- package/build/runtime/lib/deepEquals.d.ts +0 -1
- package/build/runtime/lib/flatten.d.ts +0 -2
- package/build/runtime/lib/index.d.ts +0 -10
- package/build/runtime/lib/key.d.ts +0 -6
- package/build/runtime/lib/log.d.ts +0 -6
- package/build/runtime/lib/lru.d.ts +0 -52
- package/build/runtime/lib/pageInfo.d.ts +0 -7
- package/build/runtime/lib/pagination.d.ts +0 -27
- package/build/runtime/lib/scalars.d.ts +0 -14
- package/build/runtime/lib/selection.d.ts +0 -2
- package/build/runtime/public/cache.d.ts +0 -42
- package/build/runtime/public/index.d.ts +0 -1
- package/build/runtime/public/list.d.ts +0 -18
- package/build/runtime/public/record.d.ts +0 -40
- package/build/runtime/public/tests/test.d.ts +0 -156
- package/build/runtime/public/types.d.ts +0 -62
- package/build/runtime/router/cookies.d.ts +0 -41
- package/build/runtime/router/jwt.d.ts +0 -117
- package/build/runtime/router/server.d.ts +0 -24
- package/build/runtime/router/types.d.ts +0 -26
- package/build/runtime/server/index.d.ts +0 -17
- package/build/runtime-cjs/cache/cache.d.ts +0 -169
- package/build/runtime-cjs/cache/cache.js +0 -1077
- package/build/runtime-cjs/cache/constants.d.ts +0 -1
- package/build/runtime-cjs/cache/constants.js +0 -28
- package/build/runtime-cjs/cache/gc.d.ts +0 -10
- package/build/runtime-cjs/cache/gc.js +0 -74
- package/build/runtime-cjs/cache/index.d.ts +0 -3
- package/build/runtime-cjs/cache/index.js +0 -25
- package/build/runtime-cjs/cache/lists.d.ts +0 -89
- package/build/runtime-cjs/cache/lists.js +0 -467
- package/build/runtime-cjs/cache/staleManager.d.ts +0 -31
- package/build/runtime-cjs/cache/staleManager.js +0 -123
- package/build/runtime-cjs/cache/storage.d.ts +0 -110
- package/build/runtime-cjs/cache/storage.js +0 -451
- package/build/runtime-cjs/cache/stuff.d.ts +0 -2
- package/build/runtime-cjs/cache/stuff.js +0 -56
- package/build/runtime-cjs/cache/subscription.d.ts +0 -52
- package/build/runtime-cjs/cache/subscription.js +0 -349
- package/build/runtime-cjs/client/documentStore.d.ts +0 -107
- package/build/runtime-cjs/client/documentStore.js +0 -487
- package/build/runtime-cjs/client/index.d.ts +0 -50
- package/build/runtime-cjs/client/index.js +0 -162
- package/build/runtime-cjs/client/plugins/cache.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/cache.js +0 -138
- package/build/runtime-cjs/client/plugins/fetch.d.ts +0 -38
- package/build/runtime-cjs/client/plugins/fetch.js +0 -210
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/fetchParams.js +0 -47
- package/build/runtime-cjs/client/plugins/fragment.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/fragment.js +0 -77
- package/build/runtime-cjs/client/plugins/index.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/index.js +0 -45
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime-cjs/client/plugins/injectedPlugins.js +0 -25
- package/build/runtime-cjs/client/plugins/mutation.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/mutation.js +0 -89
- package/build/runtime-cjs/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime-cjs/client/plugins/optimisticKeys.js +0 -324
- package/build/runtime-cjs/client/plugins/query.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/query.js +0 -93
- package/build/runtime-cjs/client/plugins/subscription.d.ts +0 -20
- package/build/runtime-cjs/client/plugins/subscription.js +0 -114
- package/build/runtime-cjs/client/plugins/test.d.ts +0 -15
- package/build/runtime-cjs/client/plugins/test.js +0 -118
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime-cjs/client/plugins/throwOnError.js +0 -47
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime-cjs/client/utils/documentPlugins.js +0 -57
- package/build/runtime-cjs/client/utils/index.d.ts +0 -1
- package/build/runtime-cjs/client/utils/index.js +0 -22
- package/build/runtime-cjs/generated.d.ts +0 -5
- package/build/runtime-cjs/generated.js +0 -16
- package/build/runtime-cjs/imports/config.d.ts +0 -3
- package/build/runtime-cjs/imports/config.js +0 -24
- package/build/runtime-cjs/imports/pluginConfig.d.ts +0 -3
- package/build/runtime-cjs/imports/pluginConfig.js +0 -25
- package/build/runtime-cjs/index.d.ts +0 -8
- package/build/runtime-cjs/index.js +0 -61
- package/build/runtime-cjs/lib/config.d.ts +0 -216
- package/build/runtime-cjs/lib/config.js +0 -110
- package/build/runtime-cjs/lib/constants.d.ts +0 -6
- package/build/runtime-cjs/lib/constants.js +0 -38
- package/build/runtime-cjs/lib/deepEquals.js +0 -52
- package/build/runtime-cjs/lib/flatten.js +0 -41
- package/build/runtime-cjs/lib/index.d.ts +0 -10
- package/build/runtime-cjs/lib/index.js +0 -40
- package/build/runtime-cjs/lib/key.js +0 -41
- package/build/runtime-cjs/lib/log.js +0 -72
- package/build/runtime-cjs/lib/lru.js +0 -73
- package/build/runtime-cjs/lib/pageInfo.js +0 -79
- package/build/runtime-cjs/lib/pagination.js +0 -240
- package/build/runtime-cjs/lib/scalars.js +0 -147
- package/build/runtime-cjs/lib/selection.js +0 -66
- package/build/runtime-cjs/lib/store.d.ts +0 -19
- package/build/runtime-cjs/lib/store.js +0 -81
- package/build/runtime-cjs/lib/types.d.ts +0 -417
- package/build/runtime-cjs/lib/types.js +0 -104
- package/build/runtime-cjs/package.json +0 -1
- package/build/runtime-cjs/public/cache.d.ts +0 -42
- package/build/runtime-cjs/public/cache.js +0 -98
- package/build/runtime-cjs/public/index.d.ts +0 -1
- package/build/runtime-cjs/public/index.js +0 -28
- package/build/runtime-cjs/public/list.d.ts +0 -18
- package/build/runtime-cjs/public/list.js +0 -151
- package/build/runtime-cjs/public/record.d.ts +0 -40
- package/build/runtime-cjs/public/record.js +0 -94
- package/build/runtime-cjs/public/tests/test.d.ts +0 -156
- package/build/runtime-cjs/public/tests/test.js +0 -60
- package/build/runtime-cjs/public/types.d.ts +0 -62
- package/build/runtime-cjs/public/types.js +0 -16
- package/build/runtime-cjs/router/cookies.js +0 -168
- package/build/runtime-cjs/router/jwt.js +0 -168
- package/build/runtime-cjs/router/match.d.ts +0 -39
- package/build/runtime-cjs/router/match.js +0 -158
- package/build/runtime-cjs/router/server.d.ts +0 -24
- package/build/runtime-cjs/router/server.js +0 -117
- package/build/runtime-cjs/router/session.d.ts +0 -22
- package/build/runtime-cjs/router/session.js +0 -100
- package/build/runtime-cjs/router/types.d.ts +0 -26
- package/build/runtime-cjs/router/types.js +0 -16
- package/build/runtime-cjs/server/index.d.ts +0 -17
- package/build/runtime-cjs/server/index.js +0 -62
- package/build/runtime-esm/cache/cache.d.ts +0 -169
- package/build/runtime-esm/cache/constants.d.ts +0 -1
- package/build/runtime-esm/cache/gc.d.ts +0 -10
- package/build/runtime-esm/cache/index.d.ts +0 -3
- package/build/runtime-esm/cache/index.js +0 -5
- package/build/runtime-esm/cache/lists.d.ts +0 -89
- package/build/runtime-esm/cache/staleManager.d.ts +0 -31
- package/build/runtime-esm/cache/storage.d.ts +0 -110
- package/build/runtime-esm/cache/stuff.d.ts +0 -2
- package/build/runtime-esm/cache/subscription.d.ts +0 -52
- package/build/runtime-esm/client/documentStore.d.ts +0 -107
- package/build/runtime-esm/client/index.d.ts +0 -50
- package/build/runtime-esm/client/index.js +0 -130
- package/build/runtime-esm/client/plugins/cache.d.ts +0 -9
- package/build/runtime-esm/client/plugins/cache.js +0 -104
- package/build/runtime-esm/client/plugins/fetch.d.ts +0 -38
- package/build/runtime-esm/client/plugins/fetch.js +0 -184
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime-esm/client/plugins/fetchParams.js +0 -23
- package/build/runtime-esm/client/plugins/fragment.d.ts +0 -2
- package/build/runtime-esm/client/plugins/fragment.js +0 -53
- package/build/runtime-esm/client/plugins/index.d.ts +0 -9
- package/build/runtime-esm/client/plugins/index.js +0 -12
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime-esm/client/plugins/injectedPlugins.js +0 -5
- package/build/runtime-esm/client/plugins/mutation.d.ts +0 -2
- package/build/runtime-esm/client/plugins/mutation.js +0 -65
- package/build/runtime-esm/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime-esm/client/plugins/optimisticKeys.js +0 -290
- package/build/runtime-esm/client/plugins/query.d.ts +0 -2
- package/build/runtime-esm/client/plugins/query.js +0 -69
- package/build/runtime-esm/client/plugins/subscription.d.ts +0 -20
- package/build/runtime-esm/client/plugins/subscription.js +0 -90
- package/build/runtime-esm/client/plugins/test.d.ts +0 -15
- package/build/runtime-esm/client/plugins/test.js +0 -93
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime-esm/client/plugins/throwOnError.js +0 -23
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime-esm/client/utils/documentPlugins.js +0 -33
- package/build/runtime-esm/client/utils/index.d.ts +0 -1
- package/build/runtime-esm/client/utils/index.js +0 -1
- package/build/runtime-esm/generated.d.ts +0 -5
- package/build/runtime-esm/generated.js +0 -0
- package/build/runtime-esm/imports/config.d.ts +0 -3
- package/build/runtime-esm/imports/config.js +0 -4
- package/build/runtime-esm/imports/pluginConfig.d.ts +0 -3
- package/build/runtime-esm/imports/pluginConfig.js +0 -5
- package/build/runtime-esm/index.d.ts +0 -8
- package/build/runtime-esm/index.js +0 -22
- package/build/runtime-esm/lib/config.d.ts +0 -216
- package/build/runtime-esm/lib/config.js +0 -69
- package/build/runtime-esm/lib/constants.d.ts +0 -6
- package/build/runtime-esm/lib/deepEquals.d.ts +0 -1
- package/build/runtime-esm/lib/flatten.d.ts +0 -2
- package/build/runtime-esm/lib/index.d.ts +0 -10
- package/build/runtime-esm/lib/index.js +0 -10
- package/build/runtime-esm/lib/key.d.ts +0 -6
- package/build/runtime-esm/lib/log.d.ts +0 -6
- package/build/runtime-esm/lib/lru.d.ts +0 -52
- package/build/runtime-esm/lib/pageInfo.d.ts +0 -7
- package/build/runtime-esm/lib/pagination.d.ts +0 -27
- package/build/runtime-esm/lib/scalars.d.ts +0 -14
- package/build/runtime-esm/lib/selection.d.ts +0 -2
- package/build/runtime-esm/lib/store.d.ts +0 -19
- package/build/runtime-esm/lib/types.d.ts +0 -417
- package/build/runtime-esm/public/cache.d.ts +0 -42
- package/build/runtime-esm/public/cache.js +0 -74
- package/build/runtime-esm/public/index.d.ts +0 -1
- package/build/runtime-esm/public/index.js +0 -4
- package/build/runtime-esm/public/list.d.ts +0 -18
- package/build/runtime-esm/public/list.js +0 -127
- package/build/runtime-esm/public/record.d.ts +0 -40
- package/build/runtime-esm/public/record.js +0 -70
- package/build/runtime-esm/public/tests/test.d.ts +0 -156
- package/build/runtime-esm/public/tests/test.js +0 -36
- package/build/runtime-esm/public/types.d.ts +0 -62
- package/build/runtime-esm/router/cookies.d.ts +0 -41
- package/build/runtime-esm/router/jwt.d.ts +0 -117
- package/build/runtime-esm/router/match.d.ts +0 -39
- package/build/runtime-esm/router/match.js +0 -131
- package/build/runtime-esm/router/server.d.ts +0 -24
- package/build/runtime-esm/router/server.js +0 -92
- package/build/runtime-esm/router/session.d.ts +0 -22
- package/build/runtime-esm/router/session.js +0 -74
- package/build/runtime-esm/router/types.d.ts +0 -26
- package/build/runtime-esm/router/types.js +0 -0
- package/build/runtime-esm/server/index.d.ts +0 -17
- package/build/runtime-esm/server/index.js +0 -38
- package/build/test-cjs/index.js +0 -75249
- package/build/test-cjs/package.json +0 -1
- package/build/test-esm/index.js +0 -75244
- package/build/vite/imports.d.ts +0 -40
- package/build/vite-cjs/index.js +0 -86272
- package/build/vite-cjs/package.json +0 -1
- package/build/vite-esm/index.js +0 -86264
- /package/build/{adapter-esm → adapter}/package.json +0 -0
- /package/build/{cmd-esm → cmd}/package.json +0 -0
- /package/build/{vite → lib}/ast.d.ts +0 -0
- /package/build/{codegen-esm → lib}/package.json +0 -0
- /package/build/{lib-esm → node}/package.json +0 -0
- /package/build/{runtime-esm → oauth}/package.json +0 -0
- /package/build/{runtime-cjs/router → router}/cookies.d.ts +0 -0
- /package/build/{runtime-cjs/router → router}/jwt.d.ts +0 -0
- /package/build/{test-esm → router}/package.json +0 -0
- /package/build/{runtime-esm/public → router}/types.js +0 -0
- /package/build/{runtime-esm → runtime}/cache/constants.js +0 -0
- /package/build/{runtime-esm/lib → runtime}/constants.js +0 -0
- /package/build/{runtime-cjs/lib → runtime}/deepEquals.d.ts +0 -0
- /package/build/{runtime-esm/lib → runtime}/deepEquals.js +0 -0
- /package/build/{runtime-esm/lib → runtime}/flatten.js +0 -0
- /package/build/{runtime-cjs/lib → runtime}/log.d.ts +0 -0
- /package/build/{runtime-cjs/lib → runtime}/lru.d.ts +0 -0
- /package/build/{runtime-esm/lib → runtime}/lru.js +0 -0
- /package/build/{vite-esm → runtime}/package.json +0 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { createInterface } from "node:readline";
|
|
5
|
+
import { WebSocketServer } from "ws";
|
|
6
|
+
import { openDb } from "../lib/db.js";
|
|
7
|
+
class PluginError extends Error {
|
|
8
|
+
detail;
|
|
9
|
+
locations;
|
|
10
|
+
kind;
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
super(opts.message);
|
|
13
|
+
this.detail = opts.detail;
|
|
14
|
+
this.locations = opts.locations;
|
|
15
|
+
this.kind = opts.kind;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function plugin(config) {
|
|
19
|
+
const { transport, database, pluginKey } = parseArgs();
|
|
20
|
+
if (transport === "stdio") {
|
|
21
|
+
void runStdio(config, database, pluginKey);
|
|
22
|
+
} else {
|
|
23
|
+
void runWebSocket(config, database, pluginKey);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function runStdio(config, databasePath, pluginKey) {
|
|
27
|
+
const resolvedName = pluginKey || config.name;
|
|
28
|
+
const { pending, invokeCounter, rl } = makeStdioChannel();
|
|
29
|
+
const wireHooks = registeredHookNames(config).map(toWireName);
|
|
30
|
+
const reg = {
|
|
31
|
+
type: "register",
|
|
32
|
+
name: resolvedName,
|
|
33
|
+
hooks: wireHooks,
|
|
34
|
+
order: config.order
|
|
35
|
+
};
|
|
36
|
+
if (config.includeRuntime !== void 0) reg.includeRuntime = config.includeRuntime;
|
|
37
|
+
if (config.staticRuntime !== void 0) reg.includeStaticRuntime = config.staticRuntime;
|
|
38
|
+
if (config.configModule !== void 0) reg.configModule = config.configModule;
|
|
39
|
+
if (config.clientPlugins !== void 0) reg.clientPlugins = JSON.stringify(config.clientPlugins);
|
|
40
|
+
stdioWrite(reg);
|
|
41
|
+
const dbPromise = openDb(databasePath || ":memory:");
|
|
42
|
+
rl.on("line", async (line) => {
|
|
43
|
+
const db2 = await dbPromise;
|
|
44
|
+
let msg;
|
|
45
|
+
try {
|
|
46
|
+
msg = JSON.parse(line);
|
|
47
|
+
} catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (msg.type === "request") {
|
|
51
|
+
const ctx = {
|
|
52
|
+
taskId: msg.taskId ?? "",
|
|
53
|
+
pluginDirectory: msg.pluginDirectory ?? "",
|
|
54
|
+
db: db2,
|
|
55
|
+
invokeHook: makeInvokeHook(pending, invokeCounter, msg.taskId ?? "")
|
|
56
|
+
};
|
|
57
|
+
await dispatch(config, resolvedName, msg, ctx, (response) => stdioWrite(response));
|
|
58
|
+
} else if (msg.type === "invoke_result") {
|
|
59
|
+
resolveInvoke(pending, msg);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const db = await dbPromise;
|
|
63
|
+
rl.on("close", () => {
|
|
64
|
+
for (const { reject } of pending.values()) {
|
|
65
|
+
reject(new Error("stdin closed"));
|
|
66
|
+
}
|
|
67
|
+
pending.clear();
|
|
68
|
+
db.close();
|
|
69
|
+
process.exit(0);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function runWebSocket(config, databasePath, pluginKey) {
|
|
73
|
+
if (!databasePath) {
|
|
74
|
+
process.stderr.write("node plugin: --database path is required in websocket mode\n");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const resolvedName = pluginKey || config.name;
|
|
78
|
+
const db = await openDb(databasePath);
|
|
79
|
+
const wireHooks = registeredHookNames(config).map(toWireName);
|
|
80
|
+
const wsInvokeHook = () => {
|
|
81
|
+
throw new Error("invokeHook is not supported in websocket transport");
|
|
82
|
+
};
|
|
83
|
+
const server = http.createServer((req, res) => {
|
|
84
|
+
if (req.method !== "POST") {
|
|
85
|
+
res.writeHead(405);
|
|
86
|
+
res.end();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const hookName = (req.url ?? "/").slice(1);
|
|
90
|
+
const taskId = req.headers["x-task-id"] ?? "";
|
|
91
|
+
const pluginDirectory = req.headers["x-plugin-directory"] ?? "";
|
|
92
|
+
let body = "";
|
|
93
|
+
req.on("data", (chunk) => body += chunk);
|
|
94
|
+
req.on("end", async () => {
|
|
95
|
+
let payload = {};
|
|
96
|
+
try {
|
|
97
|
+
if (body) payload = JSON.parse(body);
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
const msg = { hook: hookName, payload, taskId, pluginDirectory, id: "" };
|
|
101
|
+
const ctx = {
|
|
102
|
+
taskId,
|
|
103
|
+
pluginDirectory,
|
|
104
|
+
db,
|
|
105
|
+
invokeHook: wsInvokeHook
|
|
106
|
+
};
|
|
107
|
+
await dispatch(config, resolvedName, msg, ctx, (response) => {
|
|
108
|
+
if (response.error) {
|
|
109
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
110
|
+
res.end(JSON.stringify(response.error));
|
|
111
|
+
} else {
|
|
112
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
113
|
+
res.end(JSON.stringify(response.result ?? {}));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const wss = new WebSocketServer({ server, path: "/ws" });
|
|
119
|
+
wss.on("connection", (ws) => {
|
|
120
|
+
ws.on("message", async (data) => {
|
|
121
|
+
let msg;
|
|
122
|
+
try {
|
|
123
|
+
msg = JSON.parse(data.toString());
|
|
124
|
+
} catch {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (msg.type !== "request") {
|
|
128
|
+
ws.send(
|
|
129
|
+
JSON.stringify({
|
|
130
|
+
id: msg.id,
|
|
131
|
+
type: "response",
|
|
132
|
+
error: { message: "expected request type" }
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const ctx = {
|
|
138
|
+
taskId: msg.taskId ?? "",
|
|
139
|
+
pluginDirectory: msg.pluginDirectory ?? "",
|
|
140
|
+
db,
|
|
141
|
+
invokeHook: wsInvokeHook
|
|
142
|
+
};
|
|
143
|
+
await dispatch(
|
|
144
|
+
config,
|
|
145
|
+
resolvedName,
|
|
146
|
+
msg,
|
|
147
|
+
ctx,
|
|
148
|
+
(response) => ws.send(JSON.stringify(response))
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
ws.on("close", () => {
|
|
152
|
+
db.close();
|
|
153
|
+
server.close();
|
|
154
|
+
process.exit(0);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
server.on("error", (err) => {
|
|
158
|
+
process.stderr.write(`node plugin: server failed to start: ${err.message}
|
|
159
|
+
`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
});
|
|
162
|
+
server.listen(0, () => {
|
|
163
|
+
const port = server.address().port;
|
|
164
|
+
db.run(
|
|
165
|
+
`INSERT INTO plugins (name, hooks, port, plugin_order, include_runtime, include_static_runtime, config_module, client_plugins)
|
|
166
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
167
|
+
[
|
|
168
|
+
resolvedName,
|
|
169
|
+
JSON.stringify(wireHooks),
|
|
170
|
+
port,
|
|
171
|
+
config.order,
|
|
172
|
+
config.includeRuntime ?? null,
|
|
173
|
+
config.staticRuntime ?? null,
|
|
174
|
+
config.configModule ?? null,
|
|
175
|
+
config.clientPlugins ? JSON.stringify(config.clientPlugins) : null
|
|
176
|
+
]
|
|
177
|
+
);
|
|
178
|
+
db.flush();
|
|
179
|
+
});
|
|
180
|
+
process.on("SIGINT", () => shutdown(db, server));
|
|
181
|
+
process.on("SIGTERM", () => shutdown(db, server));
|
|
182
|
+
}
|
|
183
|
+
async function dispatch(config, pluginName, msg, ctx, send) {
|
|
184
|
+
const normalized = msg.hook.toLowerCase();
|
|
185
|
+
const payload = msg.payload ?? {};
|
|
186
|
+
try {
|
|
187
|
+
let result;
|
|
188
|
+
switch (normalized) {
|
|
189
|
+
case "config": {
|
|
190
|
+
const handler = config.hooks.config;
|
|
191
|
+
result = handler ? await handler(ctx, payload) : void 0;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case "afterload": {
|
|
195
|
+
result = await dispatchAfterLoad(config, pluginName, ctx, payload);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "generateruntime": {
|
|
199
|
+
result = await dispatchGenerateRuntime(config, pluginName, ctx, payload);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case "indexfile": {
|
|
203
|
+
await dispatchIndexFile(config, pluginName, ctx, payload);
|
|
204
|
+
result = void 0;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
default: {
|
|
208
|
+
const hookKey = Object.keys(config.hooks).find(
|
|
209
|
+
(k) => k.toLowerCase() === normalized
|
|
210
|
+
);
|
|
211
|
+
const handler = hookKey ? config.hooks[hookKey] : void 0;
|
|
212
|
+
if (!handler) {
|
|
213
|
+
send({
|
|
214
|
+
id: msg.id,
|
|
215
|
+
type: "response",
|
|
216
|
+
error: { message: `no handler for hook ${msg.hook}` }
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
result = await handler(ctx, payload);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
send({ id: msg.id, type: "response", result: result ?? {} });
|
|
224
|
+
} catch (err) {
|
|
225
|
+
send({ id: msg.id, type: "response", error: serializeError(err) });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function dispatchAfterLoad(config, pluginName, ctx, payload) {
|
|
229
|
+
if (config.hooks.config) {
|
|
230
|
+
const defaults = await config.hooks.config(ctx, payload);
|
|
231
|
+
if (defaults !== void 0) {
|
|
232
|
+
ctx.db.run("UPDATE plugins SET config = $config WHERE name = $name", {
|
|
233
|
+
$config: JSON.stringify(defaults),
|
|
234
|
+
$name: pluginName
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (config.staticRuntime) {
|
|
239
|
+
const { projectRoot, runtimeDir } = readProjectConfig(ctx.db);
|
|
240
|
+
const src = join(ctx.pluginDirectory, config.staticRuntime);
|
|
241
|
+
const dst = pluginStaticRuntimeDir(projectRoot, runtimeDir, pluginName);
|
|
242
|
+
await recursiveCopy(src, dst, config.transformStaticRuntime);
|
|
243
|
+
}
|
|
244
|
+
if (config.hooks.afterLoad) {
|
|
245
|
+
return await config.hooks.afterLoad(ctx, payload);
|
|
246
|
+
}
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
async function dispatchGenerateRuntime(config, pluginName, ctx, payload) {
|
|
250
|
+
const paths = [];
|
|
251
|
+
if (config.includeRuntime !== void 0) {
|
|
252
|
+
const { projectRoot, runtimeDir } = readProjectConfig(ctx.db);
|
|
253
|
+
const src = join(ctx.pluginDirectory, config.includeRuntime);
|
|
254
|
+
const dst = pluginRuntimeDir(projectRoot, runtimeDir, pluginName);
|
|
255
|
+
const copied = await recursiveCopy(src, dst, config.transformRuntime);
|
|
256
|
+
paths.push(...copied);
|
|
257
|
+
}
|
|
258
|
+
if (config.hooks.generateRuntime) {
|
|
259
|
+
const result = await config.hooks.generateRuntime(ctx, payload);
|
|
260
|
+
if (Array.isArray(result)) {
|
|
261
|
+
paths.push(...result);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return paths;
|
|
265
|
+
}
|
|
266
|
+
async function dispatchIndexFile(config, pluginName, ctx, payload) {
|
|
267
|
+
if (!config.hooks.indexFile) return;
|
|
268
|
+
const { projectRoot, runtimeDir } = readProjectConfig(ctx.db);
|
|
269
|
+
const targetPath = join(projectRoot, runtimeDir, "index.ts");
|
|
270
|
+
const content = await config.hooks.indexFile(ctx, { ...payload, filepath: targetPath });
|
|
271
|
+
if (typeof content === "string" && content) {
|
|
272
|
+
const existing = existsSync(targetPath) ? readFileSync(targetPath, "utf8") : "";
|
|
273
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
274
|
+
writeFileSync(targetPath, existing + "\n" + content, "utf8");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function readProjectConfig(db) {
|
|
278
|
+
const row = db.get(
|
|
279
|
+
"SELECT project_root, runtime_dir FROM config LIMIT 1"
|
|
280
|
+
);
|
|
281
|
+
return { projectRoot: row?.project_root ?? "", runtimeDir: row?.runtime_dir ?? "" };
|
|
282
|
+
}
|
|
283
|
+
function pluginRuntimeDir(projectRoot, runtimeDir, name) {
|
|
284
|
+
if (name === "houdini-core") {
|
|
285
|
+
return join(projectRoot, runtimeDir, "runtime");
|
|
286
|
+
}
|
|
287
|
+
return join(projectRoot, runtimeDir, "plugins", name, "runtime");
|
|
288
|
+
}
|
|
289
|
+
function pluginStaticRuntimeDir(projectRoot, runtimeDir, name) {
|
|
290
|
+
return join(projectRoot, runtimeDir, "plugins", name, "static");
|
|
291
|
+
}
|
|
292
|
+
async function recursiveCopy(src, dst, transform) {
|
|
293
|
+
const written = [];
|
|
294
|
+
if (!existsSync(src)) return written;
|
|
295
|
+
const walk = async (srcDir, dstDir) => {
|
|
296
|
+
mkdirSync(dstDir, { recursive: true });
|
|
297
|
+
for (const entry of readdirSync(srcDir)) {
|
|
298
|
+
const srcPath = join(srcDir, entry);
|
|
299
|
+
const dstPath = join(dstDir, entry);
|
|
300
|
+
if (statSync(srcPath).isDirectory()) {
|
|
301
|
+
await walk(srcPath, dstPath);
|
|
302
|
+
} else {
|
|
303
|
+
let content = readFileSync(srcPath, "utf8");
|
|
304
|
+
if (transform) content = await transform(srcPath, content);
|
|
305
|
+
mkdirSync(dirname(dstPath), { recursive: true });
|
|
306
|
+
writeFileSync(dstPath, content, "utf8");
|
|
307
|
+
written.push(dstPath);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
await walk(src, dst);
|
|
312
|
+
return written;
|
|
313
|
+
}
|
|
314
|
+
function registeredHookNames(config) {
|
|
315
|
+
const names = /* @__PURE__ */ new Set();
|
|
316
|
+
names.add("config");
|
|
317
|
+
if (config.staticRuntime || config.hooks.afterLoad || config.hooks.config) {
|
|
318
|
+
names.add("afterLoad");
|
|
319
|
+
}
|
|
320
|
+
if (config.includeRuntime !== void 0 || config.hooks.generateRuntime || config.configModule !== void 0) {
|
|
321
|
+
names.add("generateRuntime");
|
|
322
|
+
}
|
|
323
|
+
for (const key of Object.keys(config.hooks)) {
|
|
324
|
+
if (typeof config.hooks[key] === "function") {
|
|
325
|
+
names.add(key);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return Array.from(names);
|
|
329
|
+
}
|
|
330
|
+
function makeStdioChannel() {
|
|
331
|
+
const pending = /* @__PURE__ */ new Map();
|
|
332
|
+
const invokeCounter = { value: 0 };
|
|
333
|
+
const rl = createInterface({ input: process.stdin });
|
|
334
|
+
return { pending, invokeCounter, rl };
|
|
335
|
+
}
|
|
336
|
+
function makeInvokeHook(pending, counter, taskId) {
|
|
337
|
+
return (hook, payload, opts) => new Promise((resolve, reject) => {
|
|
338
|
+
const id = `node-invoke-${++counter.value}`;
|
|
339
|
+
pending.set(id, { resolve, reject });
|
|
340
|
+
stdioWrite({
|
|
341
|
+
id,
|
|
342
|
+
type: "invoke",
|
|
343
|
+
hook: toWireName(hook),
|
|
344
|
+
payload: payload ?? {},
|
|
345
|
+
taskId,
|
|
346
|
+
parallel: opts?.parallel ?? false
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function resolveInvoke(pending, msg) {
|
|
351
|
+
const entry = pending.get(msg.id);
|
|
352
|
+
if (!entry) return;
|
|
353
|
+
pending.delete(msg.id);
|
|
354
|
+
if (msg.error) {
|
|
355
|
+
const message = typeof msg.error === "string" ? msg.error : msg.error?.message ?? "invoke error";
|
|
356
|
+
entry.reject(new Error(message));
|
|
357
|
+
} else {
|
|
358
|
+
entry.resolve(msg.result ?? {});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function shutdown(db, server) {
|
|
362
|
+
try {
|
|
363
|
+
db.close();
|
|
364
|
+
} catch {
|
|
365
|
+
}
|
|
366
|
+
server.close();
|
|
367
|
+
process.exit(0);
|
|
368
|
+
}
|
|
369
|
+
function parseArgs() {
|
|
370
|
+
const argv = process.argv;
|
|
371
|
+
let transport = "websocket";
|
|
372
|
+
let database = "";
|
|
373
|
+
let pluginKey = "";
|
|
374
|
+
for (let i = 2; i < argv.length; i++) {
|
|
375
|
+
if (argv[i] === "--transport" && i + 1 < argv.length) transport = argv[++i];
|
|
376
|
+
else if (argv[i] === "--database" && i + 1 < argv.length) database = argv[++i];
|
|
377
|
+
else if (argv[i] === "--plugin-key" && i + 1 < argv.length) pluginKey = argv[++i];
|
|
378
|
+
}
|
|
379
|
+
return { transport, database, pluginKey };
|
|
380
|
+
}
|
|
381
|
+
function stdioWrite(obj) {
|
|
382
|
+
process.stdout.write(`${JSON.stringify(obj)}
|
|
383
|
+
`);
|
|
384
|
+
}
|
|
385
|
+
function toWireName(name) {
|
|
386
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
387
|
+
}
|
|
388
|
+
function serializeError(err) {
|
|
389
|
+
if (err instanceof PluginError) {
|
|
390
|
+
const out = { message: err.message };
|
|
391
|
+
if (err.detail) out.detail = err.detail;
|
|
392
|
+
if (err.locations) out.locations = err.locations;
|
|
393
|
+
if (err.kind) out.kind = err.kind;
|
|
394
|
+
return out;
|
|
395
|
+
}
|
|
396
|
+
if (err instanceof Error) return { message: err.message };
|
|
397
|
+
return { message: String(err) };
|
|
398
|
+
}
|
|
399
|
+
export {
|
|
400
|
+
PluginError,
|
|
401
|
+
plugin
|
|
402
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as oauth from 'oauth4webapi';
|
|
2
|
+
export type OAuthUser = {
|
|
3
|
+
sub: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
emailVerified?: boolean;
|
|
6
|
+
name?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type OAuthTokens = {
|
|
10
|
+
accessToken: string;
|
|
11
|
+
refreshToken?: string;
|
|
12
|
+
expiresAt?: number;
|
|
13
|
+
scope?: string;
|
|
14
|
+
idToken?: string;
|
|
15
|
+
};
|
|
16
|
+
export type IdTokenClaims = oauth.IDToken;
|
|
17
|
+
export type AuthorizationServer = oauth.AuthorizationServer;
|
|
18
|
+
export type OAuthProvider = {
|
|
19
|
+
clientId: string;
|
|
20
|
+
clientSecret: string;
|
|
21
|
+
scopes: string[];
|
|
22
|
+
pkce: 'S256' | false;
|
|
23
|
+
issuer?: string;
|
|
24
|
+
allowInsecureRequests?: boolean;
|
|
25
|
+
server: () => Promise<AuthorizationServer>;
|
|
26
|
+
user: (args: {
|
|
27
|
+
tokens: OAuthTokens;
|
|
28
|
+
claims?: IdTokenClaims;
|
|
29
|
+
}) => Promise<OAuthUser> | OAuthUser;
|
|
30
|
+
};
|
|
31
|
+
export type OAuthProviderConfig = {
|
|
32
|
+
clientId: string;
|
|
33
|
+
clientSecret: string;
|
|
34
|
+
scopes?: string[];
|
|
35
|
+
allowInsecureRequests?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare function github(config: OAuthProviderConfig): OAuthProvider;
|
|
38
|
+
export type OIDCProviderConfig = OAuthProviderConfig & {
|
|
39
|
+
issuer: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function oidc(config: OIDCProviderConfig): OAuthProvider;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as oauth from "oauth4webapi";
|
|
2
|
+
function isLoopbackHost(host) {
|
|
3
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.endsWith(".localhost");
|
|
4
|
+
}
|
|
5
|
+
function insecureGate(requested, url) {
|
|
6
|
+
if (!requested) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
let host = "";
|
|
10
|
+
try {
|
|
11
|
+
host = new URL(url).hostname;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (isLoopbackHost(host)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
console.warn(
|
|
19
|
+
`[houdini] ignoring allowInsecureRequests for non-loopback OAuth host "${host}" \u2014 http is only permitted for local development`
|
|
20
|
+
);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
function github(config) {
|
|
24
|
+
const as = {
|
|
25
|
+
issuer: "https://github.com",
|
|
26
|
+
authorization_endpoint: "https://github.com/login/oauth/authorize",
|
|
27
|
+
token_endpoint: "https://github.com/login/oauth/access_token"
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
clientId: config.clientId,
|
|
31
|
+
clientSecret: config.clientSecret,
|
|
32
|
+
scopes: config.scopes ?? ["read:user", "user:email"],
|
|
33
|
+
pkce: "S256",
|
|
34
|
+
allowInsecureRequests: insecureGate(config.allowInsecureRequests, as.token_endpoint),
|
|
35
|
+
// no `issuer` → non-OIDC: no id_token to validate, the user comes from the REST API
|
|
36
|
+
server: async () => as,
|
|
37
|
+
user: async ({ tokens }) => {
|
|
38
|
+
const headers = {
|
|
39
|
+
Authorization: `Bearer ${tokens.accessToken}`,
|
|
40
|
+
Accept: "application/vnd.github+json",
|
|
41
|
+
"User-Agent": "houdini"
|
|
42
|
+
};
|
|
43
|
+
const [user, emails] = await Promise.all([
|
|
44
|
+
// fail closed on a non-2xx /user (rate limit, revoked token): GitHub returns a JSON
|
|
45
|
+
// error body with no `id`, which would otherwise collapse to sub="undefined" and key
|
|
46
|
+
// every failed login to the same account. Throw so the callback denies instead.
|
|
47
|
+
fetch("https://api.github.com/user", { headers }).then((r) => {
|
|
48
|
+
if (!r.ok) {
|
|
49
|
+
throw new Error(`github /user request failed (${r.status})`);
|
|
50
|
+
}
|
|
51
|
+
return r.json();
|
|
52
|
+
}),
|
|
53
|
+
fetch("https://api.github.com/user/emails", { headers }).then((r) => r.json()).catch(() => [])
|
|
54
|
+
]);
|
|
55
|
+
const verifiedEmail = Array.isArray(emails) ? emails.find((e) => e.primary && e.verified)?.email : void 0;
|
|
56
|
+
return {
|
|
57
|
+
sub: String(user.id),
|
|
58
|
+
email: verifiedEmail,
|
|
59
|
+
emailVerified: verifiedEmail ? true : void 0,
|
|
60
|
+
name: user.name ?? user.login,
|
|
61
|
+
login: user.login,
|
|
62
|
+
avatarUrl: user.avatar_url
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function oidc(config) {
|
|
68
|
+
let cache = null;
|
|
69
|
+
const issuerUrl = new URL(config.issuer);
|
|
70
|
+
const allowInsecure = insecureGate(config.allowInsecureRequests, config.issuer);
|
|
71
|
+
return {
|
|
72
|
+
clientId: config.clientId,
|
|
73
|
+
clientSecret: config.clientSecret,
|
|
74
|
+
scopes: config.scopes ?? ["openid", "email", "profile"],
|
|
75
|
+
pkce: "S256",
|
|
76
|
+
issuer: config.issuer,
|
|
77
|
+
allowInsecureRequests: allowInsecure,
|
|
78
|
+
server: () => {
|
|
79
|
+
if (!cache) {
|
|
80
|
+
cache = oauth.discoveryRequest(issuerUrl, {
|
|
81
|
+
algorithm: "oidc",
|
|
82
|
+
[oauth.allowInsecureRequests]: allowInsecure
|
|
83
|
+
}).then((response) => oauth.processDiscoveryResponse(issuerUrl, response));
|
|
84
|
+
cache.catch(() => {
|
|
85
|
+
cache = null;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return cache;
|
|
89
|
+
},
|
|
90
|
+
user: ({ claims }) => {
|
|
91
|
+
if (!claims) {
|
|
92
|
+
throw new Error("oidc provider: the token response carried no id_token");
|
|
93
|
+
}
|
|
94
|
+
const verified = claims.email_verified === true;
|
|
95
|
+
const email = verified ? claims.email : void 0;
|
|
96
|
+
return {
|
|
97
|
+
sub: claims.sub,
|
|
98
|
+
email,
|
|
99
|
+
emailVerified: email ? true : void 0,
|
|
100
|
+
name: claims.name
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
github,
|
|
107
|
+
oidc
|
|
108
|
+
};
|