ab-ecosystem-cpass 1.0.6 → 1.0.8

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 (44) hide show
  1. package/README.md +5 -2
  2. package/dist/client.d.ts +31 -6
  3. package/dist/client.js +36 -8
  4. package/dist/client.js.map +1 -1
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.js +9 -5
  7. package/dist/index.js.map +1 -1
  8. package/dist/resources/audience/canned-replies.d.ts +95 -0
  9. package/dist/resources/audience/canned-replies.js +112 -0
  10. package/dist/resources/audience/canned-replies.js.map +1 -0
  11. package/dist/resources/audience/notifications.d.ts +14 -0
  12. package/dist/resources/audience/notifications.js +14 -0
  13. package/dist/resources/audience/notifications.js.map +1 -1
  14. package/dist/resources/campaign-messages.d.ts +153 -0
  15. package/dist/resources/campaign-messages.js +179 -0
  16. package/dist/resources/campaign-messages.js.map +1 -0
  17. package/dist/resources/data-stores.d.ts +469 -0
  18. package/dist/resources/data-stores.js +530 -0
  19. package/dist/resources/data-stores.js.map +1 -0
  20. package/dist/resources/paths.d.ts +6 -0
  21. package/dist/resources/paths.js +7 -1
  22. package/dist/resources/paths.js.map +1 -1
  23. package/dist/types/campaign.d.ts +137 -41
  24. package/dist/types/canned-reply.d.ts +124 -0
  25. package/dist/types/canned-reply.js +6 -0
  26. package/dist/types/canned-reply.js.map +1 -0
  27. package/dist/types/datastore.d.ts +260 -0
  28. package/dist/types/datastore.js +21 -0
  29. package/dist/types/datastore.js.map +1 -0
  30. package/dist/types/index.d.ts +2 -0
  31. package/dist/types/index.js +3 -0
  32. package/dist/types/index.js.map +1 -1
  33. package/docs/audience/canned-replies.md +302 -0
  34. package/docs/audience/notifications.md +99 -0
  35. package/docs/campaign/campaign-messages.md +282 -0
  36. package/docs/campaign/campaigns.md +8 -48
  37. package/docs/data-store.md +495 -0
  38. package/package.json +1 -1
  39. package/dist/resources/campaign-report-exports.d.ts +0 -14
  40. package/dist/resources/campaign-report-exports.js +0 -28
  41. package/dist/resources/campaign-report-exports.js.map +0 -1
  42. package/dist/resources/campaign-reports.d.ts +0 -15
  43. package/dist/resources/campaign-reports.js +0 -25
  44. package/dist/resources/campaign-reports.js.map +0 -1
