houdini 2.0.0-next.8 → 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 -89304
- package/build/cmd-cjs/package.json +0 -1
- package/build/cmd-esm/index.js +0 -89308
- 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 -74661
- package/build/codegen-cjs/package.json +0 -1
- package/build/codegen-esm/index.js +0 -74660
- 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 -79736
- package/build/lib-cjs/package.json +0 -1
- package/build/lib-esm/index.js +0 -79645
- 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 -43
- 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-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 -43
- package/build/runtime-cjs/public/cache.js +0 -112
- 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 -112
- package/build/runtime-cjs/router/session.d.ts +0 -22
- package/build/runtime-cjs/router/session.js +0 -97
- package/build/runtime-cjs/router/types.d.ts +0 -26
- package/build/runtime-cjs/router/types.js +0 -16
- 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 -43
- package/build/runtime-esm/public/cache.js +0 -88
- 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 -87
- package/build/runtime-esm/router/session.d.ts +0 -22
- package/build/runtime-esm/router/session.js +0 -71
- package/build/runtime-esm/router/types.d.ts +0 -26
- package/build/runtime-esm/router/types.js +0 -0
- package/build/test-cjs/index.js +0 -75254
- package/build/test-cjs/package.json +0 -1
- package/build/test-esm/index.js +0 -75249
- package/build/vite/imports.d.ts +0 -40
- package/build/vite-cjs/index.js +0 -86271
- package/build/vite-cjs/package.json +0 -1
- package/build/vite-esm/index.js +0 -86263
- /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
|
@@ -1,1077 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cache_exports = {};
|
|
20
|
-
__export(cache_exports, {
|
|
21
|
-
Cache: () => Cache,
|
|
22
|
-
defaultComponentField: () => defaultComponentField,
|
|
23
|
-
evaluateVariables: () => evaluateVariables,
|
|
24
|
-
fragmentReference: () => fragmentReference,
|
|
25
|
-
variableValue: () => variableValue
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(cache_exports);
|
|
28
|
-
var import_lib = require("../lib");
|
|
29
|
-
var import_config = require("../lib/config");
|
|
30
|
-
var import_deepEquals = require("../lib/deepEquals");
|
|
31
|
-
var import_flatten = require("../lib/flatten");
|
|
32
|
-
var import_selection = require("../lib/selection");
|
|
33
|
-
var import_types = require("../lib/types");
|
|
34
|
-
var import_gc = require("./gc");
|
|
35
|
-
var import_lists = require("./lists");
|
|
36
|
-
var import_staleManager = require("./staleManager");
|
|
37
|
-
var import_storage = require("./storage");
|
|
38
|
-
var import_stuff = require("./stuff");
|
|
39
|
-
var import_subscription = require("./subscription");
|
|
40
|
-
class Cache {
|
|
41
|
-
// the internal implementation for a lot of the cache's methods are moved into
|
|
42
|
-
// a second class to avoid users from relying on unstable APIs. typescript's private
|
|
43
|
-
// label accomplishes this but would not prevent someone using vanilla js
|
|
44
|
-
_internal_unstable;
|
|
45
|
-
constructor({
|
|
46
|
-
disabled,
|
|
47
|
-
componentCache,
|
|
48
|
-
createComponent,
|
|
49
|
-
...config
|
|
50
|
-
} = {}) {
|
|
51
|
-
this._internal_unstable = new CacheInternal({
|
|
52
|
-
cache: this,
|
|
53
|
-
storage: new import_storage.InMemoryStorage(),
|
|
54
|
-
subscriptions: new import_subscription.InMemorySubscriptions(this),
|
|
55
|
-
lists: new import_lists.ListManager(this, import_stuff.rootID),
|
|
56
|
-
lifetimes: new import_gc.GarbageCollector(this),
|
|
57
|
-
staleManager: new import_staleManager.StaleManager(this),
|
|
58
|
-
disabled: disabled ?? typeof globalThis.window === "undefined",
|
|
59
|
-
componentCache,
|
|
60
|
-
createComponent
|
|
61
|
-
});
|
|
62
|
-
if (Object.keys(config).length > 0) {
|
|
63
|
-
this.setConfig((0, import_config.defaultConfigValues)(config));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// walk down the selection and save the values that we encounter.
|
|
67
|
-
// any changes will notify subscribers. writing to an optimistic layer will resolve it
|
|
68
|
-
write({
|
|
69
|
-
layer: layerID,
|
|
70
|
-
notifySubscribers = [],
|
|
71
|
-
...args
|
|
72
|
-
}) {
|
|
73
|
-
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
74
|
-
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
75
|
-
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
76
|
-
return subscribers;
|
|
77
|
-
}
|
|
78
|
-
// reconstruct an object with the fields/relations specified by a selection
|
|
79
|
-
read(...args) {
|
|
80
|
-
const { data, partial, stale, hasData } = this._internal_unstable.getSelection(...args);
|
|
81
|
-
if (!hasData) {
|
|
82
|
-
return { data: null, partial: false, stale: false };
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
data,
|
|
86
|
-
partial,
|
|
87
|
-
stale
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// register the provided callbacks with the fields specified by the selection
|
|
91
|
-
subscribe(spec, variables = {}) {
|
|
92
|
-
if (this._internal_unstable.disabled) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
return this._internal_unstable.subscriptions.add({
|
|
96
|
-
parent: spec.parentID || import_stuff.rootID,
|
|
97
|
-
spec,
|
|
98
|
-
selection: spec.selection,
|
|
99
|
-
variables
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// stop listening to a particular subscription
|
|
103
|
-
unsubscribe(spec, variables = {}) {
|
|
104
|
-
return this._internal_unstable.subscriptions.remove(
|
|
105
|
-
spec.parentID || import_stuff.rootID,
|
|
106
|
-
spec.selection,
|
|
107
|
-
[spec],
|
|
108
|
-
variables
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
// return the list handler to mutate a named list in the cache
|
|
112
|
-
list(name, parentID, allLists, skipMatches) {
|
|
113
|
-
const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
|
|
114
|
-
if (!handler) {
|
|
115
|
-
throw new Error(
|
|
116
|
-
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return handler;
|
|
120
|
-
}
|
|
121
|
-
// when an optimistic key resolves, we might momentarily know the same record by different IDs
|
|
122
|
-
registerKeyMap(source, mapped) {
|
|
123
|
-
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
124
|
-
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
125
|
-
}
|
|
126
|
-
// remove the record from the cache's store and unsubscribe from it
|
|
127
|
-
delete(id, layer) {
|
|
128
|
-
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
129
|
-
Boolean
|
|
130
|
-
);
|
|
131
|
-
for (const recordID of recordIDs) {
|
|
132
|
-
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
133
|
-
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
134
|
-
this._internal_unstable.storage.delete(recordID, layer);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// set the cache's config
|
|
138
|
-
setConfig(config) {
|
|
139
|
-
this._internal_unstable.setConfig(config);
|
|
140
|
-
}
|
|
141
|
-
markTypeStale(options) {
|
|
142
|
-
if (!options) {
|
|
143
|
-
this._internal_unstable.staleManager.markAllStale();
|
|
144
|
-
} else if (!options.field) {
|
|
145
|
-
this._internal_unstable.staleManager.markTypeStale(options.type);
|
|
146
|
-
} else {
|
|
147
|
-
this._internal_unstable.staleManager.markTypeFieldStale(
|
|
148
|
-
options.type,
|
|
149
|
-
options.field,
|
|
150
|
-
options.when
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
markRecordStale(id, options) {
|
|
155
|
-
if (options.field) {
|
|
156
|
-
const key = (0, import_lib.computeKey)({ field: options.field, args: options.when ?? {} });
|
|
157
|
-
this._internal_unstable.staleManager.markFieldStale(id, key);
|
|
158
|
-
} else {
|
|
159
|
-
this._internal_unstable.staleManager.markRecordStale(id);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
getFieldTime(id, field) {
|
|
163
|
-
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
164
|
-
}
|
|
165
|
-
config() {
|
|
166
|
-
return this._internal_unstable.config;
|
|
167
|
-
}
|
|
168
|
-
serialize() {
|
|
169
|
-
return this._internal_unstable.storage.serialize();
|
|
170
|
-
}
|
|
171
|
-
hydrate(...args) {
|
|
172
|
-
return this._internal_unstable.storage.hydrate(...args);
|
|
173
|
-
}
|
|
174
|
-
clearLayer(layerID) {
|
|
175
|
-
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
176
|
-
if (!layer) {
|
|
177
|
-
throw new Error("Cannot find layer with id: " + layerID);
|
|
178
|
-
}
|
|
179
|
-
const toNotify = [];
|
|
180
|
-
const allFields = [];
|
|
181
|
-
for (const target of [layer.fields, layer.links]) {
|
|
182
|
-
for (const [id, fields] of Object.entries(target)) {
|
|
183
|
-
allFields.push(
|
|
184
|
-
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const displayFields = [];
|
|
189
|
-
for (const pair of allFields) {
|
|
190
|
-
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
191
|
-
if (!displayLayers.includes(layerID)) {
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
displayFields.push(pair);
|
|
195
|
-
}
|
|
196
|
-
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
197
|
-
if (operation.deleted) {
|
|
198
|
-
displayFields.push(
|
|
199
|
-
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
const fields = Object.keys(operation.fields ?? {});
|
|
203
|
-
if (fields.length > 0) {
|
|
204
|
-
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
layer.clear();
|
|
208
|
-
for (const display of displayFields) {
|
|
209
|
-
const { field, id } = display;
|
|
210
|
-
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
211
|
-
if (notify) {
|
|
212
|
-
toNotify.push(
|
|
213
|
-
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this.#notifySubscribers(toNotify);
|
|
218
|
-
}
|
|
219
|
-
// reset the whole cache
|
|
220
|
-
reset() {
|
|
221
|
-
const subSpecs = this._internal_unstable.subscriptions.reset();
|
|
222
|
-
this._internal_unstable.staleManager.reset();
|
|
223
|
-
this._internal_unstable.lifetimes.reset();
|
|
224
|
-
this._internal_unstable.lists.reset();
|
|
225
|
-
this._internal_unstable.storage.reset();
|
|
226
|
-
this.#notifySubscribers(subSpecs);
|
|
227
|
-
}
|
|
228
|
-
#notifySubscribers(subs) {
|
|
229
|
-
if (subs.length === 0) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const notified = [];
|
|
233
|
-
for (const spec of subs) {
|
|
234
|
-
if (!notified.includes(spec.set)) {
|
|
235
|
-
notified.push(spec.set);
|
|
236
|
-
spec.set(
|
|
237
|
-
this._internal_unstable.getSelection({
|
|
238
|
-
parent: spec.parentID || import_stuff.rootID,
|
|
239
|
-
selection: spec.selection,
|
|
240
|
-
variables: spec.variables?.() || {},
|
|
241
|
-
ignoreMasking: false
|
|
242
|
-
}).data
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
class CacheInternal {
|
|
249
|
-
// for server-side requests we need to be able to flag the cache as disabled so we dont write to it
|
|
250
|
-
disabled = false;
|
|
251
|
-
_config;
|
|
252
|
-
storage;
|
|
253
|
-
subscriptions;
|
|
254
|
-
lists;
|
|
255
|
-
cache;
|
|
256
|
-
lifetimes;
|
|
257
|
-
staleManager;
|
|
258
|
-
componentCache;
|
|
259
|
-
createComponent;
|
|
260
|
-
constructor({
|
|
261
|
-
storage,
|
|
262
|
-
subscriptions,
|
|
263
|
-
lists,
|
|
264
|
-
cache,
|
|
265
|
-
lifetimes,
|
|
266
|
-
staleManager,
|
|
267
|
-
disabled,
|
|
268
|
-
config,
|
|
269
|
-
componentCache,
|
|
270
|
-
createComponent
|
|
271
|
-
}) {
|
|
272
|
-
this.storage = storage;
|
|
273
|
-
this.subscriptions = subscriptions;
|
|
274
|
-
this.lists = lists;
|
|
275
|
-
this.cache = cache;
|
|
276
|
-
this.lifetimes = lifetimes;
|
|
277
|
-
this.staleManager = staleManager;
|
|
278
|
-
this._config = config;
|
|
279
|
-
this.componentCache = componentCache ?? {};
|
|
280
|
-
this.createComponent = createComponent ?? (() => ({}));
|
|
281
|
-
this.disabled = disabled;
|
|
282
|
-
try {
|
|
283
|
-
if (process.env.HOUDINI_TEST === "true") {
|
|
284
|
-
this.disabled = false;
|
|
285
|
-
}
|
|
286
|
-
} catch {
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
get config() {
|
|
290
|
-
return this._config ?? (0, import_config.getCurrentConfig)();
|
|
291
|
-
}
|
|
292
|
-
setConfig(config) {
|
|
293
|
-
this._config = config;
|
|
294
|
-
}
|
|
295
|
-
writeSelection({
|
|
296
|
-
data,
|
|
297
|
-
selection,
|
|
298
|
-
variables = {},
|
|
299
|
-
parent = import_stuff.rootID,
|
|
300
|
-
applyUpdates,
|
|
301
|
-
layer,
|
|
302
|
-
toNotify = [],
|
|
303
|
-
forceNotify,
|
|
304
|
-
forceStale
|
|
305
|
-
}) {
|
|
306
|
-
if (this.disabled) {
|
|
307
|
-
return [];
|
|
308
|
-
}
|
|
309
|
-
let targetSelection = (0, import_selection.getFieldsForType)(
|
|
310
|
-
selection,
|
|
311
|
-
data["__typename"],
|
|
312
|
-
false
|
|
313
|
-
);
|
|
314
|
-
for (const [field, value] of Object.entries(data)) {
|
|
315
|
-
if (!selection || !targetSelection[field]) {
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
let {
|
|
319
|
-
type: linkedType,
|
|
320
|
-
keyRaw,
|
|
321
|
-
selection: fieldSelection,
|
|
322
|
-
operations,
|
|
323
|
-
abstract: isAbstract,
|
|
324
|
-
updates
|
|
325
|
-
} = targetSelection[field];
|
|
326
|
-
const key = (0, import_stuff.evaluateKey)(keyRaw, variables);
|
|
327
|
-
if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
|
|
328
|
-
linkedType = value["__typename"];
|
|
329
|
-
}
|
|
330
|
-
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
331
|
-
const specs = currentSubscribers.map((sub) => sub[0]);
|
|
332
|
-
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
333
|
-
const displayLayer = layer.isDisplayLayer(displayLayers);
|
|
334
|
-
if (displayLayer) {
|
|
335
|
-
this.lifetimes.resetLifetime(parent, key);
|
|
336
|
-
if (forceStale) {
|
|
337
|
-
this.staleManager.markFieldStale(parent, key);
|
|
338
|
-
} else {
|
|
339
|
-
this.staleManager.setFieldTimeToNow(parent, key);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
if (!fieldSelection) {
|
|
343
|
-
let newValue = value;
|
|
344
|
-
if (updates && applyUpdates && Array.isArray(value)) {
|
|
345
|
-
for (const update of applyUpdates) {
|
|
346
|
-
if (!updates.includes(update)) {
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
if (update === "append") {
|
|
350
|
-
newValue = (previousValue || []).concat(value);
|
|
351
|
-
} else if (update === "prepend") {
|
|
352
|
-
newValue = value.concat(previousValue || []);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (updates && applyUpdates?.includes("prepend") && ["endCursor", "hasNextPage"].includes(key)) {
|
|
357
|
-
newValue = previousValue;
|
|
358
|
-
} else if (updates && applyUpdates?.includes("append") && ["startCursor", "hasPreviousPage"].includes(key)) {
|
|
359
|
-
newValue = previousValue;
|
|
360
|
-
}
|
|
361
|
-
const valueChanged = !(0, import_deepEquals.deepEquals)(newValue, previousValue);
|
|
362
|
-
if (displayLayer && (valueChanged || forceNotify)) {
|
|
363
|
-
toNotify.push(...currentSubscribers);
|
|
364
|
-
}
|
|
365
|
-
layer.writeField(parent, key, newValue);
|
|
366
|
-
} else if (value === null) {
|
|
367
|
-
if (previousValue === null) {
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
const previousLinks = (0, import_flatten.flatten)([previousValue]);
|
|
371
|
-
for (const link of previousLinks) {
|
|
372
|
-
this.subscriptions.remove(link, fieldSelection, specs, variables);
|
|
373
|
-
}
|
|
374
|
-
layer.writeLink(parent, key, null);
|
|
375
|
-
toNotify.push(...currentSubscribers);
|
|
376
|
-
} else if (value instanceof Object && !Array.isArray(value)) {
|
|
377
|
-
if (isAbstract) {
|
|
378
|
-
if (!value.__typename) {
|
|
379
|
-
throw new Error(
|
|
380
|
-
"Encountered interface type without __typename in the payload"
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
let linkedID = null;
|
|
385
|
-
if (value !== null) {
|
|
386
|
-
linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent}.${key}`;
|
|
387
|
-
}
|
|
388
|
-
let linkChange = linkedID !== previousValue;
|
|
389
|
-
layer.writeLink(parent, key, linkedID);
|
|
390
|
-
if (linkedID && displayLayer && (linkChange || forceNotify)) {
|
|
391
|
-
if (previousValue && typeof previousValue === "string") {
|
|
392
|
-
this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
|
|
393
|
-
}
|
|
394
|
-
this.subscriptions.addMany({
|
|
395
|
-
parent: linkedID,
|
|
396
|
-
subscribers: currentSubscribers,
|
|
397
|
-
variables,
|
|
398
|
-
parentType: linkedType
|
|
399
|
-
});
|
|
400
|
-
toNotify.push(...currentSubscribers);
|
|
401
|
-
}
|
|
402
|
-
if (linkedID) {
|
|
403
|
-
this.writeSelection({
|
|
404
|
-
selection: fieldSelection,
|
|
405
|
-
parent: linkedID,
|
|
406
|
-
data: value,
|
|
407
|
-
variables,
|
|
408
|
-
toNotify,
|
|
409
|
-
applyUpdates,
|
|
410
|
-
layer,
|
|
411
|
-
forceNotify
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
} else if (Array.isArray(value) && // make typescript happy
|
|
415
|
-
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
416
|
-
let oldIDs = [...previousValue || []];
|
|
417
|
-
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
418
|
-
oldIDs = oldIDs.filter((id) => {
|
|
419
|
-
for (const layer2 of this.storage.data) {
|
|
420
|
-
for (const operation of Object.values(layer2.operations)) {
|
|
421
|
-
if (operation.fields?.[key])
|
|
422
|
-
for (const listOperation of operation.fields[key]) {
|
|
423
|
-
if ("id" in listOperation && listOperation.id === id) {
|
|
424
|
-
return false;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return true;
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
let linkedIDs = [];
|
|
433
|
-
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
434
|
-
value,
|
|
435
|
-
abstract: Boolean(isAbstract),
|
|
436
|
-
specs: toNotify,
|
|
437
|
-
applyUpdates,
|
|
438
|
-
recordID: parent,
|
|
439
|
-
key,
|
|
440
|
-
linkedType,
|
|
441
|
-
variables,
|
|
442
|
-
fields: fieldSelection,
|
|
443
|
-
layer,
|
|
444
|
-
forceNotify
|
|
445
|
-
});
|
|
446
|
-
let action = () => {
|
|
447
|
-
layer.writeLink(parent, key, linkedIDs);
|
|
448
|
-
};
|
|
449
|
-
if (applyUpdates && updates) {
|
|
450
|
-
const filterIDs = (keep, insert) => {
|
|
451
|
-
const existingIDs = /* @__PURE__ */ new Set();
|
|
452
|
-
for (const id of keep) {
|
|
453
|
-
if (!id) {
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
const { value: node } = this.storage.get(id, "node");
|
|
457
|
-
if (!node) {
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
const nodeID = this.storage.get(node, "id");
|
|
461
|
-
if (!nodeID) {
|
|
462
|
-
continue;
|
|
463
|
-
}
|
|
464
|
-
existingIDs.add(nodeID.value);
|
|
465
|
-
}
|
|
466
|
-
return insert.filter((id) => {
|
|
467
|
-
if (!id) {
|
|
468
|
-
return true;
|
|
469
|
-
}
|
|
470
|
-
const { value: node } = this.storage.get(id, "node");
|
|
471
|
-
if (!node) {
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
const nodeID = this.storage.get(node, "id");
|
|
475
|
-
if (!nodeID) {
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
return !existingIDs.has(nodeID.value);
|
|
479
|
-
});
|
|
480
|
-
};
|
|
481
|
-
for (const update of applyUpdates) {
|
|
482
|
-
if (update !== "replace" && !updates.includes(update)) {
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
if (update === "prepend") {
|
|
486
|
-
linkedIDs = newIDs.concat(
|
|
487
|
-
filterIDs(newIDs, oldIDs)
|
|
488
|
-
);
|
|
489
|
-
if (layer?.optimistic) {
|
|
490
|
-
action = () => {
|
|
491
|
-
for (const id of newIDs) {
|
|
492
|
-
if (id) {
|
|
493
|
-
layer.insert(parent, key, "start", id);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
} else if (update === "append") {
|
|
499
|
-
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
500
|
-
if (layer?.optimistic) {
|
|
501
|
-
action = () => {
|
|
502
|
-
for (const id of newIDs) {
|
|
503
|
-
if (id) {
|
|
504
|
-
layer.insert(parent, key, "end", id);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
} else if (update === "replace") {
|
|
510
|
-
linkedIDs = newIDs;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
} else {
|
|
514
|
-
linkedIDs = nestedIDs;
|
|
515
|
-
}
|
|
516
|
-
const contentChanged = !(0, import_deepEquals.deepEquals)(linkedIDs, oldIDs) || previousValue === null;
|
|
517
|
-
if (contentChanged || forceNotify) {
|
|
518
|
-
toNotify.push(...currentSubscribers);
|
|
519
|
-
}
|
|
520
|
-
for (const lostID of oldIDs) {
|
|
521
|
-
if (linkedIDs.includes(lostID) || !lostID) {
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
525
|
-
}
|
|
526
|
-
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
527
|
-
action();
|
|
528
|
-
}
|
|
529
|
-
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
530
|
-
if (id == null) {
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
|
-
this.subscriptions.addMany({
|
|
534
|
-
parent: id,
|
|
535
|
-
subscribers: currentSubscribers,
|
|
536
|
-
variables,
|
|
537
|
-
parentType: linkedType
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
const processedOperations = /* @__PURE__ */ new Set();
|
|
542
|
-
for (const operation of operations || []) {
|
|
543
|
-
let parentID;
|
|
544
|
-
if (operation.parentID) {
|
|
545
|
-
if (operation.parentID.kind !== "Variable") {
|
|
546
|
-
parentID = operation.parentID.value;
|
|
547
|
-
} else {
|
|
548
|
-
const id = variables[operation.parentID.value];
|
|
549
|
-
if (typeof id !== "string") {
|
|
550
|
-
throw new Error("parentID value must be a string");
|
|
551
|
-
}
|
|
552
|
-
parentID = id;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (operation.list && !this.lists.get(operation.list, parentID, operation.target === "all")) {
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
const targets = Array.isArray(value) ? value : [value];
|
|
559
|
-
for (const target of targets) {
|
|
560
|
-
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
561
|
-
this.cache.list(
|
|
562
|
-
operation.list,
|
|
563
|
-
parentID,
|
|
564
|
-
operation.target === "all",
|
|
565
|
-
processedOperations
|
|
566
|
-
).when(operation.when).addToList(
|
|
567
|
-
fieldSelection,
|
|
568
|
-
target,
|
|
569
|
-
variables,
|
|
570
|
-
operation.position || "last",
|
|
571
|
-
layer
|
|
572
|
-
);
|
|
573
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
574
|
-
this.cache.list(
|
|
575
|
-
operation.list,
|
|
576
|
-
parentID,
|
|
577
|
-
operation.target === "all",
|
|
578
|
-
processedOperations
|
|
579
|
-
).when(operation.when).toggleElement({
|
|
580
|
-
selection: fieldSelection,
|
|
581
|
-
data: target,
|
|
582
|
-
variables,
|
|
583
|
-
where: operation.position || "last",
|
|
584
|
-
layer
|
|
585
|
-
});
|
|
586
|
-
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
587
|
-
this.cache.list(
|
|
588
|
-
operation.list,
|
|
589
|
-
parentID,
|
|
590
|
-
operation.target === "all",
|
|
591
|
-
processedOperations
|
|
592
|
-
).when(operation.when).remove(target, variables, layer);
|
|
593
|
-
} else if (operation.action === "delete" && operation.type && target) {
|
|
594
|
-
const targetID = this.id(operation.type, target);
|
|
595
|
-
if (!targetID) {
|
|
596
|
-
continue;
|
|
597
|
-
}
|
|
598
|
-
toNotify.push(
|
|
599
|
-
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
600
|
-
);
|
|
601
|
-
this.cache.delete(targetID, layer);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
if (operation.list) {
|
|
605
|
-
const matchingLists = this.cache.list(
|
|
606
|
-
operation.list,
|
|
607
|
-
parentID,
|
|
608
|
-
operation.target === "all"
|
|
609
|
-
);
|
|
610
|
-
for (const list of matchingLists.lists) {
|
|
611
|
-
processedOperations.add(list.fieldRef);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return toNotify;
|
|
617
|
-
}
|
|
618
|
-
// reconstruct an object defined by its selection
|
|
619
|
-
getSelection({
|
|
620
|
-
selection,
|
|
621
|
-
parent = import_stuff.rootID,
|
|
622
|
-
variables,
|
|
623
|
-
stepsFromConnection = null,
|
|
624
|
-
ignoreMasking,
|
|
625
|
-
fullCheck = false,
|
|
626
|
-
loading: generateLoading
|
|
627
|
-
}) {
|
|
628
|
-
if (parent === null) {
|
|
629
|
-
return { data: null, partial: false, stale: false, hasData: true };
|
|
630
|
-
}
|
|
631
|
-
const target = {};
|
|
632
|
-
if (selection.fragments) {
|
|
633
|
-
target[import_types.fragmentKey] = {
|
|
634
|
-
loading: Boolean(generateLoading),
|
|
635
|
-
values: Object.fromEntries(
|
|
636
|
-
Object.entries(selection.fragments).filter(([, value]) => !generateLoading || value.loading).map(([key, value]) => [
|
|
637
|
-
key,
|
|
638
|
-
{
|
|
639
|
-
parent,
|
|
640
|
-
variables: evaluateVariables(value.arguments, variables ?? {})
|
|
641
|
-
}
|
|
642
|
-
])
|
|
643
|
-
)
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
let hasData = !!selection.fragments;
|
|
647
|
-
let partial = false;
|
|
648
|
-
let cascadeNull = false;
|
|
649
|
-
let stale = false;
|
|
650
|
-
const typename = this.storage.get(parent, "__typename").value;
|
|
651
|
-
let targetSelection = (0, import_selection.getFieldsForType)(selection, typename, !!generateLoading);
|
|
652
|
-
for (const [
|
|
653
|
-
attributeName,
|
|
654
|
-
{
|
|
655
|
-
type,
|
|
656
|
-
keyRaw,
|
|
657
|
-
selection: fieldSelection,
|
|
658
|
-
nullable,
|
|
659
|
-
list,
|
|
660
|
-
visible,
|
|
661
|
-
directives,
|
|
662
|
-
loading: fieldLoading,
|
|
663
|
-
abstractHasRequired,
|
|
664
|
-
component
|
|
665
|
-
}
|
|
666
|
-
] of Object.entries(targetSelection)) {
|
|
667
|
-
if (!visible && !ignoreMasking && !fullCheck) {
|
|
668
|
-
continue;
|
|
669
|
-
}
|
|
670
|
-
const includeDirective = directives?.find((d) => {
|
|
671
|
-
return d.name === "include";
|
|
672
|
-
});
|
|
673
|
-
if (includeDirective) {
|
|
674
|
-
if (!evaluateVariables(includeDirective.arguments, variables ?? {})["if"]) {
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
const skipDirective = directives?.find((d) => {
|
|
679
|
-
return d.name === "skip";
|
|
680
|
-
});
|
|
681
|
-
if (skipDirective) {
|
|
682
|
-
if (evaluateVariables(skipDirective.arguments, variables ?? {})["if"]) {
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
const fieldTarget = visible || ignoreMasking ? target : {};
|
|
687
|
-
const key = (0, import_stuff.evaluateKey)(keyRaw, variables);
|
|
688
|
-
if (generateLoading && !fieldLoading) {
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
const defaultValue = !component ? void 0 : defaultComponentField({
|
|
692
|
-
cache: this.cache,
|
|
693
|
-
component,
|
|
694
|
-
variables,
|
|
695
|
-
parent
|
|
696
|
-
});
|
|
697
|
-
let { value } = this.storage.get(parent, key, defaultValue);
|
|
698
|
-
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
699
|
-
if (dt_field === null) {
|
|
700
|
-
stale = true;
|
|
701
|
-
}
|
|
702
|
-
if (generateLoading) {
|
|
703
|
-
value = void 0;
|
|
704
|
-
}
|
|
705
|
-
let nextStep = stepsFromConnection;
|
|
706
|
-
if (nextStep !== null) {
|
|
707
|
-
if (nextStep >= 2) {
|
|
708
|
-
nextStep = null;
|
|
709
|
-
} else {
|
|
710
|
-
nextStep += 1;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
if (list?.connection) {
|
|
714
|
-
nextStep = 0;
|
|
715
|
-
}
|
|
716
|
-
const embeddedCursor = key === "cursor" && stepsFromConnection === 1;
|
|
717
|
-
if (typeof value === "undefined" && !embeddedCursor) {
|
|
718
|
-
partial = true;
|
|
719
|
-
}
|
|
720
|
-
if (generateLoading && fieldLoading?.kind === "value") {
|
|
721
|
-
fieldTarget[attributeName] = import_lib.PendingValue;
|
|
722
|
-
hasData = true;
|
|
723
|
-
} else if (!generateLoading && typeof value === "undefined" || value === null) {
|
|
724
|
-
fieldTarget[attributeName] = null;
|
|
725
|
-
if (typeof value !== "undefined") {
|
|
726
|
-
hasData = true;
|
|
727
|
-
}
|
|
728
|
-
} else if (!fieldSelection) {
|
|
729
|
-
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
730
|
-
if (fnUnmarshal) {
|
|
731
|
-
if (Array.isArray(value)) {
|
|
732
|
-
fieldTarget[attributeName] = value.map(
|
|
733
|
-
(v) => fnUnmarshal(v)
|
|
734
|
-
);
|
|
735
|
-
} else {
|
|
736
|
-
fieldTarget[attributeName] = fnUnmarshal(value);
|
|
737
|
-
}
|
|
738
|
-
} else {
|
|
739
|
-
fieldTarget[attributeName] = value;
|
|
740
|
-
}
|
|
741
|
-
hasData = true;
|
|
742
|
-
} else if (Array.isArray(value)) {
|
|
743
|
-
const listValue = this.hydrateNestedList({
|
|
744
|
-
fields: fieldSelection,
|
|
745
|
-
variables,
|
|
746
|
-
linkedList: value,
|
|
747
|
-
stepsFromConnection: nextStep,
|
|
748
|
-
ignoreMasking: !!ignoreMasking,
|
|
749
|
-
fullCheck,
|
|
750
|
-
loading: generateLoading,
|
|
751
|
-
nullable: !!nullable
|
|
752
|
-
});
|
|
753
|
-
fieldTarget[attributeName] = listValue.data;
|
|
754
|
-
if (listValue.partial) {
|
|
755
|
-
partial = true;
|
|
756
|
-
}
|
|
757
|
-
if (listValue.cascadeNull) {
|
|
758
|
-
cascadeNull = true;
|
|
759
|
-
}
|
|
760
|
-
if (listValue.stale) {
|
|
761
|
-
stale = true;
|
|
762
|
-
}
|
|
763
|
-
if (listValue.hasData || value.length === 0) {
|
|
764
|
-
hasData = true;
|
|
765
|
-
}
|
|
766
|
-
} else {
|
|
767
|
-
const objectFields = this.getSelection({
|
|
768
|
-
parent: value,
|
|
769
|
-
selection: fieldSelection,
|
|
770
|
-
variables,
|
|
771
|
-
stepsFromConnection: nextStep,
|
|
772
|
-
ignoreMasking,
|
|
773
|
-
fullCheck,
|
|
774
|
-
loading: generateLoading
|
|
775
|
-
});
|
|
776
|
-
fieldTarget[attributeName] = objectFields.data;
|
|
777
|
-
if (objectFields.partial) {
|
|
778
|
-
partial = true;
|
|
779
|
-
}
|
|
780
|
-
if (objectFields.stale) {
|
|
781
|
-
stale = true;
|
|
782
|
-
}
|
|
783
|
-
if (objectFields.hasData) {
|
|
784
|
-
hasData = true;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
if (generateLoading && fieldLoading?.list) {
|
|
788
|
-
fieldTarget[attributeName] = wrapInLists(
|
|
789
|
-
Array.from({ length: fieldLoading.list.count }).fill(
|
|
790
|
-
fieldTarget[attributeName]
|
|
791
|
-
),
|
|
792
|
-
fieldLoading.list.depth - 1
|
|
793
|
-
);
|
|
794
|
-
}
|
|
795
|
-
if (fieldTarget[attributeName] === null && !nullable && !embeddedCursor) {
|
|
796
|
-
if (abstractHasRequired) {
|
|
797
|
-
target[attributeName] = {
|
|
798
|
-
__typename: "@required field missing; don't match this"
|
|
799
|
-
};
|
|
800
|
-
} else {
|
|
801
|
-
cascadeNull = true;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
return {
|
|
806
|
-
data: cascadeNull ? null : target,
|
|
807
|
-
// our value is considered true if there is some data but not everything
|
|
808
|
-
// has a full value
|
|
809
|
-
partial: !generateLoading && hasData && partial,
|
|
810
|
-
stale: hasData && stale,
|
|
811
|
-
hasData
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
id(type, data) {
|
|
815
|
-
const id = typeof data === "object" ? this.computeID(type, data) : data;
|
|
816
|
-
if (!id) {
|
|
817
|
-
return null;
|
|
818
|
-
}
|
|
819
|
-
if (!type) {
|
|
820
|
-
return id;
|
|
821
|
-
}
|
|
822
|
-
return type + ":" + id;
|
|
823
|
-
}
|
|
824
|
-
// the list of fields that we need in order to compute an objects id
|
|
825
|
-
idFields(type) {
|
|
826
|
-
return (0, import_config.keyFieldsForType)(this.config, type);
|
|
827
|
-
}
|
|
828
|
-
computeID(type, data) {
|
|
829
|
-
return (0, import_config.computeID)(this.config, type, data);
|
|
830
|
-
}
|
|
831
|
-
// figure out if this is an embedded object or a linked one by looking for all of the fields marked as
|
|
832
|
-
// required to compute the entity's id
|
|
833
|
-
isEmbedded(linkedType, value) {
|
|
834
|
-
const idFields = this.idFields(linkedType);
|
|
835
|
-
return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
|
|
836
|
-
}
|
|
837
|
-
hydrateNestedList({
|
|
838
|
-
fields,
|
|
839
|
-
variables,
|
|
840
|
-
linkedList,
|
|
841
|
-
stepsFromConnection,
|
|
842
|
-
ignoreMasking,
|
|
843
|
-
fullCheck,
|
|
844
|
-
loading,
|
|
845
|
-
nullable
|
|
846
|
-
}) {
|
|
847
|
-
const result = [];
|
|
848
|
-
let partialData = false;
|
|
849
|
-
let stale = false;
|
|
850
|
-
let hasValues = false;
|
|
851
|
-
let cascadeNull = false;
|
|
852
|
-
for (const entry of linkedList) {
|
|
853
|
-
if (Array.isArray(entry)) {
|
|
854
|
-
const nestedValue = this.hydrateNestedList({
|
|
855
|
-
fields,
|
|
856
|
-
nullable,
|
|
857
|
-
variables,
|
|
858
|
-
linkedList: entry,
|
|
859
|
-
stepsFromConnection,
|
|
860
|
-
ignoreMasking,
|
|
861
|
-
fullCheck,
|
|
862
|
-
loading
|
|
863
|
-
});
|
|
864
|
-
result.push(nestedValue.data);
|
|
865
|
-
if (nestedValue.partial) {
|
|
866
|
-
partialData = true;
|
|
867
|
-
}
|
|
868
|
-
if (nestedValue.cascadeNull) {
|
|
869
|
-
cascadeNull = true;
|
|
870
|
-
}
|
|
871
|
-
continue;
|
|
872
|
-
}
|
|
873
|
-
if (entry === null) {
|
|
874
|
-
result.push(entry);
|
|
875
|
-
continue;
|
|
876
|
-
}
|
|
877
|
-
const {
|
|
878
|
-
data,
|
|
879
|
-
partial,
|
|
880
|
-
stale: local_stale,
|
|
881
|
-
hasData
|
|
882
|
-
} = this.getSelection({
|
|
883
|
-
parent: entry,
|
|
884
|
-
selection: fields,
|
|
885
|
-
variables,
|
|
886
|
-
stepsFromConnection,
|
|
887
|
-
ignoreMasking,
|
|
888
|
-
fullCheck,
|
|
889
|
-
loading
|
|
890
|
-
});
|
|
891
|
-
if (data === null && !nullable) {
|
|
892
|
-
cascadeNull = true;
|
|
893
|
-
}
|
|
894
|
-
result.push(data);
|
|
895
|
-
if (partial) {
|
|
896
|
-
partialData = true;
|
|
897
|
-
}
|
|
898
|
-
if (local_stale) {
|
|
899
|
-
stale = true;
|
|
900
|
-
}
|
|
901
|
-
if (hasData) {
|
|
902
|
-
hasValues = true;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return {
|
|
906
|
-
data: result,
|
|
907
|
-
partial: partialData,
|
|
908
|
-
stale,
|
|
909
|
-
hasData: hasValues,
|
|
910
|
-
cascadeNull
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
extractNestedListIDs({
|
|
914
|
-
value,
|
|
915
|
-
abstract,
|
|
916
|
-
recordID,
|
|
917
|
-
key,
|
|
918
|
-
linkedType,
|
|
919
|
-
fields,
|
|
920
|
-
variables,
|
|
921
|
-
applyUpdates,
|
|
922
|
-
specs,
|
|
923
|
-
layer,
|
|
924
|
-
forceNotify
|
|
925
|
-
}) {
|
|
926
|
-
const nestedIDs = [];
|
|
927
|
-
const newIDs = [];
|
|
928
|
-
for (const [i, entry] of value.entries()) {
|
|
929
|
-
if (Array.isArray(entry)) {
|
|
930
|
-
const inner = this.extractNestedListIDs({
|
|
931
|
-
value: entry,
|
|
932
|
-
abstract,
|
|
933
|
-
recordID,
|
|
934
|
-
key,
|
|
935
|
-
linkedType,
|
|
936
|
-
fields,
|
|
937
|
-
variables,
|
|
938
|
-
applyUpdates,
|
|
939
|
-
specs,
|
|
940
|
-
layer,
|
|
941
|
-
forceNotify
|
|
942
|
-
});
|
|
943
|
-
newIDs.push(...inner.newIDs);
|
|
944
|
-
nestedIDs[i] = inner.nestedIDs;
|
|
945
|
-
continue;
|
|
946
|
-
}
|
|
947
|
-
if (entry === null || typeof entry === "undefined") {
|
|
948
|
-
newIDs.push(null);
|
|
949
|
-
nestedIDs[i] = null;
|
|
950
|
-
continue;
|
|
951
|
-
}
|
|
952
|
-
const entryObj = entry;
|
|
953
|
-
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
954
|
-
let innerType = linkedType;
|
|
955
|
-
const typename = entryObj.__typename;
|
|
956
|
-
if (typename) {
|
|
957
|
-
innerType = typename;
|
|
958
|
-
} else if (abstract) {
|
|
959
|
-
throw new Error("Encountered interface type without __typename in the payload");
|
|
960
|
-
}
|
|
961
|
-
if (!this.isEmbedded(linkedType, entry)) {
|
|
962
|
-
const id = this.id(innerType, entry);
|
|
963
|
-
if (id) {
|
|
964
|
-
linkedID = id;
|
|
965
|
-
} else {
|
|
966
|
-
continue;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
this.writeSelection({
|
|
970
|
-
root: import_stuff.rootID,
|
|
971
|
-
selection: fields,
|
|
972
|
-
parent: linkedID,
|
|
973
|
-
data: entryObj,
|
|
974
|
-
variables,
|
|
975
|
-
toNotify: specs,
|
|
976
|
-
applyUpdates,
|
|
977
|
-
layer,
|
|
978
|
-
forceNotify
|
|
979
|
-
});
|
|
980
|
-
newIDs.push(linkedID);
|
|
981
|
-
nestedIDs[i] = linkedID;
|
|
982
|
-
}
|
|
983
|
-
return { newIDs, nestedIDs };
|
|
984
|
-
}
|
|
985
|
-
collectGarbage() {
|
|
986
|
-
this.lifetimes.tick();
|
|
987
|
-
if (this.storage.layerCount === 1) {
|
|
988
|
-
this.storage.topLayer.removeUndefinedFields();
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
function evaluateVariables(variables, args) {
|
|
993
|
-
return Object.fromEntries(
|
|
994
|
-
Object.entries(variables).map(([key, value]) => [key, variableValue(value, args)])
|
|
995
|
-
);
|
|
996
|
-
}
|
|
997
|
-
function wrapInLists(target, count = 0) {
|
|
998
|
-
if (count === 0) {
|
|
999
|
-
return target;
|
|
1000
|
-
}
|
|
1001
|
-
return wrapInLists([target], count - 1);
|
|
1002
|
-
}
|
|
1003
|
-
function variableValue(value, args) {
|
|
1004
|
-
if (value.kind === "StringValue") {
|
|
1005
|
-
return value.value;
|
|
1006
|
-
}
|
|
1007
|
-
if (value.kind === "BooleanValue") {
|
|
1008
|
-
return value.value;
|
|
1009
|
-
}
|
|
1010
|
-
if (value.kind === "EnumValue") {
|
|
1011
|
-
return value.value;
|
|
1012
|
-
}
|
|
1013
|
-
if (value.kind === "FloatValue") {
|
|
1014
|
-
return parseFloat(value.value);
|
|
1015
|
-
}
|
|
1016
|
-
if (value.kind === "IntValue") {
|
|
1017
|
-
return parseInt(value.value, 10);
|
|
1018
|
-
}
|
|
1019
|
-
if (value.kind === "NullValue") {
|
|
1020
|
-
return null;
|
|
1021
|
-
}
|
|
1022
|
-
if (value.kind === "Variable") {
|
|
1023
|
-
return args[value.name.value];
|
|
1024
|
-
}
|
|
1025
|
-
if (value.kind === "ListValue") {
|
|
1026
|
-
return value.values.map((value2) => variableValue(value2, args));
|
|
1027
|
-
}
|
|
1028
|
-
if (value.kind === "ObjectValue") {
|
|
1029
|
-
return value.fields.reduce(
|
|
1030
|
-
(obj, field) => ({
|
|
1031
|
-
...obj,
|
|
1032
|
-
[field.name.value]: variableValue(field.value, args)
|
|
1033
|
-
}),
|
|
1034
|
-
{}
|
|
1035
|
-
);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
function fragmentReference({
|
|
1039
|
-
component,
|
|
1040
|
-
prop
|
|
1041
|
-
}) {
|
|
1042
|
-
return `${component.name}.${prop}`;
|
|
1043
|
-
}
|
|
1044
|
-
function defaultComponentField({
|
|
1045
|
-
cache,
|
|
1046
|
-
component,
|
|
1047
|
-
loading,
|
|
1048
|
-
variables,
|
|
1049
|
-
parent
|
|
1050
|
-
}) {
|
|
1051
|
-
return (props) => {
|
|
1052
|
-
const componentFn = cache._internal_unstable.componentCache[component.key];
|
|
1053
|
-
const args = evaluateVariables(component.variables ?? {}, variables ?? {});
|
|
1054
|
-
return cache._internal_unstable.createComponent(componentFn, {
|
|
1055
|
-
...props,
|
|
1056
|
-
[component.prop]: {
|
|
1057
|
-
[import_types.fragmentKey]: {
|
|
1058
|
-
loading,
|
|
1059
|
-
values: {
|
|
1060
|
-
[component.fragment]: {
|
|
1061
|
-
variables: args,
|
|
1062
|
-
parent
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
});
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1071
|
-
0 && (module.exports = {
|
|
1072
|
-
Cache,
|
|
1073
|
-
defaultComponentField,
|
|
1074
|
-
evaluateVariables,
|
|
1075
|
-
fragmentReference,
|
|
1076
|
-
variableValue
|
|
1077
|
-
});
|