Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@8base/utils

Package Overview
Dependencies
Maintainers
2
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@8base/utils - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

src/formatters/formatConnectionForMutation.js

144

lib/utils.js

@@ -193,2 +193,40 @@ (function webpackUniversalModuleDefinition(root, factory) {

/***/ "./src/formatters/formatConnectionForMutation.js":
/*!*******************************************************!*\
!*** ./src/formatters/formatConnectionForMutation.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatConnectionForMutation = undefined;
var _constants = __webpack_require__(/*! ../constants */ "./src/constants.js");
const formatConnectionForMutation = (type, data) => {
let formatedData = data;
if (Array.isArray(formatedData)) {
formatedData = formatedData.map(id => ({ id }));
} else {
formatedData = { id: formatedData };
}
if (type === _constants.MUTATION_TYPE.CREATE) {
formatedData = { connect: formatedData };
} else if (type === _constants.MUTATION_TYPE.UPDATE) {
formatedData = { reconnect: formatedData };
}
return formatedData;
};
exports.formatConnectionForMutation = formatConnectionForMutation;
/***/ }),
/***/ "./src/formatters/formatDataForMutation.js":

@@ -287,7 +325,7 @@ /*!*************************************************!*\

var _formatRelationReferenceForMutation = __webpack_require__(/*! ./formatRelationReferenceForMutation */ "./src/formatters/formatRelationReferenceForMutation.js");
var _formatConnectionForMutation = __webpack_require__(/*! ./formatConnectionForMutation */ "./src/formatters/formatConnectionForMutation.js");
var _formatRelationInstanceForMutation = __webpack_require__(/*! ./formatRelationInstanceForMutation */ "./src/formatters/formatRelationInstanceForMutation.js");
var _formatRelationCreationForMutation = __webpack_require__(/*! ./formatRelationCreationForMutation */ "./src/formatters/formatRelationCreationForMutation.js");
var _formatFileInstanceForMutation = __webpack_require__(/*! ./formatFileInstanceForMutation */ "./src/formatters/formatFileInstanceForMutation.js");
var _formatFileCreationForMutation = __webpack_require__(/*! ./formatFileCreationForMutation */ "./src/formatters/formatFileCreationForMutation.js");

@@ -298,7 +336,7 @@ const formatFieldDataForMutation = (type, fieldSchema, data, schema) => {

if ((0, _verifiers.isRelationReference)(fieldSchema, data) || (0, _verifiers.isFileReference)(fieldSchema, data)) {
formatedData = (0, _formatRelationReferenceForMutation.formatRelationReferenceForMutation)(type, data);
formatedData = (0, _formatConnectionForMutation.formatConnectionForMutation)(type, data);
} else if ((0, _verifiers.isRelationInstance)(fieldSchema, data)) {
formatedData = (0, _formatRelationInstanceForMutation.formatRelationInstanceForMutation)(type, fieldSchema, data, schema);
formatedData = (0, _formatRelationCreationForMutation.formatRelationCreationForMutation)(type, fieldSchema, data, schema);
} else if ((0, _verifiers.isFileInstance)(fieldSchema, data)) {
formatedData = (0, _formatFileInstanceForMutation.formatFileInstanceForMutation)(type, data);
formatedData = (0, _formatFileCreationForMutation.formatFileCreationForMutation)(type, data, (0, _verifiers.isFileEntity)(fieldSchema, data));
}

@@ -313,5 +351,5 @@

/***/ "./src/formatters/formatFileInstanceForMutation.js":
/***/ "./src/formatters/formatFileCreationForMutation.js":
/*!*********************************************************!*\
!*** ./src/formatters/formatFileInstanceForMutation.js ***!
!*** ./src/formatters/formatFileCreationForMutation.js ***!
\*********************************************************/

@@ -329,12 +367,12 @@ /*! no static exports found */

const formatFileInstanceForMutation = (type, data) => {
return { create: { $file: data } };
const formatFileCreationForMutation = (type, data, isEntity) => {
return isEntity ? { create: { $file: data } } : { create: data };
};
exports.formatFileInstanceForMutation = formatFileInstanceForMutation;
exports.formatFileCreationForMutation = formatFileCreationForMutation;
/***/ }),
/***/ "./src/formatters/formatRelationInstanceForMutation.js":
/***/ "./src/formatters/formatRelationCreationForMutation.js":
/*!*************************************************************!*\
!*** ./src/formatters/formatRelationInstanceForMutation.js ***!
!*** ./src/formatters/formatRelationCreationForMutation.js ***!
\*************************************************************/

