diff --git a/Makefile b/Makefile index d6ae2a14..8ef84fd6 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ release: ## [Local development] Release a new version of the API. git push origin main @echo "Done, check '\033[0;31mhttps://github.com/different-ai/embedbase/actions\033[0m'" -openapi: - curl localhost:8000/openapi.json | yq -y > .well-known/openapi.yaml +integrations/zapier: + rm -rf integrations/zapier && zapier convert 182530 integrations/zapier --version=1.0.0 #* Poetry .PHONY: poetry-download diff --git a/integrations/zapier/.gitignore b/integrations/zapier/.gitignore new file mode 100644 index 00000000..32dd95d8 --- /dev/null +++ b/integrations/zapier/.gitignore @@ -0,0 +1,62 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/ + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# environment variables file +.env +.environment + +# next.js build output +.next diff --git a/integrations/zapier/.zapierapprc b/integrations/zapier/.zapierapprc new file mode 100644 index 00000000..7c08f8b4 --- /dev/null +++ b/integrations/zapier/.zapierapprc @@ -0,0 +1,3 @@ +{ + "id": 182530 +} \ No newline at end of file diff --git a/integrations/zapier/authentication.js b/integrations/zapier/authentication.js new file mode 100644 index 00000000..d177198c --- /dev/null +++ b/integrations/zapier/authentication.js @@ -0,0 +1,37 @@ +const testAuth = async (z, bundle) => { + const options = { + url: 'https://api.embedbase.xyz/v1/datasets', + method: 'GET', + headers: { + Authorization: 'Bearer ' + bundle.authData.api_key, + 'Content-Type': 'application/json', + }, + }; + + return z.request(options).then((response) => { + console.log(options); + console.log(response); + response.throwForStatus(); + const results = response.json; + + // You can do any parsing you need for results here before returning them + + return results; + }); +}; + +module.exports = { + type: 'custom', + test: testAuth, + fields: [ + { + computed: false, + key: 'api_key', + required: true, + label: 'Embedbase API key', + type: 'string', + helpText: 'Get your Embedbase API key here https://app.embedbase.xyz', + }, + ], + customConfig: {}, +}; diff --git a/integrations/zapier/creates/add.js b/integrations/zapier/creates/add.js new file mode 100644 index 00000000..9e37f0f3 --- /dev/null +++ b/integrations/zapier/creates/add.js @@ -0,0 +1,89 @@ +const perform = async (z, bundle) => { + const options = { + url: 'https://api.embedbase.xyz/v1/' + bundle.inputData.dataset_id, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer ' + bundle.authData.api_key, + }, + body: { + documents: [ + { + data: bundle.inputData.data, + metadata: bundle.inputData.metadata || {}, + }, + ], + }, + }; + + return z.request(options).then((response) => { + response.throwForStatus(); + const results = response.json; + + // You can do any parsing you need for results here before returning them + + return results; + }); +}; + +module.exports = { + key: 'add', + noun: 'Add', + display: { + label: 'Add document(s)', + description: 'Add document(s) to embedbase', + hidden: false, + important: true, + }, + operation: { + inputFields: [ + { + key: 'data', + label: 'Data', + type: 'text', + required: true, + list: false, + altersDynamicFields: false, + }, + { + key: 'dataset_id', + label: 'Dataset ID', + type: 'string', + dynamic: 'datasets.dataset_id.dataset_id', + required: true, + list: false, + altersDynamicFields: false, + }, + { + key: 'metadata', + label: 'Metadata', + dict: true, + required: false, + altersDynamicFields: false, + }, + ], + sample: { + results: [ + { + id: '7d5e4de6e5fe4acbd4ff0b84fd5a1dc3ccb2c08aaf668bad3f210e408bce9f56', + data: 'foo', + embedding: + '[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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4820cc7c8b14cc164582c03ea5d61b128d44131e056b1380cc7c8a830358', + data: 'bar', + embedding: + '[-0.0025537256,-0.016694399,-0.0027871886,-0.035313968,-0.00024334024,0.006483087,-0.020257402,-0.038331028,-0.0039257696,-0.011967671,-0.0036420221,0.0368656,0.009633041,-0.01444597,-0.014352585,-0.0042418423,0.026032917,0.016881168,0.011694699,-0.02874827,-0.017542047,3.4907203e-05,0.007578567,0.024754258,-0.016090985,-0.0017527681,0.0041987416,-0.016277757,-0.012348395,-0.0013810232,0.0235187,-0.011673149,-0.031693496,-0.017929956,-0.019409752,-0.0103729395,0.0027027829,-0.008706373,0.020803345,-0.0033708462,0.0029577962,-0.0071296,-0.011845551,0.0024316066,-0.0023687512,0.024280148,-0.020228667,0.005437891,-0.035170298,-0.004633342,0.03246931,-0.0134546505,-0.020487273,0.00454714,0.006853036,0.0038898522,0.017858122,0.021737197,0.01328943,-0.0077222367,-0.009791078,0.019539054,0.0021586346,0.014453153,0.0070541734,-0.020243036,-0.029969461,-0.0021999395,0.014036512,-0.0015264886,0.0077509703,0.040169995,0.0037856917,0.0013585748,0.011960487,-0.015990417,-0.00048847636,-0.026162218,-0.004428613,0.0050212494,0.021708464,-0.041549224,0.0007987127,0.023978442,0.017355278,0.001261598,0.017513314,0.021550428,0.00095719815,-0.016177187,0.02657886,0.016737498,0.0043531866,0.013346898,-0.01428075,-0.0001583732,-0.0081963455,0.028317261,0.011651598,-0.033474997,-0.0076863193,0.019237349,-0.010782397,-0.014244833,0.012362762,-0.01729781,0.01293744,0.017642617,0.011910203,-0.011802451,-0.009683326,0.038819503,0.027929354,-0.03295779,0.006439986,0.015056565,0.013907209,-0.014266383,-0.006127505,-0.009927563,0.008756657,0.003922178,0.010990718,-0.002492666,0.013461834,0.006651899,-0.011249323,0.0036330428,-0.0023615677,0.0076935026,0.001125112,0.011227773,0.02285782,0.005700088,-0.0059802434,0.018231662,-0.025257101,0.001864112,-0.006659082,-0.028058657,0.0111990385,0.021708464,-0.013993411,-0.01828913,-0.004809337,0.017728819,0.0075713834,0.024624955,-0.022096371,-0.013986227,-0.009977848,-0.028202327,0.024438186,-0.014927262,-0.0065944307,0.015070932,-0.0063645598,0.026032917,-0.029337315,-0.0034408849,-0.012341212,-0.0030745277,0.037296608,-0.019998796,0.014855428,0.027282842,0.003439089,-0.0077222367,-0.010653094,-0.014410052,-0.0038503432,0.021564795,-0.012118524,0.016191555,0.0030242433,0.022426812,0.026262788,-0.0076073008,-0.0021155337,0.007909007,-0.027929354,-0.0041843746,0.03473929,0.027455244,0.006795568,-0.0015570184,0.005840166,-0.0142304655,0.007302003,-0.008964978,0.026851833,0.012678835,0.017168507,-0.0035396577,-0.6666266,0.0141011635,-0.01818856,0.015631244,0.014481887,0.007743787,-0.003029631,0.0040191547,-0.021219987,0.0048237043,-0.010997902,0.0058545326,0.010710563,0.0056102946,-0.013684521,-0.0056569874,0.01246333,-0.010358572,-0.005107451,0.010301105,-0.009467822,0.024395084,0.021607894,0.013152944,0.0024765034,-0.0011403768,-0.00069679716,-0.02800119,-0.017139774,-0.0059551015,-0.012061056,0.008217896,0.02436635,-0.0046836264,0.037813816,-0.0042167003,-0.022024537,0.030314269,0.011687515,0.035601307,-0.0032523186,-0.006659082,0.029380416,-0.017944323,-0.008713556,0.0042382507,0.018677037,-0.004561507,-0.0074995486,-0.026018549,0.01461119,-0.016047886,-0.00041753953,0.025486972,-0.006263991,-0.021780299,0.025113432,-0.03321639,-0.013749173,0.0007960189,0.00047051767,0.022254407,-0.001712361,-0.018519001,-0.01112002,-0.006400477,-0.02583178,-0.018202927,0.0014627352,-0.0015650998,0.0005324751,0.014553722,-0.028590234,-0.0009652796,0.014654291,0.02634899,0.017139774,-0.019294817,-0.007370246,0.006292725,-0.002893145,-0.008088593,-0.030371737,-0.0006752467,0.018375332,-0.013734805,-0.033158924,0.013275064,0.02234061,0.0091014635,0.008921877,0.03379107,0.0026345397,0.011551029,0.0014375931,0.020516006,0.0017249321,0.0201281,0.015372639,-0.023978442,-0.006098771,0.009158932,0.005179286,0.006400477,-0.0019108045,0.019955697,-0.017312177,0.015157134,0.039422914,-0.023992809,-0.008102961,-0.007901823,0.0016737499,-0.00053292414,0.008972161,-0.036118515,0.0070218476,0.005534868,0.010401673,-0.012736303,0.007643218,-0.010645911,0.016105352,-0.012377129,0.012994908,0.0034372932,-0.004615383,0.008110144,-0.023173893,0.00074483664,-0.0018237049,-0.01190302,0.011285241,-0.012542349,0.014417236,0.0053768316,0.018159827,-0.0023418132,0.017901221,0.0030799152,-0.029998194,-0.019510321,0.019926962,-0.009841362,-0.0119245695,-0.012556716,0.0041448656,0.0005998202,-0.026779998,0.0037928752,0.001041604,0.008469318,0.013375632,0.003397784,0.012290928,-0.029797059,-0.011989221,-0.019711457,-0.0167806,-0.007305595,0.012599817,0.015027831,-0.03149236,0.014244833,0.011084103,-0.0039114025,0.006989522,-0.014912896,-0.008174796,-0.040141262,0.015674345,-0.0184328,-0.010387306,-0.0010784193,-0.0037533662,0.008871593,0.004820112,-0.005998202,0.0014016757,0.00537324,0.016134087,0.019007478,-0.023504334,-0.0076288516,0.014539355,0.021952702,0.0006177789,0.012104156,-0.010028132,0.015760547,-0.0030404062,0.008146062,-0.0072265766,0.011464828,-0.0061310967,-0.012413046,0.011852735,-0.00030215495,-0.006113138,0.034250814,0.017585149,0.017929956,0.016622564,-0.0055312766,0.018303497,-0.01767135,0.014122713,-0.0368656,0.017211609,0.033474997,0.016220288,-0.018404065,-0.008555519,-0.011005085,0.0046082,0.038331028,-0.017829387,0.01611972,0.020156832,-0.0076144845,0.001259802,0.007463631,0.007923374,0.025285834,-0.024811726,-0.0005540256,-0.011838368,0.039422914,0.002729721,-0.023058958,-0.0024513612,-0.00022021843,-0.00890751,0.025285834,-0.0055025425,-0.009834179,0.007463631,0.029193645,0.012283743,0.006705775,-0.0103729395,0.0044106543,0.021665363,-0.0066554905,0.030745277,-0.02031487,0.019424118,-0.028963774,-0.023590535,0.012865605,-0.010171802,-0.00041911093,0.0028069431,0.0143597685,0.007937741,0.00036029622,0.010997902,0.024466919,0.01998443,0.035170298,0.007844356,0.008131695,0.009431904,-0.0045579155,0.0027638422,-0.0028841656,-0.017240342,-0.01998443,-0.0025788678,0.00018250519,-0.0011466623,0.014187365,0.027124805,-0.006084404,0.014524988,-0.025716843,-0.0021209212,-0.0063609676,0.0023669554,-0.0009275663,-0.0012193951,-0.020056264,0.01630649,0.0027656383,0.0077006863,0.00010101763,-0.034107145,-0.00411254,0.0002675845,0.0007057765,-0.008354383,0.009065546,0.011637231,-0.0012445372,0.04307212,0.008878776,0.01041604,-0.015415739,-0.020329237,-0.0028482482,0.00050239434,-0.017340912,-0.021277456,-0.0095683895,0.010739297,-0.011421727,-0.0039509116,-0.021392392,-0.036463324,-0.012348395,0.024021544,0.0021316966,-0.019064944,-0.013828191,-0.0011430706,-0.006630348,-0.012118524,0.0033331327,0.016608195,0.017412746,-0.016435793,-0.024251414,-0.009123014,-0.011005085,0.04585931,0.009453454,-0.012204725,0.030314269,-0.014955997,0.0007493263,-0.026392091,-0.01060281,0.018246029,0.0007569588,0.0015597122,-0.022800352,0.012362762,-0.009223583,0.017570782,0.0031804838,0.0012849442,-0.013210412,0.041577958,-0.033388797,-0.0144890705,0.0075426497,-0.0012876381,0.031980835,0.0117809,-0.008670456,-0.0009625858,0.03218197,0.01616282,-0.037641414,0.010523792,0.01463274,-0.012362762,0.021622263,0.0134762,0.017585149,-0.0045184065,-0.0042454344,0.038675833,0.02573121,-0.0004424572,0.010710563,-0.013160128,-0.013181678,0.024452552,0.016277757,0.014237649,0.010071233,0.012707569,0.013856925,0.019941328,0.02785752,-0.0018210111,0.0032559105,-0.021564795,0.02469679,-0.010444774,0.0040119714,-0.00820353,0.015832381,-0.016464526,-0.011112837,0.014769226,-0.010200536,-0.0011574376,-0.03726787,-0.023504334,-0.014323851,0.005057167,-0.011996404,-0.009726427,-0.01857647,-0.023906607,0.030687809,0.020616576,-0.0029560004,0.034480684,-0.006896137,0.0075067324,0.0075713834,0.0029362456,-0.022613581,0.004593833,-0.02889194,-0.006777609,0.018389698,0.016292123,-0.022398077,-0.015717445,0.0081173275,-0.000308216,-0.021995803,0.006526188,-0.020544741,0.0039185863,-0.0069140955,0.012714752,-0.005247529,-0.011752167,-0.014000595,0.0005383117,-0.019639622,-0.0010011969,-0.012154441,0.03218197,-0.01159413,0.007262494,0.017269077,-0.02389224,-0.017067939,0.018720139,-0.003219993,0.009941931,0.009949114,0.004507631,-0.00092846423,-0.0054450748,0.02507033,-0.013117027,-0.03769888,-0.016593829,-0.012183175,0.025214,0.027024236,-0.019424118,0.0022699784,-0.0059622847,0.003936545,-0.0027189455,-0.0057898816,-0.011744983,0.016737498,-0.012298111,-0.024007177,-0.043675534,-0.01729781,-0.001138581,0.027024236,-0.014438787,-0.0061957478,-0.03732534,0.006924871,-0.006896137,-0.009245133,-0.015889848,-0.0470374,-0.0076935026,0.0008992814,-0.003577371,0.020817714,-0.0027620464,0.026018549,-0.0020095774,0.016809333,-0.015387005,-0.031549826,-0.023719838,-0.012944624,0.011292424,0.033446264,0.023633635,-0.0045722825,-0.0014142469,-0.0016890147,0.012887156,-0.013691705,-0.028360363,-0.007973658,-0.024208313,0.03445195,0.03393474,0.009676142,0.0010460936,0.01781502,7.54265e-05,0.02531457,-0.015803646,-0.015573775,-0.014524988,0.0017401971,0.0058329822,-0.017498948,-0.015430106,0.01564561,0.0069536045,-0.0040622554,0.032411844,-0.010401673,-0.007865906,-0.012664468,0.0235618,0.0005778208,0.033733603,0.013871292,-0.010983534,0.016665664,-0.026593227,-0.0010020948,-0.0050248415,0.023231361,0.024596222,0.015559409,-0.006809935,-0.027024236,-0.01494163,0.030601608,-0.0038826687,-0.0022663865,0.0052834465,-0.016593829,-0.017182874,-0.026923668,-0.028618967,-0.012621367,0.0065585133,-0.003385213,-0.009496555,0.011364259,0.013907209,-0.006472312,0.01969709,-0.015703078,0.025386404,-0.012894339,0.03505536,0.0140221445,-0.002070637,-0.014539355,0.0122621935,0.0028177183,-0.012484881,0.017570782,0.022742884,0.006730917,-0.016349591,0.00074483664,0.010760847,-0.033101458,-0.037497744,0.036492057,0.023015857,0.007126008,-0.012592633,0.0101646185,-0.026507026,0.036032315,-0.0028715944,-0.020659676,0.0005077819,-0.021090684,-0.020860814,-0.01022927,-0.039451648,0.0120035885,0.0053947903,-0.01597605,-0.038158625,-0.008217896,-0.02492666,0.0065585133,0.00529063,0.040514804,-0.004123315,0.01870577,0.012686018,0.013066743,-0.023245728,-0.01378509,-0.0062711746,0.025372036,-0.041491758,-0.013821008,-0.001082011,-0.0017841958,0.038014956,0.0009190359,-0.005093084,-0.014539355,-0.017067939,0.011292424,-0.0049027223,0.023576168,-0.038014956,-0.0143023,-0.007251719,-0.00772942,-0.004701585,-0.01175935,0.015415739,0.012068239,-0.039566584,0.00010606851,-0.008476501,0.016421426,0.008002392,-0.004015563,0.005452258,0.036405854,-0.03953785,0.025716843,-0.0059155924,0.015674345,-0.033618666,0.0077006863,-0.014093979,-0.0032702773,0.005797065,-0.002550134,-0.009043996,-0.016378324,-0.005947918,0.026377723,0.0096474085,-0.010128701,-0.0058581247,-0.020199934,-0.0035127196,-0.025386404,-0.03106135,0.0154732065,-0.016033517,0.008972161,0.008433401,-0.025645008,-8.83343e-05,0.005491767,0.008562704,0.016953003,-0.0202143,-0.00419515,-0.0040442967,0.00942472,-0.018763239,-0.020659676,-0.029452251,0.007535466,-0.021378024,0.009230766,-0.011658781,0.022096371,0.021564795,0.023360664,0.02432325,0.021148153,-0.030429203,-0.023863507,0.0034606394,0.008304098,-0.026190953,-0.014244833,-0.013382816,0.008289731,-0.003139179,-0.01227656,-0.017858122,0.008239447,-0.012298111,0.013425916,-0.021033218,0.0048560295,0.029710855,-0.00737743,0.012951807,0.0045830575,-0.0041771913,0.021607894,-0.04741094,-0.032498043,0.0044106543,0.0042777597,0.0041735996,-0.03393474,-0.022656683,-0.037785083,0.02451002,0.0156025095,0.018633936,0.039106842,-0.012800954,-0.0011322954,-0.012168808,0.003002693,0.022268776,-0.012118524,0.017427113,-0.029351681,0.0037856917,0.03637712,0.0057683312,-0.0028859614,0.003672552,-0.010811131,-0.0064076604,0.0013774314,-0.0063753347,-0.017685717,-0.00049970055,-0.003713857,0.01194612,-0.002837473,-0.011048186,0.032268174,0.00025568684,-0.023231361,0.001316372,-0.0019179881,-0.014172998,-0.017096672,-0.0052583045,-0.015142767,-0.002945225,-0.03295779,-0.009431904,-0.006332234,0.0032469311,0.0069823386,-0.021607894,0.0008961386,0.02341813,0.025803044,-0.010839865,0.0041771913,0.020199934,-0.002616581,0.004931456,-0.026521392,0.006450761,-0.0049530067,-0.008562704,0.010114334,-0.0022232858,-0.01645016,0.009877279,0.01258545,0.007370246,0.0046548923,0.18964376,-0.0060808123,0.00092038285,0.044049073,0.00032752161,-0.00663394,0.021665363,0.013275064,0.015803646,-0.0015965275,-0.010997902,0.011234956,-0.008519602,0.007363063,0.010753663,-0.021378024,-0.044393882,-0.02800119,-0.0184759,0.0011403768,0.016033517,-0.003315174,-0.024811726,-0.0047231354,0.03238311,0.0061167297,-0.022326242,0.0074348976,0.026076017,0.016981738,0.0061059543,-0.019309184,-5.1294508e-05,-0.010753663,-0.026909301,-0.010258003,-6.7794055e-05,0.009719243,0.014884162,0.013382816,-0.010954801,0.0016899128,-0.0057072714,-0.02926548,-0.006906912,0.011184672,-0.004662076,0.017944323,0.014352585,-0.00022437138,-0.023777304,0.0026650697,0.024280148,0.027139172,0.0202143,0.021320557,0.028460931,0.01461119,0.006249624,0.0054019736,-0.015387005,0.042353775,-0.01279377,0.026650695,-0.042152636,0.0011996405,0.0007372042,0.0127794035,0.0017931751,0.002823106,-0.001259802,-0.031808432,-0.015659977,0.0076288516,-0.022699784,-0.026047284,0.034969162,0.0074779983,-0.0063035,0.015114034,-0.00973361,-0.0017357074,-0.0012086198,0.019797659,0.011335525,-0.037354074,0.020372337,0.02959592,-0.013203229,-0.027972454,-0.012872789,-0.023734204,0.013691705,-0.021550428,0.0076001175,0.005272671,-0.02554444,0.018590836,-0.020199934,0.0011313974,-0.026736896,-0.016033517,0.031607293,-0.015588143,-0.017498948,-0.006637532,0.00369949,0.019194247,0.0030350185,0.016090985,0.0015139176,-0.01917988,0.0023238545,-0.0021855726,0.011163121,0.00030395083,-0.009927563,-0.00940317,0.02153606,-0.0065549216,0.019481586,-0.009798261,0.0125207985,0.00080679415,0.00419515,-0.027297208,-0.007086499,-0.0059263674,-0.011443277,-0.021435492,0.0144890705,-0.013174495,-0.0043100854,-0.020300502,-0.02587488,0.009482188,-0.018303497,-0.026234053,-0.014014961,0.00276923,-0.0020724328,0.019582156,0.00056524976,0.0019826393,0.011313975,-0.022886554,0.030228067,-0.006450761,-0.005700088,-0.017024837,-0.018159827,0.013835374,-0.0095683895,-0.0036132883,0.010042499,-0.0019126005,-0.0201712,-0.04629032,0.012556716,-0.0022430404,-0.03295779,-6.0329974e-05,0.040083796,-0.0042238836,-0.019625256,-0.006950013,-0.18860935,0.015832381,0.020113733,-0.031406157,0.03129122,-0.01159413,0.023576168,0.0062029315,-0.023964075,0.0066806325,-0.0106818285,-0.012642917,-0.03775635,-0.010574076,-0.017757552,0.010143068,-0.00058320846,-0.012686018,0.008318465,-0.015846748,0.03054414,-0.0061885645,-0.0002281876,-0.00019305591,0.0101646185,0.017269077,-0.0045112227,0.03307272,0.012923073,-0.016838068,-0.021607894,-0.01804489,0.023791673,-0.02120562,-0.010337022,-0.002329242,0.0235187,0.009123014,0.007165517,0.022944022,0.008641722,0.034681823,-0.007959291,0.0066159815,0.011091286,0.029279847,0.02479736,0.016651297,-0.0040191547,-0.013066743,-0.01239868,-0.0071224165,0.021392392,-0.0065082293,-0.01258545,0.015674345,0.003728224,0.016033517,-0.019395385,0.014208916,-0.02734031,-0.010315471,-0.01494163,-0.0036563892,-0.025630642,-0.023432499,-0.030371737,0.009941931,-0.0070362147,0.011349892,0.011744983,-0.018016158,0.008921877,-0.012506432,0.016579462,0.014654291,-0.017053572,-0.0031463625,0.029538453,-0.007592934,-0.019381018,0.06493862,-0.016981738,-0.01998443,0.001809338,0.016292123,0.004274168,-0.013117027,0.005746781,-0.026693797,0.018605202,-0.025903614,-0.012305294,-0.028963774,0.013167311,0.0007825499,-0.007643218,-0.0006698591,0.01145046,-0.0142592,-0.0061203213,0.008598621,-0.035658773,0.027110437,0.035141565,0.003552229,-0.017312177,0.016249022,0.013569586,0.0121328905,-0.031693496,0.0005728822,0.042468708,0.010832681,-0.001602813,0.008612988,-0.0047841948,-0.015674345,0.020760246,-0.0007439387,0.022513013,-0.0055851527,0.007032623,-0.00572523,0.0068314853,-0.029006876,-0.13895716,-0.01899311,0.008383117,0.031463623,-0.024754258,0.006511821,-0.0038683016,0.007427714,-0.033446264,0.042957187,-0.03732534,-0.034509417,-0.0033474998,-0.014237649,0.016421426,0.007442081,-0.014524988,-0.018030524,-0.01696737,0.040169995,0.006145464,-0.0014833878,-0.014726126,-0.0026345397,0.0059802434,-0.010459141,-0.012010772,0.027958088,0.01857647,-0.0021496553,0.006070037,-0.0008207121,0.024193946,-0.024423817,-0.009410353,0.006590839,-0.0066231648,-0.014496254,0.031406157,-0.01653636,0.027627649,0.023734204,-0.009949114,-0.030515406,0.0016764437,-0.00038633632,0.0056282533,0.023303196,0.032699183,0.0016019151,-0.02540077,0.01291589,-0.013569586,-0.025860513,0.042928454,-0.00613828,-0.012808138,0.021234354,-0.015961682,0.025716843,-0.02436635,-0.009791078,-0.006824302,0.022412445,0.0022645907,0.00020091284,-0.017326543,-0.0012211909,-0.0034624354,-0.005032025,0.012535165,-0.000753816,-0.012405863,0.04999699,-0.01729781,0.018748872,-0.023978442,0.00622089,0.010042499,-0.015904216,0.008771024,-0.014216099,-0.013792274,-0.022785986,0.025558807,0.013842558,0.0047913785,0.0031373831,0.01142891,-0.017096672,0.011177489,0.0047375024,0.008009575,-0.013002091,0.004618975,0.00022773864,0.013756356,-0.020559108,-0.023691103,0.012786587,-0.005545643,-0.00787309,-0.07315652,0.017599516,-0.016464526,-0.0121328905,0.0013055968,-0.012800954,0.0042274757,0.0031463625,-0.016033517,-0.0044717137,-0.015501941,0.019955697,-0.03114755,-0.02926548,-0.029279847,-0.0010694399,0.02031487,0.0034211304,0.011436094,0.0041448656,-0.00027162518,-0.0020454947,0.019294817,-0.010006581,-0.018260395,-0.015918583,-0.0152146015,0.0116659645,-0.012183175,-0.014999097,0.020932648,-0.008749474,-0.009022445,0.004500448,-0.0038323845,-0.006192156,-0.0058724913,0.018519001,0.011163121,0.006892545,-0.025099065,-0.0369518,0.0041771913,0.0037821,-0.012247826,0.0018039504,-0.000520802,0.008612988,0.01744148,-0.017800653,0.0063358257,0.022584848,0.018748872,-0.026392091,-0.020544741,-0.021090684,0.02300149,0.004320861,-0.012757853,-0.02591798,0.010595627,0.026693797,-0.0031750964,-0.003986829,0.012204725,-0.0032253806,-0.004306494,-0.0047913785,0.016809333,-0.028733904,-0.013612687,-0.00336905,0.016694399,0.00655133,0.014194548,-0.012377129,-0.00589045,-0.009819811,-0.019352283,0.015372639,0.0036258595,-0.0030888945,0.011234956,0.0134331,0.03732534,0.012908706,-0.016349591,-0.012980541,-0.0076935026,0.0008620171,0.005114635,0.007865906,0.011845551,0.0075713834,0.013397182,-0.008641722,-0.00014782246,-0.01374199,0.039710253,0.013397182,0.005032025,-0.004220292,0.0026650697,-0.0064148437,0.009870096,-0.016708765,-0.015487574,-0.02201017,0.0067524672,-0.0025573175,0.013088293,-0.0002552379,0.006483087,0.019582156,0.0060664453,0.01494163,-0.011565397,-0.010997902,-0.024351982,0.013691705,0.028202327,0.021421125,-0.0058437577,0.017700085,-0.014460337,0.0039257696,0.012140074,-0.004906314,-0.008354383,-0.0044250214,0.0041376823,-0.0218665,0.00595151,-0.023461232,-0.017384011,-0.014079613,0.022613581,0.005111043,-0.021392392,0.045744374,0.014884162,-0.0029937136,0.003825201,-0.0007565098,0.026248422,0.019294817,-0.006052078,-0.0034372932,-0.0048847636,0.035170298,-0.00822508,0.004798562,-0.016909903,0.0040909895,-0.008569887,-0.0011807838,0.026392091,-0.025932347,0.010552526,0.015358271,0.0025932349,0.005757556,-0.013591136,-0.008519602,-0.019740192,0.0036815314,0.0024064644,-0.0029631837,-0.032498043,0.005498951,-0.0023076916,-0.04557197,-0.022958389,0.018389698,-0.018734505,0.0068853614,-0.009805445,0.0045974245,0.017915588,-0.009453454,0.02719664,-0.026492659,-0.031779695,0.017656984,0.011349892,-0.005840166,-0.002180185,-0.040687207]', + hash: 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9', + metadata: { baz: 'qux' }, + }, + ], + }, + outputFields: [], + perform: perform, + }, +}; diff --git a/integrations/zapier/index.js b/integrations/zapier/index.js new file mode 100644 index 00000000..61af32ec --- /dev/null +++ b/integrations/zapier/index.js @@ -0,0 +1,17 @@ +const authentication = require('./authentication'); +const searchTrigger = require('./triggers/search.js'); +const datasetsTrigger = require('./triggers/datasets.js'); +const addCreate = require('./creates/add.js'); +const listDatasetsSearch = require('./searches/list_datasets.js'); + +module.exports = { + version: require('./package.json').version, + platformVersion: require('zapier-platform-core').version, + authentication: authentication, + triggers: { + [searchTrigger.key]: searchTrigger, + [datasetsTrigger.key]: datasetsTrigger, + }, + creates: { [addCreate.key]: addCreate }, + searches: { [listDatasetsSearch.key]: listDatasetsSearch }, +}; diff --git a/integrations/zapier/package.json b/integrations/zapier/package.json new file mode 100644 index 00000000..493769af --- /dev/null +++ b/integrations/zapier/package.json @@ -0,0 +1,24 @@ +{ + "name": "embedbase", + "version": "1.0.1", + "description": "Synchronize everything into embedbase", + "main": "index.js", + "scripts": { + "test": "mocha --recursive -t 10000" + }, + "engines": { + "node": ">=v16", + "npm": ">=5.6.0" + }, + "dependencies": { + "zapier-platform-core": "14.0.0" + }, + "devDependencies": { + "mocha": "^5.2.0", + "should": "^13.2.0" + }, + "private": true, + "zapier": { + "convertedByCLIVersion": "14.0.0" + } +} \ No newline at end of file diff --git a/integrations/zapier/searches/list_datasets.js b/integrations/zapier/searches/list_datasets.js new file mode 100644 index 00000000..5200c139 --- /dev/null +++ b/integrations/zapier/searches/list_datasets.js @@ -0,0 +1,11 @@ +module.exports = { + operation: { perform: {} }, + key: 'list_datasets', + noun: 'Datasets', + display: { + label: 'List datasets', + description: 'List your embedbase datasets', + hidden: false, + important: true, + }, +}; diff --git a/integrations/zapier/test/creates/add.js b/integrations/zapier/test/creates/add.js new file mode 100644 index 00000000..546a215a --- /dev/null +++ b/integrations/zapier/test/creates/add.js @@ -0,0 +1,30 @@ +require('should'); + +const zapier = require('zapier-platform-core'); + +const App = require('../../index'); +const appTester = zapier.createAppTester(App); + +describe('Create - add', () => { + zapier.tools.env.inject(); + + it('should create an object', async () => { + const bundle = { + authData: { + api_key: process.env.API_KEY, + oauth_consumer_key: process.env.OAUTH_CONSUMER_KEY, + oauth_consumer_secret: process.env.OAUTH_CONSUMER_SECRET, + oauth_token: process.env.OAUTH_TOKEN, + oauth_token_secret: process.env.OAUTH_TOKEN_SECRET, + }, + + inputData: {}, + }; + + const result = await appTester( + App.creates['add'].operation.perform, + bundle + ); + result.should.not.be.an.Array(); + }); +}); diff --git a/integrations/zapier/test/searches/list_datasets.js b/integrations/zapier/test/searches/list_datasets.js new file mode 100644 index 00000000..c5ed1144 --- /dev/null +++ b/integrations/zapier/test/searches/list_datasets.js @@ -0,0 +1,32 @@ +require('should'); + +const zapier = require('zapier-platform-core'); + +const App = require('../../index'); +const appTester = zapier.createAppTester(App); + +describe('Search - list_datasets', () => { + zapier.tools.env.inject(); + + it('should get an array', async () => { + const bundle = { + authData: { + api_key: process.env.API_KEY, + oauth_consumer_key: process.env.OAUTH_CONSUMER_KEY, + oauth_consumer_secret: process.env.OAUTH_CONSUMER_SECRET, + oauth_token: process.env.OAUTH_TOKEN, + oauth_token_secret: process.env.OAUTH_TOKEN_SECRET, + }, + + inputData: {}, + }; + + const results = await appTester( + App.searches['list_datasets'].operation.perform, + bundle + ); + results.should.be.an.Array(); + results.length.should.be.aboveOrEqual(1); + results[0].should.have.property('id'); + }); +}); diff --git a/integrations/zapier/test/triggers/datasets.js b/integrations/zapier/test/triggers/datasets.js new file mode 100644 index 00000000..f38d24c6 --- /dev/null +++ b/integrations/zapier/test/triggers/datasets.js @@ -0,0 +1,30 @@ +require('should'); + +const zapier = require('zapier-platform-core'); + +const App = require('../../index'); +const appTester = zapier.createAppTester(App); + +describe('Trigger - datasets', () => { + zapier.tools.env.inject(); + + it('should get an array', async () => { + const bundle = { + authData: { + api_key: process.env.API_KEY, + oauth_consumer_key: process.env.OAUTH_CONSUMER_KEY, + oauth_consumer_secret: process.env.OAUTH_CONSUMER_SECRET, + oauth_token: process.env.OAUTH_TOKEN, + oauth_token_secret: process.env.OAUTH_TOKEN_SECRET, + }, + + inputData: {}, + }; + + const results = await appTester( + App.triggers['datasets'].operation.perform, + bundle + ); + results.should.be.an.Array(); + }); +}); diff --git a/integrations/zapier/test/triggers/search.js b/integrations/zapier/test/triggers/search.js new file mode 100644 index 00000000..64a2a057 --- /dev/null +++ b/integrations/zapier/test/triggers/search.js @@ -0,0 +1,30 @@ +require('should'); + +const zapier = require('zapier-platform-core'); + +const App = require('../../index'); +const appTester = zapier.createAppTester(App); + +describe('Trigger - search', () => { + zapier.tools.env.inject(); + + it('should get an array', async () => { + const bundle = { + authData: { + api_key: process.env.API_KEY, + oauth_consumer_key: process.env.OAUTH_CONSUMER_KEY, + oauth_consumer_secret: process.env.OAUTH_CONSUMER_SECRET, + oauth_token: process.env.OAUTH_TOKEN, + oauth_token_secret: process.env.OAUTH_TOKEN_SECRET, + }, + + inputData: {}, + }; + + const results = await appTester( + App.triggers['search'].operation.perform, + bundle + ); + results.should.be.an.Array(); + }); +}); diff --git a/integrations/zapier/triggers/datasets.js b/integrations/zapier/triggers/datasets.js new file mode 100644 index 00000000..e7d92d3a --- /dev/null +++ b/integrations/zapier/triggers/datasets.js @@ -0,0 +1,44 @@ +const perform = async (z, bundle) => { + return bundle.cleanedRequest; +}; + +const performList = async (z, bundle) => { + const options = { + url: 'https://api.embedbase.xyz/v1/datasets', + method: 'GET', + headers: { + Accept: 'application/json', + Authorization: 'Bearer ' + bundle.authData.api_key, + }, + }; + + return z.request(options).then((response) => { + response.throwForStatus(); + const results = response.json; + + // You can do any parsing you need for results here before returning them + + return results.datasets; + }); +}; + +module.exports = { + operation: { + perform: perform, + type: 'hook', + performList: performList, + sample: { dataset_id: 'foo', documents_count: 65 }, + outputFields: [ + { key: 'dataset_id', type: 'string' }, + { key: 'documents_count', type: 'number' }, + ], + }, + key: 'datasets', + noun: 'Datasets', + display: { + label: 'List datasets', + description: 'List your embedbase datasets', + hidden: false, + important: true, + }, +}; diff --git a/integrations/zapier/triggers/search.js b/integrations/zapier/triggers/search.js new file mode 100644 index 00000000..50fa64ad --- /dev/null +++ b/integrations/zapier/triggers/search.js @@ -0,0 +1,76 @@ +const perform = async (z, bundle) => { + return bundle.cleanedRequest; +}; + +const performList = async (z, bundle) => { + const options = { + url: + 'https://api.embedbase.xyz/v1/' + bundle.inputData.dataset_id + '/search', + method: 'POST', + headers: { + Accept: 'application/json', + Authorization: 'Bearer ' + bundle.authData.api_key, + }, + body: { + query: bundle.inputData.query, + }, + }; + + return z.request(options).then((response) => { + response.throwForStatus(); + const results = response.json; + + // You can do any parsing you need for results here before returning them + + return results.similarities; + }); +}; + +module.exports = { + operation: { + perform: perform, + inputFields: [ + { + key: 'query', + type: 'string', + label: 'Query value', + required: true, + list: false, + altersDynamicFields: false, + }, + { + key: 'dataset_id', + type: 'string', + label: 'Dataset ID', + dynamic: 'datasets.dataset_id.dataset_id', + required: true, + list: false, + altersDynamicFields: false, + }, + ], + type: 'hook', + performList: performList, + sample: { + score: 0.765, + id: 'abcd', + data: 'lions are dangerous', + hash: 'abcd', + embedding: [0.765, 0.765, 0.765, 0.765], + metadata: { animals: 'savannah' }, + }, + outputFields: [ + { key: 'score', type: 'number' }, + { key: 'id', type: 'string' }, + { key: 'data', type: 'string' }, + { key: 'hash', type: 'string' }, + ], + }, + key: 'search', + noun: 'Search', + display: { + label: 'Search documents', + description: 'Search documents in embedbase', + hidden: false, + important: true, + }, +};