@managemint-solutions/sdk 0.4.0 → 0.6.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 +102 -6
- package/dist/additional-details/dto.d.ts +2 -5
- package/dist/additional-details/dto.js +2 -0
- package/dist/additional-details/dto.js.map +1 -1
- package/dist/additional-details/index.js +5 -6
- package/dist/additional-details/index.js.map +1 -1
- package/dist/additional-details/values.d.ts +2 -2
- package/dist/additional-details/values.js +2 -2
- package/dist/client.d.ts +7 -2
- package/dist/client.js +9 -0
- package/dist/client.js.map +1 -1
- package/dist/clients/dto.d.ts +30 -0
- package/dist/clients/dto.js +181 -0
- package/dist/clients/dto.js.map +1 -0
- package/dist/clients/index.d.ts +20 -0
- package/dist/clients/index.js +266 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/notes/dto.d.ts +1 -4
- package/dist/notes/dto.js +2 -0
- package/dist/notes/dto.js.map +1 -1
- package/dist/notes/index.js +3 -5
- package/dist/notes/index.js.map +1 -1
- package/dist/projects/dto.d.ts +38 -0
- package/dist/projects/dto.js +238 -0
- package/dist/projects/dto.js.map +1 -0
- package/dist/projects/index.d.ts +20 -0
- package/dist/projects/index.js +299 -0
- package/dist/projects/index.js.map +1 -0
- package/dist/statuses/dto.d.ts +2 -5
- package/dist/statuses/dto.js +2 -0
- package/dist/statuses/dto.js.map +1 -1
- package/dist/statuses/index.js +3 -4
- package/dist/statuses/index.js.map +1 -1
- package/dist/supporting-files/index.js +3 -3
- package/dist/supporting-files/index.js.map +1 -1
- package/dist/tasks/dto.d.ts +43 -0
- package/dist/tasks/dto.js +288 -0
- package/dist/tasks/dto.js.map +1 -0
- package/dist/tasks/index.d.ts +20 -0
- package/dist/tasks/index.js +241 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/transforms.d.ts +14 -0
- package/dist/transforms.js +38 -0
- package/dist/transforms.js.map +1 -0
- package/dist/validators.d.ts +2 -0
- package/dist/validators.js +8 -0
- package/dist/validators.js.map +1 -0
- package/package.json +1 -1
- package/dist/database.types.d.ts +0 -2570
- package/dist/database.types.js +0 -12
- package/dist/database.types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ManageMint Solutions SDK
|
|
2
2
|
|
|
3
|
-
Typed Supabase data-access SDK for ManageMint Solutions. Query logic
|
|
4
|
-
|
|
3
|
+
Typed Supabase data-access SDK for ManageMint Solutions. Query logic lives here; consumers
|
|
4
|
+
(api, portal) get responses typed as the shared `@managemint-solutions/entities` types with no casts.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -13,7 +13,9 @@ npm install @managemint-solutions/sdk @supabase/supabase-js
|
|
|
13
13
|
are peer dependencies — the request DTOs (`AddStatusDto`, `UpdateStatusDto`, `StatusIdDto`,
|
|
14
14
|
`GetStatusesDto`, `AddAdditionalDetailsDto`, `UpdateAdditionalDetailsDto`,
|
|
15
15
|
`AdditionalDetailsIdDto`, `GetAdditionalDetailsDto`, `AddNoteDto`, `NoteIdDto`,
|
|
16
|
-
`GetNotesDto`, `SupportingFileIdDto`, `GetSupportingFilesDto`
|
|
16
|
+
`GetNotesDto`, `SupportingFileIdDto`, `GetSupportingFilesDto`, `GetClientsDto`, `ClientIdDto`,
|
|
17
|
+
`CreateClientDto`, `UpdateClientDto`, `GetProjectsDto`, `ProjectIdDto`, `CreateProjectDto`,
|
|
18
|
+
`UpdateProjectDto`, `GetTasksDto`, `TaskIdDto`, `CreateTaskDto`, `UpdateTaskDto`) ship with their class-validator
|
|
17
19
|
decorators so consumers validate against
|
|
18
20
|
the same rules the SDK's input types describe. `@nestjs/common` (^11) is an optional peer
|
|
19
21
|
dependency, needed only for the `@managemint-solutions/sdk/nest` subpath.
|
|
@@ -96,8 +98,102 @@ await supabase.supportingFiles.remove(files[0].mms_id); // deletes the row and t
|
|
|
96
98
|
Uploads run in batches of 5 and upsert, so re-uploading a file refreshes the object without
|
|
97
99
|
adding a second row; `upload` returns the entity's full file list.
|
|
98
100
|
|
|
101
|
+
```ts
|
|
102
|
+
// Clients are paginated; the query DTO's page/page_size default to 1/10.
|
|
103
|
+
const page = await supabase.clients.list({ page: 1, page_size: 10, archive: false });
|
|
104
|
+
// → { results, page, per_page, count, total_pages, has_next_page, has_previous_page }
|
|
105
|
+
// `search` matches name/email, `created_after`/`created_before` bound created_at, and
|
|
106
|
+
// `status_id_in` filters by status.
|
|
107
|
+
|
|
108
|
+
const client = await supabase.clients.create({
|
|
109
|
+
name: 'Acme',
|
|
110
|
+
email: 'hello@acme.test',
|
|
111
|
+
phone: '0123456789',
|
|
112
|
+
status_id: statusId,
|
|
113
|
+
contract_client: true,
|
|
114
|
+
contracted_hours: 40,
|
|
115
|
+
});
|
|
116
|
+
await supabase.clients.getById(client.mms_id);
|
|
117
|
+
await supabase.clients.update(client.mms_id, { ...client, name: 'Acme Ltd' });
|
|
118
|
+
await supabase.clients.archive(client.mms_id); // archived + archived_at/by
|
|
119
|
+
await supabase.clients.unarchive(client.mms_id); // archived = false + unarchived_at/by
|
|
120
|
+
await supabase.clients.remove(client.mms_id); // soft delete — deleted + deleted_at/by
|
|
121
|
+
await supabase.clients.restore(client.mms_id); // deleted = false + restored_at/by
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`getById` on a soft-deleted client returns the audit trail with the details blanked (name,
|
|
125
|
+
email and phone empty, no status, `contract_client` false, `contracted_hours` 0). Every write
|
|
126
|
+
except `remove` re-reads and returns the full record afterwards.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
// Projects are paginated the same way, with extra date-range and client filters.
|
|
130
|
+
const page = await supabase.projects.list({
|
|
131
|
+
page: 1,
|
|
132
|
+
page_size: 10,
|
|
133
|
+
archive: false,
|
|
134
|
+
client_id: clientId, // a UUID, or the base64-JSON option value a select sends
|
|
135
|
+
});
|
|
136
|
+
// `search` matches name/specification; `created_*`, `start_date_*` and `end_date_*` bound the
|
|
137
|
+
// date columns, and `status_id_in` filters by status.
|
|
138
|
+
|
|
139
|
+
const project = await supabase.projects.create({
|
|
140
|
+
name: 'Website rebuild',
|
|
141
|
+
specification: 'Rebuild the marketing site',
|
|
142
|
+
start_date: '2026-04-22',
|
|
143
|
+
end_date: '2026-06-30',
|
|
144
|
+
has_budget: true,
|
|
145
|
+
status_id: statusId,
|
|
146
|
+
client_id: clientId,
|
|
147
|
+
manager_id: userId,
|
|
148
|
+
});
|
|
149
|
+
await supabase.projects.getById(project.mms_id);
|
|
150
|
+
await supabase.projects.update(project.mms_id, { ...project, name: 'Website rebuild v2' });
|
|
151
|
+
await supabase.projects.archive(project.mms_id);
|
|
152
|
+
await supabase.projects.unarchive(project.mms_id);
|
|
153
|
+
await supabase.projects.remove(project.mms_id); // soft delete
|
|
154
|
+
await supabase.projects.restore(project.mms_id);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Each project carries its embedded `status`, `manager` and `client`; `getById` on a soft-deleted
|
|
158
|
+
project returns the creation audit with the rest blanked (empty name, no specification, dates,
|
|
159
|
+
status, manager or client).
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// Tasks are paginated too, ordered by priority then newest first.
|
|
163
|
+
const page = await supabase.tasks.list({
|
|
164
|
+
page: 1,
|
|
165
|
+
page_size: 10,
|
|
166
|
+
archive: false,
|
|
167
|
+
project_id: projectId,
|
|
168
|
+
priority_in: [1, 3],
|
|
169
|
+
});
|
|
170
|
+
// `search` matches name/description, and `client_id`, `assigned_to_id`, the date ranges and
|
|
171
|
+
// `status_id_in` narrow it further.
|
|
172
|
+
|
|
173
|
+
const task = await supabase.tasks.create({
|
|
174
|
+
name: 'Draft the proposal',
|
|
175
|
+
description: 'Write the first pass and circulate it',
|
|
176
|
+
start_date: '2026-04-22',
|
|
177
|
+
end_date: '2026-04-30',
|
|
178
|
+
status_id: statusId,
|
|
179
|
+
priority: 2,
|
|
180
|
+
assigned_to_id: userId,
|
|
181
|
+
project_id: projectId,
|
|
182
|
+
client_id: clientId,
|
|
183
|
+
});
|
|
184
|
+
await supabase.tasks.getById(task.mms_id);
|
|
185
|
+
await supabase.tasks.update(task.mms_id, { ...task, priority: 3 });
|
|
186
|
+
await supabase.tasks.archive(task.mms_id);
|
|
187
|
+
await supabase.tasks.unarchive(task.mms_id);
|
|
188
|
+
await supabase.tasks.remove(task.mms_id); // soft delete
|
|
189
|
+
await supabase.tasks.restore(task.mms_id);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
A task's `task_id` (its per-organization number) is assigned by the database on insert, and each
|
|
193
|
+
task carries its embedded `status`, `assigned_to`, `project` and `client`.
|
|
194
|
+
|
|
99
195
|
The client decodes `{ mms_id, organization_id }` from the JWT itself and scopes every query
|
|
100
|
-
by `organization_id`. `supabase.supabase` is the raw
|
|
196
|
+
by `organization_id`. `supabase.supabase` is the raw `@supabase/supabase-js` client
|
|
101
197
|
(`TypedSupabaseClient`) — the escape hatch for queries not yet covered by a resource.
|
|
102
198
|
|
|
103
199
|
## Errors
|
|
@@ -141,6 +237,6 @@ npm test # jest + ts-jest; specs live in src/<resource>/tests/*.spec.ts
|
|
|
141
237
|
npm run build # tsc -p tsconfig.build.json (excludes specs), CommonJS output in dist/ — the type gate
|
|
142
238
|
```
|
|
143
239
|
|
|
144
|
-
|
|
145
|
-
|
|
240
|
+
The SDK carries no generated database types: the schema of record is the api's
|
|
241
|
+
`supabase/migrations`, and each resource declares the row shape its select string produces.
|
|
146
242
|
Publishing happens on push to `main` via `.github/workflows/release.yml`.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type ValidationOptions } from 'class-validator';
|
|
2
2
|
import type { AddAdditionalDetailsDto as AddAdditionalDetailsDtoType, AdditionalDetailsIdDto as AdditionalDetailsIdDtoType, GetAdditionalDetailsDto as GetAdditionalDetailsDtoType, UpdateAdditionalDetailsDto as UpdateAdditionalDetailsDtoType } from '@managemint-solutions/entities/additional-details/dto';
|
|
3
3
|
import { AdditionalDetailsEntityTypes, AdditionalDetailsTypes } from '@managemint-solutions/entities/additional-details/enum';
|
|
4
|
-
import type { TablesInsert } from '../database.types';
|
|
5
4
|
/** Validates `value` against the sibling `type` property (the discriminator). */
|
|
6
5
|
export declare function IsAdditionalDetailsValueByType(typeProperty: string, validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
7
|
-
type AdditionalDetailsInsertColumns = Required<Pick<TablesInsert<'additional_details'>, 'key' | 'copyable'>>;
|
|
8
6
|
export declare class AdditionalDetailsIdDto implements AdditionalDetailsIdDtoType {
|
|
9
7
|
readonly additionalDetailsId: string;
|
|
10
8
|
}
|
|
@@ -12,16 +10,15 @@ export declare class GetAdditionalDetailsDto implements GetAdditionalDetailsDtoT
|
|
|
12
10
|
readonly entity: AdditionalDetailsEntityTypes;
|
|
13
11
|
readonly entityId: string;
|
|
14
12
|
}
|
|
15
|
-
export declare class AddAdditionalDetailsDto implements AddAdditionalDetailsDtoType
|
|
13
|
+
export declare class AddAdditionalDetailsDto implements AddAdditionalDetailsDtoType {
|
|
16
14
|
readonly key: string;
|
|
17
15
|
readonly value: string | number | boolean | Date | URL;
|
|
18
16
|
readonly type: AdditionalDetailsTypes;
|
|
19
17
|
readonly copyable: boolean;
|
|
20
18
|
}
|
|
21
|
-
export declare class UpdateAdditionalDetailsDto implements UpdateAdditionalDetailsDtoType
|
|
19
|
+
export declare class UpdateAdditionalDetailsDto implements UpdateAdditionalDetailsDtoType {
|
|
22
20
|
readonly key: string;
|
|
23
21
|
readonly value: string | number | boolean;
|
|
24
22
|
readonly type: AdditionalDetailsTypes;
|
|
25
23
|
readonly copyable: boolean;
|
|
26
24
|
}
|
|
27
|
-
export {};
|
|
@@ -66,6 +66,8 @@ function IsAdditionalDetailsValueByType(typeProperty, validationOptions) {
|
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
// class-validator versions of the shared DTO types from @managemint-solutions/entities.
|
|
70
|
+
// Each class `implements` its entities type so the wire contract cannot drift.
|
|
69
71
|
class AdditionalDetailsIdDto {
|
|
70
72
|
additionalDetailsId;
|
|
71
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/additional-details/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/additional-details/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,wEA4DC;AApFD,qDAWyB;AAOzB,iFAGgE;AAEhE,iFAAiF;AACjF,SAAgB,8BAA8B,CAC5C,YAAoB,EACpB,iBAAqC;IAErC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,IAAI,EAAE,gCAAgC;YACtC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY;YACZ,WAAW,EAAE,CAAC,YAAY,CAAC;YAC3B,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACT,QAAQ,CAAC,KAAc,EAAE,IAAyB;oBAChD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;oBACnC,MAAM,YAAY,GAAI,IAAI,CAAC,MAAkC,CAAC,OAAO,CAExD,CAAC;oBAEd,4DAA4D;oBAC5D,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;wBACnF,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBAC1C,OAAO,KAAK,CAAC;oBACf,CAAC;oBAED,QAAQ,YAAY,EAAE,CAAC;wBACrB,KAAK,6BAAsB,CAAC,IAAI;4BAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CA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AChD,IAAA,2BAAS,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC;;uDAC1C;AAIb;IAFR,IAAA,2BAAS,EAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC3C,8BAA8B,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;;yDACnD;AAGlC;IADR,IAAA,wBAAM,EAAC,6BAAsB,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;;wDACxC;AAG9B;IADR,IAAA,2BAAS,EAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;;4DACrB"}
|
|
@@ -19,12 +19,11 @@ const errors_1 = require("../errors");
|
|
|
19
19
|
const values_1 = require("./values");
|
|
20
20
|
__exportStar(require("./dto"), exports);
|
|
21
21
|
__exportStar(require("./values"), exports);
|
|
22
|
-
// The
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// declares the parsed string | number | boolean | Date | URL union that castValueByType produces.
|
|
22
|
+
// The public contract is the shared AdditionalDetailsEntity / AdditionalDetailSummary from
|
|
23
|
+
// @managemint-solutions/entities; the casts at the returns declare the shape the select strings
|
|
24
|
+
// below produce (the columns are defined in the api's supabase/migrations). `value` is a `text`
|
|
25
|
+
// column, and castValueByType turns it into the string | number | boolean | Date | URL union the
|
|
26
|
+
// entity declares.
|
|
28
27
|
const ADDITIONAL_DETAILS_SELECT = 'mms_id, created_at, created_by:user_profiles!created_by(*), updated_at, last_updated_by:user_profiles!last_updated_by(*), key, value, type, copyable';
|
|
29
28
|
const ADDITIONAL_DETAILS_SUMMARY_SELECT = 'mms_id, key, value, type, copyable';
|
|
30
29
|
const withCastValue = (detail) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/additional-details/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAcA,sCAA8C;AA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AAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ;aACxC,IAAI,CAAC,oBAAoB,CAAC;aAC1B,MAAM,CAAC;YACN,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,KAAK,EAAE,IAAA,uBAAc,EAAC,KAAK,CAAC,KAAK,CAAC;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;SAClC,CAAC;aACD,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC;aACjC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aAChD,MAAM,CAAC,yBAAyB,CAAC;aACjC,MAAM,EAAE,CAAC;QACZ,IAAI,KAAK;YAAE,MAAM,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,aAAa,CAAC,IAAI,CAAuC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,mBAA2B;QACtC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ;aAClC,IAAI,CAAC,oBAAoB,CAAC;aAC1B,MAAM,EAAE;aACR,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC;aACjC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpD,IAAI,KAAK;YAAE,MAAM,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AArFD,8DAqFC"}
|
|
@@ -5,7 +5,7 @@ import { AdditionalDetailsTypes } from '@managemint-solutions/entities/additiona
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const castValueByType: (type: AdditionalDetailsTypes, value: unknown) => unknown;
|
|
7
7
|
/**
|
|
8
|
-
* What gets written to the `text` column.
|
|
9
|
-
*
|
|
8
|
+
* What gets written to the `text` column. `String()` reproduces the JSON → text coercion
|
|
9
|
+
* PostgREST used to do for number/boolean/string.
|
|
10
10
|
*/
|
|
11
11
|
export declare const serializeValue: (value: string | number | boolean | Date | URL) => string;
|
|
@@ -29,8 +29,8 @@ const castValueByType = (type, value) => {
|
|
|
29
29
|
};
|
|
30
30
|
exports.castValueByType = castValueByType;
|
|
31
31
|
/**
|
|
32
|
-
* What gets written to the `text` column.
|
|
33
|
-
*
|
|
32
|
+
* What gets written to the `text` column. `String()` reproduces the JSON → text coercion
|
|
33
|
+
* PostgREST used to do for number/boolean/string.
|
|
34
34
|
*/
|
|
35
35
|
const serializeValue = (value) => value instanceof Date ? value.toISOString() : String(value);
|
|
36
36
|
exports.serializeValue = serializeValue;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type SupabaseClient as SupabaseJsClient } from '@supabase/supabase-js';
|
|
2
|
-
import type { Database } from './database.types';
|
|
3
2
|
import { type AuthContext } from './auth';
|
|
4
3
|
import { AdditionalDetailsResource } from './additional-details';
|
|
4
|
+
import { ClientsResource } from './clients';
|
|
5
5
|
import { NotesResource } from './notes';
|
|
6
|
+
import { ProjectsResource } from './projects';
|
|
6
7
|
import { StatusesResource } from './statuses';
|
|
7
8
|
import { SupportingFilesResource } from './supporting-files';
|
|
8
|
-
|
|
9
|
+
import { TasksResource } from './tasks';
|
|
10
|
+
export type TypedSupabaseClient = SupabaseJsClient;
|
|
9
11
|
export type SupabaseClientConfig = {
|
|
10
12
|
url: string;
|
|
11
13
|
key: string;
|
|
@@ -18,6 +20,9 @@ export declare class SupabaseClient {
|
|
|
18
20
|
readonly additionalDetails: AdditionalDetailsResource;
|
|
19
21
|
readonly notes: NotesResource;
|
|
20
22
|
readonly supportingFiles: SupportingFilesResource;
|
|
23
|
+
readonly clients: ClientsResource;
|
|
24
|
+
readonly projects: ProjectsResource;
|
|
25
|
+
readonly tasks: TasksResource;
|
|
21
26
|
constructor(config: SupabaseClientConfig);
|
|
22
27
|
}
|
|
23
28
|
export declare const createSupabaseClient: (config: SupabaseClientConfig) => SupabaseClient;
|
package/dist/client.js
CHANGED
|
@@ -4,9 +4,12 @@ exports.createSupabaseClient = exports.SupabaseClient = void 0;
|
|
|
4
4
|
const supabase_js_1 = require("@supabase/supabase-js");
|
|
5
5
|
const auth_1 = require("./auth");
|
|
6
6
|
const additional_details_1 = require("./additional-details");
|
|
7
|
+
const clients_1 = require("./clients");
|
|
7
8
|
const notes_1 = require("./notes");
|
|
9
|
+
const projects_1 = require("./projects");
|
|
8
10
|
const statuses_1 = require("./statuses");
|
|
9
11
|
const supporting_files_1 = require("./supporting-files");
|
|
12
|
+
const tasks_1 = require("./tasks");
|
|
10
13
|
class SupabaseClient {
|
|
11
14
|
supabase; // escape hatch for not-yet-migrated queries
|
|
12
15
|
auth;
|
|
@@ -14,6 +17,9 @@ class SupabaseClient {
|
|
|
14
17
|
additionalDetails;
|
|
15
18
|
notes;
|
|
16
19
|
supportingFiles;
|
|
20
|
+
clients;
|
|
21
|
+
projects;
|
|
22
|
+
tasks;
|
|
17
23
|
constructor(config) {
|
|
18
24
|
this.auth = (0, auth_1.decodeAuthContext)(config.accessToken);
|
|
19
25
|
this.supabase = (0, supabase_js_1.createClient)(config.url, config.key, {
|
|
@@ -24,6 +30,9 @@ class SupabaseClient {
|
|
|
24
30
|
this.additionalDetails = new additional_details_1.AdditionalDetailsResource(this.supabase, this.auth);
|
|
25
31
|
this.notes = new notes_1.NotesResource(this.supabase, this.auth);
|
|
26
32
|
this.supportingFiles = new supporting_files_1.SupportingFilesResource(this.supabase, this.auth);
|
|
33
|
+
this.clients = new clients_1.ClientsResource(this.supabase, this.auth);
|
|
34
|
+
this.projects = new projects_1.ProjectsResource(this.supabase, this.auth);
|
|
35
|
+
this.tasks = new tasks_1.TasksResource(this.supabase, this.auth);
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
exports.SupabaseClient = SupabaseClient;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,uDAA8F;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,uDAA8F;AAC9F,iCAA6D;AAC7D,6DAAiE;AACjE,uCAA4C;AAC5C,mCAAwC;AACxC,yCAA8C;AAC9C,yCAA8C;AAC9C,yDAA6D;AAC7D,mCAAwC;AAaxC,MAAa,cAAc;IAChB,QAAQ,CAAsB,CAAC,4CAA4C;IAC3E,IAAI,CAAc;IAClB,QAAQ,CAAmB;IAC3B,iBAAiB,CAA4B;IAC7C,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,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;YACnD,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE,EAAE,EAAE;YACtE,IAAI,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE;SACzD,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,iBAAiB,GAAG,IAAI,8CAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,eAAe,GAAG,IAAI,0CAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7E,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;CACF;AAzBD,wCAyBC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAA4B,EAAkB,EAAE,CACnF,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AADhB,QAAA,oBAAoB,wBACJ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UUID } from 'crypto';
|
|
2
|
+
import type { ClientIdDto as ClientIdDtoType, CreateClientDto as CreateClientDtoType, GetClientsDto as GetClientsDtoType, UpdateClientDto as UpdateClientDtoType } from '@managemint-solutions/entities/clients/dto';
|
|
3
|
+
export declare class GetClientsDto implements Omit<GetClientsDtoType, 'status_id_in'> {
|
|
4
|
+
readonly search?: string | null;
|
|
5
|
+
readonly page: number;
|
|
6
|
+
readonly page_size: number;
|
|
7
|
+
readonly created_after?: string | null;
|
|
8
|
+
readonly created_before?: string | null;
|
|
9
|
+
readonly status_id_in?: string[] | null;
|
|
10
|
+
readonly archive: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class ClientIdDto implements ClientIdDtoType {
|
|
13
|
+
readonly clientId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class CreateClientDto implements CreateClientDtoType {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly email: string | null;
|
|
18
|
+
readonly phone: string | null;
|
|
19
|
+
readonly status_id: UUID | null;
|
|
20
|
+
readonly contract_client: boolean;
|
|
21
|
+
readonly contracted_hours: number | null;
|
|
22
|
+
}
|
|
23
|
+
export declare class UpdateClientDto implements UpdateClientDtoType {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly email: string | null;
|
|
26
|
+
readonly phone: string | null;
|
|
27
|
+
readonly status_id: UUID | null;
|
|
28
|
+
readonly contract_client: boolean;
|
|
29
|
+
readonly contracted_hours: number | null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdateClientDto = exports.CreateClientDto = exports.ClientIdDto = exports.GetClientsDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const validators_1 = require("../validators");
|
|
16
|
+
// class-validator versions of the shared DTO types from @managemint-solutions/entities, so the
|
|
17
|
+
// wire contract cannot drift. `status_id` is typed as the entities' `UUID | null` for the same
|
|
18
|
+
// reason; class-validator only sees the runtime string.
|
|
19
|
+
// `status_id_in` is omitted from the implemented type on purpose: the entities type carries the
|
|
20
|
+
// CSV wire value (`string | null`), while this class carries the `@Transform`-parsed
|
|
21
|
+
// `string[] | null` the query builder feeds to `.in('status_id', ...)`.
|
|
22
|
+
class GetClientsDto {
|
|
23
|
+
search;
|
|
24
|
+
page = 1;
|
|
25
|
+
page_size = 10;
|
|
26
|
+
created_after;
|
|
27
|
+
created_before;
|
|
28
|
+
status_id_in;
|
|
29
|
+
archive = false;
|
|
30
|
+
}
|
|
31
|
+
exports.GetClientsDto = GetClientsDto;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
(0, validators_1.IsNullable)(),
|
|
35
|
+
(0, class_validator_1.IsString)({ message: 'Search query must be a string' }),
|
|
36
|
+
(0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
|
|
37
|
+
(0, class_validator_1.MaxLength)(255, { message: 'Search query cannot exceed 255 characters' }),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], GetClientsDto.prototype, "search", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
|
|
43
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
|
|
44
|
+
(0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], GetClientsDto.prototype, "page", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, class_validator_1.IsOptional)(),
|
|
49
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
|
|
50
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
|
|
51
|
+
(0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
|
|
52
|
+
(0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], GetClientsDto.prototype, "page_size", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, class_validator_1.IsOptional)(),
|
|
57
|
+
(0, validators_1.IsNullable)(),
|
|
58
|
+
(0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], GetClientsDto.prototype, "created_after", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, class_validator_1.IsOptional)(),
|
|
63
|
+
(0, validators_1.IsNullable)(),
|
|
64
|
+
(0, class_validator_1.IsDateString)({}, { message: 'End date must be a valid ISO 8601 date string' }),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], GetClientsDto.prototype, "created_before", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, class_validator_1.IsOptional)(),
|
|
69
|
+
(0, validators_1.IsNullable)(),
|
|
70
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? value.split(',').map((id) => id.trim()) : null, { toClassOnly: true }),
|
|
71
|
+
(0, class_validator_1.IsUUID)('4', { each: true, message: 'Each status ID must be a valid UUID v4' }),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], GetClientsDto.prototype, "status_id_in", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, class_validator_1.IsOptional)(),
|
|
76
|
+
(0, validators_1.IsNullable)(),
|
|
77
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? value === 'true' : false, { toClassOnly: true }),
|
|
78
|
+
(0, class_validator_1.IsBoolean)({ message: 'Include archived must be a boolean' }),
|
|
79
|
+
__metadata("design:type", Boolean)
|
|
80
|
+
], GetClientsDto.prototype, "archive", void 0);
|
|
81
|
+
class ClientIdDto {
|
|
82
|
+
clientId;
|
|
83
|
+
}
|
|
84
|
+
exports.ClientIdDto = ClientIdDto;
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid client ID format' }),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], ClientIdDto.prototype, "clientId", void 0);
|
|
89
|
+
class CreateClientDto {
|
|
90
|
+
name;
|
|
91
|
+
email;
|
|
92
|
+
phone;
|
|
93
|
+
status_id;
|
|
94
|
+
contract_client;
|
|
95
|
+
contracted_hours;
|
|
96
|
+
}
|
|
97
|
+
exports.CreateClientDto = CreateClientDto;
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
100
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
101
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
102
|
+
__metadata("design:type", String)
|
|
103
|
+
], CreateClientDto.prototype, "name", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, validators_1.IsNullable)(),
|
|
106
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? value : null, { toClassOnly: true }),
|
|
107
|
+
(0, class_validator_1.ValidateIf)((o) => o.email !== ''),
|
|
108
|
+
(0, class_validator_1.IsEmail)({}, { message: 'Invalid email address' }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], CreateClientDto.prototype, "email", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, validators_1.IsNullable)(),
|
|
113
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? value : null, { toClassOnly: true }),
|
|
114
|
+
(0, class_validator_1.ValidateIf)((o) => o.phone !== ''),
|
|
115
|
+
(0, class_validator_1.IsString)({ message: 'Invalid phone number' }),
|
|
116
|
+
(0, class_validator_1.MinLength)(1, { message: 'Phone number cannot be empty' }),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], CreateClientDto.prototype, "phone", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, validators_1.IsNullable)(),
|
|
121
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid status ID format' }),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], CreateClientDto.prototype, "status_id", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, class_validator_1.IsBoolean)({ message: 'Contract client must be a boolean' }),
|
|
126
|
+
__metadata("design:type", Boolean)
|
|
127
|
+
], CreateClientDto.prototype, "contract_client", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, validators_1.IsNullable)(),
|
|
130
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? Number(value) : null, { toClassOnly: true }),
|
|
131
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Contracted hours must be a number' }),
|
|
132
|
+
(0, class_validator_1.Min)(0, { message: 'Contracted hours must be at least 0' }),
|
|
133
|
+
__metadata("design:type", Object)
|
|
134
|
+
], CreateClientDto.prototype, "contracted_hours", void 0);
|
|
135
|
+
class UpdateClientDto {
|
|
136
|
+
name;
|
|
137
|
+
email;
|
|
138
|
+
phone;
|
|
139
|
+
status_id;
|
|
140
|
+
contract_client;
|
|
141
|
+
contracted_hours;
|
|
142
|
+
}
|
|
143
|
+
exports.UpdateClientDto = UpdateClientDto;
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
146
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
147
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
148
|
+
__metadata("design:type", String)
|
|
149
|
+
], UpdateClientDto.prototype, "name", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, validators_1.IsNullable)(),
|
|
152
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? value : null, { toClassOnly: true }),
|
|
153
|
+
(0, class_validator_1.ValidateIf)((o) => o.email !== ''),
|
|
154
|
+
(0, class_validator_1.IsEmail)({}, { message: 'Invalid email address' }),
|
|
155
|
+
__metadata("design:type", Object)
|
|
156
|
+
], UpdateClientDto.prototype, "email", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
(0, validators_1.IsNullable)(),
|
|
159
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? value : null, { toClassOnly: true }),
|
|
160
|
+
(0, class_validator_1.ValidateIf)((o) => o.phone !== ''),
|
|
161
|
+
(0, class_validator_1.IsString)({ message: 'Invalid phone number' }),
|
|
162
|
+
(0, class_validator_1.MinLength)(1, { message: 'Phone number cannot be empty' }),
|
|
163
|
+
__metadata("design:type", Object)
|
|
164
|
+
], UpdateClientDto.prototype, "phone", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, validators_1.IsNullable)(),
|
|
167
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid status ID format' }),
|
|
168
|
+
__metadata("design:type", Object)
|
|
169
|
+
], UpdateClientDto.prototype, "status_id", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, class_validator_1.IsBoolean)({ message: 'Contract client must be a boolean' }),
|
|
172
|
+
__metadata("design:type", Boolean)
|
|
173
|
+
], UpdateClientDto.prototype, "contract_client", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, validators_1.IsNullable)(),
|
|
176
|
+
(0, class_transformer_1.Transform)(({ value }) => value !== undefined ? Number(value) : null, { toClassOnly: true }),
|
|
177
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Contracted hours must be a number' }),
|
|
178
|
+
(0, class_validator_1.Min)(0, { message: 'Contracted hours must be at least 0' }),
|
|
179
|
+
__metadata("design:type", Object)
|
|
180
|
+
], UpdateClientDto.prototype, "contracted_hours", void 0);
|
|
181
|
+
//# sourceMappingURL=dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/clients/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuJ;AACvJ,yDAA8C;AAQ9C,8CAA2C;AAE3C,+FAA+F;AA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,qCAAqC,EAAE,CAAC;;yDACjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ClientEntity, ClientSummary } from '@managemint-solutions/entities/clients';
|
|
2
|
+
import type { MmsList } from '@managemint-solutions/entities/common';
|
|
3
|
+
import type { AuthContext } from '../auth';
|
|
4
|
+
import type { TypedSupabaseClient } from '../client';
|
|
5
|
+
import type { CreateClientDto, GetClientsDto, UpdateClientDto } from './dto';
|
|
6
|
+
export * from './dto';
|
|
7
|
+
export declare class ClientsResource {
|
|
8
|
+
private readonly supabase;
|
|
9
|
+
private readonly auth;
|
|
10
|
+
constructor(supabase: TypedSupabaseClient, auth: AuthContext);
|
|
11
|
+
list(query: GetClientsDto): Promise<MmsList<ClientSummary>>;
|
|
12
|
+
getById(clientId: string): Promise<ClientEntity>;
|
|
13
|
+
create(input: CreateClientDto): Promise<ClientEntity>;
|
|
14
|
+
update(clientId: string, input: UpdateClientDto): Promise<ClientEntity>;
|
|
15
|
+
archive(clientId: string): Promise<ClientEntity>;
|
|
16
|
+
unarchive(clientId: string): Promise<ClientEntity>;
|
|
17
|
+
restore(clientId: string): Promise<ClientEntity>;
|
|
18
|
+
/** Soft delete — the row stays, flagged `deleted`, and `restore()` brings it back. */
|
|
19
|
+
remove(clientId: string): Promise<void>;
|
|
20
|
+
}
|