@sqrzro/addon-admins 4.0.0-alpha.16 → 4.0.0-alpha.17

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.
Files changed (51) hide show
  1. package/package.json +9 -9
  2. package/dist/DEPRECATED_addon/config.d.ts +0 -10
  3. package/dist/DEPRECATED_addon/config.d.ts.map +0 -1
  4. package/dist/DEPRECATED_addon/config.js +0 -11
  5. package/dist/DEPRECATED_addon/defaults.d.ts +0 -6
  6. package/dist/DEPRECATED_addon/defaults.d.ts.map +0 -1
  7. package/dist/DEPRECATED_addon/defaults.js +0 -6
  8. package/dist/DEPRECATED_addon/index.d.ts +0 -6
  9. package/dist/DEPRECATED_addon/index.d.ts.map +0 -1
  10. package/dist/DEPRECATED_addon/index.js +0 -9
  11. package/dist/DEPRECATED_addon/interfaces.d.ts +0 -8
  12. package/dist/DEPRECATED_addon/interfaces.d.ts.map +0 -1
  13. package/dist/DEPRECATED_addon/interfaces.js +0 -1
  14. package/dist/addon/config.d.ts +0 -10
  15. package/dist/addon/config.d.ts.map +0 -1
  16. package/dist/addon/config.js +0 -11
  17. package/dist/addon/defaults.d.ts +0 -6
  18. package/dist/addon/defaults.d.ts.map +0 -1
  19. package/dist/addon/defaults.js +0 -6
  20. package/dist/addon/index.d.ts +0 -6
  21. package/dist/addon/index.d.ts.map +0 -1
  22. package/dist/addon/index.js +0 -9
  23. package/dist/addon/interfaces.d.ts +0 -8
  24. package/dist/addon/interfaces.d.ts.map +0 -1
  25. package/dist/addon/interfaces.js +0 -1
  26. package/dist/addon.d.ts +0 -4
  27. package/dist/addon.d.ts.map +0 -1
  28. package/dist/addon.js +0 -4
  29. package/dist/components/AdminPage/index.d.ts +0 -3
  30. package/dist/components/AdminPage/index.js +0 -5
  31. package/dist/config/index.d.ts +0 -7
  32. package/dist/config/index.d.ts.map +0 -1
  33. package/dist/config/index.js +0 -10
  34. package/dist/config.d.ts +0 -4
  35. package/dist/config.d.ts.map +0 -1
  36. package/dist/config.js +0 -10
  37. package/dist/interfaces.d.ts +0 -2
  38. package/dist/interfaces.d.ts.map +0 -1
  39. package/dist/interfaces.js +0 -1
  40. package/dist/mail/AdminInviteMail.d.ts +0 -6
  41. package/dist/mail/AdminInviteMail.d.ts.map +0 -1
  42. package/dist/mail/AdminInviteMail.js +0 -14
  43. package/dist/register-admins-addon.d.ts +0 -4
  44. package/dist/register-admins-addon.d.ts.map +0 -1
  45. package/dist/register-admins-addon.js +0 -5
  46. package/dist/repositories/index.d.ts +0 -147
  47. package/dist/repositories/index.d.ts.map +0 -1
  48. package/dist/repositories/index.js +0 -67
  49. package/dist/repository/index.d.ts +0 -149
  50. package/dist/repository/index.d.ts.map +0 -1
  51. package/dist/repository/index.js +0 -80
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/addon-admins",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.16",
4
+ "version": "4.0.0-alpha.17",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",
@@ -16,22 +16,22 @@
16
16
  }
17
17
  },
18
18
  "files": [
19
- "dist/**/*"
19
+ "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@sqrzro/addon-auth": "^4.0.0-alpha.30",
23
- "@sqrzro/addon-onboarding": "^4.0.0-alpha.26",
24
- "@sqrzro/addons": "^4.0.0-alpha.16",
25
- "@sqrzro/admin": "^4.0.0-alpha.35",
26
- "@sqrzro/server": "^4.0.0-alpha.64",
27
- "@sqrzro/ui": "^4.0.0-alpha.81",
22
+ "@sqrzro/addon-auth": "^4.0.0-alpha.31",
23
+ "@sqrzro/addon-onboarding": "^4.0.0-alpha.27",
24
+ "@sqrzro/addons": "^4.0.0-alpha.17",
25
+ "@sqrzro/admin": "^4.0.0-alpha.36",
26
+ "@sqrzro/server": "^4.0.0-alpha.65",
27
+ "@sqrzro/ui": "^4.0.0-alpha.82",
28
28
  "@sqrzro/utility": "^4.0.0-alpha.23",
29
29
  "drizzle-orm": "^0.45.4",
30
30
  "zod": "^4.6.7"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^19.3.0",
34
- "szx": "^4.0.0-alpha.21",
34
+ "szx": "^4.0.0-alpha.22",
35
35
  "typescript": "^7.0.2"
36
36
  },
37
37
  "peerDependencies": {
@@ -1,10 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- import type { AdminsAddonConfigObject, BaseAdminsAddonConfigObject } from './interfaces';
4
- export declare function setConfig(
5
- db: NodePgDatabase,
6
- appConfig: AppConfig,
7
- cfg?: Partial<BaseAdminsAddonConfigObject>
8
- ): void;
9
- export declare function getConfig(): AdminsAddonConfigObject;
10
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/DEPRECATED_addon/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAIzF,wBAAgB,SAAS,CACrB,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,SAAS,EACpB,GAAG,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAC3C,IAAI,CAEN;AAED,wBAAgB,SAAS,IAAI,uBAAuB,CAKnD"}
@@ -1,11 +0,0 @@
1
- import applyDefaults from './defaults';
2
- let config = null;
3
- export function setConfig(db, appConfig, cfg) {
4
- config = { ...applyDefaults(cfg), db, app: appConfig };
5
- }
6
- export function getConfig() {
7
- // if (!config) {
8
- // throw new MissingConfigError('admins');
9
- // }
10
- return config;
11
- }
@@ -1,6 +0,0 @@
1
- import type { BaseAdminsAddonConfigObject } from './interfaces';
2
- declare function applyDefaults(
3
- config?: Partial<BaseAdminsAddonConfigObject>
4
- ): BaseAdminsAddonConfigObject;
5
- export default applyDefaults;
6
- //# sourceMappingURL=defaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/DEPRECATED_addon/defaults.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAIhE,iBAAS,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAEjG;AAED,eAAe,aAAa,CAAC"}
@@ -1,6 +0,0 @@
1
- import { deepMerge } from '@sqrzro/utility';
2
- const defaults = {};
3
- function applyDefaults(config) {
4
- return deepMerge(defaults, config || {});
5
- }
6
- export default applyDefaults;
@@ -1,6 +0,0 @@
1
- import type { AddonRegisterFunction } from '@sqrzro/addons';
2
- import { BaseAdminsAddonConfigObject } from './interfaces';
3
- export * from './interfaces';
4
- declare const withAdmin: AddonRegisterFunction<Partial<BaseAdminsAddonConfigObject>>;
5
- export default withAdmin;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DEPRECATED_addon/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,cAAc,cAAc,CAAC;AAE7B,QAAA,MAAM,SAAS,EAAE,qBAAqB,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAOzE,CAAC;AAEH,eAAe,SAAS,CAAC"}
@@ -1,9 +0,0 @@
1
- import { setConfig } from './config';
2
- export * from './interfaces';
3
- const withAdmin = (config) => ({
4
- register: (db, appConfig) => {
5
- setConfig(db, appConfig, config);
6
- },
7
- schema: '@sqrzro/addon-admins/schema',
8
- });
9
- export default withAdmin;
@@ -1,8 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- export interface BaseAdminsAddonConfigObject {}
4
- export interface AdminsAddonConfigObject extends BaseAdminsAddonConfigObject {
5
- app: AppConfig;
6
- db: NodePgDatabase;
7
- }
8
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/DEPRECATED_addon/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,WAAW,2BAA2B;CAAG;AAE/C,MAAM,WAAW,uBAAwB,SAAQ,2BAA2B;IACxE,GAAG,EAAE,SAAS,CAAC;IACf,EAAE,EAAE,cAAc,CAAC;CACtB"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- import type { AdminsAddonConfigObject, BaseAdminsAddonConfigObject } from './interfaces';
4
- export declare function setConfig(
5
- db: NodePgDatabase,
6
- appConfig: AppConfig,
7
- cfg?: Partial<BaseAdminsAddonConfigObject>
8
- ): void;
9
- export declare function getConfig(): AdminsAddonConfigObject;
10
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/addon/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAIzF,wBAAgB,SAAS,CACrB,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,SAAS,EACpB,GAAG,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAC3C,IAAI,CAEN;AAED,wBAAgB,SAAS,IAAI,uBAAuB,CAKnD"}
@@ -1,11 +0,0 @@
1
- import applyDefaults from './defaults';
2
- let config = null;
3
- export function setConfig(db, appConfig, cfg) {
4
- config = { ...applyDefaults(cfg), db, app: appConfig };
5
- }
6
- export function getConfig() {
7
- // if (!config) {
8
- // throw new MissingConfigError('admins');
9
- // }
10
- return config;
11
- }
@@ -1,6 +0,0 @@
1
- import type { BaseAdminsAddonConfigObject } from './interfaces';
2
- declare function applyDefaults(
3
- config?: Partial<BaseAdminsAddonConfigObject>
4
- ): BaseAdminsAddonConfigObject;
5
- export default applyDefaults;
6
- //# sourceMappingURL=defaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/addon/defaults.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAIhE,iBAAS,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAEjG;AAED,eAAe,aAAa,CAAC"}
@@ -1,6 +0,0 @@
1
- import { deepMerge } from '@sqrzro/utility';
2
- const defaults = {};
3
- function applyDefaults(config) {
4
- return deepMerge(defaults, config || {});
5
- }
6
- export default applyDefaults;
@@ -1,6 +0,0 @@
1
- import type { AddonRegisterFunction } from '@sqrzro/addons';
2
- import { BaseAdminsAddonConfigObject } from './interfaces';
3
- export * from './interfaces';
4
- declare const withAdmin: AddonRegisterFunction<Partial<BaseAdminsAddonConfigObject>>;
5
- export default withAdmin;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/addon/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,cAAc,cAAc,CAAC;AAE7B,QAAA,MAAM,SAAS,EAAE,qBAAqB,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAOzE,CAAC;AAEH,eAAe,SAAS,CAAC"}
@@ -1,9 +0,0 @@
1
- import { setConfig } from './config';
2
- export * from './interfaces';
3
- const withAdmin = (config) => ({
4
- register: (db, appConfig) => {
5
- setConfig(db, appConfig, config);
6
- },
7
- schema: '@sqrzro/addon-admins/schema',
8
- });
9
- export default withAdmin;
@@ -1,8 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- export interface BaseAdminsAddonConfigObject {}
4
- export interface AdminsAddonConfigObject extends BaseAdminsAddonConfigObject {
5
- app: AppConfig;
6
- db: NodePgDatabase;
7
- }
8
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/addon/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,WAAW,2BAA2B;CAAG;AAE/C,MAAM,WAAW,uBAAwB,SAAQ,2BAA2B;IACxE,GAAG,EAAE,SAAS,CAAC;IACf,EAAE,EAAE,cAAc,CAAC;CACtB"}
@@ -1 +0,0 @@
1
- export {};
package/dist/addon.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { AddonObject } from '@sqrzro/addons';
2
- declare const addon: AddonObject;
3
- export default addon;
4
- //# sourceMappingURL=addon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addon.d.ts","sourceRoot":"","sources":["../src/addon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,QAAA,MAAM,KAAK,EAAE,WAEZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
package/dist/addon.js DELETED
@@ -1,4 +0,0 @@
1
- const addon = {
2
- schema: '@sqrzro/addon-admins/schema',
3
- };
4
- export default addon;
@@ -1,3 +0,0 @@
1
- interface AdminPageProps {}
2
- declare function AdminPage({}: AdminPageProps): React.ReactElement;
3
- export default AdminPage;
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx } from 'react/jsx-runtime';
2
- function AdminPage({}) {
3
- return _jsx('div', { children: 'AdminPage' });
4
- }
5
- export default AdminPage;
@@ -1,7 +0,0 @@
1
- import createAdminRepository from '../repository';
2
- export interface AdminsConfig {
3
- repository: ReturnType<typeof createAdminRepository>;
4
- }
5
- export declare function setConfig(cfg: AdminsConfig): void;
6
- export declare function getConfig(): AdminsConfig;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,eAAe,CAAC;AAElD,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CACxD;AAID,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,QAE1C;AAED,wBAAgB,SAAS,IAAI,YAAY,CAKxC"}
@@ -1,10 +0,0 @@
1
- let config = null;
2
- export function setConfig(cfg) {
3
- config = cfg;
4
- }
5
- export function getConfig() {
6
- if (!config) {
7
- throw new Error('Admin config has not been set');
8
- }
9
- return config;
10
- }
package/dist/config.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { AddonRegistrationConfig } from '@sqrzro/addons';
2
- export declare function setConfig(newConfig: AddonRegistrationConfig): void;
3
- export declare function getConfig(): AddonRegistrationConfig;
4
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAI9D,wBAAgB,SAAS,CAAC,SAAS,EAAE,uBAAuB,GAAG,IAAI,CAElE;AAED,wBAAgB,SAAS,IAAI,uBAAuB,CAKnD"}
package/dist/config.js DELETED
@@ -1,10 +0,0 @@
1
- let config = null;
2
- export function setConfig(newConfig) {
3
- config = newConfig;
4
- }
5
- export function getConfig() {
6
- if (!config) {
7
- throw new Error('Config has not been set yet');
8
- }
9
- return config;
10
- }
@@ -1,2 +0,0 @@
1
- export interface AdminsConfigObject {}
2
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;CAAG"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- interface AdminInviteMailProps {
2
- readonly token: string;
3
- }
4
- declare const _default: import('@sqrzro/server/mail').MailObject<AdminInviteMailProps>;
5
- export default _default;
6
- //# sourceMappingURL=AdminInviteMail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdminInviteMail.d.ts","sourceRoot":"","sources":["../../src/mail/AdminInviteMail.tsx"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;;AAWD,wBAA2D"}
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime';
2
- import { createMail } from '@sqrzro/server/mail';
3
- function AdminInviteMail({ token }) {
4
- return _jsxs('div', {
5
- children: [
6
- 'AdminInviteMail',
7
- _jsx('a', {
8
- href: `http://localhost:8001/onboarding/start?token=${token}`,
9
- children: 'Accept Invite',
10
- }),
11
- ],
12
- });
13
- }
14
- export default createMail('ADMIN INVITE', AdminInviteMail);
@@ -1,4 +0,0 @@
1
- import type { AddonRegistrationConfig } from '@sqrzro/addons';
2
- declare function registerAdminsAddon(config: AddonRegistrationConfig): void;
3
- export default registerAdminsAddon;
4
- //# sourceMappingURL=register-admins-addon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-admins-addon.d.ts","sourceRoot":"","sources":["../src/register-admins-addon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAI9D,iBAAS,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAElE;AAED,eAAe,mBAAmB,CAAC"}
@@ -1,5 +0,0 @@
1
- import { setConfig } from './config';
2
- function registerAdminsAddon(config) {
3
- setConfig(config);
4
- }
5
- export default registerAdminsAddon;
@@ -1,147 +0,0 @@
1
- import { AdminID } from '../utility/ids';
2
- import type { AdminData } from '../utility/interfaces';
3
- export declare const ADMIN_ROLE = 100;
4
- declare const _default: {
5
- getByEmail: (email: string) => Promise<{
6
- email: string;
7
- id: `adm_${string}`;
8
- name: string;
9
- createdAt: Date;
10
- deletedAt: Date | null;
11
- } | null>;
12
- create: ((data: AdminData) => Promise<{
13
- email: string;
14
- id: `adm_${string}`;
15
- name: string;
16
- createdAt: Date;
17
- deletedAt: Date | null;
18
- }>) &
19
- ((data: AdminData) => Promise<
20
- Promise<{
21
- email: string;
22
- id: `adm_${string}`;
23
- name: string;
24
- createdAt: Date;
25
- deletedAt: Date | null;
26
- }>
27
- >);
28
- delete: ((id: `adm_${string}`) => Promise<void>) & ((id: string) => Promise<void>);
29
- ensureByID: (id: `adm_${string}`) => Promise<{
30
- email: string;
31
- id: `adm_${string}`;
32
- name: string;
33
- createdAt: Date;
34
- deletedAt: Date | null;
35
- }>;
36
- ensureByIndex: <K extends string>(
37
- key: K,
38
- value: any,
39
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
40
- ) => Promise<{
41
- email: string;
42
- id: `adm_${string}`;
43
- name: string;
44
- createdAt: Date;
45
- deletedAt: Date | null;
46
- }>;
47
- ensureFromParams: (
48
- params?: Promise<Record<string, string>> | Record<string, string> | null
49
- ) => Promise<{
50
- email: string;
51
- id: `adm_${string}`;
52
- name: string;
53
- createdAt: Date;
54
- deletedAt: Date | null;
55
- }>;
56
- ensureID: (id: string | null | undefined) => `adm_${string}`;
57
- ensureIDFromParams: (
58
- params?: Promise<Record<string, string>> | Record<string, string> | null
59
- ) => Promise<`adm_${string}`>;
60
- getAll: (
61
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
62
- ) => Promise<
63
- {
64
- email: string;
65
- id: `adm_${string}`;
66
- name: string;
67
- createdAt: Date;
68
- deletedAt: Date | null;
69
- }[]
70
- >;
71
- getByID: (id: `adm_${string}`) => Promise<{
72
- email: string;
73
- id: `adm_${string}`;
74
- name: string;
75
- createdAt: Date;
76
- deletedAt: Date | null;
77
- } | null>;
78
- getByIndex: <K extends string>(
79
- key: K,
80
- value: any,
81
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
82
- ) => Promise<{
83
- email: string;
84
- id: `adm_${string}`;
85
- name: string;
86
- createdAt: Date;
87
- deletedAt: Date | null;
88
- } | null>;
89
- getFromParams: (
90
- params?: Promise<Record<string, string>> | Record<string, string> | null
91
- ) => Promise<{
92
- email: string;
93
- id: `adm_${string}`;
94
- name: string;
95
- createdAt: Date;
96
- deletedAt: Date | null;
97
- } | null>;
98
- getIDFromParams: (
99
- params?: Promise<Record<string, string>> | Record<string, string> | null
100
- ) => Promise<`adm_${string}` | null>;
101
- getPaginated: (
102
- fnConfig?:
103
- | import('@sqrzro/server/database').PaginatedFunctionConfig<never, never>
104
- | undefined
105
- ) => Promise<
106
- import('@sqrzro/server/utility').Paginated<{
107
- email: string;
108
- id: `adm_${string}`;
109
- name: string;
110
- createdAt: Date;
111
- deletedAt: Date | null;
112
- }>
113
- >;
114
- guardID: {
115
- (id: (string | null | undefined)[]): `adm_${string}`[];
116
- (id: string | null | undefined): `adm_${string}` | null;
117
- };
118
- undelete: ((id: `adm_${string}`) => Promise<void>) & ((id: string) => Promise<void>);
119
- update: ((
120
- data: Partial<AdminData> & {
121
- id: AdminID;
122
- }
123
- ) => Promise<{
124
- email: string;
125
- id: `adm_${string}`;
126
- name: string;
127
- createdAt: Date;
128
- deletedAt: Date | null;
129
- }>) &
130
- ((
131
- data: Partial<AdminData> & {
132
- id: AdminID;
133
- }
134
- ) => Promise<
135
- Promise<{
136
- email: string;
137
- id: `adm_${string}`;
138
- name: string;
139
- createdAt: Date;
140
- deletedAt: Date | null;
141
- }>
142
- >);
143
- ensureFromSession: () => Promise<any>;
144
- sendInvite: (user: { id: string; email: string }) => Promise<void>;
145
- };
146
- export default _default;
147
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAgB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI9D,eAAO,MAAM,UAAU,MAAM,CAAC;;wBAqEA,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA1B0B,OAAO;;;;;;;;YAAP,OAAO;;;;;;;;;;;;;;AAwBrE,wBAGE"}
@@ -1,67 +0,0 @@
1
- import { extendRepository } from '@sqrzro/addons';
2
- import withAuth from '@sqrzro/addon-auth/repository';
3
- import withOnboarding from '@sqrzro/addon-onboarding/repository';
4
- import { db } from '@sqrzro/server/database';
5
- import { createRepository } from '@sqrzro/server/database';
6
- import { generateID } from '@sqrzro/server/utility';
7
- import { pick } from '@sqrzro/utility';
8
- import { and, count, eq } from 'drizzle-orm';
9
- import { ADMIN_PREFIX } from '../utility/ids';
10
- import { adminTable } from '../schema';
11
- export const ADMIN_ROLE = 100;
12
- const fillable = ['email', 'name'];
13
- const BaseAdminRepository = createRepository({
14
- indexes: { email: adminTable.email, id: adminTable.id },
15
- async makeCountQuery(conditions) {
16
- const [meta] = await db
17
- .select({ count: count() })
18
- .from(adminTable)
19
- .where(and(...conditions));
20
- return meta.count;
21
- },
22
- async makeQuery(conditions, config) {
23
- return db
24
- .select()
25
- .from(adminTable)
26
- .where(and(...conditions))
27
- .limit(config.limit)
28
- .offset(config.offset);
29
- },
30
- async makeDeleteMutation(id) {
31
- await db.update(adminTable).set({ deletedAt: new Date() }).where(eq(adminTable.id, id));
32
- },
33
- async makeUndeleteMutation(id) {
34
- await db.update(adminTable).set({ deletedAt: null }).where(eq(adminTable.id, id));
35
- },
36
- async makeInsertMutation(data) {
37
- const values = {
38
- id: generateID(ADMIN_PREFIX),
39
- ...pick(data, fillable),
40
- };
41
- const [result] = await db.insert(adminTable).values(values).returning();
42
- return result;
43
- },
44
- async makeUpdateMutation(data) {
45
- const [result] = await db
46
- .update(adminTable)
47
- .set(data)
48
- .where(eq(adminTable.id, data.id))
49
- .returning();
50
- return result;
51
- },
52
- paramKey: 'admins[0]',
53
- prefix: ADMIN_PREFIX,
54
- });
55
- const AdminRepository = extendRepository(
56
- BaseAdminRepository,
57
- withAuth({ role: ADMIN_ROLE }),
58
- withOnboarding({
59
- baseURL: process.env.APP_URL,
60
- role: ADMIN_ROLE,
61
- siteName: process.env.APP_NAME,
62
- })
63
- );
64
- export default {
65
- ...AdminRepository,
66
- getByEmail: async (email) => AdminRepository.getByIndex('email', email),
67
- };
@@ -1,149 +0,0 @@
1
- import { AdminID } from '../utility/ids';
2
- import type { AdminData } from '../utility/interfaces';
3
- export declare const ADMIN_ROLE = 100;
4
- declare function createAdminRepository(site: { name: string; url: string }): {
5
- getByEmail: (email: string) => Promise<{
6
- email: string;
7
- id: `adm_${string}`;
8
- name: string;
9
- createdAt: Date;
10
- deletedAt: Date | null;
11
- } | null>;
12
- create: ((data: AdminData) => Promise<{
13
- email: string;
14
- id: `adm_${string}`;
15
- name: string;
16
- createdAt: Date;
17
- deletedAt: Date | null;
18
- }>) &
19
- ((data: AdminData) => Promise<
20
- Promise<{
21
- email: string;
22
- id: `adm_${string}`;
23
- name: string;
24
- createdAt: Date;
25
- deletedAt: Date | null;
26
- }>
27
- >);
28
- delete: ((id: `adm_${string}`) => Promise<void>) & ((id: string) => Promise<void>);
29
- ensureByID: (id: `adm_${string}`) => Promise<{
30
- email: string;
31
- id: `adm_${string}`;
32
- name: string;
33
- createdAt: Date;
34
- deletedAt: Date | null;
35
- }>;
36
- ensureByIndex: <K extends string>(
37
- key: K,
38
- value: any,
39
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
40
- ) => Promise<{
41
- email: string;
42
- id: `adm_${string}`;
43
- name: string;
44
- createdAt: Date;
45
- deletedAt: Date | null;
46
- }>;
47
- ensureFromParams: (
48
- params?: Promise<Record<string, string>> | Record<string, string> | null
49
- ) => Promise<{
50
- email: string;
51
- id: `adm_${string}`;
52
- name: string;
53
- createdAt: Date;
54
- deletedAt: Date | null;
55
- }>;
56
- ensureID: (id: string | null | undefined) => `adm_${string}`;
57
- ensureIDFromParams: (
58
- params?: Promise<Record<string, string>> | Record<string, string> | null
59
- ) => Promise<`adm_${string}`>;
60
- getAll: (
61
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
62
- ) => Promise<
63
- {
64
- email: string;
65
- id: `adm_${string}`;
66
- name: string;
67
- createdAt: Date;
68
- deletedAt: Date | null;
69
- }[]
70
- >;
71
- getByID: (id: `adm_${string}`) => Promise<{
72
- email: string;
73
- id: `adm_${string}`;
74
- name: string;
75
- createdAt: Date;
76
- deletedAt: Date | null;
77
- } | null>;
78
- getByIndex: <K extends string>(
79
- key: K,
80
- value: any,
81
- fnConfig?: import('@sqrzro/server/database').SelectFunctionConfig<never, never> | undefined
82
- ) => Promise<{
83
- email: string;
84
- id: `adm_${string}`;
85
- name: string;
86
- createdAt: Date;
87
- deletedAt: Date | null;
88
- } | null>;
89
- getFromParams: (
90
- params?: Promise<Record<string, string>> | Record<string, string> | null
91
- ) => Promise<{
92
- email: string;
93
- id: `adm_${string}`;
94
- name: string;
95
- createdAt: Date;
96
- deletedAt: Date | null;
97
- } | null>;
98
- getIDFromParams: (
99
- params?: Promise<Record<string, string>> | Record<string, string> | null
100
- ) => Promise<`adm_${string}` | null>;
101
- getPaginated: (
102
- fnConfig?:
103
- | import('@sqrzro/server/database').PaginatedFunctionConfig<never, never>
104
- | undefined
105
- ) => Promise<
106
- import('@sqrzro/server/utility').Paginated<{
107
- email: string;
108
- id: `adm_${string}`;
109
- name: string;
110
- createdAt: Date;
111
- deletedAt: Date | null;
112
- }>
113
- >;
114
- guardID: {
115
- (id: (string | null | undefined)[]): `adm_${string}`[];
116
- (id: string | null | undefined): `adm_${string}` | null;
117
- };
118
- undelete: ((id: `adm_${string}`) => Promise<void>) & ((id: string) => Promise<void>);
119
- update: ((
120
- data: Partial<AdminData> & {
121
- id: AdminID;
122
- }
123
- ) => Promise<{
124
- email: string;
125
- id: `adm_${string}`;
126
- name: string;
127
- createdAt: Date;
128
- deletedAt: Date | null;
129
- }>) &
130
- ((
131
- data: Partial<AdminData> & {
132
- id: AdminID;
133
- }
134
- ) => Promise<
135
- Promise<{
136
- email: string;
137
- id: `adm_${string}`;
138
- name: string;
139
- createdAt: Date;
140
- deletedAt: Date | null;
141
- }>
142
- >);
143
- ensureFromSession: () => Promise<any>;
144
- sendInvite: (user: { id: string; email: string }) => Promise<void>;
145
- };
146
- export declare function setRepository(repo: ReturnType<typeof createAdminRepository>): void;
147
- export declare function getRepository(): ReturnType<typeof createAdminRepository>;
148
- export default createAdminRepository;
149
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAgB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI9D,eAAO,MAAM,UAAU,MAAM,CAAC;AAI9B,iBAAS,qBAAqB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE;wBAkEhC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA1B0B,OAAO;;;;;;;;YAAP,OAAO;;;;;;;;;;;;;EA4BxE;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,GAAG,IAAI,CAElF;AAED,wBAAgB,aAAa,IAAI,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAKxE;AAED,eAAe,qBAAqB,CAAC"}
@@ -1,80 +0,0 @@
1
- import { extendRepository } from '@sqrzro/addons';
2
- import withAuth from '@sqrzro/addon-auth/repository';
3
- import withOnboarding from '@sqrzro/addon-onboarding/repository';
4
- import { db } from '@sqrzro/server/database';
5
- import { createRepository } from '@sqrzro/server/database';
6
- import { generateID } from '@sqrzro/server/utility';
7
- import { pick } from '@sqrzro/utility';
8
- import { and, count, eq } from 'drizzle-orm';
9
- import { ADMIN_PREFIX } from '../utility/ids';
10
- import { adminTable } from '../schema';
11
- export const ADMIN_ROLE = 100;
12
- const fillable = ['email', 'name'];
13
- function createAdminRepository(site) {
14
- const BaseAdminRepository = createRepository({
15
- indexes: { email: adminTable.email, id: adminTable.id },
16
- async makeCountQuery(conditions) {
17
- const [meta] = await db
18
- .select({ count: count() })
19
- .from(adminTable)
20
- .where(and(...conditions));
21
- return meta.count;
22
- },
23
- async makeQuery(conditions, config) {
24
- return db
25
- .select()
26
- .from(adminTable)
27
- .where(and(...conditions))
28
- .limit(config.limit)
29
- .offset(config.offset);
30
- },
31
- async makeDeleteMutation(id) {
32
- await db.update(adminTable).set({ deletedAt: new Date() }).where(eq(adminTable.id, id));
33
- },
34
- async makeUndeleteMutation(id) {
35
- await db.update(adminTable).set({ deletedAt: null }).where(eq(adminTable.id, id));
36
- },
37
- async makeInsertMutation(data) {
38
- const values = {
39
- id: generateID(ADMIN_PREFIX),
40
- ...pick(data, fillable),
41
- };
42
- const [result] = await db.insert(adminTable).values(values).returning();
43
- return result;
44
- },
45
- async makeUpdateMutation(data) {
46
- const [result] = await db
47
- .update(adminTable)
48
- .set(data)
49
- .where(eq(adminTable.id, data.id))
50
- .returning();
51
- return result;
52
- },
53
- paramKey: 'admins[0]',
54
- prefix: ADMIN_PREFIX,
55
- });
56
- const AdminRepository = extendRepository(
57
- BaseAdminRepository,
58
- withAuth({ role: ADMIN_ROLE }),
59
- withOnboarding({
60
- baseURL: site.url,
61
- role: ADMIN_ROLE,
62
- siteName: site.name,
63
- })
64
- );
65
- return {
66
- ...AdminRepository,
67
- getByEmail: async (email) => AdminRepository.getByIndex('email', email),
68
- };
69
- }
70
- let repository = null;
71
- export function setRepository(repo) {
72
- repository = repo;
73
- }
74
- export function getRepository() {
75
- if (!repository) {
76
- throw new Error('Admin repository has not been set');
77
- }
78
- return repository;
79
- }
80
- export default createAdminRepository;