-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js.map
1 lines (1 loc) · 4.5 KB
/
common.js.map
1
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;;;;;;AAK9B,MAAM,iBAAiB,SAAqB,EAAE,GAAY;;IACtD,IAAI,cAAc,GAAG,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAE/E,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,iBAAiB,GAAG,cAAc,GAAG,IAAI,CAAC;CAC3E;;;;;;AAGD,MAAM,kCAAkC,QAAkB,EAAE,QAAuB;IAC/E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,IAAI,CAAC;KACf;IAED,KAAK,IAAI,kBAAkB,IAAI,QAAQ,CAAC,aAAa,EAAE;QACnD,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE;YAC9F,OAAO,KAAK,CAAC;SAChB;KACJ;IAED,OAAO,IAAI,CAAC;CACf;;;;;;AAKD,MAAM,uBAAuB,QAA+C;IACxE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;QAChB,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;CACnC;;;;;;AAKD,MAAM,qBAAqB,QAA+C;IACtE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;QAChB,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC;CAChC;;;;;;;AAKD,MAAM,8BAA8B,MAAc,EAAE,GAAoB,EAAE,UAA8B;;IACpG,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC;IAElC,UAAU,CAAC,KAAK,GAAG;;QACf,IAAI,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;QACjD,IAAI,IAAI,CAAS;QACjB,IAAI;YACA,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aAClB;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;aACvB;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,mGAAmG,CAAC,CAAC;YAElH,OAAO,IAAI,CAAC;SACf;;QAED,MAAM,qBAAqB,GAAG,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,qBAAqB,EAAE;YACxB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,mCAAmC,CAAC,CAAC;YAEhE,OAAO,IAAI,CAAC;SACf;;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1C,OAAO,MAAM,CAAC;KACjB,CAAC;IAEF,OAAO,UAAU,CAAC;CACrB","sourcesContent":["import { ICacheable } from './interfaces/cacheable';\nimport { Core } from './core';\nimport { DocumentResource } from './document-resource';\nimport { DocumentCollection } from './document-collection';\nimport { Resource } from './resource';\n\nexport function isLive(cacheable: ICacheable, ttl?: number): boolean {\n let ttl_in_seconds = ttl && typeof ttl === 'number' ? ttl : cacheable.ttl || 0;\n\n return Date.now() < cacheable.cache_last_update + ttl_in_seconds * 1000;\n}\n\n// @todo test required for hasMany and hasOne\nexport function relationshipsAreBuilded(resource: Resource, includes: Array<string>): boolean {\n if (includes.length === 0) {\n return true;\n }\n\n for (let relationship_alias in resource.relationships) {\n if (includes.includes(relationship_alias) && !resource.relationships[relationship_alias].builded) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * @deprecated since 2.2.0\n */\nexport function isCollection(document: DocumentResource | DocumentCollection): document is DocumentCollection {\n if (!document.data) {\n return false;\n }\n\n return !('id' in document.data);\n}\n\n/**\n * @deprecated since 2.2.0\n */\nexport function isResource(document: DocumentResource | DocumentCollection): document is DocumentResource {\n if (!document.data) {\n return false;\n }\n\n return 'id' in document.data;\n}\n\n// NOTE: Checks that the service passed to the method is registered (method needs to have service's type or a resource as first arg)\n// changes \"PropertyDescriptor | null\" type for \"any\" to avoid typescript error in decorators property decorators\n// (see https://stackoverflow.com/questions/37694322/typescript-ts1241-unable-to-resolve-signature-of-method-decorator-when-called-a)\nexport function serviceIsRegistered(target: Object, key: string | symbol, descriptor: PropertyDescriptor): any {\n const original = descriptor.value;\n\n descriptor.value = function() {\n let args = Array.prototype.slice.call(arguments);\n let type: string;\n try {\n if (typeof args[0] === 'string') {\n type = args[0];\n } else {\n type = args[0].type;\n }\n } catch (err) {\n console.warn(`ERROR: First argument of methods decorated with serviceIsRegistered has to be string or Resource.`);\n\n return null;\n }\n\n const service_is_registered = Core.me.getResourceService(type);\n if (!service_is_registered) {\n console.warn(`ERROR: ${type} service has not been registered.`);\n\n return null;\n }\n\n const result = original.apply(this, args);\n\n return result;\n };\n\n return descriptor;\n}\n"]}