@crispy-streaming/supabase-contract 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Aayush Rautela
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @crispy/supabase-contract
2
+
3
+ Shared Supabase database contract types and Zod validators for Crispy clients.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @crispy-streaming/supabase-contract zod
9
+ ```
10
+
11
+ `zod` is a peer dependency, so install it in the consuming app.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import {
17
+ parseMembershipPayload,
18
+ profileNameSchema,
19
+ type Database,
20
+ type TableRow,
21
+ } from '@crispy/supabase-contract';
22
+ } from '@crispy-streaming/supabase-contract';
23
+
24
+ const name = profileNameSchema.parse(' Ada ');
25
+
26
+ const membership = parseMembershipPayload({
27
+ household_id: '7b32659c-04e4-4694-b03f-90a55338183d',
28
+ role: 'owner',
29
+ });
30
+
31
+ type Profile = TableRow<'profiles'>;
32
+ type Db = Database;
33
+ ```
34
+
35
+ ## Exports
36
+
37
+ - Database helper types from `database.types.ts`
38
+ - Zod schemas and parser helpers from `validators.ts`
39
+
40
+ ## Development
41
+
42
+ ```bash
43
+ npm install
44
+ npm run build
45
+ npm pack --dry-run
46
+ ```
@@ -0,0 +1,214 @@
1
+ export type Json = string | number | boolean | null | {
2
+ [key: string]: Json | undefined;
3
+ } | Json[];
4
+ export type HouseholdRole = 'owner' | 'member';
5
+ export interface Database {
6
+ public: {
7
+ Tables: {
8
+ households: {
9
+ Row: {
10
+ id: string;
11
+ owner_user_id: string | null;
12
+ created_at: string;
13
+ updated_at: string;
14
+ };
15
+ Insert: {
16
+ id?: string;
17
+ owner_user_id?: string | null;
18
+ created_at?: string;
19
+ updated_at?: string;
20
+ };
21
+ Update: {
22
+ id?: string;
23
+ owner_user_id?: string | null;
24
+ created_at?: string;
25
+ updated_at?: string;
26
+ };
27
+ Relationships: [];
28
+ };
29
+ household_members: {
30
+ Row: {
31
+ household_id: string;
32
+ user_id: string;
33
+ role: HouseholdRole;
34
+ last_active_at: string | null;
35
+ created_at: string;
36
+ updated_at: string;
37
+ };
38
+ Insert: {
39
+ household_id: string;
40
+ user_id: string;
41
+ role: HouseholdRole;
42
+ last_active_at?: string | null;
43
+ created_at?: string;
44
+ updated_at?: string;
45
+ };
46
+ Update: {
47
+ household_id?: string;
48
+ user_id?: string;
49
+ role?: HouseholdRole;
50
+ last_active_at?: string | null;
51
+ created_at?: string;
52
+ updated_at?: string;
53
+ };
54
+ Relationships: [];
55
+ };
56
+ profiles: {
57
+ Row: {
58
+ id: string;
59
+ household_id: string;
60
+ name: string;
61
+ avatar: string | null;
62
+ order_index: number;
63
+ last_active_at: string | null;
64
+ created_by: string | null;
65
+ created_at: string;
66
+ updated_at: string;
67
+ };
68
+ Insert: {
69
+ id?: string;
70
+ household_id: string;
71
+ name: string;
72
+ avatar?: string | null;
73
+ order_index?: number;
74
+ last_active_at?: string | null;
75
+ created_by?: string | null;
76
+ created_at?: string;
77
+ updated_at?: string;
78
+ };
79
+ Update: {
80
+ id?: string;
81
+ household_id?: string;
82
+ name?: string;
83
+ avatar?: string | null;
84
+ order_index?: number;
85
+ last_active_at?: string | null;
86
+ created_by?: string | null;
87
+ created_at?: string;
88
+ updated_at?: string;
89
+ };
90
+ Relationships: [];
91
+ };
92
+ profile_data: {
93
+ Row: {
94
+ profile_id: string;
95
+ settings: Json;
96
+ catalog_prefs: Json;
97
+ trakt_auth: Json;
98
+ version: number;
99
+ created_at: string;
100
+ updated_at: string;
101
+ };
102
+ Insert: {
103
+ profile_id: string;
104
+ settings?: Json;
105
+ catalog_prefs?: Json;
106
+ trakt_auth?: Json;
107
+ version?: number;
108
+ created_at?: string;
109
+ updated_at?: string;
110
+ };
111
+ Update: {
112
+ profile_id?: string;
113
+ settings?: Json;
114
+ catalog_prefs?: Json;
115
+ trakt_auth?: Json;
116
+ version?: number;
117
+ created_at?: string;
118
+ updated_at?: string;
119
+ };
120
+ Relationships: [];
121
+ };
122
+ addons: {
123
+ Row: {
124
+ household_id: string;
125
+ url: string;
126
+ enabled: boolean;
127
+ name: string | null;
128
+ created_by: string | null;
129
+ updated_by: string | null;
130
+ created_at: string;
131
+ updated_at: string;
132
+ };
133
+ Insert: {
134
+ household_id: string;
135
+ url: string;
136
+ enabled?: boolean;
137
+ name?: string | null;
138
+ created_by?: string | null;
139
+ updated_by?: string | null;
140
+ created_at?: string;
141
+ updated_at?: string;
142
+ };
143
+ Update: {
144
+ household_id?: string;
145
+ url?: string;
146
+ enabled?: boolean;
147
+ name?: string | null;
148
+ created_by?: string | null;
149
+ updated_by?: string | null;
150
+ created_at?: string;
151
+ updated_at?: string;
152
+ };
153
+ Relationships: [];
154
+ };
155
+ };
156
+ Views: {
157
+ [_ in never]: never;
158
+ };
159
+ Functions: {
160
+ ensure_household_membership: {
161
+ Args: Record<PropertyKey, never>;
162
+ Returns: {
163
+ household_id: string;
164
+ role: HouseholdRole;
165
+ }[];
166
+ };
167
+ get_household_addons: {
168
+ Args: Record<PropertyKey, never>;
169
+ Returns: Json;
170
+ };
171
+ replace_household_addons: {
172
+ Args: {
173
+ p_addons: Json;
174
+ };
175
+ Returns: undefined;
176
+ };
177
+ upsert_profile_data: {
178
+ Args: {
179
+ p_profile_id: string;
180
+ p_settings: Json;
181
+ p_catalog_prefs: Json;
182
+ p_trakt_auth: Json;
183
+ };
184
+ Returns: undefined;
185
+ };
186
+ is_household_member: {
187
+ Args: {
188
+ p_household_id: string;
189
+ p_user_id: string;
190
+ };
191
+ Returns: boolean;
192
+ };
193
+ can_manage_household_addons: {
194
+ Args: {
195
+ p_household_id: string;
196
+ p_user_id: string;
197
+ };
198
+ Returns: boolean;
199
+ };
200
+ };
201
+ Enums: {
202
+ household_role: HouseholdRole;
203
+ };
204
+ CompositeTypes: {
205
+ [_ in never]: never;
206
+ };
207
+ };
208
+ }
209
+ export type TableRow<T extends keyof Database['public']['Tables']> = Database['public']['Tables'][T]['Row'];
210
+ export type TableInsert<T extends keyof Database['public']['Tables']> = Database['public']['Tables'][T]['Insert'];
211
+ export type TableUpdate<T extends keyof Database['public']['Tables']> = Database['public']['Tables'][T]['Update'];
212
+ export type ProfileRow = TableRow<'profiles'>;
213
+ export type HouseholdMemberRow = TableRow<'household_members'>;
214
+ //# sourceMappingURL=database.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.types.d.ts","sourceRoot":"","sources":["../src/database.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACnC,IAAI,EAAE,CAAC;AAEX,MAAM,MAAM,aAAa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AQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAClE,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE5C,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAClE,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=database.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.types.js","sourceRoot":"","sources":["../src/database.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export type { Database, HouseholdRole, Json, ProfileRow, HouseholdMemberRow, TableInsert, TableRow, TableUpdate, } from './database.types.js';
2
+ export { avatarUrlSchema, confirmationKeywordSchema, emailSchema, ensureMembershipPayloadSchema, householdRoleSchema, membershipRecordSchema, parseMembershipPayload, passwordSchema, profileNameSchema, } from './validators.js';
3
+ export type { HouseholdRole as HouseholdRoleValue, MembershipRecord } from './validators.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,6BAA6B,EAC7B,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,aAAa,IAAI,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { avatarUrlSchema, confirmationKeywordSchema, emailSchema, ensureMembershipPayloadSchema, householdRoleSchema, membershipRecordSchema, parseMembershipPayload, passwordSchema, profileNameSchema, } from './validators.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,6BAA6B,EAC7B,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ export declare const householdRoleSchema: z.ZodEnum<["owner", "member"]>;
3
+ export declare const profileNameSchema: z.ZodEffects<z.ZodString, string, string>;
4
+ export declare const avatarUrlSchema: z.ZodNullable<z.ZodString>;
5
+ export declare const membershipRecordSchema: z.ZodObject<{
6
+ household_id: z.ZodString;
7
+ role: z.ZodEnum<["owner", "member"]>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ household_id: string;
10
+ role: "owner" | "member";
11
+ }, {
12
+ household_id: string;
13
+ role: "owner" | "member";
14
+ }>;
15
+ export declare const ensureMembershipPayloadSchema: z.ZodUnion<[z.ZodObject<{
16
+ household_id: z.ZodString;
17
+ role: z.ZodEnum<["owner", "member"]>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ household_id: string;
20
+ role: "owner" | "member";
21
+ }, {
22
+ household_id: string;
23
+ role: "owner" | "member";
24
+ }>, z.ZodArray<z.ZodObject<{
25
+ household_id: z.ZodString;
26
+ role: z.ZodEnum<["owner", "member"]>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ household_id: string;
29
+ role: "owner" | "member";
30
+ }, {
31
+ household_id: string;
32
+ role: "owner" | "member";
33
+ }>, "many">]>;
34
+ export declare const emailSchema: z.ZodEffects<z.ZodString, string, string>;
35
+ export declare const passwordSchema: z.ZodString;
36
+ export declare const confirmationKeywordSchema: z.ZodLiteral<"DELETE">;
37
+ export type HouseholdRole = z.infer<typeof householdRoleSchema>;
38
+ export type MembershipRecord = z.infer<typeof membershipRecordSchema>;
39
+ export declare function parseMembershipPayload(payload: unknown): MembershipRecord;
40
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB,gCAA8B,CAAC;AAE/D,eAAO,MAAM,iBAAiB,2CAKO,CAAC;AAEtC,eAAO,MAAM,eAAe,4BAKf,CAAC;AAEd,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;aAGxC,CAAC;AAEH,eAAO,MAAM,WAAW,2CAIoB,CAAC;AAE7C,eAAO,MAAM,cAAc,aAE8B,CAAC;AAE1D,eAAO,MAAM,yBAAyB,wBAAsB,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAQzE"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export const householdRoleSchema = z.enum(['owner', 'member']);
3
+ export const profileNameSchema = z
4
+ .string()
5
+ .trim()
6
+ .min(1, 'Profile name is required.')
7
+ .max(32, 'Profile name must be 32 characters or fewer.')
8
+ .transform((value) => value.trim());
9
+ export const avatarUrlSchema = z
10
+ .string()
11
+ .trim()
12
+ .url('Avatar URL must be a valid URL.')
13
+ .max(1024, 'Avatar URL is too long.')
14
+ .nullable();
15
+ export const membershipRecordSchema = z.object({
16
+ household_id: z.string().uuid('Membership payload has invalid household id.'),
17
+ role: householdRoleSchema,
18
+ });
19
+ export const ensureMembershipPayloadSchema = z.union([
20
+ membershipRecordSchema,
21
+ z.array(membershipRecordSchema).min(1),
22
+ ]);
23
+ export const emailSchema = z
24
+ .string()
25
+ .trim()
26
+ .email('Enter a valid email address.')
27
+ .transform((value) => value.toLowerCase());
28
+ export const passwordSchema = z
29
+ .string()
30
+ .min(8, 'Password must be at least 8 characters long.');
31
+ export const confirmationKeywordSchema = z.literal('DELETE');
32
+ export function parseMembershipPayload(payload) {
33
+ const parsed = ensureMembershipPayloadSchema.parse(payload);
34
+ if (Array.isArray(parsed)) {
35
+ return parsed[0];
36
+ }
37
+ return parsed;
38
+ }
39
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;KACnC,GAAG,CAAC,EAAE,EAAE,8CAA8C,CAAC;KACvD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,iCAAiC,CAAC;KACtC,GAAG,CAAC,IAAI,EAAE,yBAAyB,CAAC;KACpC,QAAQ,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,8CAA8C,CAAC;IAC7E,IAAI,EAAE,mBAAmB;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC;IACnD,sBAAsB;IACtB,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,KAAK,CAAC,8BAA8B,CAAC;KACrC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,EAAE,8CAA8C,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAK7D,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,MAAM,GAAG,6BAA6B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@crispy-streaming/supabase-contract",
3
+ "version": "0.1.1",
4
+ "description": "Shared Supabase database contract and Zod validators for Crispy clients",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "sideEffects": false,
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "scripts": {
23
+ "clean": "rm -rf dist",
24
+ "build": "npm run clean && tsc -p tsconfig.json",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "prepack": "npm run build"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/aayushrautela/crispy-supabase-contract.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/aayushrautela/crispy-supabase-contract/issues"
37
+ },
38
+ "homepage": "https://github.com/aayushrautela/crispy-supabase-contract#readme",
39
+ "keywords": [
40
+ "supabase",
41
+ "contract",
42
+ "zod",
43
+ "types"
44
+ ],
45
+ "peerDependencies": {
46
+ "zod": "^3.25.76"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "^5.7.3",
50
+ "zod": "^3.25.76"
51
+ }
52
+ }