@managemint-solutions/sdk 0.16.0 → 0.18.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 (55) hide show
  1. package/dist/audit/index.d.ts +23 -2
  2. package/dist/audit/index.js +56 -21
  3. package/dist/audit/index.js.map +1 -1
  4. package/dist/auth-client/index.d.ts +1 -6
  5. package/dist/auth-client/index.js +3 -18
  6. package/dist/auth-client/index.js.map +1 -1
  7. package/dist/auth.d.ts +36 -1
  8. package/dist/auth.js +52 -22
  9. package/dist/auth.js.map +1 -1
  10. package/dist/billing/index.d.ts +22 -13
  11. package/dist/billing/index.js +51 -48
  12. package/dist/billing/index.js.map +1 -1
  13. package/dist/client.d.ts +18 -1
  14. package/dist/client.js +11 -6
  15. package/dist/client.js.map +1 -1
  16. package/dist/clients/index.js +13 -75
  17. package/dist/clients/index.js.map +1 -1
  18. package/dist/errors.d.ts +4 -1
  19. package/dist/errors.js +7 -58
  20. package/dist/errors.js.map +1 -1
  21. package/dist/index.d.ts +48 -22
  22. package/dist/index.js +116 -36
  23. package/dist/index.js.map +1 -1
  24. package/dist/nest/index.d.ts +26 -3
  25. package/dist/nest/index.js +54 -15
  26. package/dist/nest/index.js.map +1 -1
  27. package/dist/notifications/index.d.ts +0 -1
  28. package/dist/notifications/index.js +4 -16
  29. package/dist/notifications/index.js.map +1 -1
  30. package/dist/organization-invites/index.d.ts +29 -0
  31. package/dist/organization-invites/index.js +48 -0
  32. package/dist/organization-invites/index.js.map +1 -0
  33. package/dist/organizations/index.js +4 -9
  34. package/dist/organizations/index.js.map +1 -1
  35. package/dist/permissions/index.d.ts +8 -0
  36. package/dist/permissions/index.js +16 -1
  37. package/dist/permissions/index.js.map +1 -1
  38. package/dist/projects/index.js +12 -75
  39. package/dist/projects/index.js.map +1 -1
  40. package/dist/service-client/index.d.ts +2 -0
  41. package/dist/service-client/index.js +7 -6
  42. package/dist/service-client/index.js.map +1 -1
  43. package/dist/supporting-files/index.js +31 -15
  44. package/dist/supporting-files/index.js.map +1 -1
  45. package/dist/supporting-files/paths.d.ts +19 -5
  46. package/dist/supporting-files/paths.js +46 -10
  47. package/dist/supporting-files/paths.js.map +1 -1
  48. package/dist/tasks/index.js +7 -33
  49. package/dist/tasks/index.js.map +1 -1
  50. package/dist/transforms.d.ts +43 -0
  51. package/dist/transforms.js +73 -2
  52. package/dist/transforms.js.map +1 -1
  53. package/dist/users/index.js +4 -14
  54. package/dist/users/index.js.map +1 -1
  55. package/package.json +6 -2
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BillingResource = void 0;
17
+ exports.BillingResource = exports.BillingReadsResource = void 0;
18
18
  const enum_1 = require("@managemint-solutions/entities/audit-trail/enum");
19
19
  const enum_2 = require("@managemint-solutions/entities/billing/enum");
20
20
  const audit_1 = require("../audit");
@@ -25,46 +25,17 @@ const BILLING_TRANSACTIONS_TABLE = {
25
25
  entityType: enum_1.AuditTrailEntityType.BILLING_TRANSACTIONS,
26
26
  };
27
27
  /**
28
- * The ledger and its narrative log. Every policy here is `false` for `authenticated` except
29
- * READ, so this only ever runs on the service client the ledger is written by the billing
30
- * service and by webhooks, never by a caller.
28
+ * The readable half of the ledger. `billing_transactions` and `billing_events` are org-scoped
29
+ * for READ, and the catalog is readable by `anon`, so all of this runs perfectly well on the
30
+ * caller's own client — and should, so that RLS is what scopes it rather than a filter the api
31
+ * remembered to add.
31
32
  */
