@daffodil/core 0.39.5 → 0.39.9

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.
@@ -1,16 +1,9 @@
1
+ import { unique } from '@daffodil/core';
1
2
  import { ɵɵdefineInjectable, ɵɵinject, Injectable } from '@angular/core';
2
3
  import { Apollo } from 'apollo-angular';
3
4
  import { Observable } from 'rxjs';
4
5
 
5
- /**
6
- * Filters a list of fragments, removing duplicates.
7
- */
8
- const daffFilterDuplicateFragments = (...documents) =>
9
- // TODO(griest024): extract to core util
10
- documents.filter((doc, index) => documents.slice(index + 1).indexOf(doc) === -1);
11
-
12
6
  const getFragmentNames = (fragment) => fragment.definitions.filter(def => def.kind === 'FragmentDefinition').map(def => def.name.value);
13
- const ɵ0 = getFragmentNames;
14
7
  /**
15
8
  * Builds a list of fragment names present inside the specified GraphQL document nodes.
16
9
  * Returns an empty array if no fragments have been defined or if null is passed.
@@ -18,7 +11,7 @@ const ɵ0 = getFragmentNames;
18
11
  * @param fragments The created fragments.
19
12
  */
20
13
  const daffGetFragmentNames = (...fragments) => fragments.reduce((acc, fragment) => acc.concat(getFragmentNames(fragment)), []);
21
- const ɵ1 = daffGetFragmentNames;
14
+ const ɵ0 = daffGetFragmentNames;
22
15
  /**
23
16
  * Builds a string of fragment names that can be interpolated into a GraphQL query.
24
17
  * Each name is separated by a newline character: '\n'.
@@ -26,7 +19,7 @@ const ɵ1 = daffGetFragmentNames;
26
19
  *
27
20
  * @param fragments A list of GraphQL documents that contain fragments.
28
21
  */