@@ -0,0 +1,530 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataStoreRecords = exports.DataStoreCollections = exports.DataStores = void 0;
4
+ const paths_1 = require("./paths");
5
+ const BASE = paths_1.DATASTORE;
6
+ const storePath = (store) => `${BASE}/${(0, paths_1.seg)(store)}`;
7
+ const collectionsPath = (store) => `${storePath(store)}/collections`;
8
+ const collectionPath = (store, collection) => `${collectionsPath(store)}/${(0, paths_1.seg)(collection)}`;
9
+ const recordsPath = (store, collection) => `${collectionPath(store, collection)}/records`;
10
+ /**
11
+ * Data stores: a MongoDB **you** own, registered with the platform.
12
+ *
13
+ * ```ts
14
+ * const store = await crm.dataStores.create({
15
+ * title: 'Orders DB',
16
+ * credentials: {
17
+ * type: 'field',
18
+ * host: 'cluster0.ab12c.mongodb.net',
19
+ * username: 'crm_writer',
20
+ * password: process.env.ORDERS_DB_PASSWORD!,
21
+ * database: 'shop',
22
+ * },
23
+ * });
24
+ *
25
+ * const orders = await crm.dataStoreCollections.create(store.id, {
26
+ * title: 'Orders',
27
+ * fields: [
28
+ * { name: 'order_no', type: 'String' },
29
+ * { name: 'total', type: 'Number' },
30
+ * { name: 'paid', type: 'Boolean', default: false },
31
+ * ],
32
+ * });
33
+ *
34
+ * await crm.dataStoreRecords.insert(store.id, orders.id, {
35
+ * record: { order_no: 'A-1001', total: 49.9 },
36
+ * });
37
+ * ```
38
+ *
39
+ * ## What the platform holds, and what it does not
40
+ *
41
+ * It holds the credential -- encrypted -- and the schemas you declare. It holds
42
+ * **none of your data**: records are read from and written to your cluster on
43
+ * every call, so nothing here is a copy that can go stale, and nothing here
44
+ * survives you revoking the credential.
45
+ *
46
+ * Which also means every record call costs a round trip to your database. The
47
+ * platform keeps the connection open between calls, so that is one query's
48
+ * latency rather than a fresh TLS handshake each time, but a loop of a thousand
49
+ * single inserts is a thousand round trips: send them as one `insert` with
50
+ * `records` instead.
51
+ *
52
+ * ## Deleting never deletes your data
53
+ *
54
+ * `remove()` on a store forgets the credential and the schemas. `remove()` on a
55
+ * collection forgets the declaration. **Neither touches your database** -- the
56
+ * collections and every document in them are exactly as they were, and
57
+ * re-registering the same credential with the same collection name reads it all
58
+ * straight back. Deleting *records* is the only thing here that deletes
59
+ * anything of yours.
60
+ *
61
+ * ## The host must be reachable from the internet
62
+ *
63
+ * A credential pointing at a private or loopback address is refused with
64
+ * `422 invalid_datastore_host`: the platform would be connecting to its own
65
+ * network rather than to yours. Atlas users will usually also need to allow the
66
+ * platform's egress addresses in their project's IP access list -- the symptom
67
+ * otherwise is `502 datastore_unreachable` with a server-selection timeout.
68
+ */
69
+ class DataStores {
70
+ http;
71
+ constructor(http) {
72
+ this.http = http;
73
+ }
74
+ /**
75
+ * `POST /v1/datastores` -- 201 with the store.
76
+ *
77
+ * ### Payload
78
+ *
79
+ * | Field | Type | Required | Notes |
80
+ * | --- | --- | --- | --- |
81
+ * | `title` | string | yes | What you call it. 1-120 characters. |
82
+ * | `credentials` | object | yes | Either form below. |
83
+ *
84
+ * **`credentials.type: 'field'`**
85
+ *
86
+ * | Field | Type | Notes |
87
+ * | --- | --- | --- |
88
+ * | `host` | string | Hostname only: `cluster0.ab12c.mongodb.net`. |
89
+ * | `username` | string | |
90
+ * | `password` | string | Encrypted at rest; never returned. |
91
+ * | `database` | string | |
92
+ *
93
+ * Assembled into `mongodb+srv://…?retryWrites=true&w=majority`, with both
94
+ * halves of the credential percent-encoded -- so a password containing `@`,
95
+ * `/` or `?` works, which it did not in the legacy panel.
96
+ *
97
+ * **`credentials.type: 'string'`**
98
+ *
99
+ * | Field | Type | Notes |
100
+ * | --- | --- | --- |
101
+ * | `uri` | string | `mongodb://` or `mongodb+srv://`, and it must name a database. |
102
+ *
103
+ * ### What happens before the row is written
104
+ *
105
+ * The credential is checked for shape, the host is resolved and refused if it
106
+ * is private, and a connection is opened and pinged. Only then is anything
107
+ * stored -- so a 201 means the database really did accept these credentials,
108
+ * and a store you can see is a store that worked at least once.
109
+ *
110
+ * | Status | Code | Meaning |
111
+ * | --- | --- | --- |
112
+ * | 422 | `validation_failed` | Malformed URI, a host with a scheme in it, or no database named. |
113
+ * | 422 | `invalid_datastore_host` | The host does not resolve, or resolves somewhere private. |
114
+ * | 502 | `datastore_auth_failed` | The database refused the username or password. |
115
+ * | 502 | `datastore_unreachable` | No answer in time -- usually an IP access list. |
116
+ *
117
+ * Scope: `datastores:write`.
118
+ */
119
+ create(input) {
120
+ return this.http.request('POST', BASE, { body: input });
121
+ }
122
+ /**
123
+ * `GET /v1/datastores` -- offset paginated, newest first.
124
+ *
125
+ * | Query | Type | Default | Notes |
126
+ * | --- | --- | --- | --- |
127
+ * | `page` | number | `1` | 1-based. |
128
+ * | `rows` | number | `25` | 1-100. |
129
+ * | `search` | string | — | Case-insensitive match on the title. |
130
+ *
131
+ * Scope: `datastores:read`.
132
+ */
133
+ list(query = {}) {
134
+ return this.http.request('GET', BASE, { query });
135
+ }
136
+ /** `GET /v1/datastores/:store`. Scope: `datastores:read`. */
137
+ get(store) {
138
+ return this.http.request('GET', storePath(store));
139
+ }
140
+ /**
141
+ * `PATCH /v1/datastores/:store` -- rename, re-point, or both.
142
+ *
143
+ * | Field | Type | Notes |
144
+ * | --- | --- | --- |
145
+ * | `title` | string | |
146
+ * | `credentials` | object | Replaced whole, and tested before it is stored. |
147
+ *
148
+ * A partial credential is not accepted: send all four fields, or the whole
149
+ * URI. New credentials go through the same checks as `create`, and the old
150
+ * connection is dropped -- so the next record call reads from the new cluster
151
+ * rather than from a connection that happens to still be open.
152
+ *
153
+ * Scope: `datastores:write`.
154
+ */
155
+ update(store, input) {
156
+ return this.http.request('PATCH', storePath(store), { body: input });
157
+ }
158
+ /**
159
+ * `DELETE /v1/datastores/:store` -- 204.
160
+ *
161
+ * Forgets the credential and every schema declared on it. **Your database is
162
+ * not touched**: the collections and all their documents remain, and
163
+ * registering the same credential again with the same collection names reads
164
+ * them straight back.
165
+ *
166
+ * Scope: `datastores:write`.
167
+ */
168
+ remove(store) {
169
+ return this.http.request('DELETE', storePath(store));
170
+ }
171
+ /**
172
+ * `POST /v1/datastores/:store/test` -- connect, and report.
173
+ *
174
+ * ```ts
175
+ * const { ok, database, collections, latencyMs } = await crm.dataStores.test(store.id);
176
+ * ```
177
+ *
178
+ * The answer to "is it us or them". A credential that worked last month may
179
+ * have been rotated, an Atlas project may be paused, an IP access list may
180
+ * have been tightened -- each of which this distinguishes by status code
181
+ * rather than leaving to be inferred from a failing record call.
182
+ *
183
+ * `collections` is also what you need in order to point a new schema at a
184
+ * collection that already exists. It is empty when the database user has no
185
+ * `listCollections` privilege, which is a perfectly good credential -- not a
186
+ * sign the database is empty.
187
+ *
188
+ * A POST rather than a GET because it opens a connection and updates
189
+ * `verifiedAt`. Scope: `datastores:read`.
190
+ */
191
+ test(store) {
192
+ return this.http.request('POST', `${storePath(store)}/test`);
193
+ }
194
+ }
195
+ exports.DataStores = DataStores;
196
+ /**
197
+ * The collections you declare over a data store: a name, and the fields in it.
198
+ *
199
+ * ```ts
200
+ * const customers = await crm.dataStoreCollections.create(store.id, {
201
+ * title: 'Customers',
202
+ * fields: [
203
+ * { name: 'Email', type: 'String' }, // stored as `email`
204
+ * { name: 'Signed Up', type: 'Date' }, // stored as `signed_up`
205
+ * { name: 'Credits', type: 'Number', default: 0 },
206
+ * { name: 'Tags', type: 'Array' },
207
+ * ],
208
+ * });
209
+ *
210
+ * customers.fields.map((field) => field.name); // ['email','signed_up','credits','tags']
211
+ * ```
212
+ *
213
+ * ## Field names are slugged, once
214
+ *
215
+ * The server normalises every name -- punctuation dropped, spaces and hyphens to
216
+ * underscores, lowercased -- and the normalised name is both what comes back and
217
+ * what the document actually stores. **Use the returned names as your record
218
+ * keys.** The legacy panel slugged the name for the database but kept the
219
+ * original in the schema, so a field called `First Name` stored under
220
+ * `first_name` while the schema said otherwise, and records written against the
221
+ * schema's spelling silently went nowhere.
222
+ *
223
+ * ## Declaring a collection does not create one
224
+ *
225
+ * Mongo creates a collection on its first write, so a new schema addresses a
226
+ * collection that does not exist yet. Reads against it correctly return an empty
227
+ * page rather than failing.
228
+ *
229
+ * ## Editing fields rewrites nothing
230
+ *
231
+ * `update()` changes validation and coercion from the next call onward. It does
232
+ * not migrate documents: dropping a field hides the values under that key
233
+ * (re-declare it and they are back), and changing a field's type leaves old
234
+ * documents holding the old type. The collection a schema points at cannot be
235
+ * changed at all -- every record ever written through it lives there.
236
+ */
237
+ class DataStoreCollections {
238
+ http;
239
+ constructor(http) {
240
+ this.http = http;
241
+ }
242
+ /**
243
+ * `POST /v1/datastores/:store/collections` -- 201.
244
+ *
245
+ * | Field | Type | Required | Notes |
246
+ * | --- | --- | --- | --- |
247
+ * | `title` | string | yes | 1-120 characters. |
248
+ * | `fields` | array | yes | 1-100 fields; see below. |
249
+ * | `collection` | string | no | An existing collection to adopt. Immutable afterwards. |
250
+ * | `show_in_chat` | boolean | no | Default `false`. Whether the chat panel offers it. |
251
+ * | `display.theme` | string | no | Presentation only. |
252
+ * | `display.fields` | string[] | no | Field names to show, in order. Presentation only. |
253
+ *
254
+ * **Each field**
255
+ *
256
+ * | Field | Type | Notes |
257
+ * | --- | --- | --- |
258
+ * | `name` | string | Slugged by the server; the slug is the document key. |
259
+ * | `type` | `String` `Number` `Boolean` `Date` `Array` | |
260
+ * | `label` | string | Display only. |
261
+ * | `default` | string \| number \| boolean | `String`, `Number` and `Boolean` only. |
262
+ *
263
+ * Omit `collection` and the server generates `<id>_<slugged title>`, which
264
+ * cannot collide with anything already in your database. Supply it to point at
265
+ * a collection you already have -- the way to use a database with data in it
266
+ * rather than duplicating it.
267
+ *
268
+ * | Status | Code | Meaning |
269
+ * | --- | --- | --- |
270
+ * | 404 | `not_found` | No such store in this account. |
271
+ * | 409 | `conflict` | This store already has a schema for that collection name. |
272
+ * | 422 | `validation_failed` | A field name that slugs to nothing, a duplicate after slugging, or a default of the wrong type. |
273
+ *
274
+ * Scope: `datastores:write`.
275
+ */
276
+ create(store, input) {
277
+ return this.http.request('POST', collectionsPath(store), { body: input });
278
+ }
279
+ /**
280
+ * `GET /v1/datastores/:store/collections` -- offset paginated,
281
+ * newest first. `page`, `rows`, and `search` on the title.
282
+ *
283
+ * Scope: `datastores:read`.
284
+ */
285
+ list(store, query = {}) {
286
+ return this.http.request('GET', collectionsPath(store), { query });
287
+ }
288
+ /**
289
+ * `GET /v1/datastores/:store/collections/:collection`.
290
+ *
291
+ * Both ids are checked: a collection id belonging to a different store -- even
292
+ * one of your own -- is a 404 rather than a match.
293
+ *
294
+ * Scope: `datastores:read`.
295
+ */
296
+ get(store, collection) {
297
+ return this.http.request('GET', collectionPath(store, collection));
298
+ }
299
+ /**
300
+ * `PATCH /v1/datastores/:store/collections/:collection`.
301
+ *
302
+ * `title`, `fields`, `show_in_chat` and `display`. Not `collection`: a schema
303
+ * points at one collection for its whole life, and re-pointing it would orphan
304
+ * every record written through it. Point a new schema at the other collection
305
+ * instead.
306
+ *
307
+ * Scope: `datastores:write`.
308
+ */
309
+ update(store, collection, input) {
310
+ return this.http.request('PATCH', collectionPath(store, collection), {
311
+ body: input,
312
+ });
313
+ }
314
+ /**
315
+ * `DELETE /v1/datastores/:store/collections/:collection` -- 204.
316
+ *
317
+ * Forgets the declaration. **Your collection and its documents remain** --
318
+ * declaring the same collection name again reads the same records back.
319
+ *
320
+ * Scope: `datastores:write`.
321
+ */
322
+ remove(store, collection) {
323
+ return this.http.request('DELETE', collectionPath(store, collection));
324
+ }
325
+ }
326
+ exports.DataStoreCollections = DataStoreCollections;
327
+ /**
328
+ * The records in a data store collection -- documents in **your** database.
329
+ *
330
+ * ```ts
331
+ * await crm.dataStoreRecords.insert(store.id, orders.id, {
332
+ * records: [{ order_no: 'A-1', total: 10 }, { order_no: 'A-2', total: 20 }],
333
+ * });
334
+ *
335
+ * const { data, pagination } = await crm.dataStoreRecords.search(store.id, orders.id, {
336
+ * filter: { paid: false, total: { $gte: 20 } },
337
+ * sort: 'total',
338
+ * order: 'desc',
339
+ * });
340
+ * ```
341
+ *
342
+ * ## Writes are validated against the declaration
343
+ *
344
+ * Keys must be declared field names, and values are coerced to the declared
345
+ * type -- `"42"` into a `Number` field is stored as `42`, an ISO string into a
346
+ * `Date` field as a date. An **undeclared key is a 422 naming it**, which is the
347
+ * one deliberate break from the legacy endpoint: there, an unknown key was
348
+ * dropped silently, so a typo meant data quietly went nowhere.
349
+ *
350
+ * `null` clears a field. `created_on` and `updated_on` are stamped by the server
351
+ * -- unix seconds, or real dates if the collection declared them as `Date` --
352
+ * and ignored if you send them. `id` cannot be written.
353
+ *
354
+ * ## Reads return everything that is stored
355
+ *
356
+ * Including keys the schema does not declare, because the documents are yours
357
+ * and may have been written by something else. `_id` reads back as `id`.
358
+ *
359
+ * ## There is no aggregation endpoint
360
+ *
361
+ * Deliberately: a pipeline can read other collections with `$lookup` and write
362
+ * them with `$merge`, which would make a schema's boundary meaningless, and
363
+ * `$function` runs JavaScript on your cluster. The same three operators are
364
+ * refused inside a filter. For anything that needs a pipeline, use your own
365
+ * credentials and your own driver -- it is your database.
366
+ */
367
+ class DataStoreRecords {
368
+ http;
369
+ constructor(http) {
370
+ this.http = http;
371
+ }
372
+ /**
373
+ * `POST /v1/datastores/:store/collections/:collection/records` -- 201.
374
+ *
375
+ * | Field | Type | Notes |
376
+ * | --- | --- | --- |
377
+ * | `record` | object | One record. Exactly one of this or `records`. |
378
+ * | `records` | object[] | 1-1000 records. |
379
+ *
380
+ * ```ts
381
+ * const { inserted, ids } = await crm.dataStoreRecords.insert(store, collection, {
382
+ * records: rows,
383
+ * });
384
+ * ```
385
+ *
386
+ * A batch is **unordered**: one document rejected by a unique index of yours
387
+ * does not abandon the rest, so `inserted` may be lower than what you sent.
388
+ * `ids` are in the order the documents were sent.
389
+ *
390
+ * Prefer one call with `records` over a loop of single inserts -- each call is
391
+ * a round trip to your cluster.
392
+ *
393
+ * Scope: `datastore-records:write`.
394
+ */
395
+ insert(store, collection, input) {
396
+ return this.http.request('POST', recordsPath(store, collection), {
397
+ body: input,
398
+ });
399
+ }
400
+ /**
401
+ * `GET /v1/datastores/:store/collections/:collection/records`
402
+ *
403
+ * | Query | Type | Default | Notes |
404
+ * | --- | --- | --- | --- |
405
+ * | `page` | number | `1` | 1-based. |
406
+ * | `rows` | number | `25` | 1-100. |
407
+ * | `sort` | string | `created_on` | Any field name. |
408
+ * | `order` | `asc` \| `desc` | `desc` | |
409
+ *
410
+ * `_id` is appended to the sort as a tiebreaker, so paging is reproducible
411
+ * even when the sort field repeats -- or does not exist, which it will not on
412
+ * an adopted collection that something else wrote.
413
+ *
414
+ * Scope: `datastore-records:read`.
415
+ */
416
+ list(store, collection, query = {}) {
417
+ return this.http.request('GET', recordsPath(store, collection), {
418
+ query,
419
+ });
420
+ }
421
+ /**
422
+ * `POST /v1/datastores/:store/collections/:collection/records/search`
423
+ *
424
+ * | Field | Type | Notes |
425
+ * | --- | --- | --- |
426
+ * | `filter` | object | A Mongo query. Required; `{}` matches everything. |
427
+ * | `page` `rows` `sort` `order` | | As `list`. |
428
+ *
429
+ * ```ts
430
+ * await crm.dataStoreRecords.search(store, collection, {
431
+ * filter: {
432
+ * $or: [{ status: 'open' }, { total: { $gte: 100 } }],
433
+ * signed_up: { $gte: '2026-01-01' }, // coerced to a Date for a Date field
434
+ * tags: 'vip', // an Array field contains this
435
+ * },
436
+ * });
437
+ * ```
438
+ *
439
+ * A POST because a Mongo filter is a nested object and encoding one into a
440
+ * query string is a different argument in every HTTP client. It reads and
441
+ * changes nothing.
442
+ *
443
+ * Operand values are coerced per declared field, so dates and numbers written
444
+ * as JSON strings match. `$where`, `$function` and `$accumulator` are refused
445
+ * with `422 filter_operator_not_allowed`, and a filter nested deeper than ten
446
+ * levels or holding more than 500 keys with `422 filter_too_complex`.
447
+ *
448
+ * Scope: `datastore-records:read`.
449
+ */
450
+ search(store, collection, input) {
451
+ return this.http.request('POST', `${recordsPath(store, collection)}/search`, { body: input });
452
+ }
453
+ /**
454
+ * `GET /v1/datastores/:store/collections/:collection/records/:record`
455
+ *
456
+ * 404 when there is no such document. Scope: `datastore-records:read`.
457
+ */
458
+ get(store, collection, record) {
459
+ return this.http.request('GET', `${recordsPath(store, collection)}/${(0, paths_1.seg)(record)}`);
460
+ }
461
+ /**
462
+ * `PATCH /v1/datastores/:store/collections/:collection/records/:record`
463
+ *
464
+ * | Field | Type | Notes |
465
+ * | --- | --- | --- |
466
+ * | `record` | object | The fields to change. Validated exactly as an insert. |
467
+ *
468
+ * A `$set` of those fields and nothing else -- keys you leave out are
469
+ * untouched, and `null` clears a value. `updated_on` is stamped; `created_on`
470
+ * cannot be moved. Returns the record as it is after the write.
471
+ *
472
+ * Scope: `datastore-records:write`.
473
+ */
474
+ update(store, collection, record, input) {
475
+ return this.http.request('PATCH', `${recordsPath(store, collection)}/${(0, paths_1.seg)(record)}`, { body: input });
476
+ }
477
+ /**
478
+ * `POST /v1/datastores/:store/collections/:collection/records/bulk-update`
479
+ *
480
+ * | Field | Type | Notes |
481
+ * | --- | --- | --- |
482
+ * | `filter` | object | Required and **non-empty**. |
483
+ * | `update` | object | The fields to set on every match. |
484
+ *
485
+ * ```ts
486
+ * const { matched, modified } = await crm.dataStoreRecords.bulkUpdate(store, collection, {
487
+ * filter: { status: 'pending', created_on: { $lt: cutoff } },
488
+ * update: { status: 'expired' },
489
+ * });
490
+ * ```
491
+ *
492
+ * `{}` as the filter is refused: it matches the whole collection, and a
493
+ * one-character slip that rewrites every record is not something to make
494
+ * convenient. `modified` is lower than `matched` where a record already held
495
+ * the values.
496
+ *
497
+ * Scope: `datastore-records:write`.
498
+ */
499
+ bulkUpdate(store, collection, input) {
500
+ return this.http.request('POST', `${recordsPath(store, collection)}/bulk-update`, { body: input });
501
+ }
502
+ /**
503
+ * `DELETE /v1/datastores/:store/collections/:collection/records/:record`
504
+ *
505
+ * 404 when there is no such document. This one really does delete your data.
506
+ *
507
+ * Scope: `datastore-records:write`.
508
+ */
509
+ remove(store, collection, record) {
510
+ return this.http.request('DELETE', `${recordsPath(store, collection)}/${(0, paths_1.seg)(record)}`);
511
+ }
512
+ /**
513
+ * `POST /v1/datastores/:store/collections/:collection/records/bulk-delete`
514
+ *
515
+ * | Field | Type | Notes |
516
+ * | --- | --- | --- |
517
+ * | `filter` | object | Required and **non-empty**. |
518
+ *
519
+ * Deletes every match, irreversibly, from your database. The empty filter is
520
+ * refused for the same reason as in `bulkUpdate` -- emptying a collection
521
+ * deliberately means paging through it.
522
+ *
523
+ * Scope: `datastore-records:write`.
524
+ */
525
+ bulkRemove(store, collection, input) {
526
+ return this.http.request('POST', `${recordsPath(store, collection)}/bulk-delete`, { body: input });
527
+ }
528
+ }
529
+ exports.DataStoreRecords = DataStoreRecords;
530
+ //# sourceMappingURL=data-stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-stores.js","sourceRoot":"","sources":["../../src/resources/data-stores.ts"],"names":[],"mappings":";;;AAsBA,mCAAyC;AAEzC,MAAM,IAAI,GAAG,iBAAS,CAAC;AAEvB,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,KAAK,CAAC,EAAE,CAAC;AAC7D,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;AAC7E,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,UAAkB,EAAE,EAAE,CAC3D,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,IAAA,WAAG,EAAC,UAAU,CAAC,EAAE,CAAC;AACjD,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,UAAkB,EAAE,EAAE,CACxD,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC;AAEjD;;;;;;;;;;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,KAAK,EAAE,UAAU,CAAC,IAAI,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,EAClD,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CAAC,KAAa,EAAE,UAAkB,EAAE,KAAsC;QAClF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,MAAM,EACN,GAAG,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,EAC/C,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAa,EAAE,UAAkB,EAAE,MAAc;QACtD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,QAAQ,EACR,GAAG,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,CACnD,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,KAAa,EAAE,UAAkB,EAAE,KAAsC;QAClF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,MAAM,EACN,GAAG,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,EAC/C,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACJ,CAAC;CACF;AA5LD,4CA4LC"}
@@ -8,5 +8,11 @@
8
8
  */