@@ -350,3 +388,3 @@ /*! no static exports found */

});
exports.formatRelationInstanceForMutation = undefined;
exports.formatRelationCreationForMutation = undefined;

@@ -359,3 +397,3 @@ var _selectors = __webpack_require__(/*! ../selectors */ "./src/selectors/index.js");

const formatRelationInstanceForMutation = (type, fieldSchema, data, schema) => {
const formatRelationCreationForMutation = (type, fieldSchema, data, schema) => {
const relationTableSchema = (0, _selectors.getTableSchemaById)(fieldSchema.relation.refTable.id, schema);

@@ -379,44 +417,6 @@

};
exports.formatRelationInstanceForMutation = formatRelationInstanceForMutation;
exports.formatRelationCreationForMutation = formatRelationCreationForMutation;
/***/ }),
/***/ "./src/formatters/formatRelationReferenceForMutation.js":
/*!**************************************************************!*\
!*** ./src/formatters/formatRelationReferenceForMutation.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatRelationReferenceForMutation = undefined;
var _constants = __webpack_require__(/*! ../constants */ "./src/constants.js");
const formatRelationReferenceForMutation = (type, data) => {
let formatedData = data;
if (Array.isArray(formatedData)) {
formatedData = formatedData.map(id => ({ id }));
} else {
formatedData = { id: formatedData };
}
if (type === _constants.MUTATION_TYPE.CREATE) {
formatedData = { connect: formatedData };
} else if (type === _constants.MUTATION_TYPE.UPDATE) {
formatedData = { reconnect: formatedData };
}
return formatedData;
};
exports.formatRelationReferenceForMutation = formatRelationReferenceForMutation;
/***/ }),
/***/ "./src/formatters/index.js":

@@ -722,2 +722,11 @@ /*!*********************************!*\

var _isFileEntity = __webpack_require__(/*! ./isFileEntity */ "./src/verifiers/isFileEntity.js");
Object.defineProperty(exports, 'isFileEntity', {
enumerable: true,
get: function () {
return _isFileEntity.isFileEntity;
}
});
var _isFileField = __webpack_require__(/*! ./isFileField */ "./src/verifiers/isFileField.js");

@@ -797,2 +806,24 @@

/***/ "./src/verifiers/isFileEntity.js":
/*!***************************************!*\
!*** ./src/verifiers/isFileEntity.js ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isFileEntity = undefined;
var _isFileField = __webpack_require__(/*! ./isFileField */ "./src/verifiers/isFileField.js");
const isFileEntity = (fieldSchema, data) => (0, _isFileField.isFileField)(fieldSchema) && (data instanceof File || Array.isArray(data) && data[0] instanceof File);
exports.isFileEntity = isFileEntity;
/***/ }),
/***/ "./src/verifiers/isFileField.js":

@@ -844,3 +875,6 @@ /*!**************************************!*\

const isFileInstance = (fieldSchema, data) => (0, _isFileField.isFileField)(fieldSchema) && (data instanceof File || Array.isArray(data) && data[0] instanceof File);
var _isFileEntity = __webpack_require__(/*! ./isFileEntity */ "./src/verifiers/isFileEntity.js");
const isFileInstance = (fieldSchema, data) => (0, _isFileField.isFileField)(fieldSchema) && ((0, _isFileEntity.isFileEntity)(fieldSchema, data) || data && typeof data.fileId === 'string');
exports.isFileInstance = isFileInstance;

