@proveanything/smartlinks 1.4.8 → 1.5.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.
@@ -0,0 +1,127 @@
1
+ import type { AppCase, CreateCaseInput, UpdateCaseInput, AppendHistoryInput, CaseSummaryRequest, CaseSummaryResponse, CaseListQueryParams, AppThread, CreateThreadInput, UpdateThreadInput, ReplyInput, ThreadListQueryParams, AppRecord, CreateRecordInput, UpdateRecordInput, RecordListQueryParams, PaginatedResponse, AggregateRequest, AggregateResponse, RelatedResponse } from '../types/appObjects';
2
+ export declare namespace cases {
3
+ /**
4
+ * Create a new case
5
+ * POST /cases
6
+ */
7
+ function create(collectionId: string, appId: string, input: CreateCaseInput, admin?: boolean): Promise<AppCase>;
8
+ /**
9
+ * List cases with optional query parameters
10
+ * GET /cases
11
+ */
12
+ function list(collectionId: string, appId: string, params?: CaseListQueryParams, admin?: boolean): Promise<PaginatedResponse<AppCase>>;
13
+ /**
14
+ * Get a single case by ID
15
+ * GET /cases/:caseId
16
+ */
17
+ function get(collectionId: string, appId: string, caseId: string, admin?: boolean): Promise<AppCase>;
18
+ /**
19
+ * Update a case
20
+ * PATCH /cases/:caseId
21
+ * Admin can update any field, public (owner) can only update data and owner zones
22
+ */
23
+ function update(collectionId: string, appId: string, caseId: string, input: UpdateCaseInput, admin?: boolean): Promise<AppCase>;
24
+ /**
25
+ * Soft delete a case
26
+ * DELETE /cases/:caseId
27
+ */
28
+ function remove(collectionId: string, appId: string, caseId: string, admin?: boolean): Promise<{
29
+ success: boolean;
30
+ }>;
31
+ /**
32
+ * Get aggregate statistics for cases
33
+ * POST /cases/aggregate
34
+ */
35
+ function aggregate(collectionId: string, appId: string, request: AggregateRequest, admin?: boolean): Promise<AggregateResponse>;
36
+ /**
37
+ * Get case summary (admin only)
38
+ * POST /cases/summary
39
+ */
40
+ function summary(collectionId: string, appId: string, request?: CaseSummaryRequest): Promise<CaseSummaryResponse>;
41
+ /**
42
+ * Append an entry to case history (admin only)
43
+ * POST /cases/:caseId/history
44
+ */
45
+ function appendHistory(collectionId: string, appId: string, caseId: string, input: AppendHistoryInput): Promise<AppCase>;
46
+ /**
47
+ * Get related threads and records for a case (admin only)
48
+ * GET /cases/:caseId/related
49
+ */
50
+ function related(collectionId: string, appId: string, caseId: string): Promise<RelatedResponse>;
51
+ }
52
+ export declare namespace threads {
53
+ /**
54
+ * Create a new thread
55
+ * POST /threads
56
+ */
57
+ function create(collectionId: string, appId: string, input: CreateThreadInput, admin?: boolean): Promise<AppThread>;
58
+ /**
59
+ * List threads with optional query parameters
60
+ * GET /threads
61
+ */
62
+ function list(collectionId: string, appId: string, params?: ThreadListQueryParams, admin?: boolean): Promise<PaginatedResponse<AppThread>>;
63
+ /**
64
+ * Get a single thread by ID
65
+ * GET /threads/:threadId
66
+ */
67
+ function get(collectionId: string, appId: string, threadId: string, admin?: boolean): Promise<AppThread>;
68
+ /**
69
+ * Update a thread
70
+ * PATCH /threads/:threadId
71
+ * Admin can update any field, public (owner) can only update body, tags, data, owner
72
+ */
73
+ function update(collectionId: string, appId: string, threadId: string, input: UpdateThreadInput, admin?: boolean): Promise<AppThread>;
74
+ /**
75
+ * Soft delete a thread
76
+ * DELETE /threads/:threadId
77
+ */
78
+ function remove(collectionId: string, appId: string, threadId: string, admin?: boolean): Promise<{
79
+ success: boolean;
80
+ }>;
81
+ /**
82
+ * Add a reply to a thread
83
+ * POST /threads/:threadId/reply
84
+ * Atomically appends to replies array, increments replyCount, updates lastReplyAt
85
+ */
86
+ function reply(collectionId: string, appId: string, threadId: string, input: ReplyInput, admin?: boolean): Promise<AppThread>;
87
+ /**
88
+ * Get aggregate statistics for threads
89
+ * POST /threads/aggregate
90
+ */
91
+ function aggregate(collectionId: string, appId: string, request: AggregateRequest, admin?: boolean): Promise<AggregateResponse>;
92
+ }
93
+ export declare namespace records {
94
+ /**
95
+ * Create a new record
96
+ * POST /records
97
+ */
98
+ function create(collectionId: string, appId: string, input: CreateRecordInput, admin?: boolean): Promise<AppRecord>;
99
+ /**
100
+ * List records with optional query parameters
101
+ * GET /records
102
+ */
103
+ function list(collectionId: string, appId: string, params?: RecordListQueryParams, admin?: boolean): Promise<PaginatedResponse<AppRecord>>;
104
+ /**
105
+ * Get a single record by ID
106
+ * GET /records/:recordId
107
+ */
108
+ function get(collectionId: string, appId: string, recordId: string, admin?: boolean): Promise<AppRecord>;
109
+ /**
110
+ * Update a record
111
+ * PATCH /records/:recordId
112
+ * Admin can update any field, public (owner) can only update data and owner
113
+ */
114
+ function update(collectionId: string, appId: string, recordId: string, input: UpdateRecordInput, admin?: boolean): Promise<AppRecord>;
115
+ /**
116
+ * Soft delete a record
117
+ * DELETE /records/:recordId
118
+ */
119
+ function remove(collectionId: string, appId: string, recordId: string, admin?: boolean): Promise<{
120
+ success: boolean;
121
+ }>;
122
+ /**
123
+ * Get aggregate statistics for records
124
+ * POST /records/aggregate
125
+ */
126
+ function aggregate(collectionId: string, appId: string, request: AggregateRequest, admin?: boolean): Promise<AggregateResponse>;
127
+ }
@@ -0,0 +1,257 @@
1
+ // src/api/appObjects.ts
2
+ import { request, post, patch, del } from '../http';
3
+ // ==================== CASES ====================
4
+ export var cases;
5
+ (function (cases) {
6
+ /**
7
+ * Build the base path for cases endpoints
8
+ */
9
+ function basePath(collectionId, appId, admin = false) {
10
+ const zone = admin ? 'admin' : 'public';
11
+ return `/api/v1/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/cases`;
12
+ }
13
+ /**
14
+ * Create a new case
15
+ * POST /cases
16
+ */
17
+ async function create(collectionId, appId, input, admin = false) {
18
+ const path = basePath(collectionId, appId, admin);
19
+ return post(path, input);
20
+ }
21
+ cases.create = create;
22
+ /**
23
+ * List cases with optional query parameters
24
+ * GET /cases
25
+ */
26
+ async function list(collectionId, appId, params, admin = false) {
27
+ const path = basePath(collectionId, appId, admin);
28
+ const queryParams = params ? buildQueryString(params) : '';
29
+ return request(`${path}${queryParams}`);
30
+ }
31
+ cases.list = list;
32
+ /**
33
+ * Get a single case by ID
34
+ * GET /cases/:caseId
35
+ */
36
+ async function get(collectionId, appId, caseId, admin = false) {
37
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(caseId)}`;
38
+ return request(path);
39
+ }
40
+ cases.get = get;
41
+ /**
42
+ * Update a case
43
+ * PATCH /cases/:caseId
44
+ * Admin can update any field, public (owner) can only update data and owner zones
45
+ */
46
+ async function update(collectionId, appId, caseId, input, admin = false) {
47
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(caseId)}`;
48
+ return patch(path, input);
49
+ }
50
+ cases.update = update;
51
+ /**
52
+ * Soft delete a case
53
+ * DELETE /cases/:caseId
54
+ */
55
+ async function remove(collectionId, appId, caseId, admin = false) {
56
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(caseId)}`;
57
+ return del(path);
58
+ }
59
+ cases.remove = remove;
60
+ /**
61
+ * Get aggregate statistics for cases
62
+ * POST /cases/aggregate
63
+ */
64
+ async function aggregate(collectionId, appId, request, admin = false) {
65
+ const path = `${basePath(collectionId, appId, admin)}/aggregate`;
66
+ return post(path, request);
67
+ }
68
+ cases.aggregate = aggregate;
69
+ /**
70
+ * Get case summary (admin only)
71
+ * POST /cases/summary
72
+ */
73
+ async function summary(collectionId, appId, request) {
74
+ const path = `${basePath(collectionId, appId, true)}/summary`;
75
+ return post(path, request || {});
76
+ }
77
+ cases.summary = summary;
78
+ /**
79
+ * Append an entry to case history (admin only)
80
+ * POST /cases/:caseId/history
81
+ */
82
+ async function appendHistory(collectionId, appId, caseId, input) {
83
+ const path = `${basePath(collectionId, appId, true)}/${encodeURIComponent(caseId)}/history`;
84
+ return post(path, input);
85
+ }
86
+ cases.appendHistory = appendHistory;
87
+ /**
88
+ * Get related threads and records for a case (admin only)
89
+ * GET /cases/:caseId/related
90
+ */
91
+ async function related(collectionId, appId, caseId) {
92
+ const path = `${basePath(collectionId, appId, true)}/${encodeURIComponent(caseId)}/related`;
93
+ return request(path);
94
+ }
95
+ cases.related = related;
96
+ })(cases || (cases = {}));
97
+ // ==================== THREADS ====================
98
+ export var threads;
99
+ (function (threads) {
100
+ /**
101
+ * Build the base path for threads endpoints
102
+ */
103
+ function basePath(collectionId, appId, admin = false) {
104
+ const zone = admin ? 'admin' : 'public';
105
+ return `/api/v1/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/threads`;
106
+ }
107
+ /**
108
+ * Create a new thread
109
+ * POST /threads
110
+ */
111
+ async function create(collectionId, appId, input, admin = false) {
112
+ const path = basePath(collectionId, appId, admin);
113
+ return post(path, input);
114
+ }
115
+ threads.create = create;
116
+ /**
117
+ * List threads with optional query parameters
118
+ * GET /threads
119
+ */
120
+ async function list(collectionId, appId, params, admin = false) {
121
+ const path = basePath(collectionId, appId, admin);
122
+ const queryParams = params ? buildQueryString(params) : '';
123
+ return request(`${path}${queryParams}`);
124
+ }
125
+ threads.list = list;
126
+ /**
127
+ * Get a single thread by ID
128
+ * GET /threads/:threadId
129
+ */
130
+ async function get(collectionId, appId, threadId, admin = false) {
131
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(threadId)}`;
132
+ return request(path);
133
+ }
134
+ threads.get = get;
135
+ /**
136
+ * Update a thread
137
+ * PATCH /threads/:threadId
138
+ * Admin can update any field, public (owner) can only update body, tags, data, owner
139
+ */
140
+ async function update(collectionId, appId, threadId, input, admin = false) {
141
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(threadId)}`;
142
+ return patch(path, input);
143
+ }
144
+ threads.update = update;
145
+ /**
146
+ * Soft delete a thread
147
+ * DELETE /threads/:threadId
148
+ */
149
+ async function remove(collectionId, appId, threadId, admin = false) {
150
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(threadId)}`;
151
+ return del(path);
152
+ }
153
+ threads.remove = remove;
154
+ /**
155
+ * Add a reply to a thread
156
+ * POST /threads/:threadId/reply
157
+ * Atomically appends to replies array, increments replyCount, updates lastReplyAt
158
+ */
159
+ async function reply(collectionId, appId, threadId, input, admin = false) {
160
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(threadId)}/reply`;
161
+ return post(path, input);
162
+ }
163
+ threads.reply = reply;
164
+ /**
165
+ * Get aggregate statistics for threads
166
+ * POST /threads/aggregate
167
+ */
168
+ async function aggregate(collectionId, appId, request, admin = false) {
169
+ const path = `${basePath(collectionId, appId, admin)}/aggregate`;
170
+ return post(path, request);
171
+ }
172
+ threads.aggregate = aggregate;
173
+ })(threads || (threads = {}));
174
+ // ==================== RECORDS ====================
175
+ export var records;
176
+ (function (records) {
177
+ /**
178
+ * Build the base path for records endpoints
179
+ */
180
+ function basePath(collectionId, appId, admin = false) {
181
+ const zone = admin ? 'admin' : 'public';
182
+ return `/api/v1/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/records`;
183
+ }
184
+ /**
185
+ * Create a new record
186
+ * POST /records
187
+ */
188
+ async function create(collectionId, appId, input, admin = false) {
189
+ const path = basePath(collectionId, appId, admin);
190
+ return post(path, input);
191
+ }
192
+ records.create = create;
193
+ /**
194
+ * List records with optional query parameters
195
+ * GET /records
196
+ */
197
+ async function list(collectionId, appId, params, admin = false) {
198
+ const path = basePath(collectionId, appId, admin);
199
+ const queryParams = params ? buildQueryString(params) : '';
200
+ return request(`${path}${queryParams}`);
201
+ }
202
+ records.list = list;
203
+ /**
204
+ * Get a single record by ID
205
+ * GET /records/:recordId
206
+ */
207
+ async function get(collectionId, appId, recordId, admin = false) {
208
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(recordId)}`;
209
+ return request(path);
210
+ }
211
+ records.get = get;
212
+ /**
213
+ * Update a record
214
+ * PATCH /records/:recordId
215
+ * Admin can update any field, public (owner) can only update data and owner
216
+ */
217
+ async function update(collectionId, appId, recordId, input, admin = false) {
218
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(recordId)}`;
219
+ return patch(path, input);
220
+ }
221
+ records.update = update;
222
+ /**
223
+ * Soft delete a record
224
+ * DELETE /records/:recordId
225
+ */
226
+ async function remove(collectionId, appId, recordId, admin = false) {
227
+ const path = `${basePath(collectionId, appId, admin)}/${encodeURIComponent(recordId)}`;
228
+ return del(path);
229
+ }
230
+ records.remove = remove;
231
+ /**
232
+ * Get aggregate statistics for records
233
+ * POST /records/aggregate
234
+ */
235
+ async function aggregate(collectionId, appId, request, admin = false) {
236
+ const path = `${basePath(collectionId, appId, admin)}/aggregate`;
237
+ return post(path, request);
238
+ }
239
+ records.aggregate = aggregate;
240
+ })(records || (records = {}));
241
+ // ==================== HELPERS ====================
242
+ /**
243
+ * Build a query string from an object of parameters
244
+ */
245
+ function buildQueryString(params) {
246
+ const entries = Object.entries(params).filter(([_, value]) => value !== undefined && value !== null);
247
+ if (entries.length === 0)
248
+ return '';
249
+ const queryString = entries
250
+ .map(([key, value]) => {
251
+ const encodedKey = encodeURIComponent(key);
252
+ const encodedValue = encodeURIComponent(String(value));
253
+ return `${encodedKey}=${encodedValue}`;
254
+ })
255
+ .join('&');
256
+ return `?${queryString}`;
257
+ }
@@ -1,6 +0,0 @@
1
- export declare namespace appRecord {
2
- function get(collectionId: string, appId: string): Promise<any>;
3
- function create(collectionId: string, appId: string, data: any): Promise<any>;
4
- function update(collectionId: string, appId: string, data: any): Promise<any>;
5
- function remove(collectionId: string, appId: string): Promise<void>;
6
- }
@@ -1,29 +1 @@
1
- // src/api/appRecord.ts
2
- import { request, post, put, del } from "../http";
3
- export var appRecord;
4
- (function (appRecord) {
5
- // Get app record (admin only)
6
- async function get(collectionId, appId) {
7
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
8
- return request(path);
9
- }
10
- appRecord.get = get;
11
- // Create app record (admin only)
12
- async function create(collectionId, appId, data) {
13
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
14
- return post(path, data);
15
- }
16
- appRecord.create = create;
17
- // Update app record (admin only)
18
- async function update(collectionId, appId, data) {
19
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
20
- return put(path, data);
21
- }
22
- appRecord.update = update;
23
- // Delete app record (admin only)
24
- async function remove(collectionId, appId) {
25
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
26
- return del(path);
27
- }
28
- appRecord.remove = remove;
29
- })(appRecord || (appRecord = {}));
1
+ "use strict";
@@ -28,3 +28,4 @@ export { location } from "./location";
28
28
  export * as realtime from "./realtime";
29
29
  export { tags } from "./tags";
30
30
  export { order } from "./order";
31
+ export { cases, threads, records } from "./appObjects";
package/dist/api/index.js CHANGED
@@ -31,3 +31,4 @@ import * as realtime_1 from "./realtime";
31
31
  export { realtime_1 as realtime };
32
32
  export { tags } from "./tags";
33
33
  export { order } from "./order";
34
+ export { cases, threads, records } from "./appObjects";