@transifex/native 2.4.1 → 3.2.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 CHANGED
@@ -243,6 +243,87 @@ const html = t('<b>Hello {username}</b>', {
243
243
  });
244
244
  ```
245
245
 
246
+ ## Push source content
247
+
248
+ For server side integrations you can also push source content programmatically
249
+ without using the CLI.
250
+
251
+ ```js
252
+ tx.pushSource(payload, params): Promise
253
+ payload: Object({
254
+ key: {
255
+ string: String,
256
+ meta: {
257
+ context: String,
258
+ developer_comment: String,
259
+ character_limit: Number,
260
+ tags: Array(String),
261
+ occurrences: Array(String),
262
+ },
263
+ },
264
+ key: { .. }
265
+ })
266
+ params: Object({
267
+ // Replace the entire resource content with the pushed content of this request
268
+ purge: Boolean,
269
+
270
+ // Replace the existing string tags with the tags of this request
271
+ overrideTags: Boolean,
272
+
273
+ // If true, when wait for processing to be complete before
274
+ // resolving this promise
275
+ noWait: Boolean,
276
+ })
277
+ ```
278
+
279
+ For example:
280
+
281
+ ```js
282
+ const { createNativeInstance } = require('@transifex/native');
283
+
284
+ const tx = createNativeInstance({
285
+ token: 'token',
286
+ secret: 'secret',
287
+ });
288
+
289
+ await tx.pushSource({
290
+ 'mykey': {
291
+ string: 'My string',
292
+ meta: {
293
+ context: 'content', // optional
294
+ developer_comment: 'developer comment', // optional
295
+ character_limit: 10, // optional
296
+ tags: ['tag1', 'tag2'], // optional
297
+ occurrences: ['file.jsx', 'file2.js'], // optional
298
+ },
299
+ }
300
+ });
301
+ ```
302
+
303
+ ## Invalidate CDS cache
304
+
305
+ Server side integrations can also invalidate the CDS cache programmatically.
306
+
307
+ ```js
308
+ tx.invalidateCDS({
309
+ // if true, then purge the cache entirely (not recommended)
310
+ purge: Boolean,
311
+ }): Promise
312
+ ```
313
+
314
+ For example:
315
+
316
+ ```js
317
+ const { createNativeInstance } = require('@transifex/native');
318
+
319
+ const tx = createNativeInstance({
320
+ token: 'token',
321
+ secret: 'secret',
322
+ });
323
+
324
+ await tx.invalidateCDS();
325
+ ```
326
+
246
327
  ## Events
247
328
 
248
329
  Library for listening to various async events.