@managemint-solutions/sdk 0.5.0 → 0.7.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 (59) hide show
  1. package/README.md +121 -7
  2. package/dist/additional-details/dto.d.ts +2 -5
  3. package/dist/additional-details/dto.js +2 -0
  4. package/dist/additional-details/dto.js.map +1 -1
  5. package/dist/additional-details/index.js +5 -6
  6. package/dist/additional-details/index.js.map +1 -1
  7. package/dist/additional-details/values.d.ts +2 -2
  8. package/dist/additional-details/values.js +2 -2
  9. package/dist/auth-client/dto.d.ts +19 -0
  10. package/dist/auth-client/dto.js +72 -0
  11. package/dist/auth-client/dto.js.map +1 -0
  12. package/dist/auth-client/index.d.ts +38 -0
  13. package/dist/auth-client/index.js +135 -0
  14. package/dist/auth-client/index.js.map +1 -0
  15. package/dist/client.d.ts +5 -2
  16. package/dist/client.js +6 -0
  17. package/dist/client.js.map +1 -1
  18. package/dist/clients/index.js +3 -6
  19. package/dist/clients/index.js.map +1 -1
  20. package/dist/errors.d.ts +7 -1
  21. package/dist/errors.js +12 -1
  22. package/dist/errors.js.map +1 -1
  23. package/dist/index.d.ts +4 -1
  24. package/dist/index.js +4 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/nest/index.d.ts +5 -0
  27. package/dist/nest/index.js +10 -1
  28. package/dist/nest/index.js.map +1 -1
  29. package/dist/notes/dto.d.ts +1 -4
  30. package/dist/notes/dto.js +2 -0
  31. package/dist/notes/dto.js.map +1 -1
  32. package/dist/notes/index.js +3 -5
  33. package/dist/notes/index.js.map +1 -1
  34. package/dist/projects/dto.d.ts +38 -0
  35. package/dist/projects/dto.js +238 -0
  36. package/dist/projects/dto.js.map +1 -0
  37. package/dist/projects/index.d.ts +20 -0
  38. package/dist/projects/index.js +299 -0
  39. package/dist/projects/index.js.map +1 -0
  40. package/dist/statuses/dto.d.ts +2 -5
  41. package/dist/statuses/dto.js +2 -0
  42. package/dist/statuses/dto.js.map +1 -1
  43. package/dist/statuses/index.js +3 -4
  44. package/dist/statuses/index.js.map +1 -1
  45. package/dist/supporting-files/index.js +3 -3
  46. package/dist/supporting-files/index.js.map +1 -1
  47. package/dist/tasks/dto.d.ts +43 -0
  48. package/dist/tasks/dto.js +288 -0
  49. package/dist/tasks/dto.js.map +1 -0
  50. package/dist/tasks/index.d.ts +20 -0
  51. package/dist/tasks/index.js +241 -0
  52. package/dist/tasks/index.js.map +1 -0
  53. package/dist/transforms.d.ts +14 -0
  54. package/dist/transforms.js +38 -0
  55. package/dist/transforms.js.map +1 -0
  56. package/package.json +1 -1
  57. package/dist/database.types.d.ts +0 -2570
  58. package/dist/database.types.js +0 -12
  59. package/dist/database.types.js.map +0 -1
