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

1 line
12 KiB
Plaintext

{"version":3,"sources":["../src/utils.ts","../src/cache.ts","../src/types/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;WAQgB,a,CAAc,G,EAAQ;AACpC,QAAM,EAAE,GAA4B;AAClC,MAAA,IAAI,EAAE,qBAD4B;AAElC,MAAA,SAAS,EAAE,OAFuB;AAGlC,MAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MADF;AAEJ,QAAA,KAAK,EAAE;AAFH,OAH4B;AAOlC,MAAA,YAAY,EAAE,mBAAmB,CAAC,GAAD;AAPC,KAApC;AAUA,QAAM,GAAG,GAAiB;AACxB,MAAA,IAAI,EAAE,UADkB;AAExB,MAAA,WAAW,EAAE,CAAC,EAAD;AAFW,KAA1B;AAKA,WAAO,GAAP;AACD;;AAED,WAAgB,gBAAhB,CAAiC,GAAjC,EAA2C,QAA3C,EAA4D;AAC1D,QAAM,IAAI,GAA2B;AACnC,MAAA,IAAI,EAAE,oBAD6B;AAEnC,MAAA,aAAa,EAAE;AACb,QAAA,IAAI,EAAE,WADO;AAEb,QAAA,IAAI,EAAE;AACJ,UAAA,IAAI,EAAE,MADF;AAEJ,UAAA,KAAK,EAAE,QAAQ,IAAI;AAFf;AAFO,OAFoB;AASnC,MAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MADF;AAEJ,QAAA,KAAK,EAAE;AAFH,OAT6B;AAanC,MAAA,YAAY,EAAE,mBAAmB,CAAC,GAAD;AAbE,KAArC;AAgBA,QAAM,GAAG,GAAiB;AACxB,MAAA,IAAI,EAAE,UADkB;AAExB,MAAA,WAAW,EAAE,CAAC,IAAD;AAFW,KAA1B;AAKA,WAAO,GAAP;AACD;;AAED,WAAS,mBAAT,CAA6B,GAA7B,EAAqC;AACnC,QACE,OAAO,GAAP,KAAe,QAAf,IACA,OAAO,GAAP,KAAe,SADf,IAEA,OAAO,GAAP,KAAe,QAF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UAAL,CAAgB;AAAE,UAAA,KAAK,EAAE,aAAa,CAAC,IAAD,CAAtB;AAA8B,UAAA,IAAI,EAAA;AAAlC,SAAhB;AACD;AACF,KAnCM;;AAoCT,WAAA,WAAA;AAAC,G;;;MCnJgB,K;;;AAAjB,GAAA,UAAiB,KAAjB,EAAsB,CAqCrB,CArCD,EAAiB,KAAK,sBAAL,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"]}