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,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { deepEquals } from "../deepEquals.js";
|
|
2
|
+
import { flatten } from "../flatten.js";
|
|
3
|
+
import { rootID } from "./stuff.js";
|
|
4
|
+
function opaqueListID(parentID, listName) {
|
|
5
|
+
return `${parentID}::${listName}`;
|
|
6
|
+
}
|
|
3
7
|
class ListManager {
|
|
4
8
|
rootID;
|
|
5
9
|
cache;
|
|
@@ -10,6 +14,8 @@ class ListManager {
|
|
|
10
14
|
// associate list names with the handler that wraps the list
|
|
11
15
|
lists = /* @__PURE__ */ new Map();
|
|
12
16
|
listsByField = /* @__PURE__ */ new Map();
|
|
17
|
+
// indexed by the opaque list ID exposed as __id
|
|
18
|
+
listsByOpaqueID = /* @__PURE__ */ new Map();
|
|
13
19
|
get(listName, id, allLists, skipMatches) {
|
|
14
20
|
const lists = this.getLists(listName, id, allLists);
|
|
15
21
|
if (!lists) {
|
|
@@ -21,6 +27,17 @@ class ListManager {
|
|
|
21
27
|
return lists;
|
|
22
28
|
}
|
|
23
29
|
}
|
|
30
|
+
// look up a list by the opaque ID that was attached as __id
|
|
31
|
+
getByOpaqueID(opaqueID, skipMatches) {
|
|
32
|
+
const collection = this.listsByOpaqueID.get(opaqueID);
|
|
33
|
+
if (!collection) return null;
|
|
34
|
+
if (skipMatches) {
|
|
35
|
+
return new ListCollection(
|
|
36
|
+
collection.lists.filter((list) => !skipMatches.has(list.fieldRef))
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return collection;
|
|
40
|
+
}
|
|
24
41
|
getLists(listName, id, allLists) {
|
|
25
42
|
const matches = this.lists.get(listName);
|
|
26
43
|
if (!matches || matches.size === 0) {
|
|
@@ -28,7 +45,7 @@ class ListManager {
|
|
|
28
45
|
}
|
|
29
46
|
if (allLists) {
|
|
30
47
|
return new ListCollection(
|
|
31
|
-
Array.from(matches, ([
|
|
48
|
+
Array.from(matches, ([_key, value]) => [...value.lists]).flat()
|
|
32
49
|
);
|
|
33
50
|
}
|
|
34
51
|
const head = [...matches.values()][0];
|
|
@@ -42,14 +59,16 @@ class ListManager {
|
|
|
42
59
|
}
|
|
43
60
|
if (!id) {
|
|
44
61
|
console.error(
|
|
45
|
-
`Found multiple instances of "${listName}". Please provide one of @parentID or @allLists directives to help identify which list you want modify. For more information, visit this guide: https://www.houdinigraphql.com/api/graphql#parentidvalue-string `
|
|
62
|
+
`Found multiple instances of "${listName}". Please provide one of @parentID, @listID, or @allLists directives to help identify which list you want modify. For more information, visit this guide: https://www.houdinigraphql.com/api/graphql#parentidvalue-string `
|
|
46
63
|
);
|
|
47
64
|
return null;
|
|
48
65
|
}
|
|
49
66
|
return this.lists.get(listName)?.get(parentID);
|
|
50
67
|
}
|
|
51
68
|
remove(listName, id) {
|
|
52
|
-
|
|
69
|
+
const parentID = id || this.rootID;
|
|
70
|
+
this.lists.get(listName)?.delete(parentID);
|
|
71
|
+
this.listsByOpaqueID.delete(opaqueListID(parentID, listName));
|
|
53
72
|
}
|
|
54
73
|
add(list) {
|
|
55
74
|
if (!this.lists.has(list.name)) {
|
|
@@ -75,6 +94,7 @@ class ListManager {
|
|
|
75
94
|
const handler = new List({ ...list, manager: this });
|
|
76
95
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
77
96
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
97
|
+
this.listsByOpaqueID.set(opaqueListID(parentID, name), this.lists.get(name).get(parentID));
|
|
78
98
|
}
|
|
79
99
|
removeIDFromAllLists(id, layer) {
|
|
80
100
|
let removed = false;
|
|
@@ -95,6 +115,7 @@ class ListManager {
|
|
|
95
115
|
this.lists.get(list.name)?.get(list.recordID)?.deleteListWithKey(field);
|
|
96
116
|
if (this.lists.get(list.name)?.get(list.recordID)?.lists.length === 0) {
|
|
97
117
|
this.lists.get(list.name)?.delete(list.recordID);
|
|
118
|
+
this.listsByOpaqueID.delete(opaqueListID(list.recordID, list.name));
|
|
98
119
|
}
|
|
99
120
|
}
|
|
100
121
|
this.listsByField.get(parentID).delete(field);
|
|
@@ -102,6 +123,7 @@ class ListManager {
|
|
|
102
123
|
reset() {
|
|
103
124
|
this.lists.clear();
|
|
104
125
|
this.listsByField.clear();
|
|
126
|
+
this.listsByOpaqueID.clear();
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
129
|
class List {
|
|
@@ -219,7 +241,7 @@ class List {
|
|
|
219
241
|
newEntry: {
|
|
220
242
|
edges: [
|
|
221
243
|
{
|
|
222
|
-
__typename: listType
|
|
244
|
+
__typename: `${listType}Edge`,
|
|
223
245
|
node: {
|
|
224
246
|
...data,
|
|
225
247
|
__typename: listType
|
|
@@ -297,29 +319,40 @@ class List {
|
|
|
297
319
|
parentID = embeddedConnectionID;
|
|
298
320
|
targetKey = "edges";
|
|
299
321
|
}
|
|
300
|
-
|
|
301
|
-
if (!value
|
|
322
|
+
const value = this.cache._internal_unstable.storage.get(parentID, targetKey).value;
|
|
323
|
+
if (!value?.includes(targetID)) {
|
|
302
324
|
return;
|
|
303
325
|
}
|
|
304
326
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
327
|
+
const maskedParentSubscribers = this.cache._internal_unstable.subscriptions.getMaskedParents(this.recordID, this.key);
|
|
328
|
+
const targetSelection = this.connection ? this.selection.fields.edges.selection : this.selection;
|
|
305
329
|
this.cache._internal_unstable.subscriptions.remove(
|
|
306
330
|
targetID,
|
|
307
|
-
|
|
308
|
-
// are tucked away under edges
|
|
309
|
-
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
331
|
+
targetSelection,
|
|
310
332
|
subscribers.map((sub) => sub[0]),
|
|
311
333
|
variables
|
|
312
334
|
);
|
|
335
|
+
if (maskedParentSubscribers.length > 0) {
|
|
336
|
+
this.cache._internal_unstable.subscriptions.remove(
|
|
337
|
+
targetID,
|
|
338
|
+
targetSelection,
|
|
339
|
+
maskedParentSubscribers.map((sub) => sub[0]),
|
|
340
|
+
variables,
|
|
341
|
+
[],
|
|
342
|
+
true
|
|
343
|
+
);
|
|
344
|
+
}
|
|
313
345
|
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
314
346
|
for (const [spec] of subscribers) {
|
|
315
|
-
spec.
|
|
316
|
-
|
|
347
|
+
spec.onMessage({
|
|
348
|
+
kind: "update",
|
|
349
|
+
data: this.cache._internal_unstable.getSelection({
|
|
317
350
|
parent: spec.parentID || this.manager.rootID,
|
|
318
351
|
selection: spec.selection,
|
|
319
352
|
variables: spec.variables?.() || {},
|
|
320
353
|
ignoreMasking: false
|
|
321
354
|
}).data
|
|
322
|
-
);
|
|
355
|
+
});
|
|
323
356
|
}
|
|
324
357
|
return true;
|
|
325
358
|
}
|
|
@@ -334,19 +367,19 @@ class List {
|
|
|
334
367
|
return data.__typename || this.type;
|
|
335
368
|
}
|
|
336
369
|
validateWhen(when) {
|
|
337
|
-
|
|
370
|
+
const filters = when || this._when;
|
|
338
371
|
let ok = true;
|
|
339
372
|
if (filters) {
|
|
340
373
|
const targets = this.filters;
|
|
341
374
|
if (filters.must && targets) {
|
|
342
375
|
ok = Object.entries(filters.must).reduce(
|
|
343
|
-
(prev, [key, value]) => Boolean(prev && targets[key]
|
|
376
|
+
(prev, [key, value]) => Boolean(prev && deepEquals(targets[key], value)),
|
|
344
377
|
ok
|
|
345
378
|
);
|
|
346
379
|
}
|
|
347
380
|
if (filters.must_not) {
|
|
348
381
|
ok = !targets || Object.entries(filters.must_not).reduce(
|
|
349
|
-
(prev, [key, value]) => Boolean(prev && targets[key]
|
|
382
|
+
(prev, [key, value]) => Boolean(prev && !deepEquals(targets[key], value)),
|
|
350
383
|
ok
|
|
351
384
|
);
|
|
352
385
|
}
|
|
@@ -364,17 +397,56 @@ class List {
|
|
|
364
397
|
this.addToList(selection, data, variables, where, layer);
|
|
365
398
|
}
|
|
366
399
|
}
|
|
400
|
+
upsertInList(selection, data, variables = {}, where, layer) {
|
|
401
|
+
const listType = this.listType(data);
|
|
402
|
+
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
403
|
+
if (!this.validateWhen() || !dataID) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
let isInList = false;
|
|
407
|
+
if (this.connection) {
|
|
408
|
+
const { value: embeddedConnection } = this.cache._internal_unstable.storage.get(
|
|
409
|
+
this.recordID,
|
|
410
|
+
this.key
|
|
411
|
+
);
|
|
412
|
+
if (embeddedConnection) {
|
|
413
|
+
const { value: edges } = this.cache._internal_unstable.storage.get(
|
|
414
|
+
embeddedConnection,
|
|
415
|
+
"edges"
|
|
416
|
+
);
|
|
417
|
+
for (const edge of flatten(edges) || []) {
|
|
418
|
+
if (!edge) continue;
|
|
419
|
+
const { value: nodeID } = this.cache._internal_unstable.storage.get(
|
|
420
|
+
edge,
|
|
421
|
+
"node"
|
|
422
|
+
);
|
|
423
|
+
if (nodeID === dataID) {
|
|
424
|
+
isInList = true;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
const { value } = this.cache._internal_unstable.storage.get(this.recordID, this.key);
|
|
431
|
+
isInList = !!value?.includes(dataID);
|
|
432
|
+
}
|
|
433
|
+
if (isInList) {
|
|
434
|
+
this.cache.write({ selection, data, variables, layer: layer?.id });
|
|
435
|
+
} else {
|
|
436
|
+
this.addToList(selection, data, variables, where, layer);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
367
439
|
// iterating over the list handler should be the same as iterating over
|
|
368
440
|
// the underlying linked list
|
|
369
441
|
*[Symbol.iterator]() {
|
|
370
442
|
let entries = [];
|
|
371
|
-
|
|
443
|
+
const value = this.cache._internal_unstable.storage.get(this.recordID, this.key).value;
|
|
372
444
|
if (!this.connection) {
|
|
373
445
|
entries = flatten(value);
|
|
374
446
|
} else {
|
|
375
447
|
entries = this.cache._internal_unstable.storage.get(value, "edges").value;
|
|
376
448
|
}
|
|
377
|
-
for (
|
|
449
|
+
for (const record of entries) {
|
|
378
450
|
yield record;
|
|
379
451
|
}
|
|
380
452
|
}
|
|
@@ -388,13 +460,19 @@ class ListCollection {
|
|
|
388
460
|
return this.lists[0].selection;
|
|
389
461
|
}
|
|
390
462
|
append(...args) {
|
|
391
|
-
this.lists.forEach((list) =>
|
|
463
|
+
this.lists.forEach((list) => {
|
|
464
|
+
list.append(...args);
|
|
465
|
+
});
|
|
392
466
|
}
|
|
393
467
|
prepend(...args) {
|
|
394
|
-
this.lists.forEach((list) =>
|
|
468
|
+
this.lists.forEach((list) => {
|
|
469
|
+
list.prepend(...args);
|
|
470
|
+
});
|
|
395
471
|
}
|
|
396
472
|
addToList(...args) {
|
|
397
|
-
this.lists.forEach((list) =>
|
|
473
|
+
this.lists.forEach((list) => {
|
|
474
|
+
list.addToList(...args);
|
|
475
|
+
});
|
|
398
476
|
}
|
|
399
477
|
removeID(...args) {
|
|
400
478
|
let removed = false;
|
|
@@ -406,10 +484,19 @@ class ListCollection {
|
|
|
406
484
|
return removed;
|
|
407
485
|
}
|
|
408
486
|
remove(...args) {
|
|
409
|
-
this.lists.forEach((list) =>
|
|
487
|
+
this.lists.forEach((list) => {
|
|
488
|
+
list.remove(...args);
|
|
489
|
+
});
|
|
410
490
|
}
|
|
411
491
|
toggleElement(...args) {
|
|
412
|
-
this.lists.forEach((list) =>
|
|
492
|
+
this.lists.forEach((list) => {
|
|
493
|
+
list.toggleElement(...args);
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
upsertInList(...args) {
|
|
497
|
+
this.lists.forEach((list) => {
|
|
498
|
+
list.upsertInList(...args);
|
|
499
|
+
});
|
|
413
500
|
}
|
|
414
501
|
when(when) {
|
|
415
502
|
return new ListCollection(
|
|
@@ -422,12 +509,13 @@ class ListCollection {
|
|
|
422
509
|
return !!this.lists.find((list) => list.key === key);
|
|
423
510
|
}
|
|
424
511
|
deleteListWithKey(key) {
|
|
425
|
-
|
|
512
|
+
this.lists = this.lists.filter((list) => list.key !== key);
|
|
513
|
+
return this.lists;
|
|
426
514
|
}
|
|
427
515
|
// iterating over the collection should be the same as iterating over
|
|
428
516
|
// the underlying list
|
|
429
517
|
*[Symbol.iterator]() {
|
|
430
|
-
for (
|
|
518
|
+
for (const list of this.lists) {
|
|
431
519
|
for (const entry of list) {
|
|
432
520
|
yield entry;
|
|
433
521
|
}
|
|
@@ -437,5 +525,6 @@ class ListCollection {
|
|
|
437
525
|
export {
|
|
438
526
|
List,
|
|
439
527
|
ListCollection,
|
|
440
|
-
ListManager
|
|
528
|
+
ListManager,
|
|
529
|
+
opaqueListID
|
|
441
530
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Cache } from './
|
|
1
|
+
import type { Cache } from './index.js';
|
|
2
2
|
export declare class StaleManager {
|
|
3
3
|
#private;
|
|
4
4
|
cache: Cache;
|
|
@@ -26,6 +26,7 @@ export declare class StaleManager {
|
|
|
26
26
|
markRecordStale(id: string): void;
|
|
27
27
|
markTypeStale(type: string): void;
|
|
28
28
|
markTypeFieldStale(type: string, field: string, when?: {}): void;
|
|
29
|
+
deleteRecord(id: string): void;
|
|
29
30
|
delete(id: string, field: string): void;
|
|
30
31
|
reset(): void;
|
|
31
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computeKey } from "../
|
|
1
|
+
import { computeKey } from "../key.js";
|
|
2
2
|
class StaleManager {
|
|
3
3
|
cache;
|
|
4
4
|
// id { "User:1" "_ROOT_"
|
|
@@ -34,7 +34,7 @@ class StaleManager {
|
|
|
34
34
|
*/
|
|
35
35
|
setFieldTimeToNow(id, field) {
|
|
36
36
|
this.#initMapId(id);
|
|
37
|
-
this.fieldsTime.get(id)?.set(field,
|
|
37
|
+
this.fieldsTime.get(id)?.set(field, Date.now());
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* set null to a field (stale)
|
|
@@ -81,6 +81,10 @@ class StaleManager {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
// remove every entry associated with a record
|
|
85
|
+
deleteRecord(id) {
|
|
86
|
+
this.fieldsTime.delete(id);
|
|
87
|
+
}
|
|
84
88
|
// clean up the stale manager
|
|
85
89
|
delete(id, field) {
|
|
86
90
|
if (this.fieldsTime.has(id)) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { GraphQLValue } from '../
|
|
1
|
+
import type { GraphQLValue } from '../types.js';
|
|
2
2
|
export declare class InMemoryStorage {
|
|
3
3
|
data: Layer[];
|
|
4
4
|
private idCount;
|
|
5
5
|
private rank;
|
|
6
6
|
idMaps: Record<string, string>;
|
|
7
|
+
typenames: Map<string, string>;
|
|
7
8
|
constructor();
|
|
8
9
|
get layerCount(): number;
|
|
9
10
|
get nextRank(): number;
|
|
@@ -13,6 +14,7 @@ export declare class InMemoryStorage {
|
|
|
13
14
|
remove(id: string, field: string, target: string, layer?: Layer): void;
|
|
14
15
|
delete(id: string, layer?: Layer): void;
|
|
15
16
|
deleteField(id: string, field: string): void;
|
|
17
|
+
removeEmbeddedRecord(id: string): void;
|
|
16
18
|
getLayer(id: number): Layer;
|
|
17
19
|
replaceID(replacement: {
|
|
18
20
|
from: string;
|
|
@@ -32,7 +34,8 @@ export declare class InMemoryStorage {
|
|
|
32
34
|
rank: number;
|
|
33
35
|
fields: EntityFieldMap;
|
|
34
36
|
links: LinkMap;
|
|
35
|
-
}, layer?: Layer):
|
|
37
|
+
}, layer?: Layer): Layer | undefined;
|
|
38
|
+
getTypename(id: string): string | undefined;
|
|
36
39
|
reset(): void;
|
|
37
40
|
}
|
|
38
41
|
export declare class Layer {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { flatten } from "../
|
|
1
|
+
import { flatten } from "../flatten.js";
|
|
2
2
|
class InMemoryStorage {
|
|
3
3
|
data;
|
|
4
4
|
idCount = 1;
|
|
5
5
|
rank = 0;
|
|
6
6
|
idMaps = {};
|
|
7
|
+
// fast lookup: record id → __typename, maintained alongside normal field writes
|
|
8
|
+
typenames = /* @__PURE__ */ new Map();
|
|
7
9
|
constructor() {
|
|
8
10
|
this.data = [];
|
|
9
11
|
}
|
|
@@ -36,50 +38,66 @@ class InMemoryStorage {
|
|
|
36
38
|
deleteField(id, field) {
|
|
37
39
|
return this.topLayer.deleteField(id, field);
|
|
38
40
|
}
|
|
41
|
+
// embedded records are only ever referenced by the field that wrote them so once
|
|
42
|
+
// that reference is gone the data can be physically removed. any embedded
|
|
43
|
+
// descendants are left for the garbage collector
|
|
44
|
+
removeEmbeddedRecord(id) {
|
|
45
|
+
for (const layer of this.data) {
|
|
46
|
+
if (layer.optimistic) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
delete layer.fields[id];
|
|
50
|
+
delete layer.links[id];
|
|
51
|
+
}
|
|
52
|
+
this.typenames.delete(id);
|
|
53
|
+
}
|
|
39
54
|
getLayer(id) {
|
|
40
55
|
for (const layer of this.data) {
|
|
41
56
|
if (layer.id === id) {
|
|
42
57
|
return layer;
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
|
-
throw new Error(
|
|
60
|
+
throw new Error(`Could not find layer with id: ${id}`);
|
|
46
61
|
}
|
|
47
62
|
replaceID(replacement) {
|
|
48
63
|
for (const layer of this.data) {
|
|
49
64
|
layer.replaceID(replacement);
|
|
50
65
|
}
|
|
66
|
+
const typename = this.typenames.get(replacement.from);
|
|
67
|
+
if (typename) this.typenames.set(replacement.to, typename);
|
|
51
68
|
}
|
|
52
69
|
get(targetID, field, defaultValue) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
const layerIDs = [];
|
|
61
|
-
const recordIDs = [this.idMaps[targetID], targetID].filter(Boolean);
|
|
70
|
+
let insertStart;
|
|
71
|
+
let insertEnd;
|
|
72
|
+
let removeSet;
|
|
73
|
+
let layerIDs;
|
|
74
|
+
const mappedID = this.idMaps[targetID];
|
|
75
|
+
const recordIDs = mappedID ? [mappedID, targetID] : [targetID];
|
|
62
76
|
for (let i = this.data.length - 1; i >= 0; i--) {
|
|
63
77
|
for (const id of recordIDs) {
|
|
64
78
|
const layer = this.data[i];
|
|
65
79
|
let [layerValue, kind] = layer.get(id, field);
|
|
66
|
-
const layerOperations = layer.getOperations(id, field)
|
|
67
|
-
layer.deletedIDs.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
const layerOperations = layer.getOperations(id, field);
|
|
81
|
+
if (layer.deletedIDs.size > 0) {
|
|
82
|
+
layer.deletedIDs.forEach((v) => {
|
|
83
|
+
if (layer.operations[v]?.undoDeletesInList?.includes(field)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!removeSet) removeSet = /* @__PURE__ */ new Set();
|
|
87
|
+
removeSet.add(v);
|
|
88
|
+
if (this.idMaps[v]) {
|
|
89
|
+
removeSet.add(this.idMaps[v]);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
76
93
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
77
94
|
const targetLayer = this.topLayer;
|
|
78
95
|
targetLayer.writeField(id, field, defaultValue);
|
|
79
96
|
layerValue = defaultValue;
|
|
80
97
|
}
|
|
81
|
-
if (typeof layerValue === "undefined" && layerOperations
|
|
98
|
+
if (typeof layerValue === "undefined" && !layerOperations?.length) {
|
|
82
99
|
if (layer.deletedIDs.size > 0) {
|
|
100
|
+
if (!layerIDs) layerIDs = [];
|
|
83
101
|
layerIDs.push(layer.id);
|
|
84
102
|
}
|
|
85
103
|
continue;
|
|
@@ -91,17 +109,21 @@ class InMemoryStorage {
|
|
|
91
109
|
displayLayers: [layer.id]
|
|
92
110
|
};
|
|
93
111
|
}
|
|
112
|
+
if (!layerIDs) layerIDs = [];
|
|
94
113
|
layerIDs.push(layer.id);
|
|
95
|
-
if (layerOperations
|
|
114
|
+
if (layerOperations?.length) {
|
|
96
115
|
for (const op of layerOperations) {
|
|
97
116
|
if (isRemoveOperation(op)) {
|
|
98
|
-
|
|
117
|
+
if (!removeSet) removeSet = /* @__PURE__ */ new Set();
|
|
118
|
+
removeSet.add(op.id);
|
|
99
119
|
}
|
|
100
120
|
if (isInsertOperation(op)) {
|
|
101
121
|
if (op.location === OperationLocation.end) {
|
|
102
|
-
|
|
122
|
+
if (!insertEnd) insertEnd = [];
|
|
123
|
+
insertEnd.unshift(op.id);
|
|
103
124
|
} else {
|
|
104
|
-
|
|
125
|
+
if (!insertStart) insertStart = [];
|
|
126
|
+
insertStart.push(op.id);
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
129
|
if (isDeleteOperation(op)) {
|
|
@@ -116,15 +138,13 @@ class InMemoryStorage {
|
|
|
116
138
|
if (typeof layerValue === "undefined") {
|
|
117
139
|
continue;
|
|
118
140
|
}
|
|
119
|
-
if (!
|
|
141
|
+
if (!removeSet?.size && !insertStart?.length && !insertEnd?.length) {
|
|
120
142
|
return { value: layerValue, displayLayers: layerIDs, kind: "link" };
|
|
121
143
|
}
|
|
122
144
|
return {
|
|
123
|
-
value: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
...operations.insert.end
|
|
127
|
-
].filter((value) => !operations.remove.has(value)),
|
|
145
|
+
value: [...insertStart ?? [], ...layerValue, ...insertEnd ?? []].filter(
|
|
146
|
+
(value) => !removeSet?.has(value)
|
|
147
|
+
),
|
|
128
148
|
displayLayers: layerIDs,
|
|
129
149
|
kind
|
|
130
150
|
};
|
|
@@ -153,7 +173,7 @@ class InMemoryStorage {
|
|
|
153
173
|
break;
|
|
154
174
|
}
|
|
155
175
|
if (startingIndex === null) {
|
|
156
|
-
throw new Error(
|
|
176
|
+
throw new Error(`could not find layer with id: ${id}`);
|
|
157
177
|
}
|
|
158
178
|
if (startingIndex === -1) {
|
|
159
179
|
startingIndex = 0;
|
|
@@ -210,9 +230,20 @@ class InMemoryStorage {
|
|
|
210
230
|
layer ??= this.createLayer(true);
|
|
211
231
|
layer.fields = fields;
|
|
212
232
|
layer.links = links;
|
|
233
|
+
return layer;
|
|
234
|
+
}
|
|
235
|
+
// fast typename lookup with lazy-populate fallback for records written via hydrate()
|
|
236
|
+
getTypename(id) {
|
|
237
|
+
let typename = this.typenames.get(id);
|
|
238
|
+
if (typename === void 0) {
|
|
239
|
+
typename = this.get(id, "__typename").value;
|
|
240
|
+
if (typename !== void 0) this.typenames.set(id, typename);
|
|
241
|
+
}
|
|
242
|
+
return typename;
|
|
213
243
|
}
|
|
214
244
|
reset() {
|
|
215
245
|
this.data = [];
|
|
246
|
+
this.typenames.clear();
|
|
216
247
|
}
|
|
217
248
|
}
|
|
218
249
|
class Layer {
|
|
@@ -232,23 +263,18 @@ class Layer {
|
|
|
232
263
|
return [this.fields[id]?.[field], "scalar"];
|
|
233
264
|
}
|
|
234
265
|
getOperations(id, field) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
target: id
|
|
240
|
-
}
|
|
241
|
-
];
|
|
242
|
-
}
|
|
243
|
-
if (this.operations[id]?.fields?.[field]) {
|
|
244
|
-
return this.operations[id].fields[field];
|
|
245
|
-
}
|
|
266
|
+
const ops = this.operations[id];
|
|
267
|
+
if (!ops) return void 0;
|
|
268
|
+
if (ops.deleted) return [{ kind: OperationKind.delete, target: id }];
|
|
269
|
+
return ops.fields?.[field];
|
|
246
270
|
}
|
|
247
271
|
writeField(id, field, value) {
|
|
248
|
-
this.fields[id]
|
|
249
|
-
|
|
250
|
-
[field]
|
|
251
|
-
}
|
|
272
|
+
const record = this.fields[id];
|
|
273
|
+
if (record) {
|
|
274
|
+
record[field] = value;
|
|
275
|
+
} else {
|
|
276
|
+
this.fields[id] = { [field]: value };
|
|
277
|
+
}
|
|
252
278
|
return this.id;
|
|
253
279
|
}
|
|
254
280
|
writeLink(id, field, value) {
|
|
@@ -269,14 +295,24 @@ class Layer {
|
|
|
269
295
|
);
|
|
270
296
|
}
|
|
271
297
|
}
|
|
272
|
-
this.links[id]
|
|
273
|
-
|
|
274
|
-
[field]
|
|
275
|
-
}
|
|
298
|
+
const linkRecord = this.links[id];
|
|
299
|
+
if (linkRecord) {
|
|
300
|
+
linkRecord[field] = value;
|
|
301
|
+
} else {
|
|
302
|
+
this.links[id] = { [field]: value };
|
|
303
|
+
}
|
|
276
304
|
return this.id;
|
|
277
305
|
}
|
|
278
306
|
isDisplayLayer(displayLayers) {
|
|
279
|
-
|
|
307
|
+
const n = displayLayers.length;
|
|
308
|
+
if (n === 0) return true;
|
|
309
|
+
let max = 0;
|
|
310
|
+
for (let i = 0; i < n; i++) {
|
|
311
|
+
const d = displayLayers[i];
|
|
312
|
+
if (d === this.id) return true;
|
|
313
|
+
if (d > max) max = d;
|
|
314
|
+
}
|
|
315
|
+
return max < this.id;
|
|
280
316
|
}
|
|
281
317
|
clear() {
|
|
282
318
|
this.links = {};
|
|
@@ -356,6 +392,40 @@ class Layer {
|
|
|
356
392
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
357
393
|
}
|
|
358
394
|
}
|
|
395
|
+
for (const [fieldName, ops2] of Object.entries(fields)) {
|
|
396
|
+
const insertCount = /* @__PURE__ */ new Map();
|
|
397
|
+
const removeCount = /* @__PURE__ */ new Map();
|
|
398
|
+
for (const op of ops2) {
|
|
399
|
+
if (isInsertOperation(op))
|
|
400
|
+
insertCount.set(op.id, (insertCount.get(op.id) ?? 0) + 1);
|
|
401
|
+
else if (isRemoveOperation(op))
|
|
402
|
+
removeCount.set(op.id, (removeCount.get(op.id) ?? 0) + 1);
|
|
403
|
+
}
|
|
404
|
+
const net = /* @__PURE__ */ new Map();
|
|
405
|
+
for (const [id2, n] of insertCount) net.set(id2, n);
|
|
406
|
+
for (const [id2, n] of removeCount) net.set(id2, (net.get(id2) ?? 0) - n);
|
|
407
|
+
const keptInserts = /* @__PURE__ */ new Map();
|
|
408
|
+
const keptRemoves = /* @__PURE__ */ new Map();
|
|
409
|
+
fields[fieldName] = ops2.filter((op) => {
|
|
410
|
+
if (isInsertOperation(op)) {
|
|
411
|
+
const n = net.get(op.id) ?? 0;
|
|
412
|
+
if (n <= 0) return false;
|
|
413
|
+
const kept = keptInserts.get(op.id) ?? 0;
|
|
414
|
+
if (kept >= n) return false;
|
|
415
|
+
keptInserts.set(op.id, kept + 1);
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
if (isRemoveOperation(op)) {
|
|
419
|
+
const n = net.get(op.id) ?? 0;
|
|
420
|
+
if (n >= 0) return false;
|
|
421
|
+
const kept = keptRemoves.get(op.id) ?? 0;
|
|
422
|
+
if (kept >= -n) return false;
|
|
423
|
+
keptRemoves.set(op.id, kept + 1);
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
});
|
|
428
|
+
}
|
|
359
429
|
if (Object.keys(fields).length > 0) {
|
|
360
430
|
this.operations[id] = {
|
|
361
431
|
...this.operations[id],
|
|
@@ -383,7 +453,9 @@ class Layer {
|
|
|
383
453
|
this.writeLink(id, field, value);
|
|
384
454
|
}
|
|
385
455
|
}
|
|
386
|
-
layer.deletedIDs.forEach((v) =>
|
|
456
|
+
layer.deletedIDs.forEach((v) => {
|
|
457
|
+
this.deletedIDs.add(v);
|
|
458
|
+
});
|
|
387
459
|
}
|
|
388
460
|
addFieldOperation(id, field, operation) {
|
|
389
461
|
this.operations = {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
function evaluateKey(key, variables = null) {
|
|
2
|
+
if (!key.includes("$")) return key;
|
|
2
3
|
let evaluated = "";
|
|
3
4
|
let varName = "";
|
|
4
5
|
let inString = false;
|
|
5
6
|
for (const char of key) {
|
|
6
7
|
if (varName) {
|
|
7
|
-
if (
|
|
8
|
+
if (varCharSet.has(char)) {
|
|
8
9
|
varName += char;
|
|
9
10
|
continue;
|
|
10
11
|
}
|
|
11
12
|
const value = variables?.[varName.slice(1)];
|
|
12
|
-
evaluated +=
|
|
13
|
+
evaluated += JSON.stringify(value ?? null);
|
|
13
14
|
varName = "";
|
|
14
15
|
}
|
|
15
16
|
if (char === "$" && !inString) {
|
|
@@ -23,7 +24,7 @@ function evaluateKey(key, variables = null) {
|
|
|
23
24
|
}
|
|
24
25
|
return evaluated;
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
+
const varCharSet = new Set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789");
|
|
27
28
|
const rootID = "_ROOT_";
|
|
28
29
|
export {
|
|
29
30
|
evaluateKey,
|