MessagesForMacintosh/JS/node_modules/apollo-cache/lib/bundle.cjs.js.map

1 line
12 KiB
Plaintext

{"version":3,"sources":["../src/utils.ts","../src/cache.ts","../src/types/Cache.ts"],"names":[],"mappings":";;;;;;;SAQgB,a,CAAc,G,EAAQ;AACpC,MAAM,EAAE,GAA4B;AAClC,IAAA,IAAI,EAAE,qBAD4B;AAElC,IAAA,SAAS,EAAE,OAFuB;AAGlC,IAAA,IAAI,EAAE;AACJ,MAAA,IAAI,EAAE,MADF;AAEJ,MAAA,KAAK,EAAE;AAFH,KAH4B;AAOlC,IAAA,YAAY,EAAE,mBAAmB,CAAC,GAAD;AAPC,GAApC;AAUA,MAAM,GAAG,GAAiB;AACxB,IAAA,IAAI,EAAE,UADkB;AAExB,IAAA,WAAW,EAAE,CAAC,EAAD;AAFW,GAA1B;AAKA,SAAO,GAAP;AACD;;AAED,SAAgB,gBAAhB,CAAiC,GAAjC,EAA2C,QAA3C,EAA4D;AAC1D,MAAM,IAAI,GAA2B;AACnC,IAAA,IAAI,EAAE,oBAD6B;AAEnC,IAAA,aAAa,EAAE;AACb,MAAA,IAAI,EAAE,WADO;AAEb,MAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MADF;AAEJ,QAAA,KAAK,EAAE,QAAQ,IAAI;AAFf;AAFO,KAFoB;AASnC,IAAA,IAAI,EAAE;AACJ,MAAA,IAAI,EAAE,MADF;AAEJ,MAAA,KAAK,EAAE;AAFH,KAT6B;AAanC,IAAA,YAAY,EAAE,mBAAmB,CAAC,GAAD;AAbE,GAArC;AAgBA,MAAM,GAAG,GAAiB;AACxB,IAAA,IAAI,EAAE,UADkB;AAExB,IAAA,WAAW,EAAE,CAAC,IAAD;AAFW,GAA1B;AAKA,SAAO,GAAP;AACD;;AAED,SAAS,mBAAT,CAA6B,GAA7B,EAAqC;AACnC,MACE,OAAO,GAAP,KAAe,QAAf,IACA,OAAO,GAAP,KAAe,SADf,IAEA,OAAO,GAAP,KAAe,QAFf,IAGA,OAA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;AAAE,QAAA,KAAK,EAAE,aAAa,CAAC,IAAD,CAAtB;AAA8B,QAAA,IAAI,EAAA;AAAlC,OAAhB;AACD;AACF,GAnCM;;AAoCT,SAAA,WAAA;AAAC,C;;;ICnJgB,K;;;AAAjB,CAAA,UAAiB,KAAjB,EAAsB,CAqCrB,CArCD,EAAiB,KAAK,qBAAL,KAAK,GAAA,EAAA,CAAtB,E","sourcesContent":["import {\n DocumentNode,\n OperationDefinitionNode,\n SelectionSetNode,\n FieldNode,\n FragmentDefinitionNode,\n} from 'graphql';\n\nexport function queryFromPojo(obj: any): DocumentNode {\n const op: OperationDefinitionNode = {\n kind: 'OperationDefinition',\n operation: 'query',\n name: {\n kind: 'Name',\n value: 'GeneratedClientQuery',\n },\n selectionSet: selectionSetFromObj(obj),\n };\n\n const out: DocumentNode = {\n kind: 'Document',\n definitions: [op],\n };\n\n return out;\n}\n\nexport function fragmentFromPojo(obj: any, typename?: string): DocumentNode {\n const frag: FragmentDefinitionNode = {\n kind: 'FragmentDefinition',\n typeCondition: {\n kind: 'NamedType',\n name: {\n kind: 'Name',\n value: typename || '__FakeType',\n },\n },\n name: {\n kind: 'Name',\n value: 'GeneratedClientQuery',\n },\n selectionSet: selectionSetFromObj(obj),\n };\n\n const out: DocumentNode = {\n kind: 'Document',\n definitions: [frag],\n };\n\n return out;\n}\n\nfunction selectionSetFromObj(obj: any): SelectionSetNode {\n if (\n typeof obj === 'number' ||\n typeof obj === 'boolean' ||\n typeof obj === 'string' ||\n typeof obj === 'undefined' ||\n obj === null\n ) {\n // No selection set here\n return null;\n }\n\n if (Array.isArray(obj)) {\n // GraphQL queries don't include arrays\n return selectionSetFromObj(obj[0]);\n }\n\n // Now we know it's an object\n const selections: FieldNode[] = [];\n\n Object.keys(obj).forEach(key => {\n const nestedSelSet: SelectionSetNode = selectionSetFromObj(obj[key]);\n\n const field: FieldNode = {\n kind: 'Field',\n name: {\n kind: 'Name',\n value: key,\n },\n selectionSet: nestedSelSet || undefined,\n };\n\n selections.push(field);\n });\n\n const selectionSet: SelectionSetNode = {\n kind: 'SelectionSet',\n selections,\n };\n\n return selectionSet;\n}\n\nexport const justTypenameQuery: DocumentNode = {\n kind: 'Document',\n definitions: [\n {\n kind: 'OperationDefinition',\n operation: 'query',\n name: null,\n variableDefinitions: null,\n directives: [],\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {\n kind: 'Field',\n alias: null,\n name: {\n kind: 'Name',\n value: '__typename',\n },\n arguments: [],\n directives: [],\n selectionSet: null,\n },\n ],\n },\n },\n ],\n};\n","import { DocumentNode } from 'graphql';\nimport { getFragmentQueryDocument } from 'apollo-utilities';\n\nimport { DataProxy, Cache } from './types';\nimport { justTypenameQuery, queryFromPojo, fragmentFromPojo } from './utils';\n\nexport type Transaction<T> = (c: ApolloCache<T>) => void;\n\nexport abstract class ApolloCache<TSerialized> implements DataProxy {\n // required to implement\n // core API\n public abstract read<T, TVariables = any>(\n query: Cache.ReadOptions<TVariables>,\n ): T | null;\n public abstract write<TResult = any, TVariables = any>(\n write: Cache.WriteOptions<TResult, TVariables>,\n ): void;\n public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;\n public abstract watch(watch: Cache.WatchOptions): () => void;\n public abstract evict<TVariables = any>(\n query: Cache.EvictOptions<TVariables>,\n ): Cache.EvictionResult;\n public abstract reset(): Promise<void>;\n\n // intializer / offline / ssr API\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public abstract restore(\n serializedState: TSerialized,\n ): ApolloCache<TSerialized>;\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public abstract extract(optimistic?: boolean): TSerialized;\n\n // optimistic API\n public abstract removeOptimistic(id: string): void;\n\n // transactional API\n public abstract performTransaction(\n transaction: Transaction<TSerialized>,\n ): void;\n public abstract recordOptimisticTransaction(\n transaction: Transaction<TSerialized>,\n id: string,\n ): void;\n\n // optional API\n public transformDocument(document: DocumentNode): DocumentNode {\n return document;\n }\n // experimental\n public transformForLink(document: DocumentNode): DocumentNode {\n return document;\n }\n\n // DataProxy API\n /**\n *\n * @param options\n * @param optimistic\n */\n public readQuery<QueryType, TVariables = any>(\n options: DataProxy.Query<TVariables>,\n optimistic: boolean = false,\n ): QueryType | null {\n return this.read({\n query: options.query,\n variables: options.variables,\n optimistic,\n });\n }\n\n public readFragment<FragmentType, TVariables = any>(\n options: DataProxy.Fragment<TVariables>,\n optimistic: boolean = false,\n ): FragmentType | null {\n return this.read({\n query: getFragmentQueryDocument(options.fragment, options.fragmentName),\n variables: options.variables,\n rootId: options.id,\n optimistic,\n });\n }\n\n public writeQuery<TData = any, TVariables = any>(\n options: Cache.WriteQueryOptions<TData, TVariables>,\n ): void {\n this.write({\n dataId: 'ROOT_QUERY',\n result: options.data,\n query: options.query,\n variables: options.variables,\n });\n }\n\n public writeFragment<TData = any, TVariables = any>(\n options: Cache.WriteFragmentOptions<TData, TVariables>,\n ): void {\n this.write({\n dataId: options.id,\n result: options.data,\n variables: options.variables,\n query: getFragmentQueryDocument(options.fragment, options.fragmentName),\n });\n }\n\n public writeData<TData = any>({\n id,\n data,\n }: Cache.WriteDataOptions<TData>): void {\n if (typeof id !== 'undefined') {\n let typenameResult = null;\n // Since we can't use fragments without having a typename in the store,\n // we need to make sure we have one.\n // To avoid overwriting an existing typename, we need to read it out first\n // and generate a fake one if none exists.\n try {\n typenameResult = this.read<any>({\n rootId: id,\n optimistic: false,\n query: justTypenameQuery,\n });\n } catch (e) {\n // Do nothing, since an error just means no typename exists\n }\n\n // tslint:disable-next-line\n const __typename =\n (typenameResult && typenameResult.__typename) || '__ClientData';\n\n // Add a type here to satisfy the inmemory cache\n const dataToWrite = Object.assign({ __typename }, data);\n\n this.writeFragment({\n id,\n fragment: fragmentFromPojo(dataToWrite, __typename),\n data: dataToWrite,\n });\n } else {\n this.writeQuery({ query: queryFromPojo(data), data });\n }\n }\n}\n","import { DataProxy } from './DataProxy';\n\nexport namespace Cache {\n export type WatchCallback = (newData: any) => void;\n export interface EvictionResult {\n success: Boolean;\n }\n\n export interface ReadOptions<TVariables = any>\n extends DataProxy.Query<TVariables> {\n rootId?: string;\n previousResult?: any;\n optimistic: boolean;\n }\n\n export interface WriteOptions<TResult = any, TVariables = any>\n extends DataProxy.Query<TVariables> {\n dataId: string;\n result: TResult;\n }\n\n export interface DiffOptions extends ReadOptions {\n returnPartialData?: boolean;\n }\n\n export interface WatchOptions extends ReadOptions {\n callback: WatchCallback;\n }\n\n export interface EvictOptions<TVariables = any>\n extends DataProxy.Query<TVariables> {\n rootId?: string;\n }\n\n export import DiffResult = DataProxy.DiffResult;\n export import WriteQueryOptions = DataProxy.WriteQueryOptions;\n export import WriteFragmentOptions = DataProxy.WriteFragmentOptions;\n export import WriteDataOptions = DataProxy.WriteDataOptions;\n export import Fragment = DataProxy.Fragment;\n}\n"]}