29
- const daffBuildFragmentNameSpread = (...fragments) => daffGetFragmentNames(...daffFilterDuplicateFragments(...fragments)).reduce((acc, name) => acc.concat(`...${name}\n`), '');
22
+ const daffBuildFragmentNameSpread = (...fragments) => unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\n`), '');
30
23
 
31
24
  /**
32
25
  * Builds a string of fragment definitions that can be interpolated into a GraphQL query.
@@ -34,7 +27,7 @@ const daffBuildFragmentNameSpread = (...fragments) => daffGetFragmentNames(...da
34
27
  *
35
28
  * @param documents A list of GraphQL documents that should only contain fragments.
36
29
  */
37
- const daffBuildFragmentDefinition = (...documents) => daffFilterDuplicateFragments(...documents).reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\n`), '');
30
+ const daffBuildFragmentDefinition = (...documents) => documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\n`), '');
38
31
 
39
32
  /**
40
33
  * A service that will queue mutate calls to Apollo.
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-core-graphql.js","sources":["../../../libs/core/graphql/src/fragments/filter-duplicate-fragments.ts","../../../libs/core/graphql/src/fragments/build-fragment-name-spread.ts","../../../libs/core/graphql/src/fragments/build-fragment-definition.ts","../../../libs/core/graphql/src/apollo/queued-apollo/queued-apollo.service.ts","../../../libs/core/graphql/src/daffodil-core-graphql.ts"],"sourcesContent":["import { DocumentNode } from 'graphql';\n\n/**\n * Filters a list of fragments, removing duplicates.\n */\nexport const daffFilterDuplicateFragments = (...documents: DocumentNode[]): DocumentNode[] =>\n // TODO(griest024): extract to core util\n documents.filter((doc, index) => documents.slice(index + 1).indexOf(doc) === -1);\n","import {\n DocumentNode,\n FragmentDefinitionNode,\n} from 'graphql';\n\nimport { daffFilterDuplicateFragments } from './filter-duplicate-fragments';\n\nconst getFragmentNames = (fragment: DocumentNode) =>\n fragment.definitions.filter(def =>\n def.kind === 'FragmentDefinition',\n ).map(def =>\n (<FragmentDefinitionNode>def).name.value,\n );\n\n/**\n * Builds a list of fragment names present inside the specified GraphQL document nodes.\n * Returns an empty array if no fragments have been defined or if null is passed.\n *\n * @param fragments The created fragments.\n */\nconst daffGetFragmentNames = (...fragments: DocumentNode[]): string[] =>\n fragments.reduce((acc, fragment) => acc.concat(getFragmentNames(fragment)), []);\n\n/**\n * Builds a string of fragment names that can be interpolated into a GraphQL query.\n * Each name is separated by a newline character: '\\n'.\n * If an empty array is passed, an empty string is returned.\n *\n * @param fragments A list of GraphQL documents that contain fragments.\n */\nexport const daffBuildFragmentNameSpread = (...fragments: DocumentNode[]): string =>\n daffGetFragmentNames(...daffFilterDuplicateFragments(...fragments)).reduce((acc, name) => acc.concat(`...${name}\\n`), '');\n","import { DocumentNode } from 'graphql';\n\nimport { daffFilterDuplicateFragments } from './filter-duplicate-fragments';\n\n/**\n * Builds a string of fragment definitions that can be interpolated into a GraphQL query.\n * Each definition is separated by a newline character: '\\n'.\n *\n * @param documents A list of GraphQL documents that should only contain fragments.\n */\nexport const daffBuildFragmentDefinition = (...documents: DocumentNode[]): string =>\n daffFilterDuplicateFragments(...documents).reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\\n`), '');\n","import { Injectable } from '@angular/core';\nimport {\n MutationOptions,\n FetchResult,\n} from '@apollo/client/core';\nimport { Apollo } from 'apollo-angular';\nimport { EmptyObject } from 'apollo-angular/types';\nimport {\n Observable,\n Subscriber,\n Subscription,\n} from 'rxjs';\n\n/**\n * A service that will queue mutate calls to Apollo.\n * It will not send subsequent mutate requests until the previous one has been completed.\n * This is useful for avoiding race conditions on the backend.\n * This should be used alongside Apollo.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffQueuedApollo {\n queue: (() => void)[] = [];\n\n constructor(\n private apollo: Apollo,\n ) {}\n\n /**\n * Queue up a mutate request.\n * The request will not actually be queued until the returned observable is subscribed.\n * If the queue is empty, the request will be sent when it enters the queue.\n * Otherwise, it will be sent when it reaches the front of the queue.\n * The observable will complete after it emits once.\n *\n * @param options Mutation options.\n */\n mutate<T, V = EmptyObject>(options: MutationOptions<T, V>): Observable<FetchResult<T>> {\n return new Observable(subscriber => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));\n }\n\n private addRequestToQueue(subscriber: Subscriber<any>, request: Observable<any>): void {\n this.queue.push(() => {\n const sub = request.subscribe(\n response => {\n // emit the outer observable\n subscriber.next(response);\n subscriber.complete();\n\n this.finishRequestSubscription(sub);\n },\n error => {\n subscriber.error(error);\n this.finishRequestSubscription(sub);\n },\n () => {\n subscriber.complete();\n this.finishRequestSubscription(sub);\n },\n );\n });\n\n // start the queue if previously empty\n if (this.queue.length === 1) {\n this.queue[0]();\n }\n }\n\n private finishRequestSubscription(requestSubscription: Subscription): void {\n requestSubscription.unsubscribe();\n\n // process queue\n this.queue.shift();\n this.queue[0]?.();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAEA;;;AAGO,MAAM,4BAA4B,GAAG,CAAC,GAAG,SAAyB;AACvE;AACA,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;;ACAlF,MAAM,gBAAgB,GAAG,CAAC,QAAsB,KAC9C,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,IAC7B,GAAG,CAAC,IAAI,KAAK,oBAAoB,CAClC,CAAC,GAAG,CAAC,GAAG,IACkB,GAAI,CAAC,IAAI,CAAC,KAAK,CACzC,CAAC;;AAEJ;;;;;;AAMA,MAAM,oBAAoB,GAAG,CAAC,GAAG,SAAyB,KACxD,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;;AAElF;;;;;;;MAOa,2BAA2B,GAAG,CAAC,GAAG,SAAyB,KACtE,oBAAoB,CAAC,GAAG,4BAA4B,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,EAAE;;AC3B1H;;;;;;MAMa,2BAA2B,GAAG,CAAC,GAAG,SAAyB,KACtE,4BAA4B,CAAC,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AC,KAAK,EAAE,CAAC;QACnB,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC,mDAAK;KACnB;;;;YAxDF,UAAU,SAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;;YAhBQ,MAAM;;;ACLf;;;;;;"}
1
+ {"version":3,"file":"daffodil-core-graphql.js","sources":["../../../libs/core/graphql/src/fragments/build-fragment-name-spread.ts","../../../libs/core/graphql/src/fragments/build-fragment-definition.ts","../../../libs/core/graphql/src/apollo/queued-apollo/queued-apollo.service.ts","../../../libs/core/graphql/src/daffodil-core-graphql.ts"],"sourcesContent":["import {\n DocumentNode,\n FragmentDefinitionNode,\n} from 'graphql';\n\nimport { unique } from '@daffodil/core';\n\nexport const getFragmentNames = (fragment: DocumentNode) =>\n fragment.definitions.filter(def =>\n def.kind === 'FragmentDefinition',\n ).map(def =>\n (<FragmentDefinitionNode>def).name.value,\n );\n\n/**\n * Builds a list of fragment names present inside the specified GraphQL document nodes.\n * Returns an empty array if no fragments have been defined or if null is passed.\n *\n * @param fragments The created fragments.\n */\nconst daffGetFragmentNames = (...fragments: DocumentNode[]): string[] =>\n fragments.reduce((acc, fragment) => acc.concat(getFragmentNames(fragment)), []);\n\n/**\n * Builds a string of fragment names that can be interpolated into a GraphQL query.\n * Each name is separated by a newline character: '\\n'.\n * If an empty array is passed, an empty string is returned.\n *\n * @param fragments A list of GraphQL documents that contain fragments.\n */\nexport const daffBuildFragmentNameSpread = (...fragments: DocumentNode[]): string =>\n unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\\n`), '');\n","import { DocumentNode } from 'graphql';\n\n/**\n * Builds a string of fragment definitions that can be interpolated into a GraphQL query.\n * Each definition is separated by a newline character: '\\n'.\n *\n * @param documents A list of GraphQL documents that should only contain fragments.\n */\nexport const daffBuildFragmentDefinition = (...documents: DocumentNode[]): string =>\n documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\\n`), '');\n","import { Injectable } from '@angular/core';\nimport {\n MutationOptions,\n FetchResult,\n} from '@apollo/client/core';\nimport { Apollo } from 'apollo-angular';\nimport { EmptyObject } from 'apollo-angular/types';\nimport {\n Observable,\n Subscriber,\n Subscription,\n} from 'rxjs';\n\n/**\n * A service that will queue mutate calls to Apollo.\n * It will not send subsequent mutate requests until the previous one has been completed.\n * This is useful for avoiding race conditions on the backend.\n * This should be used alongside Apollo.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffQueuedApollo {\n queue: (() => void)[] = [];\n\n constructor(\n private apollo: Apollo,\n ) {}\n\n /**\n * Queue up a mutate request.\n * The request will not actually be queued until the returned observable is subscribed.\n * If the queue is empty, the request will be sent when it enters the queue.\n * Otherwise, it will be sent when it reaches the front of the queue.\n * The observable will complete after it emits once.\n *\n * @param options Mutation options.\n */\n mutate<T, V = EmptyObject>(options: MutationOptions<T, V>): Observable<FetchResult<T>> {\n return new Observable(subscriber => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));\n }\n\n private addRequestToQueue(subscriber: Subscriber<any>, request: Observable<any>): void {\n this.queue.push(() => {\n const sub = request.subscribe(\n response => {\n // emit the outer observable\n subscriber.next(response);\n subscriber.complete();\n\n this.finishRequestSubscription(sub);\n },\n error => {\n subscriber.error(error);\n this.finishRequestSubscription(sub);\n },\n () => {\n subscriber.complete();\n this.finishRequestSubscription(sub);\n },\n );\n });\n\n // start the queue if previously empty\n if (this.queue.length === 1) {\n this.queue[0]();\n }\n }\n\n private finishRequestSubscription(requestSubscription: Subscription): void {\n requestSubscription.unsubscribe();\n\n // process queue\n this.queue.shift();\n this.queue[0]?.();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAOO,MAAM,gBAAgB,GAAG,CAAC,QAAsB,KACrD,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,IAC7B,GAAG,CAAC,IAAI,KAAK,oBAAoB,CAClC,CAAC,GAAG,CAAC,GAAG,IACkB,G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AC,yBAAyB,CAAC,GAAG,CAAC,CAAC;aACrC,EACD,KAAK;gBACH,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;aACrC,EACD;gBACE,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACtB,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;aACrC,CACF,CAAC;SACH,CAAC,CAAC;;QAGH,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SACjB;KACF;IAEO,yBAAyB,CAAC,mBAAiC;;QACjE,mBAAmB,CAAC,WAAW,EAAE,CAAC;;QAGlC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC,mDAAK;KACnB;;;;YAxDF,UAAU,SAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;;YAhBQ,MAAM;;;ACLf;;;;;;"}
@@ -163,6 +163,15 @@ const daffArrayToDict = (array, getKey = (val) => val.key) => array.reduce((dict
163
163
  */
164
164
  const sample = (array) => randomSlice(array, 1)[0];
165
165
 
166
+ /**
167
+ * Filters an array of elements, removing duplicates.
168
+ * Does not guarantee order of filtered elements.
169
+ *
170
+ * An optional comparator function may be passed for arbitrary comparison behavior.
171
+ * The default is a strict equality comparison: `a === b`.
172
+ */
173
+ const unique = (array, comparator = (a, b) => a === b) => array.filter((a, index) => array.slice(index + 1).filter(b => comparator(a, b)).length === 0);
174
+
166
175
  /**
167
176
  * A class which allows you to appropriately check the inheritance of an error.
168
177
  *
@@ -354,5 +363,5 @@ function backoff(maxTries, ms) {
354
363
  * Generated bundle index. Do not edit.
355
364
  */
356
365
 
357
- export { DaffErrorStorageService, DaffInheritableError, DaffLocalStorageService, DaffNoopStorageService, DaffPersistenceServiceToken, DaffServerErrorStorageService, DaffServerSideStorageError, DaffStorageServiceError, backoff, daffAdd, daffArrayToDict, daffDivide, daffMultiply, daffSubtract, randomSlice, randomSubset, range, sample, shuffle };
366
+ export { DaffErrorStorageService, DaffInheritableError, DaffLocalStorageService, DaffNoopStorageService, DaffPersistenceServiceToken, DaffServerErrorStorageService, DaffServerSideStorageError, DaffStorageServiceError, backoff, daffAdd, daffArrayToDict, daffDivide, daffMultiply, daffSubtract, randomSlice, randomSubset, range, sample, shuffle, unique };
358
367
  //# sourceMappingURL=daffodil-core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-core.js","sources":["../../../libs/core/src/utils/long-arithmetic.ts","../../../libs/core/src/utils/range.ts","../../../libs/core/src/utils/shuffle.ts","../../../libs/core/src/utils/random-subset.ts","../../../libs/core/src/utils/random-slice.ts","../../../libs/core/src/utils/array-to-dict.ts","../../../libs/core/src/utils/sample.ts","../../../libs/core/src/errors/inheritable-error.ts","../../../libs/core/src/storage/error/error.ts","../../../libs/core/src/storage/error/error.service.ts","../../../libs/core/src/storage/server-error/server-error.ts","../../../libs/core/src/storage/server-error/server-error.service.ts","../../../libs/core/src/storage/localstorage/localstorage.service.ts","../../../libs/core/src/storage/noopstorage/noopstorage.service.ts","../../../libs/core/src/storage/persistence.interface.ts","../../../libs/core/src/operators/backoff.pipe.ts","../../../libs/core/src/daffodil-core.ts"],"sourcesContent":["/**\n * A helper function to get the number of decimal significant figures of a number.\n * This function will fail if the given number has more than 16 significant figures or\n * the value of the number is greater than 10^11\n *\n * @param number\n */\nfunction daffPrecision(number: number): number {\n let p = 10000;\n if(number === undefined || number === null) {\n return p;\n }\n while (Math.round(number * p) / p !== number) {\n p *= 10;\n }\n return p;\n}\n\n/**\n * A function to add long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are less than\n * 16 significant figures and less than 10^11\n *\n * @param numbers\n */\nexport function daffAdd(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffAdd.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.reduce((acc, number) => acc + Math.round(number*precision), 0) / precision;\n}\n\n/**\n * A function to subtract long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than\n * 16 significant figures and less than 10^11\n *\n * @param numbers\n */\nexport function daffSubtract(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffSubtract.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.slice(1).reduce(\n (acc, number) => acc - Math.round(number*precision),\n Math.round(numbers[0]*precision),\n ) / precision;\n}\n\n/**\n * A function to multiply long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures\n * and less than 10^11\n *\n * @param numbers\n */\nexport function daffMultiply(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffMultiply.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.reduce(\n (acc, number) => acc * Math.round(number*precision),\n 1,\n ) / Math.pow(precision, numbers.length);\n}\n\n/**\n * A function to divide long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures\n * and less than 10^11\n *\n * Returns NaN when attempting to use NaN as an input.\n * Returns NaN when attempting to divide by 0 or null.\n *\n * @param numbers\n */\nexport function daffDivide(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffDivide.');\n }\n // TODO(griest024): use better condition after IE support is dropped\n const illegalOperation = numbers.filter(isNaN).length > 0\n || numbers.slice(1).filter(n => n === 0 || n === null).length > 0;\n if (illegalOperation) {\n return NaN;\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.slice(1).reduce(\n (acc, number) => acc / Math.round(number*precision),\n Math.round(numbers[0]*precision),\n ) * Math.pow(precision, numbers.length - 2);\n}\n","/**\n * Range\n *\n * Range accepts two inputs, a `start` and an `end`\n * and returns an array filled with numbers from\n * `start` to `end`.\n *\n * @param start\n * @param end\n * @returns number\n */\nexport const range = (start: number, end: number): Array<number> =>\n Array.apply(null, Array(end - start + 1)).map((val, index) => index + start);\n\n","/**\n * Immutable Fisher-Yates Shuffle\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\n */\nexport const shuffle = <T>(array: T[]): T[] => {\n const result = [];\n array.forEach((el, i) => {\n const s = Math.floor(Math.random() * i);\n if( s !== i ){\n result[i] = result[s];\n }\n result[s] = el;\n });\n return result;\n};\n","import { shuffle } from './shuffle';\n\n/**\n * Returns a random subset of an array in a random order.\n *\n * @param array\n * @param length\n */\nexport const randomSubset = <T>(array: T[], length?: number): T[] => {\n if(length > array.length){\n throw new Error('Requested length is longer than array length.');\n }\n length = length ? length : Math.floor(Math.random() * array.length);\n return shuffle(array).slice(0, length);\n};\n","/**\n * Returns a random slice of an array.\n * An optional length may be specified.\n *\n * @param array\n */\nexport const randomSlice = <T>(array: T[], length?: number): T[] => {\n if(array.length === 0) {\n return [];\n };\n if(length > array.length) {\n throw new Error('Requested length is longer than array length.');\n }\n const arrayLength = length || Math.floor(Math.random() * array.length);\n const start = Math.floor(Math.random() * (array.length - arrayLength + 1));\n const end = start + arrayLength;\n return array.slice(start, end);\n};\n","import { Dict } from '../types/public_api';\n\n/**\n * Converts an array into a dictionary.\n * Dictionary values are keyed by the return of the specified getKey, or `'key'` by default.\n */\nexport const daffArrayToDict = <T>(array: T[], getKey = (val: T) => (<any>val).key): Dict<T> =>\n array.reduce(\n (dict, val) => {\n dict[getKey(val)] = val;\n return dict;\n },\n {},\n );\n","import { randomSlice } from './random-slice';\n\n/**\n * Returns a random element of an array.\n */\nexport const sample = <T>(array: T[]): T => randomSlice(array, 1)[0];\n","/**\n * A class which allows you to appropriately check the inheritance of an error.\n *\n * In typescript, when you try to extend an error with a specialized error class,\n * if you try to call something like:\n *\n * ```ts\n * class MyError extends Error {}\n *\n * let myError = new MyError();\n *\n * myError instanceof MyError; // returns false\n * ```\n *\n * You will see unexpected things. This class fixes that issue as described here\n * https://github.com/microsoft/TypeScript/issues/13965\n */\nexport class DaffInheritableError extends Error {\n\t__proto__: Error;\n\n\tconstructor(message?: string) {\n\t const trueProto = new.target.prototype;\n\t super(message);\n\n\t Object.setPrototypeOf(this, trueProto);\n\t}\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '../../errors/public_api';\n\nexport class DaffStorageServiceError extends DaffInheritableError implements DaffError {\n public readonly code: string = 'DAFF_STORAGE_FAILURE';\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\nimport { DaffStorageServiceError } from './error';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffErrorStorageService implements DaffPersistenceService {\n static readonly ERROR_MESSAGE = 'The DaffErrorStorageService always throws an error.';\n\n setItem(key: string, value: any): void {\n this.throwError();\n }\n\n getItem(key: string): any {\n this.throwError();\n }\n\n removeItem(key: string): any {\n this.throwError();\n }\n\n clear(){\n this.throwError();\n }\n\n private throwError() {\n throw new DaffStorageServiceError(DaffErrorStorageService.ERROR_MESSAGE);\n }\n}\n","import { DaffError } from '../../errors/public_api';\nimport { DaffStorageServiceError } from '../error/error';\n\n/**\n * An error thrown when there is an attempt to access storage on the server and none is available.\n */\nexport class DaffServerSideStorageError extends DaffStorageServiceError implements DaffError {\n public readonly code: string = 'DAFF_SERVER_STORAGE_FAILURE';\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\nimport { DaffServerSideStorageError } from './server-error';\n\n/**\n * A storage service meant to be loaded into SSR contexts.\n * It will always throw the {@link DaffServerSideStorageError}.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffServerErrorStorageService implements DaffPersistenceService {\n static readonly ERROR_MESSAGE = 'The DaffServerErrorStorageService always throws an error.';\n\n setItem(key: string, value: any): void {\n this.throwError();\n }\n\n getItem(key: string): any {\n this.throwError();\n }\n\n removeItem(key: string): any {\n this.throwError();\n }\n\n clear(){\n this.throwError();\n }\n\n private throwError() {\n throw new DaffServerSideStorageError(DaffServerErrorStorageService.ERROR_MESSAGE);\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffLocalStorageService implements DaffPersistenceService {\n constructor(@Inject(PLATFORM_ID) platformId: string){\n if(!isPlatformBrowser(platformId)){\n throw new Error('The DaffLocalStorageService can only be instantiated in the browser.');\n }\n }\n\n /**\n * Persist the given item into local storage.\n */\n setItem(key: string, value: any): void {\n localStorage.setItem(key, value);\n }\n\n /**\n * Retrieve the given item from localstorage.\n */\n getItem(key: string): any {\n return localStorage.getItem(key);\n }\n\n /**\n * Remove a given item from localstorage\n */\n removeItem(key: string): any {\n localStorage.removeItem(key);\n }\n\n clear(){\n localStorage.clear();\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffNoopStorageService implements DaffPersistenceService {\n setItem(key: string, value: any): void {};\n getItem(key: string): any {};\n clear(): void {};\n removeItem(key: string): void {};\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n InjectionToken,\n inject,\n PLATFORM_ID,\n} from '@angular/core';\n\nimport { DaffLocalStorageService } from './localstorage/localstorage.service';\nimport { DaffServerErrorStorageService } from './server-error/public_api';\n\nexport interface DaffPersistenceService {\n setItem(key: string, value: any): void;\n getItem(key: string): any;\n clear(): void;\n removeItem(key: string): void;\n}\n\nexport const DaffPersistenceServiceToken = new InjectionToken<DaffPersistenceService>('DaffPersistenceService', {\n providedIn: 'root',\n factory: () => isPlatformBrowser(inject<string>(PLATFORM_ID))\n ? new DaffLocalStorageService(inject<string>(PLATFORM_ID))\n : new DaffServerErrorStorageService(),\n});\n","import {\n pipe,\n timer,\n throwError,\n} from 'rxjs';\nimport {\n retryWhen,\n mergeMap,\n} from 'rxjs/operators';\n\n/**\n * Retries failed Observables\n *\n * @param maxTries The maximum number of tries the observable will be tried\n * @param ms The initial amount of time\n */\nexport function backoff(maxTries: number, ms: number) {\n return pipe(\n retryWhen(attempt => attempt.pipe(\n mergeMap((shadowedAttempt: Error, i) => {\n if(i >= maxTries) {\n return throwError(shadowedAttempt);\n }\n return timer(ms*Math.pow(2,i));\n }),\n )),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;AAOA,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,IAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;QAC1C,OAAO,CAAC,CAAC;KACV;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,MAAM,EAAE;QAC5C,CAAC,IAAI,EAAE,CAAC;KACT;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;;;SAOgB,OAAO,CAAC,GAAG,OAAiB;IAC1C,IAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAC,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;AAC5F,CAAC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BAA2B,GAAG,IAAI,cAAc,CAAyB,wBAAwB,EAAE;IAC9G,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAM,iBAAiB,CAAC,MAAM,CAAS,WAAW,CAAC,CAAC;UACzD,IAAI,uBAAuB,CAAC,MAAM,CAAS,WAAW,CAAC,CAAC;UACxD,IAAI,6BAA6B,EAAE;CACxC;;ACZD;;;;;;SAMgB,OAAO,CAAC,QAAgB,EAAE,EAAU;IAClD,OAAO,IAAI,CACT,SAAS,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAC/B,QAAQ,CAAC,CAAC,eAAsB,EAAE,CAAC;QACjC,IAAG,CAAC,IAAI,QAAQ,EAAE;YAChB,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC;SACpC;QACD,OAAO,KAAK,CAAC,EAAE,GAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;KAChC,CAAC,CACH,CAAC,CACH,CAAC;AACJ;;AC3BA;;;;;;"}
1
+ {"version":3,"file":"daffodil-core.js","sources":["../../../libs/core/src/utils/long-arithmetic.ts","../../../libs/core/src/utils/range.ts","../../../libs/core/src/utils/shuffle.ts","../../../libs/core/src/utils/random-subset.ts","../../../libs/core/src/utils/random-slice.ts","../../../libs/core/src/utils/array-to-dict.ts","../../../libs/core/src/utils/sample.ts","../../../libs/core/src/utils/unique.ts","../../../libs/core/src/errors/inheritable-error.ts","../../../libs/core/src/storage/error/error.ts","../../../libs/core/src/storage/error/error.service.ts","../../../libs/core/src/storage/server-error/server-error.ts","../../../libs/core/src/storage/server-error/server-error.service.ts","../../../libs/core/src/storage/localstorage/localstorage.service.ts","../../../libs/core/src/storage/noopstorage/noopstorage.service.ts","../../../libs/core/src/storage/persistence.interface.ts","../../../libs/core/src/operators/backoff.pipe.ts","../../../libs/core/src/daffodil-core.ts"],"sourcesContent":["/**\n * A helper function to get the number of decimal significant figures of a number.\n * This function will fail if the given number has more than 16 significant figures or\n * the value of the number is greater than 10^11\n *\n * @param number\n */\nfunction daffPrecision(number: number): number {\n let p = 10000;\n if(number === undefined || number === null) {\n return p;\n }\n while (Math.round(number * p) / p !== number) {\n p *= 10;\n }\n return p;\n}\n\n/**\n * A function to add long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are less than\n * 16 significant figures and less than 10^11\n *\n * @param numbers\n */\nexport function daffAdd(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffAdd.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.reduce((acc, number) => acc + Math.round(number*precision), 0) / precision;\n}\n\n/**\n * A function to subtract long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than\n * 16 significant figures and less than 10^11\n *\n * @param numbers\n */\nexport function daffSubtract(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffSubtract.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.slice(1).reduce(\n (acc, number) => acc - Math.round(number*precision),\n Math.round(numbers[0]*precision),\n ) / precision;\n}\n\n/**\n * A function to multiply long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures\n * and less than 10^11\n *\n * @param numbers\n */\nexport function daffMultiply(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffMultiply.');\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.reduce(\n (acc, number) => acc * Math.round(number*precision),\n 1,\n ) / Math.pow(precision, numbers.length);\n}\n\n/**\n * A function to divide long numbers accurately with conversions and integer math.\n * This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures\n * and less than 10^11\n *\n * Returns NaN when attempting to use NaN as an input.\n * Returns NaN when attempting to divide by 0 or null.\n *\n * @param numbers\n */\nexport function daffDivide(...numbers: number[]): number {\n if(numbers.length < 2) {\n throw new Error('Provide at least 2 numbers for daffDivide.');\n }\n // TODO(griest024): use better condition after IE support is dropped\n const illegalOperation = numbers.filter(isNaN).length > 0\n || numbers.slice(1).filter(n => n === 0 || n === null).length > 0;\n if (illegalOperation) {\n return NaN;\n }\n const precision = Math.max(...numbers.map(daffPrecision));\n return numbers.slice(1).reduce(\n (acc, number) => acc / Math.round(number*precision),\n Math.round(numbers[0]*precision),\n ) * Math.pow(precision, numbers.length - 2);\n}\n","/**\n * Range\n *\n * Range accepts two inputs, a `start` and an `end`\n * and returns an array filled with numbers from\n * `start` to `end`.\n *\n * @param start\n * @param end\n * @returns number\n */\nexport const range = (start: number, end: number): Array<number> =>\n Array.apply(null, Array(end - start + 1)).map((val, index) => index + start);\n\n","/**\n * Immutable Fisher-Yates Shuffle\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\n */\nexport const shuffle = <T>(array: T[]): T[] => {\n const result = [];\n array.forEach((el, i) => {\n const s = Math.floor(Math.random() * i);\n if( s !== i ){\n result[i] = result[s];\n }\n result[s] = el;\n });\n return result;\n};\n","import { shuffle } from './shuffle';\n\n/**\n * Returns a random subset of an array in a random order.\n *\n * @param array\n * @param length\n */\nexport const randomSubset = <T>(array: T[], length?: number): T[] => {\n if(length > array.length){\n throw new Error('Requested length is longer than array length.');\n }\n length = length ? length : Math.floor(Math.random() * array.length);\n return shuffle(array).slice(0, length);\n};\n","/**\n * Returns a random slice of an array.\n * An optional length may be specified.\n *\n * @param array\n */\nexport const randomSlice = <T>(array: T[], length?: number): T[] => {\n if(array.length === 0) {\n return [];\n };\n if(length > array.length) {\n throw new Error('Requested length is longer than array length.');\n }\n const arrayLength = length || Math.floor(Math.random() * array.length);\n const start = Math.floor(Math.random() * (array.length - arrayLength + 1));\n const end = start + arrayLength;\n return array.slice(start, end);\n};\n","import { Dict } from '../types/public_api';\n\n/**\n * Converts an array into a dictionary.\n * Dictionary values are keyed by the return of the specified getKey, or `'key'` by default.\n */\nexport const daffArrayToDict = <T>(array: T[], getKey = (val: T) => (<any>val).key): Dict<T> =>\n array.reduce(\n (dict, val) => {\n dict[getKey(val)] = val;\n return dict;\n },\n {},\n );\n","import { randomSlice } from './random-slice';\n\n/**\n * Returns a random element of an array.\n */\nexport const sample = <T>(array: T[]): T => randomSlice(array, 1)[0];\n","/**\n * Filters an array of elements, removing duplicates.\n * Does not guarantee order of filtered elements.\n *\n * An optional comparator function may be passed for arbitrary comparison behavior.\n * The default is a strict equality comparison: `a === b`.\n */\nexport const unique = <T>(array: T[], comparator: (a: T, b: T) => boolean = (a, b) => a === b): T[] =>\n array.filter((a, index) => array.slice(index + 1).filter(b => comparator(a, b)).length === 0);\n","/**\n * A class which allows you to appropriately check the inheritance of an error.\n *\n * In typescript, when you try to extend an error with a specialized error class,\n * if you try to call something like:\n *\n * ```ts\n * class MyError extends Error {}\n *\n * let myError = new MyError();\n *\n * myError instanceof MyError; // returns false\n * ```\n *\n * You will see unexpected things. This class fixes that issue as described here\n * https://github.com/microsoft/TypeScript/issues/13965\n */\nexport class DaffInheritableError extends Error {\n\t__proto__: Error;\n\n\tconstructor(message?: string) {\n\t const trueProto = new.target.prototype;\n\t super(message);\n\n\t Object.setPrototypeOf(this, trueProto);\n\t}\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '../../errors/public_api';\n\nexport class DaffStorageServiceError extends DaffInheritableError implements DaffError {\n public readonly code: string = 'DAFF_STORAGE_FAILURE';\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\nimport { DaffStorageServiceError } from './error';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffErrorStorageService implements DaffPersistenceService {\n static readonly ERROR_MESSAGE = 'The DaffErrorStorageService always throws an error.';\n\n setItem(key: string, value: any): void {\n this.throwError();\n }\n\n getItem(key: string): any {\n this.throwError();\n }\n\n removeItem(key: string): any {\n this.throwError();\n }\n\n clear(){\n this.throwError();\n }\n\n private throwError() {\n throw new DaffStorageServiceError(DaffErrorStorageService.ERROR_MESSAGE);\n }\n}\n","import { DaffError } from '../../errors/public_api';\nimport { DaffStorageServiceError } from '../error/error';\n\n/**\n * An error thrown when there is an attempt to access storage on the server and none is available.\n */\nexport class DaffServerSideStorageError extends DaffStorageServiceError implements DaffError {\n public readonly code: string = 'DAFF_SERVER_STORAGE_FAILURE';\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\nimport { DaffServerSideStorageError } from './server-error';\n\n/**\n * A storage service meant to be loaded into SSR contexts.\n * It will always throw the {@link DaffServerSideStorageError}.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffServerErrorStorageService implements DaffPersistenceService {\n static readonly ERROR_MESSAGE = 'The DaffServerErrorStorageService always throws an error.';\n\n setItem(key: string, value: any): void {\n this.throwError();\n }\n\n getItem(key: string): any {\n this.throwError();\n }\n\n removeItem(key: string): any {\n this.throwError();\n }\n\n clear(){\n this.throwError();\n }\n\n private throwError() {\n throw new DaffServerSideStorageError(DaffServerErrorStorageService.ERROR_MESSAGE);\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffLocalStorageService implements DaffPersistenceService {\n constructor(@Inject(PLATFORM_ID) platformId: string){\n if(!isPlatformBrowser(platformId)){\n throw new Error('The DaffLocalStorageService can only be instantiated in the browser.');\n }\n }\n\n /**\n * Persist the given item into local storage.\n */\n setItem(key: string, value: any): void {\n localStorage.setItem(key, value);\n }\n\n /**\n * Retrieve the given item from localstorage.\n */\n getItem(key: string): any {\n return localStorage.getItem(key);\n }\n\n /**\n * Remove a given item from localstorage\n */\n removeItem(key: string): any {\n localStorage.removeItem(key);\n }\n\n clear(){\n localStorage.clear();\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffPersistenceService } from '../persistence.interface';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffNoopStorageService implements DaffPersistenceService {\n setItem(key: string, value: any): void {};\n getItem(key: string): any {};\n clear(): void {};\n removeItem(key: string): void {};\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n InjectionToken,\n inject,\n PLATFORM_ID,\n} from '@angular/core';\n\nimport { DaffLocalStorageService } from './localstorage/localstorage.service';\nimport { DaffServerErrorStorageService } from './server-error/public_api';\n\nexport interface DaffPersistenceService {\n setItem(key: string, value: any): void;\n getItem(key: string): any;\n clear(): void;\n removeItem(key: string): void;\n}\n\nexport const DaffPersistenceServiceToken = new InjectionToken<DaffPersistenceService>('DaffPersistenceService', {\n providedIn: 'root',\n factory: () => isPlatformBrowser(inject<string>(PLATFORM_ID))\n ? new DaffLocalStorageService(inject<string>(PLATFORM_ID))\n : new DaffServerErrorStorageService(),\n});\n","import {\n pipe,\n timer,\n throwError,\n} from 'rxjs';\nimport {\n retryWhen,\n mergeMap,\n} from 'rxjs/operators';\n\n/**\n * Retries failed Observables\n *\n * @param maxTries The maximum number of tries the observable will be tried\n * @param ms The initial amount of time\n */\nexport function backoff(maxTries: number, ms: number) {\n return pipe(\n retryWhen(attempt => attempt.pipe(\n mergeMap((shadowedAttempt: Error, i) => {\n if(i >= maxTries) {\n return throwError(shadowedAttempt);\n }\n return timer(ms*Math.pow(2,i));\n }),\n )),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;AAOA,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,IAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;QAC1C,OAAO,CAAC,CAAC;KACV;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG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C,IAAG,CAAC,IAAI,QAAQ,EAAE;YAChB,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC;SACpC;QACD,OAAO,KAAK,CAAC,EAAE,GAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;KAChC,CAAC,CACH,CAAC,CACH,CAAC;AACJ;;AC3BA;;;;;;"}
@@ -1 +1 @@
1
- {"__symbolic":"module","version":4,"metadata":{"daffBuildFragmentNameSpread":{"__symbolic":"error","message":"Lambda not supported","line":30,"character":43,"module":"./fragments/build-fragment-name-spread"},"daffBuildFragmentDefinition":{"__symbolic":"error","message":"Lambda not supported","line":10,"character":43,"module":"./fragments/build-fragment-definition"},"DaffQueuedApollo":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":19,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"apollo-angular","name":"Apollo","line":26,"character":20}]}],"mutate":[{"__symbolic":"method"}],"addRequestToQueue":[{"__symbolic":"method"}],"finishRequestSubscription":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"DaffApolloCacheableOperationLinkGenerator":{"__symbolic":"interface"}},"origins":{"daffBuildFragmentNameSpread":"./fragments/build-fragment-name-spread","daffBuildFragmentDefinition":"./fragments/build-fragment-definition","DaffQueuedApollo":"./apollo/queued-apollo/queued-apollo.service","DaffApolloCacheableOperationLinkGenerator":"./apollo/cacheable-operations/cacheable-operations-link.interface"},"importAs":"@daffodil/core/graphql"}
1
+ {"__symbolic":"module","version":4,"metadata":{"daffBuildFragmentNameSpread":{"__symbolic":"error","message":"Lambda not supported","line":30,"character":43,"module":"./fragments/build-fragment-name-spread"},"daffBuildFragmentDefinition":{"__symbolic":"error","message":"Lambda not supported","line":8,"character":43,"module":"./fragments/build-fragment-definition"},"DaffQueuedApollo":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":19,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"apollo-angular","name":"Apollo","line":26,"character":20}]}],"mutate":[{"__symbolic":"method"}],"addRequestToQueue":[{"__symbolic":"method"}],"finishRequestSubscription":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"DaffApolloCacheableOperationLinkGenerator":{"__symbolic":"interface"}},"origins":{"daffBuildFragmentNameSpread":"./fragments/build-fragment-name-spread","daffBuildFragmentDefinition":"./fragments/build-fragment-definition","DaffQueuedApollo":"./apollo/queued-apollo/queued-apollo.service","DaffApolloCacheableOperationLinkGenerator":"./apollo/cacheable-operations/cacheable-operations-link.interface"},"importAs":"@daffodil/core/graphql"}
@@ -1,4 +1,5 @@
1
1
  import { DocumentNode } from 'graphql';
2
+ export declare const getFragmentNames: (fragment: DocumentNode) => string[];
2
3
  /**
3
4
  * Builds a string of fragment names that can be interpolated into a GraphQL query.
4
5
  * Each name is separated by a newline character: '\n'.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daffodil/core",
3
- "version": "0.39.5",
3
+ "version": "0.39.9",
4
4
  "description": "Interfaces built for daffodil/state",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,17 @@
14
14
  "homepage": "https://github.com/graycoreio/daffodil",
15
15
  "peerDependencies": {
16
16
  "@angular/core": "^11.0.0",
17
- "graphql": "^15.4.0"
17
+ "@angular/common": "^11.0.0",
18
+ "rxjs": "6.6.3"
18
19
  },
19
20
  "optionalDependencies": {
20
- "@angular/router": "^11.0.0"
21
+ "graphql": "^15.4.0",
22
+ "@angular/router": "^11.0.0",
23
+ "@apollo/client": "^3.0.0",
24
+ "@ngrx/store": "^11.0.0",
25
+ "angular-in-memory-web-api": "^0.11.0",
26
+ "apollo-angular": "^2.4.0",
27
+ "faker": "^5.5.3"
21
28
  },
22
29
  "main": "bundles/daffodil-core.umd.js",
23
30
  "module": "fesm2015/daffodil-core.js",
@@ -5,3 +5,4 @@ export { randomSubset } from './random-subset';
5
5
  export { randomSlice } from './random-slice';
6
6
  export { daffArrayToDict } from './array-to-dict';
7
7
  export { sample } from './sample';
8
+ export { unique } from './unique';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Filters an array of elements, removing duplicates.
3
+ * Does not guarantee order of filtered elements.
4
+ *
5
+ * An optional comparator function may be passed for arbitrary comparison behavior.
6
+ * The default is a strict equality comparison: `a === b`.
7
+ */
8
+ export declare const unique: <T>(array: T[], comparator?: (a: T, b: T) => boolean) => T[];
@@ -1,7 +0,0 @@
1
- /**
2
- * Filters a list of fragments, removing duplicates.
3
- */
4
- export const daffFilterDuplicateFragments = (...documents) =>
5
- // TODO(griest024): extract to core util
6
- documents.filter((doc, index) => documents.slice(index + 1).indexOf(doc) === -1);
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsdGVyLWR1cGxpY2F0ZS1mcmFnbWVudHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvZ3JhcGhxbC9zcmMvZnJhZ21lbnRzL2ZpbHRlci1kdXBsaWNhdGUtZnJhZ21lbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sNEJBQTRCLEdBQUcsQ0FBQyxHQUFHLFNBQXlCLEVBQWtCLEVBQUU7QUFDM0Ysd0NBQXdDO0FBQ3hDLFNBQVMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxHQUFHLEVBQUUsS0FBSyxFQUFFLEVBQUUsQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IERvY3VtZW50Tm9kZSB9IGZyb20gJ2dyYXBocWwnO1xuXG4vKipcbiAqIEZpbHRlcnMgYSBsaXN0IG9mIGZyYWdtZW50cywgcmVtb3ZpbmcgZHVwbGljYXRlcy5cbiAqL1xuZXhwb3J0IGNvbnN0IGRhZmZGaWx0ZXJEdXBsaWNhdGVGcmFnbWVudHMgPSAoLi4uZG9jdW1lbnRzOiBEb2N1bWVudE5vZGVbXSk6IERvY3VtZW50Tm9kZVtdID0+XG4gIC8vIFRPRE8oZ3JpZXN0MDI0KTogZXh0cmFjdCB0byBjb3JlIHV0aWxcbiAgZG9jdW1lbnRzLmZpbHRlcigoZG9jLCBpbmRleCkgPT4gZG9jdW1lbnRzLnNsaWNlKGluZGV4ICsgMSkuaW5kZXhPZihkb2MpID09PSAtMSk7XG4iXX0=
@@ -1,5 +0,0 @@
1
- import { DocumentNode } from 'graphql';
2
- /**
3
- * Filters a list of fragments, removing duplicates.
4
- */
5
- export declare const daffFilterDuplicateFragments: (...documents: DocumentNode[]) => DocumentNode[];