@joystick.js/node-canary 0.0.0-canary.436 → 0.0.0-canary.438

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 +1 @@
1
- import i from"../databases/queries/accounts.js";import m from"../../lib/camel_pascal_to_snake.js";import u from"../databases/postgresql/accounts/create_accounts_metadata_table_columns.js";import l from"../databases/database_type_map.js";import f from"./generate_account_session.js";import w from"../api/get_output.js";import p from"../databases/get_target_database_connection.js";import y from"../../lib/hash_string.js";import g from"./roles/index.js";import n from"../../lib/types.js";const b=(e=null,s=null)=>i("add_session",{user_id:e,session:s}),h=(e="")=>i("user",{_id:e}),x=async(e={})=>i("create_user",e),_=(e={})=>Object.entries(e||{}).reduce((s={},[r,a])=>(s[m(r)]=a,s),{}),E=async(e={})=>{const s=p("users"),r=l[s?.provider];let a={password:y(e.password)};if(e?.email_address&&(a.emailAddress=e?.email_address||e.emailAddress),e?.username&&(a.username=e?.username),e?.metadata&&n.is_object(e.metadata)&&r==="sql"){const t=_(e.metadata);await u(s,t);const d={...e?.metadata||{}};d?.roles&&delete d.roles,a={..._(d),...a}}if(e?.metadata&&n.is_object(e.metadata)&&r==="nosql"){let t={...e?.metadata||{}};t?.roles&&delete t.roles,a={...t||{},...a}}return a},j=(e="",s="")=>i("existing_user",{email_address:e,username:s}),v=async e=>{if(!e.email_address&&!e.emailAddress)throw new Error("Email address is required.");if(!e.password)throw new Error("Password is required.");const s=await j(e.email_address||e.emailAddress,e?.username);if(s&&process.env.NODE_ENV!=="test")throw new Error(`A user with the ${s.existing_username?"username":"email address"} ${s.existing_username||s.existing_email_address} already exists.`);let r,a=s?._id||s?.user_id;s||(r=await E(e),a=await x(r));const t=await h(a),d=f();if(a&&await b(a,d),e?.metadata?.roles?.length>0&&process.env.NODE_ENV==="test")for(let o=0;o<e?.metadata?.roles?.length;o+=1){const c=e?.metadata?.roles[o];g.grant(t?.user_id,c)}return(n.is_function(process.joystick?.app_options?.accounts?.events?.onSignup)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_signup))&&(process.joystick?.app_options?.accounts?.events?.onSignup||process.joystick?.app_options?.accounts?.events?.on_signup)({...d,user_id:a,userId:a,user:t}),{...d,userId:a,user_id:a,user:w(t,e?.output)}};var z=v;export{z as default};
1
+ import i from"../databases/queries/accounts.js";import m from"../../lib/camel_pascal_to_snake.js";import u from"../databases/postgresql/accounts/create_accounts_metadata_table_columns.js";import l from"../databases/database_type_map.js";import f from"./generate_account_session.js";import w from"../api/get_output.js";import y from"../databases/get_target_database_connection.js";import g from"../../lib/hash_string.js";import p from"./roles/index.js";import n from"../../lib/types.js";const b=(e=null,s=null)=>i("add_session",{user_id:e,session:s}),h=(e="")=>i("user",{_id:e}),x=async(e={})=>i("create_user",e),_=(e={})=>Object.entries(e||{}).reduce((s={},[r,a])=>(s[m(r)]=a,s),{}),E=async(e={})=>{const s=y("users"),r=l[s?.provider];let a={password:g(e.password)};if((e?.email_address||e?.emailAddress)&&(a.emailAddress=e?.email_address||e.emailAddress),e?.username&&(a.username=e?.username),e?.metadata&&n.is_object(e.metadata)&&r==="sql"){const t=_(e.metadata);await u(s,t);const d={...e?.metadata||{}};d?.roles&&delete d.roles,a={..._(d),...a}}if(e?.metadata&&n.is_object(e.metadata)&&r==="nosql"){let t={...e?.metadata||{}};t?.roles&&delete t.roles,a={...t||{},...a}}return a},j=(e="",s="")=>i("existing_user",{email_address:e,username:s}),v=async(e={})=>{if(!e.email_address&&!e.emailAddress)throw new Error("Email address is required.");if(!e.password)throw new Error("Password is required.");const s=await j(e.email_address||e.emailAddress,e?.username);if(s&&process.env.NODE_ENV!=="test")throw new Error(`A user with the ${s.existing_username?"username":"email address"} ${s.existing_username||s.existing_email_address} already exists.`);let r,a=s?._id||s?.user_id;s||(r=await E(e),a=await x(r));const t=await h(a),d=f();if(a&&await b(a,d),e?.metadata?.roles?.length>0&&process.env.NODE_ENV==="test")for(let o=0;o<e?.metadata?.roles?.length;o+=1){const c=e?.metadata?.roles[o];p.grant(t?.user_id,c)}return(n.is_function(process.joystick?.app_options?.accounts?.events?.onSignup)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_signup))&&(process.joystick?.app_options?.accounts?.events?.onSignup||process.joystick?.app_options?.accounts?.events?.on_signup)({...d,user_id:a,userId:a,user:t}),{...d,userId:a,user_id:a,user:w(t,e?.output)}};var z=v;export{z as default};
@@ -1 +1 @@
1
- import o from"../../lib/types.js";const s=(t={},r=[])=>{console.log("FO",{object:t,fields:r});const i=Object.entries(t||{});for(let n=0;n<i?.length;n+=1){const[a,e]=i[n],l=r.find(_=>_.key===a);if(l||delete t[a],l&&o.is_object(e)&&l.children.length===0)return e;if(l&&o.is_object(e)&&l.children.length>0&&s(e,l.children),l&&o.is_array(e)&&l.children&&l.children.length>0)for(let _=0;_<e?.length;_+=1){const c=e[_];c&&o.is_object(c)&&s(c,l.children)}}return t},f=(t=[])=>t.map(r=>r.split(".")),h=(t=[])=>{const[r,...i]=t;return{head:r,tail:i}},u=(t=[])=>t.map(r=>h(r)),d=(t=[],r=[])=>{for(let i=0;i<r?.length;i+=1){const n=r[i],a=t.find(e=>e.key===n.head);if(!a){const e=n.tail&&n.tail.length>0?h(n.tail):null;t.push({key:n.head,children:e?d([],[e]):[]})}if(a){const e=n.tail&&n.tail.length>0?h(n.tail):null;a.children=[...e?d(a.children,[e]):[]]}}return t},p=(t={},r=[])=>{const i=[],n=f(r),a=u(n);return d(i,a),o.is_array(t)?t.map(e=>s(e,i)):s(t,i)};var y=p;export{y as default};
1
+ import o from"../../lib/types.js";const s=(t={},n=[])=>{const i=Object.entries(t||{});for(let r=0;r<i?.length;r+=1){const[a,e]=i[r],l=n.find(_=>_.key===a);if(l||delete t[a],l&&o.is_object(e)&&l.children.length===0)return e;if(l&&o.is_object(e)&&l.children.length>0&&s(e,l.children),l&&o.is_array(e)&&l.children&&l.children.length>0)for(let _=0;_<e?.length;_+=1){const c=e[_];c&&o.is_object(c)&&s(c,l.children)}}return t},f=(t=[])=>t.map(n=>n.split(".")),h=(t=[])=>{const[n,...i]=t;return{head:n,tail:i}},u=(t=[])=>t.map(n=>h(n)),d=(t=[],n=[])=>{for(let i=0;i<n?.length;i+=1){const r=n[i],a=t.find(e=>e.key===r.head);if(!a){const e=r.tail&&r.tail.length>0?h(r.tail):null;t.push({key:r.head,children:e?d([],[e]):[]})}if(a){const e=r.tail&&r.tail.length>0?h(r.tail):null;a.children=[...e?d(a.children,[e]):[]]}}return t},p=(t={},n=[])=>{const i=[],r=f(n),a=u(r);return d(i,a),o.is_array(t)?t.map(e=>s(e,i)):s(t,i)};var y=p;export{y as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.436",
4
+ "version": "0.0.0-canary.438",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -36,7 +36,7 @@ const get_user_to_create = async (options = {}) => {
36
36
  password: hash_string(options.password),
37
37
  };
38
38
 
39
- if (options?.email_address) {
39
+ if (options?.email_address || options?.emailAddress) {
40
40
  user.emailAddress = options?.email_address || options.emailAddress;
41
41
  }
42
42
 
@@ -88,7 +88,7 @@ const get_existing_user = (email_address = "", username = "") => {
88
88
  return accounts_query("existing_user", { email_address, username });
89
89
  };
90
90
 
91
- const signup = async (signup_options) => {
91
+ const signup = async (signup_options = {}) => {
92
92
  if (!signup_options.email_address && !signup_options.emailAddress) {
93
93
  throw new Error("Email address is required.");
94
94
  }
@@ -1,7 +1,6 @@
1
1
  import types from "../../lib/types.js";
2
2
 
3
3
  const filter_output = (object = {}, fields = []) => {
4
- console.log('FO', { object, fields });
5
4
  const entries_for_object_to_filter = Object.entries(object || {});
6
5
 
7
6
  for (let i = 0; i < entries_for_object_to_filter?.length; i += 1) {