@managemint-solutions/sdk 0.54.0 → 0.55.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/dist/clients/index.js +5 -3
- package/dist/emulation-handshakes/index.d.ts +5 -2
- package/dist/emulation-handshakes/index.js +4 -1
- package/dist/leads/index.js +5 -3
- package/dist/projects/index.js +5 -3
- package/dist/tasks/index.js +1 -1
- package/dist/tenancy.d.ts +1 -1
- package/dist/tenancy.js +1 -1
- package/dist/users/index.js +1 -1
- package/package.json +2 -2
package/dist/clients/index.js
CHANGED
|
@@ -121,15 +121,17 @@ class ClientsResource {
|
|
|
121
121
|
return (0, transforms_1.toMmsList)(data, page, pageSize, count);
|
|
122
122
|
}
|
|
123
123
|
async getById(clientId) {
|
|
124
|
-
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('clients').select(CLIENT_DETAIL_SELECT), this.auth)
|
|
124
|
+
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('clients').select((0, tenancy_1.withOrganization)(CLIENT_DETAIL_SELECT, this.auth)), this.auth)
|
|
125
125
|
.eq('mms_id', clientId)
|
|
126
126
|
.single();
|
|
127
127
|
if (error)
|
|
128
128
|
throw (0, errors_1.mapPostgrestError)(error);
|
|
129
|
+
// The select carries the staff embed, so its row type is not inferred from the string.
|
|
130
|
+
const row = data;
|
|
129
131
|
// A soft-deleted client keeps its audit trail but gives up its details.
|
|
130
|
-
if (
|
|
132
|
+
if (row.deleted) {
|
|
131
133
|
return {
|
|
132
|
-
...
|
|
134
|
+
...row,
|
|
133
135
|
name: '',
|
|
134
136
|
email: '',
|
|
135
137
|
phone: '',
|
|
@@ -6,8 +6,11 @@ import type { TypedSupabaseClient } from '../client';
|
|
|
6
6
|
export declare class EmulationHandshakesResource {
|
|
7
7
|
private readonly supabase;
|
|
8
8
|
constructor(supabase: TypedSupabaseClient);
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Opens a handshake for `userId`'s next sign-in, good for thirty seconds. Returns its id. The
|
|
11
|
+
* credential is the one a public mint presented; a staff member's own mint has none.
|
|
12
|
+
*/
|
|
13
|
+
open(userId: string, credentialId: string | null): Promise<number>;
|
|
11
14
|
/** Deletes the handshake, spent or not, once the mint is over. */
|
|
12
15
|
close(id: number): Promise<void>;
|
|
13
16
|
}
|
|
@@ -11,7 +11,10 @@ class EmulationHandshakesResource {
|
|
|
11
11
|
constructor(supabase) {
|
|
12
12
|
this.supabase = supabase;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Opens a handshake for `userId`'s next sign-in, good for thirty seconds. Returns its id. The
|
|
16
|
+
* credential is the one a public mint presented; a staff member's own mint has none.
|
|
17
|
+
*/
|
|
15
18
|
async open(userId, credentialId) {
|
|
16
19
|
const { data, error } = await this.supabase
|
|
17
20
|
.from('emulation_handshakes')
|
package/dist/leads/index.js
CHANGED
|
@@ -165,16 +165,18 @@ class LeadsResource {
|
|
|
165
165
|
return (0, transforms_1.toMmsList)(data, page, pageSize, count);
|
|
166
166
|
}
|
|
167
167
|
async getById(leadId) {
|
|
168
|
-
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('leads').select(LEAD_DETAIL_SELECT), this.auth)
|
|
168
|
+
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('leads').select((0, tenancy_1.withOrganization)(LEAD_DETAIL_SELECT, this.auth)), this.auth)
|
|
169
169
|
.eq('mms_id', leadId)
|
|
170
170
|
.single();
|
|
171
171
|
if (error)
|
|
172
172
|
throw (0, errors_1.mapPostgrestError)(error);
|
|
173
|
+
// The select carries the staff embed, so its row type is not inferred from the string.
|
|
174
|
+
const row = data;
|
|
173
175
|
// A soft-deleted lead keeps its audit trail but gives up its details. The client it became
|
|
174
176
|
// stays, so a converted lead can still point at it.
|
|
175
|
-
if (
|
|
177
|
+
if (row.deleted) {
|
|
176
178
|
return {
|
|
177
|
-
...
|
|
179
|
+
...row,
|
|
178
180
|
name: '',
|
|
179
181
|
contact_person: null,
|
|
180
182
|
email: '',
|
package/dist/projects/index.js
CHANGED
|
@@ -150,15 +150,17 @@ class ProjectsResource {
|
|
|
150
150
|
return (0, transforms_1.toMmsList)(data, page, pageSize, count);
|
|
151
151
|
}
|
|
152
152
|
async getById(projectId) {
|
|
153
|
-
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('projects').select(PROJECT_DETAIL_SELECT), this.auth)
|
|
153
|
+
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('projects').select((0, tenancy_1.withOrganization)(PROJECT_DETAIL_SELECT, this.auth)), this.auth)
|
|
154
154
|
.eq('mms_id', projectId)
|
|
155
155
|
.single();
|
|
156
156
|
if (error)
|
|
157
157
|
throw (0, errors_1.mapPostgrestError)(error);
|
|
158
|
+
// The select carries the staff embed, so its row type is not inferred from the string.
|
|
159
|
+
const row = data;
|
|
158
160
|
// A soft-deleted project keeps its creation audit but gives up its details.
|
|
159
|
-
if (
|
|
161
|
+
if (row.deleted) {
|
|
160
162
|
return {
|
|
161
|
-
...
|
|
163
|
+
...row,
|
|
162
164
|
name: '',
|
|
163
165
|
specification: null,
|
|
164
166
|
has_budget: false,
|
package/dist/tasks/index.js
CHANGED
|
@@ -221,7 +221,7 @@ class TasksResource {
|
|
|
221
221
|
return (0, transforms_1.toMmsList)(rows, page, pageSize, count);
|
|
222
222
|
}
|
|
223
223
|
async getById(taskId) {
|
|
224
|
-
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('tasks').select(TASK_DETAIL_SELECT).eq('mms_id', taskId), this.auth)
|
|
224
|
+
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('tasks').select((0, tenancy_1.withOrganization)(TASK_DETAIL_SELECT, this.auth)).eq('mms_id', taskId), this.auth)
|
|
225
225
|
.order('created_at', { referencedTable: 'links_out' })
|
|
226
226
|
.order('created_at', { referencedTable: 'links_in' })
|
|
227
227
|
.single();
|
package/dist/tenancy.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const scopeToOrganization: <Q extends PostgrestFilterBuilder<any,
|
|
|
7
7
|
export declare const requireOrganization: (actor: {
|
|
8
8
|
organization_id: string | null;
|
|
9
9
|
}) => string;
|
|
10
|
-
/** A
|
|
10
|
+
/** A select, plus the row's organization on a staff read so the row says whose it is. */
|
|
11
11
|
export declare const withOrganization: (select: string, actor: {
|
|
12
12
|
organization_id: string | null;
|
|
13
13
|
}) => string;
|
package/dist/tenancy.js
CHANGED
|
@@ -20,6 +20,6 @@ const requireOrganization = (actor) => {
|
|
|
20
20
|
return actor.organization_id;
|
|
21
21
|
};
|
|
22
22
|
exports.requireOrganization = requireOrganization;
|
|
23
|
-
/** A
|
|
23
|
+
/** A select, plus the row's organization on a staff read so the row says whose it is. */
|
|
24
24
|
const withOrganization = (select, actor) => actor.organization_id === null ? `${select}, organization:organizations!organization_id(mms_id, name)` : select;
|
|
25
25
|
exports.withOrganization = withOrganization;
|
package/dist/users/index.js
CHANGED
|
@@ -75,7 +75,7 @@ class UsersResource {
|
|
|
75
75
|
return (0, transforms_1.toMmsList)(data, page, pageSize, count);
|
|
76
76
|
}
|
|
77
77
|
async getRow(userId) {
|
|
78
|
-
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('users').select('*').eq('mms_id', userId), this.auth).single();
|
|
78
|
+
const { data, error } = await (0, tenancy_1.scopeToOrganization)(this.supabase.from('users').select((0, tenancy_1.withOrganization)('*', this.auth)).eq('mms_id', userId), this.auth).single();
|
|
79
79
|
if (error)
|
|
80
80
|
throw (0, errors_1.mapPostgrestError)(error);
|
|
81
81
|
return (0, audit_1.withoutInternalId)(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@managemint-solutions/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Typed Supabase data-access SDK for ManageMint Solutions",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Scott Bebington <scottbebington@gmail.com>",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"testEnvironment": "node"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@managemint-solutions/entities": "^1.
|
|
54
|
+
"@managemint-solutions/entities": "^1.37.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@nestjs/common": "^11.0.0",
|