@@ -847,0 +881,0 @@

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("ramda")):"function"==typeof define&&define.amd?define("utils",["ramda"],r):"object"==typeof exports?exports.utils=r(require("ramda")):e.utils=r(e.ramda)}("undefined"!=typeof self?self:this,function(e){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=8)}([function(r,t){r.exports=e},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.FIELD_TYPE={DATE:"DATE",FILE:"FILE",ID:"ID",NUMBER:"NUMBER",RELATION:"RELATION",SWITCH:"SWITCH",TEXT:"TEXT",CUSTOM:"CUSTOM"},r.SWITCH_FORMATS={ON_OFF:"ON_OFF",YES_NO:"YES_NO",TRUE_FALSE:"TRUE_FALSE",ACTIVE_INACTIVE:"ACTIVE_INACTIVE",HIGH_LOW:"HIGH_LOW",CUSTOM:"CUSTOM"},r.TEXT_FORMATS={UNFORMATTED:"UNFORMATTED",NAME:"NAME",ADDRESS:"ADDRESS",SSN:"SSN",EIN:"EIN",PHONE:"PHONE",EMAIL:"EMAIL"},r.NUMBER_FORMATS={NUMBER:"NUMBER",CURRENCY:"CURRENCY",PERCENTAGE:"PERCENTAGE",FRACTION:"FRACTION",SCIENTIFIC:"SCIENTIFIC"},r.FILE_FORMATS={FILE:"FILE",IMAGE:"IMAGE"},r.DATE_FORMATS={DATE:"DATE",DATETIME:"DATE/TIME"},r.MUTATION_TYPE={CREATE:"CREATE",UPDATE:"UPDATE"}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(13);Object.defineProperty(r,"hasIdTokenExpiredError",{enumerable:!0,get:function(){return n.hasIdTokenExpiredError}});var o=t(14);Object.defineProperty(r,"hasRefreshTokenExpiredError",{enumerable:!0,get:function(){return o.hasRefreshTokenExpiredError}});var i=t(4);Object.defineProperty(r,"isFileField",{enumerable:!0,get:function(){return i.isFileField}});var a=t(15);Object.defineProperty(r,"isFileInstance",{enumerable:!0,get:function(){return a.isFileInstance}});var u=t(16);Object.defineProperty(r,"isFileReference",{enumerable:!0,get:function(){return u.isFileReference}});var l=t(17);Object.defineProperty(r,"isListField",{enumerable:!0,get:function(){return l.isListField}});var f=t(18);Object.defineProperty(r,"isMetaField",{enumerable:!0,get:function(){return f.isMetaField}});var c=t(5);Object.defineProperty(r,"isRelationField",{enumerable:!0,get:function(){return c.isRelationField}});var s=t(19);Object.defineProperty(r,"isRelationInstance",{enumerable:!0,get:function(){return s.isRelationInstance}});var d=t(20);Object.defineProperty(r,"isRelationReference",{enumerable:!0,get:function(){return d.isRelationReference}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(10);Object.defineProperty(r,"getFieldSchemaByName",{enumerable:!0,get:function(){return n.getFieldSchemaByName}});var o=t(11);Object.defineProperty(r,"getTableSchemaByName",{enumerable:!0,get:function(){return o.getTableSchemaByName}});var i=t(12);Object.defineProperty(r,"getTableSchemaById",{enumerable:!0,get:function(){return i.getTableSchemaById}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileField=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(1);const i=n.propEq("fieldType",o.FIELD_TYPE.FILE);r.isFileField=i},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationField=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(1);const i=n.propEq("fieldType",o.FIELD_TYPE.RELATION);r.isRelationField=i},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatDataForMutation=void 0;var n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),i=t(1),a=t(3),u=t(2),l=t(21);r.formatDataForMutation=((e,r,t,f)=>{if(o.not(e in i.MUTATION_TYPE))throw new Error(`Invalid mutation type: ${e}`);const c=(0,a.getTableSchemaByName)(r,f);if(!c)throw new Error(`Table schema with ${r} name not found in schema.`);return o.reduce((r,o)=>{if("_description"===o||"__typename"===o)return r;const i=(0,a.getFieldSchemaByName)(o,c);if(!i)throw new Error(`Field schema with ${o} name not found in table schema with ${c.name} name.`);return(0,u.isMetaField)(i)?r:n({},r,{[o]:(0,l.formatFieldDataForMutation)(e,i,t[o],f)})},{},o.keys(t))})},function(e,r){e.exports={InternalErrorCode:"InternalError",InvalidTokenErrorCode:"InvalidTokenError",NotAuthorizedErrorCode:"NotAuthorizedError",MissingHeaderErrorCode:"MissingHeaderError",TokenExpiredErrorCode:"TokenExpiredError",InvitationExpiredErrorCode:"InvitationExpiredError",UserNotConfirmedErrorCode:"UserNotConfirmedError",ValidationErrorCode:"ValidationError",EntityExistsErrorCode:"EntityExistsError",EntityNotFoundErrorCode:"EntityNotFoundError",InvalidArgumentErrorCode:"InvalidArgumentError",MutationErrorCode:"MutationError",ForcibleErrorCode:"ForcibleError"}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(1);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}})});var o=t(9);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(3);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(2);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(6);Object.defineProperty(r,"formatDataForMutation",{enumerable:!0,get:function(){return n.formatDataForMutation}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getFieldSchemaByName=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getFieldSchemaByName=((e,r)=>n.find(n.propEq("name",e),r.fields))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getTableSchemaByName=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getTableSchemaByName=((e,r)=>n.find(n.propEq("name",e),r))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getTableSchemaById=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getTableSchemaById=((e,r)=>n.find(n.propEq("id",e),r))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasIdTokenExpiredError=void 0;var n=i(t(0)),o=i(t(7));function i(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}r.hasIdTokenExpiredError=n.any(n.allPass([n.propEq("code",o.TokenExpiredErrorCode),n.propEq("message","Token expired")]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasRefreshTokenExpiredError=void 0;var n=i(t(0)),o=i(t(7));function i(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}r.hasRefreshTokenExpiredError=n.any(n.allPass([n.propEq("code",o.TokenExpiredErrorCode),n.propEq("message","Refresh Token has expired")]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileInstance=void 0;var n=t(4);r.isFileInstance=((e,r)=>(0,n.isFileField)(e)&&(r instanceof File||Array.isArray(r)&&r[0]instanceof File))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileReference=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(4);r.isFileReference=((e,r)=>(0,o.isFileField)(e)&&!n.isNil(r)&&("string"==typeof r||0===r.length||"string"==typeof r[0]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isListField=void 0;const n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)).propEq("isList",!0);r.isListField=n},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isMetaField=void 0;const n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)).propEq("isMeta",!0);r.isMetaField=n},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationInstance=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(5);r.isRelationInstance=((e,r)=>(0,o.isRelationField)(e)&&!n.isNil(r)&&"object"==typeof r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationReference=void 0;var n=t(5);r.isRelationReference=((e,r)=>(0,n.isRelationField)(e)&&("string"==typeof r||Array.isArray(r)&&(0===r.length||"string"==typeof r[0])))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatFieldDataForMutation=void 0;var n=t(2),o=t(22),i=t(23),a=t(24);r.formatFieldDataForMutation=((e,r,t,u)=>{let l=t;return(0,n.isRelationReference)(r,t)||(0,n.isFileReference)(r,t)?l=(0,o.formatRelationReferenceForMutation)(e,t):(0,n.isRelationInstance)(r,t)?l=(0,i.formatRelationInstanceForMutation)(e,r,t,u):(0,n.isFileInstance)(r,t)&&(l=(0,a.formatFileInstanceForMutation)(e,t)),l})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatRelationReferenceForMutation=void 0;var n=t(1);r.formatRelationReferenceForMutation=((e,r)=>{let t=r;return t=Array.isArray(t)?t.map(e=>({id:e})):{id:t},e===n.MUTATION_TYPE.CREATE?t={connect:t}:e===n.MUTATION_TYPE.UPDATE&&(t={reconnect:t}),t})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatRelationInstanceForMutation=void 0;var n=t(3),o=t(2),i=t(6);r.formatRelationInstanceForMutation=((e,r,t,a)=>{const u=(0,n.getTableSchemaById)(r.relation.refTable.id,a);if(!u)throw new Error(`Relation table schema with ${r.relation.refTable.id} id not found in schema.`);let l=t;return l={create:l=(0,o.isListField)(r)?l.map(r=>(0,i.formatDataForMutation)(e,u.name,r,a)):(0,i.formatDataForMutation)(e,u.name,l,a)}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.formatFileInstanceForMutation=((e,r)=>({create:{$file:r}}))}])});
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("ramda")):"function"==typeof define&&define.amd?define("utils",["ramda"],r):"object"==typeof exports?exports.utils=r(require("ramda")):e.utils=r(e.ramda)}("undefined"!=typeof self?self:this,function(e){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=9)}([function(r,t){r.exports=e},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.FIELD_TYPE={DATE:"DATE",FILE:"FILE",ID:"ID",NUMBER:"NUMBER",RELATION:"RELATION",SWITCH:"SWITCH",TEXT:"TEXT",CUSTOM:"CUSTOM"},r.SWITCH_FORMATS={ON_OFF:"ON_OFF",YES_NO:"YES_NO",TRUE_FALSE:"TRUE_FALSE",ACTIVE_INACTIVE:"ACTIVE_INACTIVE",HIGH_LOW:"HIGH_LOW",CUSTOM:"CUSTOM"},r.TEXT_FORMATS={UNFORMATTED:"UNFORMATTED",NAME:"NAME",ADDRESS:"ADDRESS",SSN:"SSN",EIN:"EIN",PHONE:"PHONE",EMAIL:"EMAIL"},r.NUMBER_FORMATS={NUMBER:"NUMBER",CURRENCY:"CURRENCY",PERCENTAGE:"PERCENTAGE",FRACTION:"FRACTION",SCIENTIFIC:"SCIENTIFIC"},r.FILE_FORMATS={FILE:"FILE",IMAGE:"IMAGE"},r.DATE_FORMATS={DATE:"DATE",DATETIME:"DATE/TIME"},r.MUTATION_TYPE={CREATE:"CREATE",UPDATE:"UPDATE"}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(14);Object.defineProperty(r,"hasIdTokenExpiredError",{enumerable:!0,get:function(){return n.hasIdTokenExpiredError}});var o=t(15);Object.defineProperty(r,"hasRefreshTokenExpiredError",{enumerable:!0,get:function(){return o.hasRefreshTokenExpiredError}});var i=t(8);Object.defineProperty(r,"isFileEntity",{enumerable:!0,get:function(){return i.isFileEntity}});var a=t(3);Object.defineProperty(r,"isFileField",{enumerable:!0,get:function(){return a.isFileField}});var u=t(16);Object.defineProperty(r,"isFileInstance",{enumerable:!0,get:function(){return u.isFileInstance}});var l=t(17);Object.defineProperty(r,"isFileReference",{enumerable:!0,get:function(){return l.isFileReference}});var f=t(18);Object.defineProperty(r,"isListField",{enumerable:!0,get:function(){return f.isListField}});var c=t(19);Object.defineProperty(r,"isMetaField",{enumerable:!0,get:function(){return c.isMetaField}});var s=t(5);Object.defineProperty(r,"isRelationField",{enumerable:!0,get:function(){return s.isRelationField}});var d=t(20);Object.defineProperty(r,"isRelationInstance",{enumerable:!0,get:function(){return d.isRelationInstance}});var p=t(21);Object.defineProperty(r,"isRelationReference",{enumerable:!0,get:function(){return p.isRelationReference}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileField=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(1);const i=n.propEq("fieldType",o.FIELD_TYPE.FILE);r.isFileField=i},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(11);Object.defineProperty(r,"getFieldSchemaByName",{enumerable:!0,get:function(){return n.getFieldSchemaByName}});var o=t(12);Object.defineProperty(r,"getTableSchemaByName",{enumerable:!0,get:function(){return o.getTableSchemaByName}});var i=t(13);Object.defineProperty(r,"getTableSchemaById",{enumerable:!0,get:function(){return i.getTableSchemaById}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationField=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(1);const i=n.propEq("fieldType",o.FIELD_TYPE.RELATION);r.isRelationField=i},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatDataForMutation=void 0;var n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),i=t(1),a=t(4),u=t(2),l=t(22);r.formatDataForMutation=((e,r,t,f)=>{if(o.not(e in i.MUTATION_TYPE))throw new Error(`Invalid mutation type: ${e}`);const c=(0,a.getTableSchemaByName)(r,f);if(!c)throw new Error(`Table schema with ${r} name not found in schema.`);return o.reduce((r,o)=>{if("_description"===o||"__typename"===o)return r;const i=(0,a.getFieldSchemaByName)(o,c);if(!i)throw new Error(`Field schema with ${o} name not found in table schema with ${c.name} name.`);return(0,u.isMetaField)(i)?r:n({},r,{[o]:(0,l.formatFieldDataForMutation)(e,i,t[o],f)})},{},o.keys(t))})},function(e,r){e.exports={InternalErrorCode:"InternalError",InvalidTokenErrorCode:"InvalidTokenError",NotAuthorizedErrorCode:"NotAuthorizedError",MissingHeaderErrorCode:"MissingHeaderError",TokenExpiredErrorCode:"TokenExpiredError",InvitationExpiredErrorCode:"InvitationExpiredError",UserNotConfirmedErrorCode:"UserNotConfirmedError",ValidationErrorCode:"ValidationError",EntityExistsErrorCode:"EntityExistsError",EntityNotFoundErrorCode:"EntityNotFoundError",InvalidArgumentErrorCode:"InvalidArgumentError",MutationErrorCode:"MutationError",ForcibleErrorCode:"ForcibleError"}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileEntity=void 0;var n=t(3);r.isFileEntity=((e,r)=>(0,n.isFileField)(e)&&(r instanceof File||Array.isArray(r)&&r[0]instanceof File))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(1);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}})});var o=t(10);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(4);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(2);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(6);Object.defineProperty(r,"formatDataForMutation",{enumerable:!0,get:function(){return n.formatDataForMutation}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getFieldSchemaByName=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getFieldSchemaByName=((e,r)=>n.find(n.propEq("name",e),r.fields))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getTableSchemaByName=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getTableSchemaByName=((e,r)=>n.find(n.propEq("name",e),r))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getTableSchemaById=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));r.getTableSchemaById=((e,r)=>n.find(n.propEq("id",e),r))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasIdTokenExpiredError=void 0;var n=i(t(0)),o=i(t(7));function i(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}r.hasIdTokenExpiredError=n.any(n.allPass([n.propEq("code",o.TokenExpiredErrorCode),n.propEq("message","Token expired")]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasRefreshTokenExpiredError=void 0;var n=i(t(0)),o=i(t(7));function i(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}r.hasRefreshTokenExpiredError=n.any(n.allPass([n.propEq("code",o.TokenExpiredErrorCode),n.propEq("message","Refresh Token has expired")]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileInstance=void 0;var n=t(3),o=t(8);r.isFileInstance=((e,r)=>(0,n.isFileField)(e)&&((0,o.isFileEntity)(e,r)||r&&"string"==typeof r.fileId))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isFileReference=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(3);r.isFileReference=((e,r)=>(0,o.isFileField)(e)&&!n.isNil(r)&&("string"==typeof r||0===r.length||"string"==typeof r[0]))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isListField=void 0;const n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)).propEq("isList",!0);r.isListField=n},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isMetaField=void 0;const n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)).propEq("isMeta",!0);r.isMetaField=n},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationInstance=void 0;var n=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0)),o=t(5);r.isRelationInstance=((e,r)=>(0,o.isRelationField)(e)&&!n.isNil(r)&&"object"==typeof r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isRelationReference=void 0;var n=t(5);r.isRelationReference=((e,r)=>(0,n.isRelationField)(e)&&("string"==typeof r||Array.isArray(r)&&(0===r.length||"string"==typeof r[0])))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatFieldDataForMutation=void 0;var n=t(2),o=t(23),i=t(24),a=t(25);r.formatFieldDataForMutation=((e,r,t,u)=>{let l=t;return(0,n.isRelationReference)(r,t)||(0,n.isFileReference)(r,t)?l=(0,o.formatConnectionForMutation)(e,t):(0,n.isRelationInstance)(r,t)?l=(0,i.formatRelationCreationForMutation)(e,r,t,u):(0,n.isFileInstance)(r,t)&&(l=(0,a.formatFileCreationForMutation)(e,t,(0,n.isFileEntity)(r,t))),l})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatConnectionForMutation=void 0;var n=t(1);r.formatConnectionForMutation=((e,r)=>{let t=r;return t=Array.isArray(t)?t.map(e=>({id:e})):{id:t},e===n.MUTATION_TYPE.CREATE?t={connect:t}:e===n.MUTATION_TYPE.UPDATE&&(t={reconnect:t}),t})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatRelationCreationForMutation=void 0;var n=t(4),o=t(2),i=t(6);r.formatRelationCreationForMutation=((e,r,t,a)=>{const u=(0,n.getTableSchemaById)(r.relation.refTable.id,a);if(!u)throw new Error(`Relation table schema with ${r.relation.refTable.id} id not found in schema.`);let l=t;return l={create:l=(0,o.isListField)(r)?l.map(r=>(0,i.formatDataForMutation)(e,u.name,r,a)):(0,i.formatDataForMutation)(e,u.name,l,a)}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.formatFileCreationForMutation=((e,r,t)=>t?{create:{$file:r}}:{create:r})}])});
//# sourceMappingURL=utils.min.js.map
{
"name": "@8base/utils",
"version": "0.2.12",
"version": "0.2.13",
"main": "lib/utils.js",

@@ -5,0 +5,0 @@ "scripts": {

//@flow
import { isRelationReference, isRelationInstance, isFileReference, isFileInstance } from '../verifiers';
import { formatRelationReferenceForMutation } from './formatRelationReferenceForMutation';
import { formatRelationInstanceForMutation } from './formatRelationInstanceForMutation';
import { formatFileInstanceForMutation } from './formatFileInstanceForMutation';
import { isRelationReference, isRelationInstance, isFileReference, isFileInstance, isFileEntity } from '../verifiers';
import { formatConnectionForMutation } from './formatConnectionForMutation';
import { formatRelationCreationForMutation } from './formatRelationCreationForMutation';
import { formatFileCreationForMutation } from './formatFileCreationForMutation';
import type { MutationType, FieldSchema, Schema } from '../types';

@@ -12,7 +12,7 @@

if (isRelationReference(fieldSchema, data) || isFileReference(fieldSchema, data)) {
formatedData = formatRelationReferenceForMutation(type, data);
formatedData = formatConnectionForMutation(type, data);
} else if (isRelationInstance(fieldSchema, data)) {
formatedData = formatRelationInstanceForMutation(type, fieldSchema, data, schema);
formatedData = formatRelationCreationForMutation(type, fieldSchema, data, schema);
} else if (isFileInstance(fieldSchema, data)) {
formatedData = formatFileInstanceForMutation(type, data);
formatedData = formatFileCreationForMutation(type, data, isFileEntity(fieldSchema, data));
}

@@ -19,0 +19,0 @@

@@ -7,2 +7,2 @@ import * as R from 'ramda';

R.propEq('message', 'Token expired'),
]));
]));

@@ -7,2 +7,2 @@ import * as R from 'ramda';

R.propEq('message', 'Refresh Token has expired'),
]));
]));
export { hasIdTokenExpiredError } from './hasIdTokenExpiredError';
export { hasRefreshTokenExpiredError } from './hasRefreshTokenExpiredError';
export { isFileEntity } from './isFileEntity';
export { isFileField } from './isFileField';

@@ -4,0 +5,0 @@ export { isFileInstance } from './isFileInstance';

//@flow
import { isFileField } from './isFileField';
import { isFileEntity } from './isFileEntity';
import type { FieldSchema } from '../types';
const isFileInstance = (fieldSchema: FieldSchema, data: any) => (
isFileField(fieldSchema)
&&
(data instanceof File || (Array.isArray(data) && data[0] instanceof File))
isFileField(fieldSchema) &&
(
isFileEntity(fieldSchema, data)
||
(data && typeof data.fileId === 'string')
)
);
export { isFileInstance };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc