monorise 1.3.0 → 1.5.0

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 (31) hide show
  1. package/dist/base/index.d.ts +95 -1
  2. package/dist/base/index.js.map +1 -1
  3. package/dist/cli/cli.js +295 -102
  4. package/dist/cli/cli.js.map +1 -1
  5. package/dist/cli/templates/files/core-routes.ts +22 -0
  6. package/dist/cli/templates/files/example-page.tsx +103 -0
  7. package/dist/cli/templates/files/global-initializer.tsx +16 -0
  8. package/dist/cli/templates/files/global-loader.tsx +45 -0
  9. package/dist/cli/templates/files/globals.css +72 -0
  10. package/dist/cli/templates/files/lib-utils.ts +6 -0
  11. package/dist/cli/templates/files/monorise.config.ts +7 -0
  12. package/dist/cli/templates/files/proxy-request.ts +49 -0
  13. package/dist/cli/templates/files/proxy-route.ts +22 -0
  14. package/dist/cli/templates/files/sst.config.ts +30 -0
  15. package/dist/cli/templates/files/team-entity.ts +37 -0
  16. package/dist/cli/templates/files/team-membership.mutual.ts +16 -0
  17. package/dist/cli/templates/files/ui-button.tsx +65 -0
  18. package/dist/cli/templates/files/ui-card.tsx +103 -0
  19. package/dist/cli/templates/files/ui-input.tsx +19 -0
  20. package/dist/cli/templates/files/ui-label.tsx +24 -0
  21. package/dist/cli/templates/files/user-entity.ts +43 -0
  22. package/dist/core/index.d.ts +13 -28
  23. package/dist/core/index.js +205 -26
  24. package/dist/core/index.js.map +1 -1
  25. package/dist/react/index.d.ts +6 -2
  26. package/dist/react/index.d.ts.map +1 -1
  27. package/dist/react/index.js +2 -1
  28. package/dist/react/index.js.map +1 -1
  29. package/dist/react/services/core.service.d.ts +3 -1
  30. package/dist/react/services/core.service.d.ts.map +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import { Slot } from 'radix-ui';
4
+
5
+ import { cn } from '#/lib/utils';
6
+
7
+ const buttonVariants = cva(
8
+ "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-none border border-transparent bg-clip-padding text-xs font-medium focus-visible:ring-1 aria-invalid:ring-1 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
13
+ outline:
14
+ 'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
15
+ secondary:
16
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
17
+ ghost:
18
+ 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
19
+ destructive:
20
+ 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
21
+ link: 'text-primary underline-offset-4 hover:underline',
22
+ },
23
+ size: {
24
+ default:
25
+ 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
26
+ xs: "h-6 gap-1 rounded-none px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
27
+ sm: "h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
28
+ lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
29
+ icon: 'size-8',
30
+ 'icon-xs': "size-6 rounded-none [&_svg:not([class*='size-'])]:size-3",
31
+ 'icon-sm': 'size-7 rounded-none',
32
+ 'icon-lg': 'size-9',
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: 'default',
37
+ size: 'default',
38
+ },
39
+ },
40
+ );
41
+
42
+ function Button({
43
+ className,
44
+ variant = 'default',
45
+ size = 'default',
46
+ asChild = false,
47
+ ...props
48
+ }: React.ComponentProps<'button'> &
49
+ VariantProps<typeof buttonVariants> & {
50
+ asChild?: boolean;
51
+ }) {
52
+ const Comp = asChild ? Slot.Root : 'button';
53
+
54
+ return (
55
+ <Comp
56
+ data-slot='button'
57
+ data-variant={variant}
58
+ data-size={size}
59
+ className={cn(buttonVariants({ variant, size, className }))}
60
+ {...props}
61
+ />
62
+ );
63
+ }
64
+
65
+ export { Button, buttonVariants };
@@ -0,0 +1,103 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '#/lib/utils';
4
+
5
+ function Card({
6
+ className,
7
+ size = 'default',
8
+ ...props
9
+ }: React.ComponentProps<'div'> & { size?: 'default' | 'sm' }) {
10
+ return (
11
+ <div
12
+ data-slot='card'
13
+ data-size={size}
14
+ className={cn(
15
+ 'ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-none py-4 text-xs/relaxed ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none group/card flex flex-col',
16
+ className,
17
+ )}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
24
+ return (
25
+ <div
26
+ data-slot='card-header'
27
+ className={cn(
28
+ 'gap-1 rounded-none px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]',
29
+ className,
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
37
+ return (
38
+ <div
39
+ data-slot='card-title'
40
+ className={cn(
41
+ 'text-sm font-medium group-data-[size=sm]/card:text-sm',
42
+ className,
43
+ )}
44
+ {...props}
45
+ />
46
+ );
47
+ }
48
+
49
+ function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
50
+ return (
51
+ <div
52
+ data-slot='card-description'
53
+ className={cn('text-muted-foreground text-xs/relaxed', className)}
54
+ {...props}
55
+ />
56
+ );
57
+ }
58
+
59
+ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
60
+ return (
61
+ <div
62
+ data-slot='card-action'
63
+ className={cn(
64
+ 'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
65
+ className,
66
+ )}
67
+ {...props}
68
+ />
69
+ );
70
+ }
71
+
72
+ function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
73
+ return (
74
+ <div
75
+ data-slot='card-content'
76
+ className={cn('px-4 group-data-[size=sm]/card:px-3', className)}
77
+ {...props}
78
+ />
79
+ );
80
+ }
81
+
82
+ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
83
+ return (
84
+ <div
85
+ data-slot='card-footer'
86
+ className={cn(
87
+ 'rounded-none border-t p-4 group-data-[size=sm]/card:p-3 flex items-center',
88
+ className,
89
+ )}
90
+ {...props}
91
+ />
92
+ );
93
+ }
94
+
95
+ export {
96
+ Card,
97
+ CardHeader,
98
+ CardFooter,
99
+ CardTitle,
100
+ CardAction,
101
+ CardDescription,
102
+ CardContent,
103
+ };
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '#/lib/utils';
4
+
5
+ function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
6
+ return (
7
+ <input
8
+ type={type}
9
+ data-slot='input'
10
+ className={cn(
11
+ 'dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-none border bg-transparent px-2.5 py-1 text-xs transition-colors file:h-6 file:text-xs file:font-medium focus-visible:ring-1 aria-invalid:ring-1 md:text-xs file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
12
+ className,
13
+ )}
14
+ {...props}
15
+ />
16
+ );
17
+ }
18
+
19
+ export { Input };
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Label as LabelPrimitive } from 'radix-ui';
5
+
6
+ import { cn } from '#/lib/utils';
7
+
8
+ function Label({
9
+ className,
10
+ ...props
11
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) {
12
+ return (
13
+ <LabelPrimitive.Root
14
+ data-slot='label'
15
+ className={cn(
16
+ 'gap-2 text-xs leading-none group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed',
17
+ className,
18
+ )}
19
+ {...props}
20
+ />
21
+ );
22
+ }
23
+
24
+ export { Label };
@@ -0,0 +1,43 @@
1
+ import { createEntityConfig } from 'monorise/base';
2
+ import type { Entity } from 'monorise/base';
3
+ import { z } from 'zod';
4
+ import teamMembership from '../mutuals/team-membership';
5
+
6
+ const baseSchema = z
7
+ .object({
8
+ displayName: z.string().min(1, 'Display name is required'),
9
+ email: z.string().email('Valid email is required'),
10
+ firstName: z.string().optional(),
11
+ lastName: z.string().optional(),
12
+ })
13
+ .partial();
14
+
15
+ const createSchema = z.object({
16
+ displayName: z.string().min(1, 'Display name is required'),
17
+ email: z.string().email('Valid email is required'),
18
+ });
19
+
20
+ const config = createEntityConfig({
21
+ name: 'user',
22
+ displayName: 'User',
23
+ baseSchema,
24
+ createSchema,
25
+ searchableFields: ['displayName', 'email'],
26
+ uniqueFields: ['email'],
27
+ // Example mutual relationship — see monorise/mutuals/team-membership.ts
28
+ mutual: {
29
+ mutualSchema: z
30
+ .object({
31
+ teamIds: z.string().array(),
32
+ })
33
+ .partial(),
34
+ mutualFields: {
35
+ teamIds: {
36
+ entityType: 'team' as unknown as Entity,
37
+ mutual: teamMembership,
38
+ },
39
+ },
40
+ },
41
+ });
42
+
43
+ export default config;
@@ -1,4 +1,4 @@
1
- import { Entity as Entity$2, EntitySchemaMap, createEntityConfig } from '../base/index';
1
+ import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions } from '../base/index';
2
2
  import * as hono from 'hono';
3
3
  import { Hono } from 'hono';
4
4
  import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput } from '@aws-sdk/client-dynamodb';
