@rjromeoent/ein-supabase 0.1.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.
- package/README.md +91 -0
- package/dist/app-context.d.ts +13 -0
- package/dist/app-context.js +16 -0
- package/dist/auth.d.ts +7 -0
- package/dist/auth.js +22 -0
- package/dist/generated/database.types.d.ts +18546 -0
- package/dist/generated/database.types.js +578 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/schema-client.d.ts +56 -0
- package/dist/schema-client.js +3 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @rjromeoent/ein-supabase
|
|
2
|
+
|
|
3
|
+
Shared Supabase contract package for EIN-connected apps.
|
|
4
|
+
|
|
5
|
+
This package is the canonical home for:
|
|
6
|
+
|
|
7
|
+
- Generated Supabase database types across EIN schemas.
|
|
8
|
+
- Registered app slugs and the `x-ein-app` header helper.
|
|
9
|
+
- Shared org-role helpers for `core.app_organization_memberships`.
|
|
10
|
+
- Typed schema-client helpers.
|
|
11
|
+
|
|
12
|
+
Regenerate database types from the Event Intelligence Network repo root:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm run generate:supabase-types
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Apps should import shared contracts from this package instead of hand-maintaining
|
|
19
|
+
partial copies of `core`, `rad`, `booking_engine`, `launchpad`, or other shared
|
|
20
|
+
schemas.
|
|
21
|
+
|
|
22
|
+
App-specific role variation should be a small local mapping from canonical
|
|
23
|
+
`CoreOrgRole` values. For example, Booking Engine maps `owner/admin` to its
|
|
24
|
+
local `admin` workflow role and `member` to `rep`.
|
|
25
|
+
|
|
26
|
+
## Build
|
|
27
|
+
|
|
28
|
+
From the Event Intelligence Network repo root:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install
|
|
32
|
+
npm run generate:supabase-types
|
|
33
|
+
npm run build:packages
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or from this package directory:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm run clean
|
|
40
|
+
npm run build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The package publishes compiled ESM and declarations from `dist`.
|
|
44
|
+
|
|
45
|
+
## Publish
|
|
46
|
+
|
|
47
|
+
This package is intended to be installed by independent Lovable app repos, so
|
|
48
|
+
apps should not depend on `file:../Event-Intelligence-Network/...` outside local
|
|
49
|
+
development.
|
|
50
|
+
|
|
51
|
+
Publish from the EIN repo root after the `rjromeoent` npm organization is
|
|
52
|
+
available to the publishing user, types are regenerated, and the package build
|
|
53
|
+
passes:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm run build:packages
|
|
57
|
+
npm run pack:ein-supabase
|
|
58
|
+
npm run publish:ein-supabase
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The package is configured as a public scoped package. That is intentional for
|
|
62
|
+
Lovable apps: app deploys can install it without an npm auth token. Do not put
|
|
63
|
+
secrets, service-role keys, database passwords, or private environment values in
|
|
64
|
+
this package.
|
|
65
|
+
|
|
66
|
+
Then app repos should depend on the released version:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@rjromeoent/ein-supabase": "^0.1.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Use semver intentionally:
|
|
77
|
+
|
|
78
|
+
- Patch: regenerated types, additive helpers, docs.
|
|
79
|
+
- Minor: additive contracts or new schemas/functions.
|
|
80
|
+
- Major: renamed or removed contracts, breaking permission/app context changes.
|
|
81
|
+
|
|
82
|
+
## Consumer Rule
|
|
83
|
+
|
|
84
|
+
App repos may keep their UI-specific adapters and view models locally, but
|
|
85
|
+
shared backend contracts belong here first:
|
|
86
|
+
|
|
87
|
+
- generated `Database` types
|
|
88
|
+
- app slugs and `x-ein-app`
|
|
89
|
+
- canonical org roles and permission helpers
|
|
90
|
+
- Edge Function request/response contracts
|
|
91
|
+
- shared runtime guards that protect persisted JSON or Edge response boundaries
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const EIN_APP_HEADER = "x-ein-app";
|
|
2
|
+
export declare const EIN_APP_SLUGS: {
|
|
3
|
+
readonly atlas: "atlas";
|
|
4
|
+
readonly bookingEngine: "booking_engine";
|
|
5
|
+
readonly eventOpsConsole: "ein_ops";
|
|
6
|
+
readonly festivalOs: "festivalos";
|
|
7
|
+
readonly rad: "rad";
|
|
8
|
+
readonly rockitLaunchpad: "rockit_launchpad";
|
|
9
|
+
};
|
|
10
|
+
export type EinAppKey = keyof typeof EIN_APP_SLUGS;
|
|
11
|
+
export type EinAppSlug = (typeof EIN_APP_SLUGS)[EinAppKey];
|
|
12
|
+
export declare function isEinAppSlug(value: unknown): value is EinAppSlug;
|
|
13
|
+
export declare function einAppHeaders(appSlug: EinAppSlug): Record<typeof EIN_APP_HEADER, EinAppSlug>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const EIN_APP_HEADER = "x-ein-app";
|
|
2
|
+
export const EIN_APP_SLUGS = {
|
|
3
|
+
atlas: "atlas",
|
|
4
|
+
bookingEngine: "booking_engine",
|
|
5
|
+
eventOpsConsole: "ein_ops",
|
|
6
|
+
festivalOs: "festivalos",
|
|
7
|
+
rad: "rad",
|
|
8
|
+
rockitLaunchpad: "rockit_launchpad",
|
|
9
|
+
};
|
|
10
|
+
const EIN_APP_SLUG_SET = new Set(Object.values(EIN_APP_SLUGS));
|
|
11
|
+
export function isEinAppSlug(value) {
|
|
12
|
+
return typeof value === "string" && EIN_APP_SLUG_SET.has(value);
|
|
13
|
+
}
|
|
14
|
+
export function einAppHeaders(appSlug) {
|
|
15
|
+
return { [EIN_APP_HEADER]: appSlug };
|
|
16
|
+
}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Database } from "./generated/database.types.js";
|
|
2
|
+
export type CoreOrgRole = Database["core"]["Enums"]["org_role"];
|
|
3
|
+
export declare const CORE_ORG_ROLES: readonly CoreOrgRole[];
|
|
4
|
+
export declare const CORE_ORG_ROLE_RANK: Record<CoreOrgRole, number>;
|
|
5
|
+
export declare function isCoreOrgRole(value: unknown): value is CoreOrgRole;
|
|
6
|
+
export declare function parseCoreOrgRole(value: unknown, fallback?: CoreOrgRole): CoreOrgRole;
|
|
7
|
+
export declare function coreOrgRoleAtLeast(role: CoreOrgRole, minimum: CoreOrgRole): boolean;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const CORE_ORG_ROLES = [
|
|
2
|
+
"owner",
|
|
3
|
+
"admin",
|
|
4
|
+
"member",
|
|
5
|
+
"viewer",
|
|
6
|
+
];
|
|
7
|
+
const CORE_ORG_ROLE_SET = new Set(CORE_ORG_ROLES);
|
|
8
|
+
export const CORE_ORG_ROLE_RANK = {
|
|
9
|
+
viewer: 0,
|
|
10
|
+
member: 1,
|
|
11
|
+
admin: 2,
|
|
12
|
+
owner: 3,
|
|
13
|
+
};
|
|
14
|
+
export function isCoreOrgRole(value) {
|
|
15
|
+
return typeof value === "string" && CORE_ORG_ROLE_SET.has(value);
|
|
16
|
+
}
|
|
17
|
+
export function parseCoreOrgRole(value, fallback = "viewer") {
|
|
18
|
+
return isCoreOrgRole(value) ? value : fallback;
|
|
19
|
+
}
|
|
20
|
+
export function coreOrgRoleAtLeast(role, minimum) {
|
|
21
|
+
return CORE_ORG_ROLE_RANK[role] >= CORE_ORG_ROLE_RANK[minimum];
|
|
22
|
+
}
|