@@ -0,0 +1,288 @@
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.UpdateTaskDto = exports.CreateTaskDto = exports.GetTasksDto = exports.TaskIdDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const transforms_1 = require("../transforms");
16
+ const validators_1 = require("../validators");
17
+ // class-validator versions of the shared DTO types from @managemint-solutions/entities, so the
18
+ // wire contract cannot drift.
19
+ class TaskIdDto {
20
+ taskId;
21
+ }
22
+ exports.TaskIdDto = TaskIdDto;
23
+ __decorate([
24
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid project ID format' }) // sic — the api's message, kept for parity
25
+ ,
26
+ __metadata("design:type", String)
27
+ ], TaskIdDto.prototype, "taskId", void 0);
28
+ // `status_id_in` and `priority_in` are omitted from the implemented type on purpose: the entities
29
+ // type carries the CSV wire values, while this class carries the `@Transform`-parsed arrays the
30
+ // query builder feeds to `.in('status_id', ...)` / `.in('priority', ...)`.
31
+ class GetTasksDto {
32
+ search;
33
+ page = 1;
34
+ page_size = 10;
35
+ client_id;
36
+ project_id;
37
+ assigned_to_id;
38
+ created_after;
39
+ created_before;
40
+ start_date_after;
41
+ start_date_before;
42
+ end_date_after;
43
+ end_date_before;
44
+ status_id_in;
45
+ priority_in;
46
+ archive = false;
47
+ }
48
+ exports.GetTasksDto = GetTasksDto;
49
+ __decorate([
50
+ (0, class_validator_1.IsOptional)(),
51
+ (0, validators_1.IsNullable)(),
52
+ (0, class_validator_1.IsString)({ message: 'Invalid search query' }),
53
+ (0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
54
+ (0, class_validator_1.MaxLength)(255, { message: 'Search query cannot exceed 255 characters' }),
55
+ __metadata("design:type", Object)
56
+ ], GetTasksDto.prototype, "search", void 0);
57
+ __decorate([
58
+ (0, class_validator_1.IsOptional)(),
59
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
60
+ (0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
61
+ (0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
62
+ __metadata("design:type", Number)
63
+ ], GetTasksDto.prototype, "page", void 0);
64
+ __decorate([
65
+ (0, class_validator_1.IsOptional)(),
66
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
67
+ (0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
68
+ (0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
69
+ (0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
70
+ __metadata("design:type", Number)
71
+ ], GetTasksDto.prototype, "page_size", void 0);
72
+ __decorate([
73
+ (0, class_validator_1.IsOptional)(),
74
+ (0, validators_1.IsNullable)(),
75
+ (0, class_transformer_1.Transform)(({ value }) => (0, transforms_1.parseEntityIdFilter)(value), { toClassOnly: true }),
76
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid client ID format' }),
77
+ __metadata("design:type", Object)
78
+ ], GetTasksDto.prototype, "client_id", void 0);
79
+ __decorate([
80
+ (0, class_validator_1.IsOptional)(),
81
+ (0, validators_1.IsNullable)(),
82
+ (0, class_transformer_1.Transform)(({ value }) => (0, transforms_1.parseEntityIdFilter)(value), { toClassOnly: true }),
83
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid project ID format' }),
84
+ __metadata("design:type", Object)
85
+ ], GetTasksDto.prototype, "project_id", void 0);
86
+ __decorate([
87
+ (0, class_validator_1.IsOptional)(),
88
+ (0, validators_1.IsNullable)(),
89
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid assigned to ID format' }),
90
+ __metadata("design:type", Object)
91
+ ], GetTasksDto.prototype, "assigned_to_id", void 0);
92
+ __decorate([
93
+ (0, class_validator_1.IsOptional)(),
94
+ (0, validators_1.IsNullable)(),
95
+ (0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
96
+ __metadata("design:type", Object)
97
+ ], GetTasksDto.prototype, "created_after", void 0);
98
+ __decorate([
99
+ (0, class_validator_1.IsOptional)(),
100
+ (0, validators_1.IsNullable)(),
101
+ (0, class_validator_1.IsDateString)({}, { message: 'End date must be a valid ISO 8601 date string' }),
102
+ __metadata("design:type", Object)
103
+ ], GetTasksDto.prototype, "created_before", void 0);
104
+ __decorate([
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, validators_1.IsNullable)(),
107
+ (0, class_validator_1.IsDateString)({}, { message: 'Invalid start date after format' }),
108
+ __metadata("design:type", Object)
109
+ ], GetTasksDto.prototype, "start_date_after", void 0);
110
+ __decorate([
111
+ (0, class_validator_1.IsOptional)(),
112
+ (0, validators_1.IsNullable)(),
113
+ (0, class_validator_1.IsDateString)({}, { message: 'Invalid start date before format' }),
114
+ __metadata("design:type", Object)
115
+ ], GetTasksDto.prototype, "start_date_before", void 0);
116
+ __decorate([
117
+ (0, class_validator_1.IsOptional)(),
118
+ (0, validators_1.IsNullable)(),
119
+ (0, class_validator_1.IsDateString)({}, { message: 'Invalid end date after format' }),
120
+ __metadata("design:type", Object)
121
+ ], GetTasksDto.prototype, "end_date_after", void 0);
122
+ __decorate([
123
+ (0, class_validator_1.IsOptional)(),
124
+ (0, validators_1.IsNullable)(),
125
+ (0, class_validator_1.IsDateString)({}, { message: 'Invalid end date before format' }),
126
+ __metadata("design:type", Object)
127
+ ], GetTasksDto.prototype, "end_date_before", void 0);
128
+ __decorate([
129
+ (0, class_validator_1.IsOptional)(),
130
+ (0, validators_1.IsNullable)(),
131
+ (0, class_transformer_1.Transform)(({ value }) => value ? value.split(',').map((id) => id.trim()) : null, { toClassOnly: true }),
132
+ (0, class_validator_1.IsUUID)('4', { each: true, message: 'Invalid status ID format' }),
133
+ __metadata("design:type", Object)
134
+ ], GetTasksDto.prototype, "status_id_in", void 0);
135
+ __decorate([
136
+ (0, class_validator_1.IsOptional)(),
137
+ (0, validators_1.IsNullable)(),
138
+ (0, class_transformer_1.Transform)(({ value }) => value ? value.split(',').map((priority) => Number(priority.trim())) : null, { toClassOnly: true }),
139
+ (0, class_validator_1.IsNumber)({}, { each: true, message: 'Priority must be a number' }),
140
+ __metadata("design:type", Object)
141
+ ], GetTasksDto.prototype, "priority_in", void 0);
142
+ __decorate([
143
+ (0, class_validator_1.IsOptional)(),
144
+ (0, validators_1.IsNullable)(),
145
+ (0, class_transformer_1.Transform)(({ value }) => value ? value === 'true' : false, { toClassOnly: true }),
146
+ (0, class_validator_1.IsBoolean)({ message: 'Include archived must be a boolean' }),
147
+ __metadata("design:type", Boolean)
148
+ ], GetTasksDto.prototype, "archive", void 0);
149
+ class CreateTaskDto {
150
+ name;
151
+ description;
152
+ start_date;
153
+ end_date;
154
+ status_id;
155
+ priority = 0;
156
+ assigned_to_id;
157
+ project_id;
158
+ client_id;
159
+ }
160
+ exports.CreateTaskDto = CreateTaskDto;
161
+ __decorate([
162
+ (0, class_validator_1.IsString)({ message: 'Invalid name' }),
163
+ (0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
164
+ (0, class_validator_1.MaxLength)(255, { message: 'Name cannot exceed 255 characters' }),
165
+ __metadata("design:type", String)
166
+ ], CreateTaskDto.prototype, "name", void 0);
167
+ __decorate([
168
+ (0, class_validator_1.IsOptional)(),
169
+ (0, validators_1.IsNullable)(),
170
+ (0, class_validator_1.ValidateIf)((o) => o.description !== null && o.description !== undefined),
171
+ (0, class_validator_1.IsString)({ message: 'Invalid description' }),
172
+ (0, class_validator_1.MaxLength)(500, { message: 'Description cannot exceed 500 characters' }),
173
+ __metadata("design:type", Object)
174
+ ], CreateTaskDto.prototype, "description", void 0);
175
+ __decorate([
176
+ (0, class_validator_1.IsOptional)(),
177
+ (0, validators_1.IsNullable)(),
178
+ (0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
179
+ __metadata("design:type", Object)
180
+ ], CreateTaskDto.prototype, "start_date", void 0);
181
+ __decorate([
182
+ (0, class_validator_1.IsOptional)(),
183
+ (0, validators_1.IsNullable)(),
184
+ (0, class_validator_1.IsDateString)({}, { message: 'End date must be a valid ISO 8601 date string' }),
185
+ __metadata("design:type", Object)
186
+ ], CreateTaskDto.prototype, "end_date", void 0);
187
+ __decorate([
188
+ (0, class_validator_1.IsOptional)(),
189
+ (0, validators_1.IsNullable)(),
190
+ (0, class_validator_1.IsUUID)('4', { each: true, message: 'Each status ID must be a valid UUID v4' }),
191
+ __metadata("design:type", Object)
192
+ ], CreateTaskDto.prototype, "status_id", void 0);
193
+ __decorate([
194
+ (0, class_validator_1.IsOptional)(),
195
+ (0, validators_1.IsNullable)(),
196
+ (0, class_transformer_1.Transform)(({ value }) => value !== undefined && value !== null ? Number(value) : 0, { toClassOnly: true }),
197
+ (0, class_validator_1.IsNumber)({}, { message: 'Priority must be a number' }),
198
+ __metadata("design:type", Number)
199
+ ], CreateTaskDto.prototype, "priority", void 0);
200
+ __decorate([
201
+ (0, class_validator_1.IsOptional)(),
202
+ (0, validators_1.IsNullable)(),
203
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid assigned to ID format' }),
204
+ __metadata("design:type", Object)
205
+ ], CreateTaskDto.prototype, "assigned_to_id", void 0);
206
+ __decorate([
207
+ (0, class_validator_1.IsOptional)(),
208
+ (0, validators_1.IsNullable)(),
209
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid project ID format' }),
210
+ __metadata("design:type", Object)
211
+ ], CreateTaskDto.prototype, "project_id", void 0);
212
+ __decorate([
213
+ (0, class_validator_1.IsOptional)(),
214
+ (0, validators_1.IsNullable)(),
215
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid client ID format' }),
216
+ __metadata("design:type", Object)
217
+ ], CreateTaskDto.prototype, "client_id", void 0);
218
+ class UpdateTaskDto {
219
+ name;
220
+ description;
221
+ start_date;
222
+ end_date;
223
+ status_id;
224
+ priority = 0;
225
+ assigned_to_id;
226
+ project_id;
227
+ client_id;
228
+ }
229
+ exports.UpdateTaskDto = UpdateTaskDto;
230
+ __decorate([
231
+ (0, class_validator_1.IsString)({ message: 'Invalid name' }),
232
+ (0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
233
+ (0, class_validator_1.MaxLength)(255, { message: 'Name cannot exceed 255 characters' }),
234
+ __metadata("design:type", String)
235
+ ], UpdateTaskDto.prototype, "name", void 0);
236
+ __decorate([
237
+ (0, class_validator_1.IsOptional)(),
238
+ (0, validators_1.IsNullable)(),
239
+ (0, class_validator_1.ValidateIf)((o) => o.description !== null && o.description !== undefined),
240
+ (0, class_validator_1.IsString)({ message: 'Invalid description' }),
241
+ (0, class_validator_1.MinLength)(1, { message: 'Description cannot be empty' }),
242
+ (0, class_validator_1.MaxLength)(500, { message: 'Description cannot exceed 500 characters' }),
243
+ __metadata("design:type", Object)
244
+ ], UpdateTaskDto.prototype, "description", void 0);
245
+ __decorate([
246
+ (0, class_validator_1.IsOptional)(),
247
+ (0, validators_1.IsNullable)(),
248
+ (0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
249
+ __metadata("design:type", Object)
250
+ ], UpdateTaskDto.prototype, "start_date", void 0);
251
+ __decorate([
252
+ (0, class_validator_1.IsOptional)(),
253
+ (0, validators_1.IsNullable)(),
254
+ (0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
255
+ __metadata("design:type", Object)
256
+ ], UpdateTaskDto.prototype, "end_date", void 0);
257
+ __decorate([
258
+ (0, class_validator_1.IsOptional)(),
259
+ (0, validators_1.IsNullable)(),
260
+ (0, class_validator_1.IsUUID)('4', { each: true, message: 'Each status ID must be a valid UUID v4' }),
261
+ __metadata("design:type", Object)
262
+ ], UpdateTaskDto.prototype, "status_id", void 0);
263
+ __decorate([
264
+ (0, class_validator_1.IsOptional)(),
265
+ (0, validators_1.IsNullable)(),
266
+ (0, class_transformer_1.Transform)(({ value }) => value !== undefined && value !== null ? Number(value) : 0, { toClassOnly: true }),
267
+ (0, class_validator_1.IsNumber)({}, { message: 'Priority must be a number' }),
268
+ __metadata("design:type", Number)
269
+ ], UpdateTaskDto.prototype, "priority", void 0);
270
+ __decorate([
271
+ (0, class_validator_1.IsOptional)(),
272
+ (0, validators_1.IsNullable)(),
273
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid assigned to ID format' }),
274
+ __metadata("design:type", Object)
275
+ ], UpdateTaskDto.prototype, "assigned_to_id", void 0);
276
+ __decorate([
277
+ (0, class_validator_1.IsOptional)(),
278
+ (0, validators_1.IsNullable)(),
279
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid project ID format' }),
280
+ __metadata("design:type", Object)
281
+ ], UpdateTaskDto.prototype, "project_id", void 0);
282
+ __decorate([
283
+ (0, class_validator_1.IsOptional)(),
284
+ (0, validators_1.IsNullable)(),
285
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid client ID format' }),
286
+ __metadata("design:type", Object)
287
+ ], UpdateTaskDto.prototype, "client_id", void 0);
288
+ //# sourceMappingURL=dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/tasks/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8I;AAC9I,yDAA8C;AAO9C,8CAAoD;AACpD,8CAA2C;AAE3C,+FAA+F;AAC/F,8BAA8B;AAE9B,MAAa,SAAS;IAEX,MAAM,CAAU;CAC1B;AAHD,8BAGC;AADU;IADR,IAAA,wBAAM,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC,CAAC,2CAA2C;;;yCACzE;AAG3B,kGAAkG;AAClG,gGAAgG;AAChG,2EAA2E;AAC3E,MAAa,WAAW;IAMb,MAAM,CAAiB;IAMvB,IAAI,GAAW,CAAC,CAAC;IAOjB,SAAS,GAAW,EAAE,CAAC;IAMvB,SAAS,CAAiB;IAM1B,UAAU,CAAiB;IAK3B,cAAc,CAAiB;IAK/B,aAAa,CAAiB;IAK9B,cAAc,CAAiB;IAK/B,gBAAgB,CAAiB;IAKjC,iBAAiB,CAAiB;IAKlC,cAAc,CAAiB;IAK/B,eAAe,CAAiB;IAMhC,YAAY,CAAmB;IAM/B,WAAW,CAAmB;IAM9B,OAAO,GAAY,KAAK,CAAC;CACnC;AArFD,kCAqFC;AA/EU;IALR,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAC7C,IAAA,2BAAS,EAAC,CAAC,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;IACz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AAE,CAAC;;+CACzB;AAKrB;IAHR,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;;qDAClB;AAK/B;IAHR,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;;iDAClB;AAK3B;IAHR,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;;gDAClB"}
@@ -0,0 +1,20 @@
1
+ import type { MmsList } from '@managemint-solutions/entities/common';
2
+ import type { TaskEntity, TaskSummary } from '@managemint-solutions/entities/tasks';
3
+ import type { AuthContext } from '../auth';
4
+ import type { TypedSupabaseClient } from '../client';
5
+ import type { CreateTaskDto, GetTasksDto, UpdateTaskDto } from './dto';
6
+ export * from './dto';
7
+ export declare class TasksResource {
8
+ private readonly supabase;
9
+ private readonly auth;
10
+ constructor(supabase: TypedSupabaseClient, auth: AuthContext);
11
+ list(query: GetTasksDto): Promise<MmsList<TaskSummary>>;
12
+ getById(taskId: string): Promise<TaskEntity>;
13
+ create(input: CreateTaskDto): Promise<TaskEntity>;
14
+ update(taskId: string, input: UpdateTaskDto): Promise<TaskEntity>;
15
+ archive(taskId: string): Promise<TaskEntity>;
16
+ unarchive(taskId: string): Promise<TaskEntity>;
17
+ restore(taskId: string): Promise<TaskEntity>;
18
+ /** Soft delete — the row stays, flagged `deleted`, and `restore()` brings it back. */
19
+ remove(taskId: string): Promise<void>;
20
+ }
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TasksResource = void 0;
18
+ const errors_1 = require("../errors");
19
+ __exportStar(require("./dto"), exports);
20
+ // The public contract is the shared TaskSummary / TaskEntity from @managemint-solutions/entities;
21
+ // the casts at the returns declare the shape the select strings below produce (the columns are
22
+ // defined in the api's supabase/migrations).
23
+ const TASK_LIST_SELECT = `
24
+ mms_id,
25
+ name,
26
+ start_date,
27
+ end_date,
28
+ status:statuses!status_id (
29
+ mms_id,
30
+ colour,
31
+ label
32
+ ),
33
+ priority,
34
+ assigned_to:user_profiles!assigned_to_id (*)
35
+ `;
36
+ const TASK_DETAIL_SELECT = `
37
+ mms_id,
38
+ created_at,
39
+ created_by:user_profiles!created_by (*),
40
+ updated_at,
41
+ last_updated_by:user_profiles!last_updated_by (*),
42
+ name,
43
+ description,
44
+ start_date,
45
+ end_date,
46
+ status:statuses!status_id (
47
+ mms_id,
48
+ colour,
49
+ label
50
+ ),
51
+ priority,
52
+ assigned_to:user_profiles!assigned_to_id (*),
53
+ project:project_profiles!project_id (*),
54
+ client:client_profiles!client_id (*),
55
+ archived,
56
+ archived_at,
57
+ archived_by:user_profiles!archived_by (*),
58
+ unarchived_at,
59
+ unarchived_by:user_profiles!unarchived_by (*),
60
+ deleted,
61
+ deleted_at,
62
+ deleted_by:user_profiles!deleted_by (*),
63
+ restored_at,
64
+ restored_by:user_profiles!restored_by (*)
65
+ `;
66
+ class TasksResource {
67
+ supabase;
68
+ auth;
69
+ constructor(supabase, auth) {
70
+ this.supabase = supabase;
71
+ this.auth = auth;
72
+ }
73
+ async list(query) {
74
+ const page = query.page;
75
+ const pageSize = query.page_size;
76
+ const offset = (page - 1) * pageSize;
77
+ const trimmedSearch = query.search?.trim();
78
+ // `order`/`range` return `this`, so the builder stays a filter builder and the conditional
79
+ // filters below can be reassigned onto it without a cast.
80
+ let tasksQuery = this.supabase
81
+ .from('tasks')
82
+ .select(TASK_LIST_SELECT, { count: 'estimated' })
83
+ .eq('organization_id', this.auth.organization_id)
84
+ .eq('archived', query.archive)
85
+ .eq('deleted', false)
86
+ .order('priority', { ascending: false })
87
+ .order('created_at', { ascending: false })
88
+ .range(offset, offset + pageSize - 1);
89
+ if (trimmedSearch) {
90
+ const escapedSearch = trimmedSearch.replace(/,/g, '\\,');
91
+ tasksQuery = tasksQuery.or(`name.ilike.%${escapedSearch}%,description.ilike.%${escapedSearch}%`);
92
+ }
93
+ if (query.client_id) {
94
+ tasksQuery = tasksQuery.eq('client_id', query.client_id);
95
+ }
96
+ if (query.project_id) {
97
+ tasksQuery = tasksQuery.eq('project_id', query.project_id);
98
+ }
99
+ if (query.assigned_to_id) {
100
+ tasksQuery = tasksQuery.eq('assigned_to_id', query.assigned_to_id);
101
+ }
102
+ if (query.created_after) {
103
+ tasksQuery = tasksQuery.gte('created_at', query.created_after);
104
+ }
105
+ if (query.created_before) {
106
+ tasksQuery = tasksQuery.lte('created_at', query.created_before);
107
+ }
108
+ if (query.start_date_after) {
109
+ tasksQuery = tasksQuery.gte('start_date', query.start_date_after);
110
+ }
111
+ if (query.start_date_before) {
112
+ tasksQuery = tasksQuery.lte('start_date', query.start_date_before);
113
+ }
114
+ if (query.end_date_after) {
115
+ tasksQuery = tasksQuery.gte('end_date', query.end_date_after);
116
+ }
117
+ if (query.end_date_before) {
118
+ tasksQuery = tasksQuery.lte('end_date', query.end_date_before);
119
+ }
120
+ if (query.status_id_in && query.status_id_in.length > 0) {
121
+ tasksQuery = tasksQuery.in('status_id', query.status_id_in);
122
+ }
123
+ if (query.priority_in && query.priority_in.length > 0) {
124
+ tasksQuery = tasksQuery.in('priority', query.priority_in);
125
+ }
126
+ const { data, error, count } = await tasksQuery;
127
+ if (error)
128
+ throw (0, errors_1.mapPostgrestError)(error);
129
+ const totalEstimated = count ?? 0;
130
+ const totalPages = totalEstimated > 0 ? Math.ceil(totalEstimated / pageSize) : 0;
131
+ return {
132
+ results: (data ?? []),
133
+ page,
134
+ per_page: pageSize,
135
+ count: totalEstimated,
136
+ total_pages: totalPages,
137
+ has_next_page: page < totalPages,
138
+ has_previous_page: page > 1,
139
+ };
140
+ }
141
+ async getById(taskId) {
142
+ const { data, error } = await this.supabase
143
+ .from('tasks')
144
+ .select(TASK_DETAIL_SELECT)
145
+ .eq('mms_id', taskId)
146
+ .eq('organization_id', this.auth.organization_id)
147
+ .single();
148
+ if (error)
149
+ throw (0, errors_1.mapPostgrestError)(error);
150
+ return data;
151
+ }
152
+ async create(input) {
153
+ // `task_id` (the per-organization task number) is left out: the table's `set_task_id`
154
+ // BEFORE INSERT trigger fills it in when it arrives null.
155
+ const { data, error } = await this.supabase
156
+ .from('tasks')
157
+ .insert({
158
+ ...input,
159
+ organization_id: this.auth.organization_id,
160
+ created_by: this.auth.mms_id,
161
+ created_at: new Date().toISOString(),
162
+ })
163
+ .select('mms_id')
164
+ .single();
165
+ if (error)
166
+ throw (0, errors_1.mapPostgrestError)(error);
167
+ return this.getById(data.mms_id);
168
+ }
169
+ async update(taskId, input) {
170
+ const { error } = await this.supabase
171
+ .from('tasks')
172
+ .update({
173
+ ...input,
174
+ last_updated_by: this.auth.mms_id,
175
+ updated_at: new Date().toISOString(),
176
+ })
177
+ .eq('mms_id', taskId)
178
+ .eq('organization_id', this.auth.organization_id);
179
+ if (error)
180
+ throw (0, errors_1.mapPostgrestError)(error);
181
+ return this.getById(taskId);
182
+ }
183
+ async archive(taskId) {
184
+ const { error } = await this.supabase
185
+ .from('tasks')
186
+ .update({
187
+ archived: true,
188
+ archived_at: new Date().toISOString(),
189
+ archived_by: this.auth.mms_id,
190
+ })
191
+ .eq('organization_id', this.auth.organization_id)
192
+ .eq('mms_id', taskId);
193
+ if (error)
194
+ throw (0, errors_1.mapPostgrestError)(error);
195
+ return this.getById(taskId);
196
+ }
197
+ async unarchive(taskId) {
198
+ const { error } = await this.supabase
199
+ .from('tasks')
200
+ .update({
201
+ archived: false,
202
+ unarchived_at: new Date().toISOString(),
203
+ unarchived_by: this.auth.mms_id,
204
+ })
205
+ .eq('organization_id', this.auth.organization_id)
206
+ .eq('mms_id', taskId);
207
+ if (error)
208
+ throw (0, errors_1.mapPostgrestError)(error);
209
+ return this.getById(taskId);
210
+ }
211
+ async restore(taskId) {
212
+ const { error } = await this.supabase
213
+ .from('tasks')
214
+ .update({
215
+ deleted: false,
216
+ restored_at: new Date().toISOString(),
217
+ restored_by: this.auth.mms_id,
218
+ })
219
+ .eq('organization_id', this.auth.organization_id)
220
+ .eq('mms_id', taskId);
221
+ if (error)
222
+ throw (0, errors_1.mapPostgrestError)(error);
223
+ return this.getById(taskId);
224
+ }
225
+ /** Soft delete — the row stays, flagged `deleted`, and `restore()` brings it back. */
226
+ async remove(taskId) {
227
+ const { error } = await this.supabase
228
+ .from('tasks')
229
+ .update({
230
+ deleted: true,
231
+ deleted_at: new Date().toISOString(),
232
+ deleted_by: this.auth.mms_id,
233
+ })
234
+ .eq('organization_id', this.auth.organization_id)
235
+ .eq('mms_id', taskId);
236
+ if (error)
237
+ throw (0, errors_1.mapPostgrestError)(error);
238
+ }
239
+ }
240
+ exports.TasksResource = TasksResource;
241
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,sCAA8C;AAG9C,wCAAsB;AAEtB,kGAAkG;AAClG,+FAA+F;AAC/F,6CAA6C;AAC7C,MAAM,gBAAgB,GAAG;;;;;;;;;;;;O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;aAClC,IAAI,CAAC,OAAO,CAAC;aACb,MAAM,CAAC;YACN,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;SAC9B,CAAC;aACD,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aAChD,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,IAAI,KAAK;YAAE,MAAM,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC;QAE1C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,sFAAsF;IACtF,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ;aAClC,IAAI,CAAC,OAAO,CAAC;aACb,MAAM,CAAC;YACN,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;SAC7B,CAAC;aACD,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aAChD,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,IAAI,KAAK;YAAE,MAAM,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AAnMD,sCAmMC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The `client_id` / `project_id` list filters accept either a plain UUID v4 or the base64-JSON
3
+ * option value the portal's selects send (`{ mms_id }`, or `{ id }` as a fallback). Anything that
4
+ * is not one of those — including a value that decodes to JSON without a UUID v4 — cannot filter
5
+ * anything, so it becomes `null` and the filter is skipped.
6
+ */
7
+ export declare const parseEntityIdFilter: (value: unknown) => string | null;
8
+ /**
9
+ * `date` columns take an ISO string. The shared `CreateProjectDto`/`UpdateProjectDto` types
10
+ * declare `Date`, but over the wire the value is the validated `@IsDateString` string — which
11
+ * must reach Postgres byte-identical ('2026-04-22' is a plain date, not an instant) — so only a
12
+ * real `Date` (a portal caller) is serialized.
13
+ */
14
+ export declare const toDateInput: (value: Date | string | null | undefined) => string | null | undefined;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ // Small conversions shared by the DTOs' `@Transform`s and the resources' write payloads.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.toDateInput = exports.parseEntityIdFilter = void 0;
5
+ const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ /**
7
+ * The `client_id` / `project_id` list filters accept either a plain UUID v4 or the base64-JSON
8
+ * option value the portal's selects send (`{ mms_id }`, or `{ id }` as a fallback). Anything that
9
+ * is not one of those — including a value that decodes to JSON without a UUID v4 — cannot filter
10
+ * anything, so it becomes `null` and the filter is skipped.
11
+ */
12
+ const parseEntityIdFilter = (value) => {
13
+ if (!value)
14
+ return null;
15
+ // If the incoming value is already a UUID v4, use it directly
16
+ if (typeof value === 'string' && UUID_V4.test(value))
17
+ return value;
18
+ // Otherwise attempt to decode as base64 JSON and extract mms_id
19
+ try {
20
+ const decoded = atob(value);
21
+ const parsed = JSON.parse(decoded);
22
+ const id = parsed?.mms_id ?? parsed?.id ?? null;
23
+ return (typeof id === 'string' && UUID_V4.test(id)) ? id : null;
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ };
29
+ exports.parseEntityIdFilter = parseEntityIdFilter;
30
+ /**
31
+ * `date` columns take an ISO string. The shared `CreateProjectDto`/`UpdateProjectDto` types
32
+ * declare `Date`, but over the wire the value is the validated `@IsDateString` string — which
33
+ * must reach Postgres byte-identical ('2026-04-22' is a plain date, not an instant) — so only a
34
+ * real `Date` (a portal caller) is serialized.
35
+ */
36
+ const toDateInput = (value) => value instanceof Date ? value.toISOString() : value;
37
+ exports.toDateInput = toDateInput;
38
+ //# sourceMappingURL=transforms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":";AAAA,yFAAyF;;;AAEzF,MAAM,OAAO,GAAG,wEAAwE,CAAC;AAEzF;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAiB,EAAE;IACnE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,8DAA8D;IAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnE,gEAAgE;IAChE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAe,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,EAAE,IAAI,IAAI,CAAC;QAChD,OAAO,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,mBAAmB,uBAe9B;AAEF;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CAAC,KAAuC,EAA6B,EAAE,CAChG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AADzC,QAAA,WAAW,eAC8B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managemint-solutions/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Typed Supabase data-access SDK for ManageMint Solutions",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Scott Bebington <scottbebington@gmail.com>",