9
9
  export declare const AUDIENCE = "/v1/audience";
10
10
  export declare const CHANNELS = "/v1/channels";
11
+ /**
12
+ * The data store service, which the gateway proxies at its own path rather than
13
+ * under another service's prefix -- it is a service of its own, with its own
14
+ * database and its own deployment.
15
+ */
16
+ export declare const DATASTORE = "/v1/datastores";
11
17
  /** Path segments are escaped: an id from a caller must not be able to add one. */
12
18
  export declare const seg: (value: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.seg = exports.CHANNELS = exports.AUDIENCE = void 0;
3
+ exports.seg = exports.DATASTORE = exports.CHANNELS = exports.AUDIENCE = void 0;
4
4
  /**
5
5
  * Where each service sits behind the gateway.
6
6
  *
@@ -11,6 +11,12 @@ exports.seg = exports.CHANNELS = exports.AUDIENCE = void 0;
11
11
  */
12
12
  exports.AUDIENCE = '/v1/audience';
13
13
  exports.CHANNELS = '/v1/channels';
14
+ /**
15
+ * The data store service, which the gateway proxies at its own path rather than
16
+ * under another service's prefix -- it is a service of its own, with its own
17
+ * database and its own deployment.
18
+ */
19
+ exports.DATASTORE = '/v1/datastores';
14
20
  /** Path segments are escaped: an id from a caller must not be able to add one. */
15
21
  const seg = (value) => encodeURIComponent(String(value));
16
22
  exports.seg = seg;
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/resources/paths.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACU,QAAA,QAAQ,GAAG,cAAc,CAAC;AAC1B,QAAA,QAAQ,GAAG,cAAc,CAAC;AAEvC,kFAAkF;AAC3E,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAAnE,QAAA,GAAG,OAAgE"}
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/resources/paths.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACU,QAAA,QAAQ,GAAG,cAAc,CAAC;AAC1B,QAAA,QAAQ,GAAG,cAAc,CAAC;AAEvC;;;;GAIG;AACU,QAAA,SAAS,GAAG,gBAAgB,CAAC;AAE1C,kFAAkF;AAC3E,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAAnE,QAAA,GAAG,OAAgE"}