@sqrzro/server 4.0.0-alpha.23 → 4.0.0-alpha.24

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,2 +1,2 @@
1
- export{a as createMFA,e as createReset,g as createSession,j as createUser,h as deleteSession,k as deleteUser,i as deleteUserSessions,c as updatePasswordWithPassword,d as updatePasswordWithToken,b as validateMFA,f as validateReset,l as validateUser}from'../chunk-6AWLN6E3.js';import'../chunk-CESWDV42.js';export{j as ensureSessionUser,i as getSessionUser,h as validateSession}from'../chunk-7LTWI5JO.js';import'../chunk-6LBWOS53.js';import'../chunk-JI2U2EMD.js';import'../chunk-3JA7XHAG.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';//# sourceMappingURL=index.js.map
1
+ export{a as createMFA,e as createReset,g as createSession,j as createUser,h as deleteSession,k as deleteUser,i as deleteUserSessions,c as updatePasswordWithPassword,d as updatePasswordWithToken,b as validateMFA,f as validateReset,l as validateUser}from'../chunk-6AWLN6E3.js';import'../chunk-CESWDV42.js';export{j as ensureSessionUser,i as getSessionUser,h as validateSession}from'../chunk-7LTWI5JO.js';import'../chunk-HTYJSYK5.js';import'../chunk-JI2U2EMD.js';import'../chunk-3JA7XHAG.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ function o(n,t){let r=Array.isArray(n)?n[0]:n;return r?.startsWith(t)?r:null}var e=o;function u(n,t){let r=e(n,t);if(!r)throw new Error(`Could not ensure ID. '${n}' is not a valid ID with prefix '${t}'.`);return r}var l=u;async function g(n,t,r){if(!r)throw new Error("");let s=r instanceof Promise?await r:r,i=e(s[n],t);if(!i)throw new Error("");return i}var w=g;export{e as a,l as b,w as c};//# sourceMappingURL=chunk-HTYJSYK5.js.map
2
+ //# sourceMappingURL=chunk-HTYJSYK5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/guard-id.ts","../src/utility/ensure-id.ts","../src/utility/get-id-from-params.ts"],"names":["guardID","id","prefix","value","guard_id_default","ensureID","guardedID","ensure_id_default","getIDFromParams","key","params","awaitedParams","get_id_from_params_default"],"mappings":"AAAA,SAASA,CAAAA,CACLC,EACAC,CAAAA,CACQ,CACR,IAAMC,CAAAA,CAAQ,KAAA,CAAM,QAAQF,CAAE,CAAA,CAAIA,EAAG,CAAC,CAAA,CAAIA,EAE1C,OAAKE,CAAAA,EAAO,WAAWD,CAAM,CAAA,CAItBC,EAHI,IAIf,KAEOC,CAAAA,CAAQJ,ECXf,SAASK,CAAAA,CAA2BJ,CAAAA,CAA0CC,EAAmB,CAC7F,IAAMI,EAAYF,CAAAA,CAAWH,CAAAA,CAAIC,CAAM,CAAA,CAEvC,GAAI,CAACI,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,CAAA,sBAAA,EAAyBL,CAAE,CAAA,iCAAA,EAAoCC,CAAM,CAAA,EAAA,CAAI,EAG7F,OAAOI,CACX,CAEA,IAAOC,CAAAA,CAAQF,ECVf,eAAeG,CAAAA,CACXC,EACAP,CAAAA,CACAQ,CAAAA,CACU,CACV,GAAI,CAACA,EACD,MAAM,IAAI,MAAM,EAAE,CAAA,CAGtB,IAAMC,CAAAA,CAAgBD,CAAAA,YAAkB,QAAU,MAAMA,CAAAA,CAASA,EAC3DT,CAAAA,CAAKG,CAAAA,CAAWO,EAAcF,CAAG,CAAA,CAAGP,CAAM,CAAA,CAEhD,GAAI,CAACD,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,EAAE,EAGtB,OAAOA,CACX,CAEA,IAAOW,CAAAA,CAAQJ","file":"chunk-HTYJSYK5.js","sourcesContent":["function guardID<T extends string>(\n id: string[] | string | null | undefined,\n prefix: string\n): T | null {\n const value = Array.isArray(id) ? id[0] : id;\n\n if (!value?.startsWith(prefix)) {\n return null;\n }\n\n return value as T;\n}\n\nexport default guardID;\n","import guardID from './guard-id';\n\nfunction ensureID<T extends string>(id: string[] | string | null | undefined, prefix: string): T {\n const guardedID = guardID<T>(id, prefix);\n\n if (!guardedID) {\n throw new Error(`Could not ensure ID. '${id}' is not a valid ID with prefix '${prefix}'.`);\n }\n\n return guardedID;\n}\n\nexport default ensureID;\n","import guardID from './guard-id';\n\nasync function getIDFromParams<T extends string>(\n key: string,\n prefix: string,\n params?: Promise<Record<string, string>> | Record<string, string> | null\n): Promise<T> {\n if (!params) {\n throw new Error('');\n }\n\n const awaitedParams = params instanceof Promise ? await params : params;\n const id = guardID<T>(awaitedParams[key], prefix);\n\n if (!id) {\n throw new Error('');\n }\n\n return id;\n}\n\nexport default getIDFromParams;\n"]}
@@ -1,2 +1,2 @@
1
- import {j}from'../chunk-7LTWI5JO.js';import {c,b,a}from'../chunk-6LBWOS53.js';import'../chunk-JI2U2EMD.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';import {cache}from'react';import {eq}from'drizzle-orm';import {notFound}from'next/navigation';function k(t){async function w(e){if(!t.makeQuery)throw new Error("Could not `getAll`. `makeQuery` function is not defined.");let r=[],n=await t.applyFilters?.(e?.filters??null);r.push(...n||[]);let i=await t.applyGuards?.(e?.guards??null);return r.push(...i||[]),t.makeQuery(r,{limit:e?.limit??-1,offset:e?.offset??0})}async function C(e){if(!t.makeMetaQuery)throw new Error("Could not `getPaginated`. `makeMetaQuery` function is not defined.");if(!t.makeQuery)throw new Error("Could not `getPaginated`. `makeQuery` function is not defined.");let r=[],n=await t.applyFilters?.(e?.filters??null);r.push(...n||[]);let i=await t.applyGuards?.(e?.guards??null);r.push(...i||[]);let u=await t.makeMetaQuery(r);return {data:await t.makeQuery(r,{limit:e?.limit??10,offset:((e?.page??1)-1)*(e?.limit??10)}),meta:{limit:e?.limit??10,page:e?.page??1,total:u.count}}}async function o(e,r,n){if(!t.makeQuery)throw new Error("Could not `getByIndex`. `makeQuery` function is not defined.");if(!t.indexes?.[e])throw new Error(`'Could not \`getByIndex\`. Index ${String(e)} is not defined in the repository configuration.`);let i=[],u=await t.applyFilters?.(n?.filters??null);i.push(...u||[]);let m=await t.applyGuards?.(n?.guards??null);i.push(...m||[]),i.push(eq(t.indexes[e],r));let[F]=await t.makeQuery(i,{limit:1,offset:0});return F??null}async function s(e,r,n){let i=await o(e,r,n);return i||notFound()}async function d(e){return o("id",e)}async function l(e){return s("id",e)}async function h(e){if(!t.paramKey)throw new Error("Could not `getFromParams`. `paramKey` is not defined.");if(!t.prefix)throw new Error("Could not `getFromParams`. `prefix` is not defined.");let r=await c(t.paramKey,t.prefix,e);return l(r)}async function g(){if(!t.prefix)throw new Error("Could not `getFromSession`. `prefix` is not defined.");let e=await j(),r=b(e.id,t.prefix),n=await d(r);if(!n)throw new Error(`Could not \`getFromSession\`. No record with ID '${r}' found.`);return n}async function x(e){if(!t.makeCreateMutation)throw new Error("Could not `create`. `makeCreateMutation` is not defined.");return t.makeCreateMutation(e)}async function Q(e){if(!t.makeUpdateMutation)throw new Error("Could not `update`. `makeUpdateMutation` is not defined.");return t.makeUpdateMutation(e)}function f(e){if(!t.prefix)throw new Error("Could not `guardID`. `prefix` is not defined.");return a(e,t.prefix)}function P(e){let r=f(e);if(!r)throw new Error(`Invalid ID '${e}'. Expected a string starting with '${t.prefix}'.`);return r}return {create:x,ensureByID:cache(l),ensureByIndex:cache(s),getAll:cache(w),getByID:cache(d),getByIndex:cache(o),getFromParams:cache(h),getFromSession:cache(g),getPaginated:cache(C),guardID:f,ensureID:P,update:Q}}var E=k;export{E as createRepository};//# sourceMappingURL=index.js.map
1
+ import {j}from'../chunk-7LTWI5JO.js';import {c,b,a}from'../chunk-HTYJSYK5.js';import'../chunk-JI2U2EMD.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';import {cache}from'react';import {eq}from'drizzle-orm';import {notFound}from'next/navigation';function k(t){async function w(e){if(!t.makeQuery)throw new Error("Could not `getAll`. `makeQuery` function is not defined.");let r=[],n=await t.applyFilters?.(e?.filters??null);r.push(...n||[]);let i=await t.applyGuards?.(e?.guards??null);return r.push(...i||[]),t.makeQuery(r,{limit:e?.limit??-1,offset:e?.offset??0})}async function C(e){if(!t.makeMetaQuery)throw new Error("Could not `getPaginated`. `makeMetaQuery` function is not defined.");if(!t.makeQuery)throw new Error("Could not `getPaginated`. `makeQuery` function is not defined.");let r=[],n=await t.applyFilters?.(e?.filters??null);r.push(...n||[]);let i=await t.applyGuards?.(e?.guards??null);r.push(...i||[]);let u=await t.makeMetaQuery(r);return {data:await t.makeQuery(r,{limit:e?.limit??10,offset:((e?.page??1)-1)*(e?.limit??10)}),meta:{limit:e?.limit??10,page:e?.page??1,total:u.count}}}async function o(e,r,n){if(!t.makeQuery)throw new Error("Could not `getByIndex`. `makeQuery` function is not defined.");if(!t.indexes?.[e])throw new Error(`'Could not \`getByIndex\`. Index ${String(e)} is not defined in the repository configuration.`);let i=[],u=await t.applyFilters?.(n?.filters??null);i.push(...u||[]);let m=await t.applyGuards?.(n?.guards??null);i.push(...m||[]),i.push(eq(t.indexes[e],r));let[F]=await t.makeQuery(i,{limit:1,offset:0});return F??null}async function s(e,r,n){let i=await o(e,r,n);return i||notFound()}async function d(e){return o("id",e)}async function l(e){return s("id",e)}async function h(e){if(!t.paramKey)throw new Error("Could not `getFromParams`. `paramKey` is not defined.");if(!t.prefix)throw new Error("Could not `getFromParams`. `prefix` is not defined.");let r=await c(t.paramKey,t.prefix,e);return l(r)}async function g(){if(!t.prefix)throw new Error("Could not `getFromSession`. `prefix` is not defined.");let e=await j(),r=b(e.id,t.prefix),n=await d(r);if(!n)throw new Error(`Could not \`getFromSession\`. No record with ID '${r}' found.`);return n}async function x(e){if(!t.makeCreateMutation)throw new Error("Could not `create`. `makeCreateMutation` is not defined.");return t.makeCreateMutation(e)}async function Q(e){if(!t.makeUpdateMutation)throw new Error("Could not `update`. `makeUpdateMutation` is not defined.");return t.makeUpdateMutation(e)}function f(e){if(!t.prefix)throw new Error("Could not `guardID`. `prefix` is not defined.");return a(e,t.prefix)}function P(e){let r=f(e);if(!r)throw new Error(`Invalid ID '${e}'. Expected a string starting with '${t.prefix}'.`);return r}return {create:x,ensureByID:cache(l),ensureByIndex:cache(s),getAll:cache(w),getByID:cache(d),getByIndex:cache(o),getFromParams:cache(h),getFromSession:cache(g),getPaginated:cache(C),guardID:f,ensureID:P,update:Q}}var E=k;export{E as createRepository};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import'../chunk-6AWLN6E3.js';import'../chunk-CESWDV42.js';import {h}from'../chunk-7LTWI5JO.js';import'../chunk-6LBWOS53.js';import'../chunk-JI2U2EMD.js';import'../chunk-3JA7XHAG.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';import {NextResponse}from'next/server';async function x(e,o){for(let r of o){let t=await r(e);if(t)return NextResponse.redirect(new URL(t.redirect,e.url))}return NextResponse.next()}var u=x;async function a(e,o){let r=await h(e.cookies);for(let t of o){let n=await t(r,e);if(n)return NextResponse.redirect(new URL(n.redirect,e.url))}return NextResponse.next()}var c=a;export{u as handleProxy,c as handleSessionProxy};//# sourceMappingURL=index.js.map
1
+ import'../chunk-6AWLN6E3.js';import'../chunk-CESWDV42.js';import {h}from'../chunk-7LTWI5JO.js';import'../chunk-HTYJSYK5.js';import'../chunk-JI2U2EMD.js';import'../chunk-3JA7XHAG.js';import'../chunk-C2XLUXVN.js';import'../chunk-KC7SPWBL.js';import {NextResponse}from'next/server';async function x(e,o){for(let r of o){let t=await r(e);if(t)return NextResponse.redirect(new URL(t.redirect,e.url))}return NextResponse.next()}var u=x;async function a(e,o){let r=await h(e.cookies);for(let t of o){let n=await t(r,e);if(n)return NextResponse.redirect(new URL(n.redirect,e.url))}return NextResponse.next()}var c=a;export{u as handleProxy,c as handleSessionProxy};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -4,7 +4,7 @@ declare function ensureID<T extends string>(id: string[] | string | null | undef
4
4
 
5
5
  declare function generateID<T extends string = string>(prefix?: string | null, length?: number): T;
6
6
 
7
- declare function getIDFromParams<T extends string>(key: string, prefix: string, params?: Promise<Record<string, string>> | null): Promise<T>;
7
+ declare function getIDFromParams<T extends string>(key: string, prefix: string, params?: Promise<Record<string, string>> | Record<string, string> | null): Promise<T>;
8
8
 
9
9
  declare function guardID<T extends string>(id: string[] | string | null | undefined, prefix: string): T | null;
10
10
 
@@ -1,2 +1,2 @@
1
- export{a as generateID}from'../chunk-CESWDV42.js';export{b as ensureID,c as getIDFromParams,a as guardID}from'../chunk-6LBWOS53.js';export{a as log}from'../chunk-KC7SPWBL.js';//# sourceMappingURL=index.js.map
1
+ export{a as generateID}from'../chunk-CESWDV42.js';export{b as ensureID,c as getIDFromParams,a as guardID}from'../chunk-HTYJSYK5.js';export{a as log}from'../chunk-KC7SPWBL.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqrzro/server",
3
- "version": "4.0.0-alpha.23",
3
+ "version": "4.0.0-alpha.24",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- function o(r,t){let n=Array.isArray(r)?r[0]:r;return n?.startsWith(t)?n:null}var e=o;function u(r,t){let n=e(r,t);if(!n)throw new Error(`Could not ensure ID. '${r}' is not a valid ID with prefix '${t}'.`);return n}var l=u;async function a(r,t,n){if(!n)throw new Error("");let s=await n,i=e(s[r],t);if(!i)throw new Error("");return i}var w=a;export{e as a,l as b,w as c};//# sourceMappingURL=chunk-6LBWOS53.js.map
2
- //# sourceMappingURL=chunk-6LBWOS53.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utility/guard-id.ts","../src/utility/ensure-id.ts","../src/utility/get-id-from-params.ts"],"names":["guardID","id","prefix","value","guard_id_default","ensureID","guardedID","ensure_id_default","getIDFromParams","key","params","awaitedParams","get_id_from_params_default"],"mappings":"AAAA,SAASA,EACLC,CAAAA,CACAC,CAAAA,CACQ,CACR,IAAMC,CAAAA,CAAQ,MAAM,OAAA,CAAQF,CAAE,EAAIA,CAAAA,CAAG,CAAC,EAAIA,CAAAA,CAE1C,OAAKE,GAAO,UAAA,CAAWD,CAAM,EAItBC,CAAAA,CAHI,IAIf,CAEA,IAAOC,CAAAA,CAAQJ,ECXf,SAASK,CAAAA,CAA2BJ,EAA0CC,CAAAA,CAAmB,CAC7F,IAAMI,CAAAA,CAAYF,CAAAA,CAAWH,EAAIC,CAAM,CAAA,CAEvC,GAAI,CAACI,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,yBAAyBL,CAAE,CAAA,iCAAA,EAAoCC,CAAM,CAAA,EAAA,CAAI,CAAA,CAG7F,OAAOI,CACX,KAEOC,CAAAA,CAAQF,ECVf,eAAeG,CAAAA,CACXC,CAAAA,CACAP,EACAQ,CAAAA,CACU,CACV,GAAI,CAACA,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,EAAE,CAAA,CAGtB,IAAMC,EAAgB,MAAMD,CAAAA,CACtBT,EAAKG,CAAAA,CAAWO,CAAAA,CAAcF,CAAG,CAAA,CAAGP,CAAM,EAEhD,GAAI,CAACD,EACD,MAAM,IAAI,MAAM,EAAE,CAAA,CAGtB,OAAOA,CACX,KAEOW,CAAAA,CAAQJ","file":"chunk-6LBWOS53.js","sourcesContent":["function guardID<T extends string>(\n id: string[] | string | null | undefined,\n prefix: string\n): T | null {\n const value = Array.isArray(id) ? id[0] : id;\n\n if (!value?.startsWith(prefix)) {\n return null;\n }\n\n return value as T;\n}\n\nexport default guardID;\n","import guardID from './guard-id';\n\nfunction ensureID<T extends string>(id: string[] | string | null | undefined, prefix: string): T {\n const guardedID = guardID<T>(id, prefix);\n\n if (!guardedID) {\n throw new Error(`Could not ensure ID. '${id}' is not a valid ID with prefix '${prefix}'.`);\n }\n\n return guardedID;\n}\n\nexport default ensureID;\n","import guardID from './guard-id';\n\nasync function getIDFromParams<T extends string>(\n key: string,\n prefix: string,\n params?: Promise<Record<string, string>> | null\n): Promise<T> {\n if (!params) {\n throw new Error('');\n }\n\n const awaitedParams = await params;\n const id = guardID<T>(awaitedParams[key], prefix);\n\n if (!id) {\n throw new Error('');\n }\n\n return id;\n}\n\nexport default getIDFromParams;\n"]}