@ai-matrx/sharing 0.1.1 → 0.1.2
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/CHANGELOG.md +7 -0
- package/dist/core.cjs +27 -24
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +27 -24
- package/dist/core.js.map +1 -1
- package/dist/react.cjs +224 -86
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +24 -3
- package/dist/react.d.ts +24 -3
- package/dist/react.js +225 -86
- package/dist/react.js.map +1 -1
- package/package.json +3 -3
package/dist/core.d.cts
CHANGED
|
@@ -3748,15 +3748,15 @@ interface CreateShareLinkOptions {
|
|
|
3748
3748
|
maxUses?: number | null | undefined;
|
|
3749
3749
|
label?: string | null | undefined;
|
|
3750
3750
|
}
|
|
3751
|
-
/** Build the absolute share URL for a token. */
|
|
3752
|
-
declare function shareLinkUrl(token: string): string;
|
|
3751
|
+
/** Build the absolute share URL for a token (on `origin` when given). */
|
|
3752
|
+
declare function shareLinkUrl(token: string, origin?: string | undefined): string;
|
|
3753
3753
|
/**
|
|
3754
3754
|
* The URL to hand a person for a share link — the short alias when one exists
|
|
3755
3755
|
* (auto-shorten-every-share-link, owner ruling 2026-08-29), the full /s/ URL
|
|
3756
3756
|
* otherwise. The alias is a redirect only; the 64-hex share token stays the
|
|
3757
3757
|
* one authorization either way.
|
|
3758
3758
|
*/
|
|
3759
|
-
declare function shareUrlForLink(link: Pick<ShareLink, "token" | "shortToken"
|
|
3759
|
+
declare function shareUrlForLink(link: Pick<ShareLink, "token" | "shortToken">, origin?: string | undefined): string;
|
|
3760
3760
|
/** Mint a share link for a resource (owner-only). Returns the token + URL. */
|
|
3761
3761
|
declare function createShareLink(options: CreateShareLinkOptions): Promise<{
|
|
3762
3762
|
success: boolean;
|
|
@@ -4062,7 +4062,7 @@ declare function resolveResourceOwnership(resourceType: ResourceType, resourceId
|
|
|
4062
4062
|
* record store it could not even be ASKED, because `custom.record` carries no
|
|
4063
4063
|
* client SELECT grant and the direct read above returns "Could not read Record".
|
|
4064
4064
|
*
|
|
4065
|
-
* So this asks the database's own predicate (`
|
|
4065
|
+
* So this asks the database's own predicate (`iam.may_manage_sharing`, lane
|
|
4066
4066
|
* SHARE 2026-09-19), which is the same one the six sharing RPCs enforce. The
|
|
4067
4067
|
* screen and the door cannot disagree, because there is one answer.
|
|
4068
4068
|
*
|
|
@@ -4671,10 +4671,10 @@ declare function setSearchEngineIndexed(resourceType: string, resourceId: string
|
|
|
4671
4671
|
|
|
4672
4672
|
type Database = any;
|
|
4673
4673
|
|
|
4674
|
-
type OrganizationMemberRow = Database["
|
|
4674
|
+
type OrganizationMemberRow = Database["iam"]["Functions"]["get_organization_members_with_users"]["Returns"][number];
|
|
4675
4675
|
/** How long a settled roster is kept: for the tab (a change made here forgets it). */
|
|
4676
4676
|
declare const MEMBER_ROWS_TTL_MS: number;
|
|
4677
|
-
type RosterClient = Pick<ReturnType<typeof createClient>, "rpc">;
|
|
4677
|
+
type RosterClient = Pick<ReturnType<typeof createClient>, "rpc" | "schema">;
|
|
4678
4678
|
declare function readOrganizationMemberRows(orgId: string, { now, fresh, client, }?: {
|
|
4679
4679
|
now?: number | undefined;
|
|
4680
4680
|
/** An explicit refresh: skip a settled answer (an in-flight read is still joined). */
|
package/dist/core.d.ts
CHANGED
|
@@ -3748,15 +3748,15 @@ interface CreateShareLinkOptions {
|
|
|
3748
3748
|
maxUses?: number | null | undefined;
|
|
3749
3749
|
label?: string | null | undefined;
|
|
3750
3750
|
}
|
|
3751
|
-
/** Build the absolute share URL for a token. */
|
|
3752
|
-
declare function shareLinkUrl(token: string): string;
|
|
3751
|
+
/** Build the absolute share URL for a token (on `origin` when given). */
|
|
3752
|
+
declare function shareLinkUrl(token: string, origin?: string | undefined): string;
|
|
3753
3753
|
/**
|
|
3754
3754
|
* The URL to hand a person for a share link — the short alias when one exists
|
|
3755
3755
|
* (auto-shorten-every-share-link, owner ruling 2026-08-29), the full /s/ URL
|
|
3756
3756
|
* otherwise. The alias is a redirect only; the 64-hex share token stays the
|
|
3757
3757
|
* one authorization either way.
|
|
3758
3758
|
*/
|
|
3759
|
-
declare function shareUrlForLink(link: Pick<ShareLink, "token" | "shortToken"
|
|
3759
|
+
declare function shareUrlForLink(link: Pick<ShareLink, "token" | "shortToken">, origin?: string | undefined): string;
|
|
3760
3760
|
/** Mint a share link for a resource (owner-only). Returns the token + URL. */
|
|
3761
3761
|
declare function createShareLink(options: CreateShareLinkOptions): Promise<{
|
|
3762
3762
|
success: boolean;
|
|
@@ -4062,7 +4062,7 @@ declare function resolveResourceOwnership(resourceType: ResourceType, resourceId
|
|
|
4062
4062
|
* record store it could not even be ASKED, because `custom.record` carries no
|
|
4063
4063
|
* client SELECT grant and the direct read above returns "Could not read Record".
|
|
4064
4064
|
*
|
|
4065
|
-
* So this asks the database's own predicate (`
|
|
4065
|
+
* So this asks the database's own predicate (`iam.may_manage_sharing`, lane
|
|
4066
4066
|
* SHARE 2026-09-19), which is the same one the six sharing RPCs enforce. The
|
|
4067
4067
|
* screen and the door cannot disagree, because there is one answer.
|
|
4068
4068
|
*
|
|
@@ -4671,10 +4671,10 @@ declare function setSearchEngineIndexed(resourceType: string, resourceId: string
|
|
|
4671
4671
|
|
|
4672
4672
|
type Database = any;
|
|
4673
4673
|
|
|
4674
|
-
type OrganizationMemberRow = Database["
|
|
4674
|
+
type OrganizationMemberRow = Database["iam"]["Functions"]["get_organization_members_with_users"]["Returns"][number];
|
|
4675
4675
|
/** How long a settled roster is kept: for the tab (a change made here forgets it). */
|
|
4676
4676
|
declare const MEMBER_ROWS_TTL_MS: number;
|
|
4677
|
-
type RosterClient = Pick<ReturnType<typeof createClient>, "rpc">;
|
|
4677
|
+
type RosterClient = Pick<ReturnType<typeof createClient>, "rpc" | "schema">;
|
|
4678
4678
|
declare function readOrganizationMemberRows(orgId: string, { now, fresh, client, }?: {
|
|
4679
4679
|
now?: number | undefined;
|
|
4680
4680
|
/** An explicit refresh: skip a settled answer (an in-flight read is still joined). */
|
package/dist/core.js
CHANGED
|
@@ -3524,13 +3524,16 @@ async function getShareCapabilities(resourceType) {
|
|
|
3524
3524
|
rowChildColumn: typeof data.row_child_column === "string" ? data.row_child_column : null
|
|
3525
3525
|
};
|
|
3526
3526
|
}
|
|
3527
|
-
function
|
|
3528
|
-
const base = process.env.NEXT_PUBLIC_APP_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
3529
|
-
return
|
|
3527
|
+
function shareBase(origin) {
|
|
3528
|
+
const base = origin || process.env.NEXT_PUBLIC_APP_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
3529
|
+
return base.replace(/\/+$/, "");
|
|
3530
3530
|
}
|
|
3531
|
-
function
|
|
3532
|
-
|
|
3533
|
-
|
|
3531
|
+
function shareLinkUrl(token, origin) {
|
|
3532
|
+
return `${shareBase(origin)}/s/${token}`;
|
|
3533
|
+
}
|
|
3534
|
+
function shareUrlForLink(link, origin) {
|
|
3535
|
+
const base = shareBase(origin);
|
|
3536
|
+
return link.shortToken ? shortLinkUrl(base, link.shortToken) : shareLinkUrl(link.token, base);
|
|
3534
3537
|
}
|
|
3535
3538
|
async function createShareLink(options) {
|
|
3536
3539
|
try {
|
|
@@ -3601,7 +3604,7 @@ async function forkSharedResource(resourceType, resourceId, shareToken, organiza
|
|
|
3601
3604
|
try {
|
|
3602
3605
|
const orgId = await ensureOrgId(organizationId);
|
|
3603
3606
|
if (resourceType === "conversation") {
|
|
3604
|
-
const { data, error } = await supabase.rpc("fork_shared_conversation", {
|
|
3607
|
+
const { data, error } = await supabase.schema("chat").rpc("fork_shared_conversation", {
|
|
3605
3608
|
p_conversation_id: resourceId,
|
|
3606
3609
|
p_organization_id: orgId,
|
|
3607
3610
|
p_token: shareToken ?? void 0
|
|
@@ -3611,7 +3614,7 @@ async function forkSharedResource(resourceType, resourceId, shareToken, organiza
|
|
|
3611
3614
|
return r?.success ? { success: true, path: `/chat/${r.conversation_id}` } : { success: false, error: r?.error };
|
|
3612
3615
|
}
|
|
3613
3616
|
if (resourceType === "fc_set") {
|
|
3614
|
-
const { data, error } = await supabase.rpc("fork_shared_flashcard_set", {
|
|
3617
|
+
const { data, error } = await supabase.schema("education").rpc("fork_shared_flashcard_set", {
|
|
3615
3618
|
p_set_id: resourceId,
|
|
3616
3619
|
p_organization_id: orgId,
|
|
3617
3620
|
p_token: shareToken ?? void 0
|
|
@@ -3621,7 +3624,7 @@ async function forkSharedResource(resourceType, resourceId, shareToken, organiza
|
|
|
3621
3624
|
return r?.success ? { success: true, path: `/education/flashcards/${r.set_id}` } : { success: false, error: r?.error };
|
|
3622
3625
|
}
|
|
3623
3626
|
if (resourceType === "quiz_session") {
|
|
3624
|
-
const { data, error } = await supabase.rpc("fork_shared_quiz", {
|
|
3627
|
+
const { data, error } = await supabase.schema("education").rpc("fork_shared_quiz", {
|
|
3625
3628
|
p_quiz_id: resourceId,
|
|
3626
3629
|
p_organization_id: orgId,
|
|
3627
3630
|
p_token: shareToken ?? void 0
|
|
@@ -3642,7 +3645,7 @@ function isForkable(resourceType) {
|
|
|
3642
3645
|
return resourceType === "conversation" || resourceType === "fc_set" || resourceType === "quiz_session";
|
|
3643
3646
|
}
|
|
3644
3647
|
async function resolveShareToken(token, client = supabase) {
|
|
3645
|
-
const { data, error } = await client.rpc("resolve_share_token", {
|
|
3648
|
+
const { data, error } = await client.schema("iam").rpc("resolve_share_token", {
|
|
3646
3649
|
p_token: token
|
|
3647
3650
|
});
|
|
3648
3651
|
if (error) {
|
|
@@ -3726,7 +3729,7 @@ async function writeRowControl(resourceType, resourceId, patch) {
|
|
|
3726
3729
|
return { success: true };
|
|
3727
3730
|
}
|
|
3728
3731
|
async function writeStoreRowControls(resourceType, resourceId, controls) {
|
|
3729
|
-
const { data: lane, error: laneError } = await supabase.rpc("store_door_lane", {
|
|
3732
|
+
const { data: lane, error: laneError } = await supabase.schema("workbench").rpc("store_door_lane", {
|
|
3730
3733
|
p_resource_type: resourceType,
|
|
3731
3734
|
p_resource_id: resourceId
|
|
3732
3735
|
});
|
|
@@ -3760,7 +3763,7 @@ async function getResourceVisibility(resourceType, resourceId) {
|
|
|
3760
3763
|
);
|
|
3761
3764
|
}
|
|
3762
3765
|
if (entry.schemaName === "custom") {
|
|
3763
|
-
const { data: data2, error: error2 } = await supabase.rpc("store_door_lane", {
|
|
3766
|
+
const { data: data2, error: error2 } = await supabase.schema("workbench").rpc("store_door_lane", {
|
|
3764
3767
|
p_resource_type: resourceType,
|
|
3765
3768
|
p_resource_id: resourceId
|
|
3766
3769
|
});
|
|
@@ -3879,7 +3882,7 @@ async function shareWithUser(options) {
|
|
|
3879
3882
|
permissionLevel,
|
|
3880
3883
|
organizationId
|
|
3881
3884
|
} = options;
|
|
3882
|
-
const { data, error } = await supabase.rpc("share_resource_with_user", {
|
|
3885
|
+
const { data, error } = await supabase.schema("iam").rpc("share_resource_with_user", {
|
|
3883
3886
|
p_resource_type: resourceType,
|
|
3884
3887
|
p_resource_id: resourceId,
|
|
3885
3888
|
p_target_user_id: userId,
|
|
@@ -3930,7 +3933,7 @@ async function shareWithUser(options) {
|
|
|
3930
3933
|
async function grantOrgAvailability(options) {
|
|
3931
3934
|
try {
|
|
3932
3935
|
const { resourceType, resourceId, organizationId, permissionLevel } = options;
|
|
3933
|
-
const { data, error } = await supabase.rpc("grant_org_availability", {
|
|
3936
|
+
const { data, error } = await supabase.schema("iam").rpc("grant_org_availability", {
|
|
3934
3937
|
p_resource_type: resourceType,
|
|
3935
3938
|
p_resource_id: resourceId,
|
|
3936
3939
|
p_target_org_id: organizationId,
|
|
@@ -3992,7 +3995,7 @@ async function makePrivate(resourceType, resourceId) {
|
|
|
3992
3995
|
}
|
|
3993
3996
|
async function revokeUserAccess(resourceType, resourceId, userId) {
|
|
3994
3997
|
try {
|
|
3995
|
-
const { data, error } = await supabase.rpc("revoke_resource_access", {
|
|
3998
|
+
const { data, error } = await supabase.schema("iam").rpc("revoke_resource_access", {
|
|
3996
3999
|
p_resource_type: resourceType,
|
|
3997
4000
|
p_resource_id: resourceId,
|
|
3998
4001
|
p_target_user_id: userId
|
|
@@ -4015,7 +4018,7 @@ async function revokeUserAccess(resourceType, resourceId, userId) {
|
|
|
4015
4018
|
}
|
|
4016
4019
|
async function revokeOrgAccess(resourceType, resourceId, organizationId) {
|
|
4017
4020
|
try {
|
|
4018
|
-
const { data, error } = await supabase.rpc("revoke_resource_org_access", {
|
|
4021
|
+
const { data, error } = await supabase.schema("iam").rpc("revoke_resource_org_access", {
|
|
4019
4022
|
p_resource_type: resourceType,
|
|
4020
4023
|
p_resource_id: resourceId,
|
|
4021
4024
|
p_target_org_id: organizationId
|
|
@@ -4056,7 +4059,7 @@ async function updatePermissionLevel(options) {
|
|
|
4056
4059
|
if (!userId && !organizationId) {
|
|
4057
4060
|
return { success: false, error: "Must specify userId or organizationId" };
|
|
4058
4061
|
}
|
|
4059
|
-
const { data, error } = await supabase.rpc("update_permission_level", {
|
|
4062
|
+
const { data, error } = await supabase.schema("iam").rpc("update_permission_level", {
|
|
4060
4063
|
p_resource_type: resourceType,
|
|
4061
4064
|
p_resource_id: resourceId,
|
|
4062
4065
|
p_target_user_id: userId,
|
|
@@ -4084,7 +4087,7 @@ async function updatePermissionLevel(options) {
|
|
|
4084
4087
|
}
|
|
4085
4088
|
async function listPermissions(resourceType, resourceId) {
|
|
4086
4089
|
try {
|
|
4087
|
-
const { data, error } = await supabase.rpc("get_resource_permissions", {
|
|
4090
|
+
const { data, error } = await supabase.schema("iam").rpc("get_resource_permissions", {
|
|
4088
4091
|
p_resource_type: resourceType,
|
|
4089
4092
|
p_resource_id: resourceId
|
|
4090
4093
|
});
|
|
@@ -4163,7 +4166,7 @@ async function resolveSharingAuthority(resourceType, resourceId) {
|
|
|
4163
4166
|
};
|
|
4164
4167
|
}
|
|
4165
4168
|
try {
|
|
4166
|
-
const { data, error } = await supabase.rpc("may_manage_sharing", {
|
|
4169
|
+
const { data, error } = await supabase.schema("iam").rpc("may_manage_sharing", {
|
|
4167
4170
|
p_resource_type: resourceType,
|
|
4168
4171
|
p_resource_id: resourceId
|
|
4169
4172
|
});
|
|
@@ -4458,7 +4461,7 @@ async function fetchEntityTitles(entityType, ids) {
|
|
|
4458
4461
|
const unique = Array.from(new Set(ids.filter(Boolean)));
|
|
4459
4462
|
if (unique.length === 0) return out;
|
|
4460
4463
|
const supabase2 = createClient();
|
|
4461
|
-
const { data, error } = await supabase2.rpc("entity_titles", {
|
|
4464
|
+
const { data, error } = await supabase2.schema("platform").rpc("entity_titles", {
|
|
4462
4465
|
p_type: entityType,
|
|
4463
4466
|
p_ids: unique
|
|
4464
4467
|
});
|
|
@@ -4977,7 +4980,7 @@ async function revokeOutside(organizationId, invitationId) {
|
|
|
4977
4980
|
return data;
|
|
4978
4981
|
}
|
|
4979
4982
|
async function peekTableShare(token) {
|
|
4980
|
-
const { data, error } = await createClient().rpc("table_share_peek", { p_token: token });
|
|
4983
|
+
const { data, error } = await createClient().schema("iam").rpc("table_share_peek", { p_token: token });
|
|
4981
4984
|
if (error) throw new Error(error.message);
|
|
4982
4985
|
return data;
|
|
4983
4986
|
}
|
|
@@ -5133,7 +5136,7 @@ function readOrganizationMemberRows2(orgId, {
|
|
|
5133
5136
|
const db = client ?? createClient();
|
|
5134
5137
|
const entry = { at: now, settled: false, rows: Promise.resolve([]) };
|
|
5135
5138
|
const rows = (async () => {
|
|
5136
|
-
const { data, error } = await db.rpc("get_organization_members_with_users", {
|
|
5139
|
+
const { data, error } = await db.schema("iam").rpc("get_organization_members_with_users", {
|
|
5137
5140
|
p_org_id: orgId
|
|
5138
5141
|
});
|
|
5139
5142
|
if (error) throw pgErrorToError(error);
|
|
@@ -5180,7 +5183,7 @@ function toRole(value) {
|
|
|
5180
5183
|
return value === "admin" || value === "member" ? value : null;
|
|
5181
5184
|
}
|
|
5182
5185
|
async function listTeams(organizationId, includeArchived = false) {
|
|
5183
|
-
const { data, error } = await shareClient().rpc("team_list", { p_organization_id: organizationId, p_include_archived: includeArchived });
|
|
5186
|
+
const { data, error } = await shareClient().schema("iam").rpc("team_list", { p_organization_id: organizationId, p_include_archived: includeArchived });
|
|
5184
5187
|
if (error) throw pgErrorToError2(error);
|
|
5185
5188
|
return (data ?? []).map((row) => ({
|
|
5186
5189
|
id: String(row.id),
|
|
@@ -5196,7 +5199,7 @@ async function listTeams(organizationId, includeArchived = false) {
|
|
|
5196
5199
|
}));
|
|
5197
5200
|
}
|
|
5198
5201
|
async function listTeamMembers(teamId) {
|
|
5199
|
-
const { data, error } = await shareClient().rpc("team_members", { p_team_id: teamId });
|
|
5202
|
+
const { data, error } = await shareClient().schema("iam").rpc("team_members", { p_team_id: teamId });
|
|
5200
5203
|
if (error) throw pgErrorToError2(error);
|
|
5201
5204
|
return (data ?? []).map((row) => ({
|
|
5202
5205
|
userId: String(row.user_id),
|