32
- class BillingResource {
33
+ class BillingReadsResource {
33
34
  supabase;
34
35
  actor;
35
- transactions;
36
- constructor(supabase, actor, audit) {
36
+ constructor(supabase, actor) {
37
37
  this.supabase = supabase;
38
38
  this.actor = actor;
39
- this.transactions = (0, audit_1.auditedTable)(supabase, actor, audit, BILLING_TRANSACTIONS_TABLE);
40
- }
41
- async createTransaction(payload) {
42
- const row = await this.transactions.insert(payload);
43
- return row;
44
- }
45
- async updateTransaction(transactionId, patch) {
46
- return this.transactions.update(transactionId, {
47
- ...patch,
48
- updated_at: new Date().toISOString(),
49
- });
50
- }
51
- /**
52
- * Claims a transaction for processing, but only while it is not already paid. This is the
53
- * send-exactly-once gate on the webhook path: a redelivered `charge.success` must not settle
54
- * the same row twice. Resolves to null when the guard finds it already settled.
55
- */
56
- async claimTransactionForProcessing(transactionId, patch) {
57
- return this.transactions.updateWhere(transactionId, (query) => query.neq('transaction_status', enum_2.BillingTransactionStatus.PAID), { ...patch, updated_at: new Date().toISOString() });
58
- }
59
- async getTransaction(transactionId) {
60
- const { data, error } = await this.supabase
61
- .from('billing_transactions')
62
- .select('*')
63
- .eq('mms_id', transactionId)
64
- .maybeSingle();
65
- if (error)
66
- throw (0, errors_1.mapPostgrestError)(error);
67
- return (data ?? null);
68
39
  }
69
40
  /** The one open transaction, if the organization has one. */
70
41
  async openTransaction(openStatuses) {
@@ -76,7 +47,7 @@ class BillingResource {
76
47
  .maybeSingle();
77
48
  if (error)
78
49
  throw (0, errors_1.mapPostgrestError)(error);
79
- return (data ?? null);
50
+ return data ? (0, audit_1.withoutInternalId)(data) : null;
80
51
  }
81
52
  /** The replay lookup: the same key must never raise a second charge. */
82
53
  async transactionByIdempotencyKey(idempotencyKey) {
@@ -88,18 +59,9 @@ class BillingResource {
88
59
  .maybeSingle();
89
60
  if (error)
90
61
  throw (0, errors_1.mapPostgrestError)(error);
91
- return (data ?? null);
62
+ return data ? (0, audit_1.withoutInternalId)(data) : null;
92
63
  }
93
- /**
94
- * Appends to `billing_events`. Deliberately unaudited: the table *is* an append-only
95
- * narrative of the billing state machine, so an audit row per event would log the log.
96
- */
97
- async recordEvent(event) {
98
- const { error } = await this.supabase.from('billing_events').insert(event);
99
- if (error)
100
- throw (0, errors_1.mapPostgrestError)(error);
101
- }
102
- /** Whether a catalog module is still on sale. */
64
+ /** Whether a catalog module is still on sale. The catalog is public, not tenant-scoped. */
103
65
  async isModuleActive(moduleId) {
104
66
  const { data, error } = await this.supabase
105
67
  .from('billing_modules')
@@ -111,5 +73,46 @@ class BillingResource {
111
73
  return data?.active === true;
112
74
  }
113
75
  }
76
+ exports.BillingReadsResource = BillingReadsResource;
77
+ /**
78
+ * The ledger writes, on the service client only. Every write policy on `billing_transactions`
79
+ * and `billing_events` is `false` for `authenticated` — the ledger is written by the billing
80
+ * service and by webhooks, never by a caller — so these are deliberately not reachable from
81
+ * `SupabaseClient`.
82
+ */
83
+ class BillingResource extends BillingReadsResource {
84
+ transactions;
85
+ constructor(supabase, actor, audit) {
86
+ super(supabase, actor);
87
+ this.transactions = (0, audit_1.auditedTable)(supabase, actor, audit, BILLING_TRANSACTIONS_TABLE);
88
+ }
89
+ async createTransaction(payload) {
90
+ const row = await this.transactions.insert(payload);
91
+ return row;
92
+ }
93
+ async updateTransaction(transactionId, patch) {
94
+ return this.transactions.update(transactionId, {
95
+ ...patch,
96
+ updated_at: new Date().toISOString(),
97
+ });
98
+ }
99
+ /**
100
+ * Claims a transaction for processing, but only while it is not already paid. This is the
101
+ * send-exactly-once gate on the webhook path: a redelivered `charge.success` must not settle
102
+ * the same row twice. Resolves to null when the guard finds it already settled.
103
+ */
104
+ async claimTransactionForProcessing(transactionId, patch) {
105
+ return this.transactions.updateWhere(transactionId, (query) => query.neq('transaction_status', enum_2.BillingTransactionStatus.PAID), { ...patch, updated_at: new Date().toISOString() });
106
+ }
107
+ /**
108
+ * Appends to `billing_events`. Deliberately unaudited: the table *is* an append-only
109
+ * narrative of the billing state machine, so an audit row per event would log the log.
110
+ */
111
+ async recordEvent(event) {
112
+ const { error } = await this.supabase.from('billing_events').insert(event);
113
+ if (error)
114
+ throw (0, errors_1.mapPostgrestError)(error);
115
+ }
116
+ }
114
117
  exports.BillingResource = BillingResource;
115
118
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../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,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,IAAI,KAAK;YAAE,MAAM,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AA7CD,0CA6CC"}
package/dist/client.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { type SupabaseClient as SupabaseJsClient } from '@supabase/supabase-js';
1
+ import type { SupabaseClient as SupabaseJsClient } from '@supabase/supabase-js';
2
2
  import { type AuthContext } from './auth';
3
3
  import { AuditResource, type AuditErrorHandler } from './audit';
4
4
  import { AdditionalDetailsResource } from './additional-details';
5
5
  import { ClientsResource } from './clients';
6
6
  import { NotesResource } from './notes';
7
7
  import { NotificationsResource } from './notifications';
8
+ import { BillingReadsResource } from './billing';
8
9
  import { OrganizationsResource } from './organizations';
9
10
  import { PermissionsResource } from './permissions';
10
11
  import { ProjectsResource } from './projects';
@@ -17,9 +18,24 @@ export type SupabaseClientConfig = {
17
18
  url: string;
18
19
  key: string;
19
20
  accessToken: string;
21
+ /**
22
+ * Who the request runs as. The caller must already have **verified** the token this came from
23
+ * (`verifyAccessToken`) — the client trusts this outright and scopes every query to it.
24
+ */
25
+ auth: AuthContext;
20
26
  /** Where a failed audit insert is reported. Defaults to `console.error`. */
21
27
  onAuditError?: AuditErrorHandler;
28
+ /**
29
+ * A raw client already built for this url/key/token — what `verifyAccessToken` was handed, so
30
+ * one request builds one supabase-js client. Defaults to building its own.
31
+ */
32
+ client?: TypedSupabaseClient;
22
33
  };
34
+ /**
35
+ * The caller's data client: every query carries their bearer token, so RLS decides what they
36
+ * may see. It performs no authentication of its own — build it from a `VerifiedAuth`, never from
37
+ * a token you have only decoded.
38
+ */
23
39
  export declare class SupabaseClient {
24
40
  readonly supabase: TypedSupabaseClient;
25
41
  readonly auth: AuthContext;
@@ -28,6 +44,7 @@ export declare class SupabaseClient {
28
44
  readonly additionalDetails: AdditionalDetailsResource;
29
45
  readonly notes: NotesResource;
30
46
  readonly notifications: NotificationsResource;
47
+ readonly billing: BillingReadsResource;
31
48
  readonly organizations: OrganizationsResource;
32
49
  readonly permissions: PermissionsResource;
33
50
  readonly users: UsersResource;
package/dist/client.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSupabaseClient = exports.SupabaseClient = void 0;
4
- const supabase_js_1 = require("@supabase/supabase-js");
5
4
  const auth_1 = require("./auth");
6
5
  const audit_1 = require("./audit");
7
6
  const additional_details_1 = require("./additional-details");
8
7
  const clients_1 = require("./clients");
9
8
  const notes_1 = require("./notes");
10
9
  const notifications_1 = require("./notifications");
10
+ const billing_1 = require("./billing");
11
11
  const organizations_1 = require("./organizations");
12
12
  const permissions_1 = require("./permissions");
13
13
  const projects_1 = require("./projects");
@@ -15,6 +15,11 @@ const statuses_1 = require("./statuses");
15
15
  const supporting_files_1 = require("./supporting-files");
16
16
  const tasks_1 = require("./tasks");
17
17
  const users_1 = require("./users");
18
+ /**
19
+ * The caller's data client: every query carries their bearer token, so RLS decides what they
20
+ * may see. It performs no authentication of its own — build it from a `VerifiedAuth`, never from
21
+ * a token you have only decoded.
22
+ */
18
23
  class SupabaseClient {
19
24
  supabase; // escape hatch for not-yet-migrated queries
20
25
  auth;
@@ -23,6 +28,7 @@ class SupabaseClient {
23
28
  additionalDetails;
24
29
  notes;
25
30
  notifications;
31
+ billing;
26
32
  organizations;
27
33
  permissions;
28
34
  users;
@@ -31,17 +37,16 @@ class SupabaseClient {
31
37
  projects;
32
38
  tasks;
33
39
  constructor(config) {
34
- this.auth = (0, auth_1.decodeAuthContext)(config.accessToken);
35
- this.supabase = (0, supabase_js_1.createClient)(config.url, config.key, {
36
- global: { headers: { Authorization: `Bearer ${config.accessToken}` } },
37
- auth: { persistSession: false, autoRefreshToken: false },
38
- });
40
+ this.auth = config.auth;
41
+ this.supabase =
42
+ config.client ?? (0, auth_1.createRawClient)(config.url, config.key, config.accessToken);
39
43
  // Built before the resources: every write they make goes through it.
40
44
  this.audit = new audit_1.AuditResource(this.supabase, this.auth, config.onAuditError);
41
45
  this.statuses = new statuses_1.StatusesResource(this.supabase, this.auth, this.audit);
42
46
  this.additionalDetails = new additional_details_1.AdditionalDetailsResource(this.supabase, this.auth, this.audit);
43
47
  this.notes = new notes_1.NotesResource(this.supabase, this.auth, this.audit);
44
48
  this.notifications = new notifications_1.NotificationsResource(this.supabase, this.auth, this.audit);
49
+ this.billing = new billing_1.BillingReadsResource(this.supabase, this.auth);
45
50
  this.organizations = new organizations_1.OrganizationsResource(this.supabase, this.auth, this.audit);
46
51
  this.permissions = new permissions_1.PermissionsResource(this.supabase, this.auth, this.audit);
47
52
  this.users = new users_1.UsersResource(this.supabase, this.auth, this.audit);
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,uDAA8F;AAC9F,iCAA6D;AAC7D,mCAAgE;AAChE,6DAAiE;AACjE,uCAA4C;AAC5C,mCAAwC;AACxC,mDAAwD;AACxD,mDAAwD;AACxD,+CAAoD;AACpD,yCAA8C;AAC9C,yCAA8C;AAC9C,yDAA6D;AAC7D,mCAAwC;AACxC,mCAAwC;AAexC,MAAa,cAAc;IAChB,QAAQ,CAAsB,CAAC,4CAA4C;IAC3E,IAAI,CAAc;IAClB,KAAK,CAAgB;IACrB,QAAQ,CAAmB;IAC3B,iBAAiB,CAA4B;IAC7C,KAAK,CAAgB;IACrB,aAAa,CAAwB;IACrC,aAAa,CAAwB;IACrC,WAAW,CAAsB;IACjC,KAAK,CAAgB;IACrB,eAAe,CAA0B;IACzC,OAAO,CAAkB;IACzB,QAAQ,CAAmB;IAC3B,KAAK,CAAgB;IAE9B,YAAY,MAA4B;QACtC,IAAI,CAAC,IAAI,GAAG,IAAA,wBAAiB,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAA,0BAAY,EAAC,MAAM,CAAC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K,CAAC,CAAC;QACrF,IAAI,CAAC,WAAW,GAAG,IAAI,iCAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACrE,IAAI,CAAC,eAAe,GAAG,IAAI,0CAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;CACF;AApCD,wCAoCC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAA4B,EAAkB,EAAE,CACnF,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AADhB,QAAA,oBAAoB,wBACJ"}
@@ -18,6 +18,7 @@ exports.ClientsResource = void 0;
18
18
  const enum_1 = require("@managemint-solutions/entities/audit-trail/enum");
19
19
  const audit_1 = require("../audit");
20
20
  const errors_1 = require("../errors");
21
+ const transforms_1 = require("../transforms");
21
22
  __exportStar(require("./dto"), exports);
22
23
  // The public contract is the shared ClientSummary / ClientEntity from
23
24
  // @managemint-solutions/entities; the casts at the returns declare the shape the select strings
@@ -48,54 +49,18 @@ const CLIENT_DETAIL_SELECT = `
48
49
  contract_client,
49
50
  contracted_hours,
50
51
  updated_at,
51
- last_updated_by:user_profiles!last_updated_by (
52
- mms_id,
53
- name,
54
- surname,
55
- email,
56
- profile_image
57
- ),
58
- created_by:user_profiles!created_by (
59
- mms_id,
60
- name,
61
- surname,
62
- email,
63
- profile_image
64
- ),
52
+ last_updated_by:user_profiles!last_updated_by ${transforms_1.USER_PROFILE_EMBED},
53
+ created_by:user_profiles!created_by ${transforms_1.USER_PROFILE_EMBED},
65
54
  archived,
66
55
  archived_at,
67
- archived_by:user_profiles!archived_by (
68
- mms_id,
69
- name,
70
- surname,
71
- email,
72
- profile_image
73
- ),
56
+ archived_by:user_profiles!archived_by ${transforms_1.USER_PROFILE_EMBED},
74
57
  unarchived_at,
75
- unarchived_by:user_profiles!unarchived_by (
76
- mms_id,
77
- name,
78
- surname,
79
- email,
80
- profile_image
81
- ),
58
+ unarchived_by:user_profiles!unarchived_by ${transforms_1.USER_PROFILE_EMBED},
82
59
  deleted,
83
60
  deleted_at,
84
- deleted_by:user_profiles!deleted_by (
85
- mms_id,
86
- name,
87
- surname,
88
- email,
89
- profile_image
90
- ),
61
+ deleted_by:user_profiles!deleted_by ${transforms_1.USER_PROFILE_EMBED},
91
62
  restored_at,
92
- restored_by:user_profiles!restored_by (
93
- mms_id,
94
- name,
95
- surname,
96
- email,
97
- profile_image
98
- )
63
+ restored_by:user_profiles!restored_by ${transforms_1.USER_PROFILE_EMBED}
99
64
  `;
100
65
  class ClientsResource {
101
66
  supabase;
@@ -125,8 +90,7 @@ class ClientsResource {
125
90
  .order('created_at', { ascending: false })
126
91
  .range(offset, offset + pageSize - 1);
127
92
  if (trimmedSearch) {
128
- const escapedSearch = trimmedSearch.replace(/,/g, '\\,');
129
- clientsQuery = clientsQuery.or(`name.ilike.%${escapedSearch}%,email.ilike.%${escapedSearch}%`);
93
+ clientsQuery = clientsQuery.or((0, transforms_1.orIlike)(['name', 'email'], trimmedSearch));
130
94
  }
131
95
  if (query.created_after) {
132
96
  clientsQuery = clientsQuery.gte('created_at', query.created_after);
@@ -140,17 +104,7 @@ class ClientsResource {
140
104
  const { data, error, count } = await clientsQuery;
141
105
  if (error)
142
106
  throw (0, errors_1.mapPostgrestError)(error);
143
- const totalEstimated = count ?? 0;
144
- const totalPages = totalEstimated > 0 ? Math.ceil(totalEstimated / pageSize) : 0;
145
- return {
146
- results: (data ?? []),
147
- page,
148
- per_page: pageSize,
149
- count: totalEstimated,
150
- total_pages: totalPages,
151
- has_next_page: page < totalPages,
152
- has_previous_page: page > 1,
153
- };
107
+ return (0, transforms_1.toMmsList)(data, page, pageSize, count);
154
108
  }
155
109
  async getById(clientId) {
156
110
  const { data, error } = await this.supabase
@@ -193,36 +147,20 @@ class ClientsResource {
193
147
  return this.getById(clientId);
194
148
  }
195
149
  async archive(clientId) {
196
- await this.table.transition(clientId, enum_1.AuditTrailAction.ARCHIVE, {
197
- archived: true,
198
- archived_at: new Date().toISOString(),
199
- archived_by: this.auth.mms_id,
200
- });
150
+ await this.table.transition(clientId, enum_1.AuditTrailAction.ARCHIVE, (0, transforms_1.archivedPatch)(this.auth.mms_id));
201
151
  return this.getById(clientId);
202
152
  }
203
153
  async unarchive(clientId) {
204
- await this.table.transition(clientId, enum_1.AuditTrailAction.UNARCHIVE, {
205
- archived: false,
206
- unarchived_at: new Date().toISOString(),
207
- unarchived_by: this.auth.mms_id,
208
- });
154
+ await this.table.transition(clientId, enum_1.AuditTrailAction.UNARCHIVE, (0, transforms_1.unarchivedPatch)(this.auth.mms_id));
209
155
  return this.getById(clientId);
210
156
  }
211
157
  async restore(clientId) {
212
- await this.table.transition(clientId, enum_1.AuditTrailAction.RESTORE, {
213
- deleted: false,
214
- restored_at: new Date().toISOString(),
215
- restored_by: this.auth.mms_id,
216
- });
158
+ await this.table.transition(clientId, enum_1.AuditTrailAction.RESTORE, (0, transforms_1.restoredPatch)(this.auth.mms_id));
217
159
  return this.getById(clientId);
218
160
  }
219
161
  /** Soft delete — the row stays, flagged `deleted`, and `restore()` brings it back. */
220
162
  async remove(clientId) {
221
- await this.table.transition(clientId, enum_1.AuditTrailAction.DELETE, {
222
- deleted: true,
223
- deleted_at: new Date().toISOString(),
224
- deleted_by: this.auth.mms_id,
225
- });
163
+ await this.table.transition(clientId, enum_1.AuditTrailAction.DELETE, (0, transforms_1.deletedPatch)(this.auth.mms_id));
226
164
  }
227
165
  }
228
166
  exports.ClientsResource = ClientsResource;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,0EAGyD;AAEzD,oCAA+E;AAE/E,sCAA8C;AAG9C,wCAAsB;AAEtB,sEAAsE;AACtE,gGAAgG;AAChG,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG;;;;;;;;;;;OAWX,CAAC;AAEjB,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8Db,CAAC;AAEjB,MAAa,eAAe;IAIP;IACA;IAJF,KAAK,CAAe;IAErC,YACmB,QAA6B,EAC7B,IAAiB,EAClC,KAAoB;QAFH,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,SAAI,GAAJ,IAAI,CAAa;QAGlC,IAAI,CAAC,KAAK,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;YAC/C,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,2BAAoB,CAAC,OAAO;SACzC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAoB;QAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;QACrC,MAAM,aAAa,GAAG,KAAK,CAAC,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,IAAI,CAAC,MAAM,CAAC,CAClC,CAAC;QAEF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC5B,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,uBAAgB,CAAC,OAAO,EAAE,IAAA,0BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjG,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,sFAAsF;IACtF,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,uBAAgB,CAAC,MAAM,EAAE,IAAA,yBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACjG,CAAC;CACF;AA7HD,0CA6HC"}
package/dist/errors.d.ts CHANGED
@@ -26,7 +26,10 @@ export declare class SupabaseClientError extends Error {
26
26
  message: string;
27
27
  };
28
28
  }
29
- /** Converts a raw Postgrest error into the SupabaseClientError the SDK throws. */
29
+ /**
30
+ * Converts a raw Postgrest error into the SupabaseClientError the SDK throws. The message is
31
+ * Postgrest's own — RLS denials say what the policy said, and nothing rewrites it.
32
+ */
30
33
  export declare const mapPostgrestError: (error: PostgrestError) => SupabaseClientError;
31
34
  /**
32
35
  * Converts a Supabase Storage error into the SupabaseClientError the SDK throws. `StorageError`
package/dist/errors.js CHANGED
@@ -61,71 +61,20 @@ const POSTGREST_CODE_TO_HTTP_STATUS = {
61
61
  PGRST302: 401,
62
62
  // Group X - Internal
63
63
  PGRSTX00: 500,
64
- // RLS / raised by is_authenticated_and_authorized()
64
+ // Not PGRST* codes: an RLS denial, and the bare HTTP statuses PostgREST reports for some
65
+ // failures.
65
66
  42501: 401,
66
67
  404: 404,
67
68
  400: 400,
68
69
  };
69
- const DETAILS_MESSAGES = {
70
- 'The result contains 0 rows': 'No records found matching the query.',
71
- };
72
- // Raised by public.is_authenticated_and_authorized(): "Unauthorized: Missing required
73
- // permission <slug>" / "Unauthorized: Module required <module>". New permissions and
74
- // modules must be added here to get a readable client message.
75
- const PERMISSION_MESSAGES = {
76
- create_client: '(Clients - Create)',
77
- read_client: '(Clients - Read)',
78
- update_client: '(Clients - Update)',
79
- delete_client: '(Clients - Delete)',
80
- read_organizations: '(Organization - Read)',
81
- create_users: '(Users - Create)',
82
- read_users: '(Users - Read)',
83
- update_users: '(Users - Update)',
84
- delete_users: '(Users - Delete)',
85
- read_user_permissions: '(User Permissions - Read)',
86
- update_user_permissions: '(User Permissions - Update)',
87
- create_clients: '(Clients - Create)',
88
- read_clients: '(Clients - Read)',
89
- update_clients: '(Clients - Update)',
90
- delete_clients: '(Clients - Delete)',
91
- create_projects: '(Projects - Create)',
92
- read_projects: '(Projects - Read)',
93
- update_projects: '(Projects - Update)',
94
- delete_projects: '(Projects - Delete)',
95
- create_budgets: '(Budgets - Create)',
96
- read_budgets: '(Budgets - Read)',
97
- update_budgets: '(Budgets - Update)',
98
- delete_budgets: '(Budgets - Delete)',
99
- create_tasks: '(Tasks - Create)',
100
- read_tasks: '(Tasks - Read)',
101
- update_tasks: '(Tasks - Update)',
102
- delete_tasks: '(Tasks - Delete)',
103
- read_notifications: '(Notifications - Read)',
104
- create_notifications: '(Notifications - Create)',
105
- update_notifications: '(Notifications - Update)',
106
- delete_notifications: '(Notifications - Delete)',
107
- create_payments: '(Payments - Create)',
108
- update_subscriptions: '(Subscriptions - Update)',
109
- };
110
- const MODULE_MESSAGES = {
111
- client: '(CRM)',
112
- };
113
- const PERMISSION_PREFIX = 'Unauthorized: Missing required permission ';
114
- const MODULE_PREFIX = 'Unauthorized: Module required ';
115
- const readableMessage = (details, message) => {
116
- if (message.includes(PERMISSION_PREFIX)) {
117
- return PERMISSION_PREFIX + (PERMISSION_MESSAGES[message.split(PERMISSION_PREFIX)[1]] || '');
118
- }
119
- if (message.includes(MODULE_PREFIX)) {
120
- return MODULE_PREFIX + (MODULE_MESSAGES[message.split(MODULE_PREFIX)[1]] || '');
121
- }
122
- return DETAILS_MESSAGES[details] || message;
123
- };
124
- /** Converts a raw Postgrest error into the SupabaseClientError the SDK throws. */
70
+ /**
71
+ * Converts a raw Postgrest error into the SupabaseClientError the SDK throws. The message is
72
+ * Postgrest's own — RLS denials say what the policy said, and nothing rewrites it.
73
+ */
125
74
  const mapPostgrestError = (error) => new SupabaseClientError({
126
75
  status: POSTGREST_CODE_TO_HTTP_STATUS[error.code] || 500,
127
76
  error: 'Database Error',
128
- message: readableMessage(error.details, error.message),
77
+ message: error.message,
129
78
  code: error.code,
130
79
  }, { cause: error });
131
80
  exports.mapPostgrestError = mapPostgrestError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAcA;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAS;IACf,KAAK,CAAS;IACd,IAAI,CAAU;IAEvB,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAA2B,EAAE,OAA6B;QAClG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,UAAU;QACR,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC;CACF;AAhBD,kDAgBC;AAED,MAAM,6BAA6B,GAA2B;IAC5D,uBAAuB;IACvB,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,G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AA,YAAY,gBAQrB"}
package/dist/index.d.ts CHANGED
@@ -1,22 +1,48 @@
1
- export * from './client';
2
- export * from './auth';
3
- export * from './auth-client';
4
- export * from './service-client';
5
- export * from './errors';
6
- export * from './validators';
7
- export * from './transforms';
8
- export * from './audit';
9
- export * from './billing';
10
- export * from './statuses';
11
- export * from './additional-details';
12
- export * from './notes';
13
- export * from './notifications';
14
- export * from './organizations';
15
- export * from './permissions';
16
- export * from './users';
17
- export * from './webhook-events';
18
- export * from './supporting-files';
19
- export * from './clients';
20
- export * from './projects';
21
- export * from './tasks';
22
- export * from './pricebooks';
1
+ export { SupabaseClient, createSupabaseClient } from './client';
2
+ export type { SupabaseClientConfig, TypedSupabaseClient } from './client';
3
+ export { verifyAccessToken } from './auth';
4
+ export type { AuthContext, VerifiedAuth, VerifyAccessTokenConfig } from './auth';
5
+ export { SupabaseAuthClient, createSupabaseAuthClient } from './auth-client';
6
+ export type { SupabaseAuthClientConfig } from './auth-client';
7
+ export { ExchangeRefreshTokenDto, ExchangeTokenHashDto, ResetPasswordDto, SendPasswordResetEmailDto, SignInDto, } from './auth-client';
8
+ export { SupabaseServiceClient, SupabaseOrganizationScope, createSupabaseServiceClient, } from './service-client';
9
+ export type { SupabaseServiceClientConfig } from './service-client';
10
+ export { SupabaseClientError } from './errors';
11
+ export type { SupabaseClientErrorInit } from './errors';
12
+ export { IsNullable } from './validators';
13
+ export { AuditResource } from './audit';
14
+ export type { AuditActor, AuditChanges, AuditEntry, AuditErrorHandler, AuditGuard, AuditRow, AuditedTable, AuditedTableOptions, } from './audit';
15
+ export { GetAuditTrailDto } from './audit';
16
+ export { BillingReadsResource, BillingResource } from './billing';
17
+ export { CancelSubscriptionDto, InitialPaymentDto, PurchaseModuleDto, ReinstateSubscriptionDto, } from './billing';
18
+ export { StatusesResource } from './statuses';
19
+ export { AddStatusDto, GetStatusesDto, StatusIdDto, UpdateStatusDto } from './statuses';
20
+ export { AdditionalDetailsResource } from './additional-details';
21
+ export { AddAdditionalDetailsDto, AdditionalDetailsIdDto, GetAdditionalDetailsDto, IsAdditionalDetailsValueByType, UpdateAdditionalDetailsDto, } from './additional-details';
22
+ export { NotesResource } from './notes';
23
+ export { AddNoteDto, GetNotesDto, NoteIdDto } from './notes';
24
+ export { NotificationsResource, NotificationsOutboxResource } from './notifications';
25
+ export type { CreateNotificationInput, CreatedNotification, NotificationContentRow, OrganizationTableFactory, QueuedNotification, } from './notifications';
26
+ export { GetNotificationsDto, NotificationIdDto } from './notifications';
27
+ export { OrganizationInvitesResource } from './organization-invites';
28
+ export type { OrganizationInvite } from './organization-invites';
29
+ export { OrganizationsResource, OrganizationSignupResource } from './organizations';
30
+ export type { CreateOrganizationRow, OrganizationRow } from './organizations';
31
+ export { CreateOrganizationDto, UpdateOrganizationDto } from './organizations';
32
+ export { PermissionsResource } from './permissions';
33
+ export type { PermissionFlags } from './permissions';
34
+ export { UpdatePermissionsDto } from './permissions';
35
+ export { UsersResource } from './users';
36
+ export type { UserRow } from './users';
37
+ export { AddUserDto, GetUsersQueryDto, UpdateUserDto, UserIdDto } from './users';
38
+ export { WebhookEventsResource } from './webhook-events';
39
+ export type { ClaimOutcome, WebhookEventRow, WebhookEventsTable } from './webhook-events';
40
+ export { SupportingFilesResource } from './supporting-files';
41
+ export { GetSupportingFilesDto, SupportingFileIdDto } from './supporting-files';
42
+ export { ClientsResource } from './clients';
43
+ export { ClientIdDto, CreateClientDto, GetClientsDto, UpdateClientDto } from './clients';
44
+ export { ProjectsResource } from './projects';
45
+ export { CreateProjectDto, GetProjectsDto, ProjectIdDto, UpdateProjectDto } from './projects';
46
+ export { TasksResource } from './tasks';
47
+ export { CreateTaskDto, GetTasksDto, TaskIdDto, UpdateTaskDto } from './tasks';
48
+ export { PricebooksResource, monthlyTotalMinor } from './pricebooks';