@@ -141,11 +141,10 @@ declare class EntityRepository extends Repository {
141
141
  ExpressionAttributeNames?: Record<string, string>;
142
142
  ExpressionAttributeValues?: Record<string, AttributeValue>;
143
143
  }): Promise<Entity$1<T>>;
144
- adjustEntity<T extends Entity$2>(entityType: T, entityId: string, adjustments: Record<string, number>, constraints?: {
145
- [field: string]: {
146
- min?: number;
147
- max?: number;
148
- };
144
+ adjustEntity<T extends Entity$2>(entityType: T, entityId: string, adjustments: Record<string, number>, opts?: {
145
+ ConditionExpression?: string;
146
+ ExpressionAttributeNames?: Record<string, string>;
147
+ ExpressionAttributeValues?: Record<string, AttributeValue>;
149
148
  }): Promise<Entity$1<T>>;
150
149
  deleteEntity<T extends Entity$2>(entityType: T, entityId: string): Promise<void>;
151
150
  queryEntities<T extends Entity$2>(entityType: T, query: string): Promise<{
@@ -4462,26 +4461,6 @@ external_exports.object({
4462
4461
  lastKey: external_exports.string().optional()
4463
4462
  });
4464
4463
 
4465
- type WhereOperator = {
4466
- $eq: string | number | boolean;
4467
- } | {
4468
- $ne: string | number | boolean;
4469
- } | {
4470
- $gt: number;
4471
- } | {
4472
- $lt: number;
4473
- } | {
4474
- $gte: number;
4475
- } | {
4476
- $lte: number;
4477
- } | {
4478
- $exists: boolean;
4479
- } | {
4480
- $beginsWith: string;
4481
- };
4482
- type WhereClause = WhereOperator | string | number | boolean;
4483
- type WhereConditions = Record<string, WhereClause>;
4484
-
4485
4464
  declare class EntityServiceLifeCycle {
4486
4465
  private EntityConfig;
4487
4466
  private publishEvent;
@@ -4507,19 +4486,24 @@ declare class EntityService {
4507
4486
  mutualId?: string;
4508
4487
  };
4509
4488
  }) => Promise<Entity<T>>;
4510
- adjustEntity: <T extends Entity$2>({ entityType, entityId, adjustments, accountId, }: {
4489
+ adjustEntity: <T extends Entity$2>({ entityType, entityId, adjustments, accountId, condition, }: {
4511
4490
  entityType: T;
4512
4491
  entityId: string;
4513
4492
  adjustments: Record<string, number>;
4514
4493
  accountId?: string;
4494
+ condition?: string;
4515
4495
  }) => Promise<Entity<T>>;
4516
- updateEntity: <T extends Entity$2>({ entityType, entityId, entityPayload, accountId, where, }: {
4496
+ updateEntity: <T extends Entity$2>({ entityType, entityId, entityPayload, accountId, condition, where, }: {
4517
4497
  entityType: T;
4518
4498
  entityId: string;
4519
4499
  entityPayload: Partial<EntitySchemaMap[T]>;
4520
4500
  accountId?: string | string[];
4501
+ condition?: string;
4502
+ /** @deprecated Use `condition` (named condition) instead of raw `where`. */
4521
4503
  where?: WhereConditions;
4522
4504
  }) => Promise<Entity<T>>;
4505
+ /** @deprecated Converts legacy adjustmentConstraints to condition expression opts. */
4506
+ private buildLegacyAdjustCondition;
4523
4507
  deleteEntity: <T extends Entity$2>({ entityType, entityId, accountId, }: {
4524
4508
  entityType: T;
4525
4509
  entityId: string;
@@ -4777,6 +4761,7 @@ declare const StandardErrorCode: {
4777
4761
  readonly ENTITY_ID_IS_UNDEFINED: "ENTITY_ID_IS_UNDEFINED";
4778
4762
  readonly ENTITY_IS_UNDEFINED: "ENTITY_IS_UNDEFINED";
4779
4763
  readonly ENTITY_NOT_FOUND: "ENTITY_NOT_FOUND";
4764
+ readonly INVALID_CONDITION: "INVALID_CONDITION";
4780
4765
  readonly INVALID_ENTITY_TYPE: "INVALID_ENTITY_TYPE";
4781
4766
  readonly INVALID_MUTUAL: "INVALID_MUTUAL";
4782
4767
  readonly INVALID_QUERY: "INVALID_QUERY";