@vtecx/vtecxnext 2.1.0 → 2.1.2

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.
@@ -409,6 +409,29 @@ export declare class VtecxNext {
409
409
  * @return true
410
410
  */
411
411
  getBQCsv: (sql: string, values?: any[], filename?: string, parent?: string) => Promise<boolean>;
412
+ /**
413
+ * post data to bdb and bigquery
414
+ * @param feed entries (JSON)
415
+ * @param uri parent key if not specified in entry
416
+ * @param tablenames key:entity's prop name, value:BigQuery table name
417
+ * @return registed entries
418
+ */
419
+ postBDBQ: (feed: any, uri?: string, tablenames?: any) => Promise<boolean>;
420
+ /**
421
+ * put data to bdb and post bigquery
422
+ * @param feed entries (JSON)
423
+ * @param uri parent key if not specified in entry
424
+ * @param tablenames key:entity's prop name, value:BigQuery table name
425
+ * @return true if successful
426
+ */
427
+ putBDBQ: (feed: any, uri?: string, tablenames?: any) => Promise<any>;
428
+ /**
429
+ * delete data from bdb and bigquery
430
+ * @param keys delete keys
431
+ * @param tablenames key:entity's prop name, value:BigQuery table name
432
+ * @return true if successful
433
+ */
434
+ deleteBDBQ: (keys: string[], tablenames?: any) => Promise<boolean>;
412
435
  /**
413
436
  * Execute a query SQL to the database and get the result.
414
437
  * @param sql query sql
package/dist/vtecxnext.js CHANGED
@@ -1541,6 +1541,128 @@ class VtecxNext {
1541
1541
  //console.log(`[vtecxnext getBQCsv] res.end(new Uint8Array(csvData))`)
1542
1542
  return true;
1543
1543
  };
1544
+ /**
1545
+ * post data to bdb and bigquery
1546
+ * @param feed entries (JSON)
1547
+ * @param uri parent key if not specified in entry
1548
+ * @param tablenames key:entity's prop name, value:BigQuery table name
1549
+ * @return registed entries
1550
+ */
1551
+ postBDBQ = async (feed, uri, tablenames) => {
1552
+ //console.log(`[vtecxnext postBQ] start. async=${async} feed=${feed}`)
1553
+ // 入力チェック
1554
+ checkNotNull(feed, 'Feed');
1555
+ if (uri) {
1556
+ // 値の設定がある場合、キー入力値チェック
1557
+ checkUri(uri);
1558
+ }
1559
+ // リクエストデータ
1560
+ const reqFeed = 'feed' in feed ? feed : { 'feed': { 'entry': feed } };
1561
+ // テーブル名の指定がある場合は指定
1562
+ const tablenamesStr = editBqTableNames(tablenames);
1563
+ if (tablenamesStr) {
1564
+ reqFeed.feed['title'] = tablenamesStr;
1565
+ }
1566
+ // vte.cxへリクエスト
1567
+ const method = 'POST';
1568
+ const url = `${SERVLETPATH_PROVIDER}${uri ? uri : '/'}?_bdbq`;
1569
+ let response;
1570
+ try {
1571
+ response = await this.requestVtecx(method, url, JSON.stringify(reqFeed));
1572
+ }
1573
+ catch (e) {
1574
+ throw newFetchError(e, true);
1575
+ }
1576
+ //console.log(`[vtecxnext postBDBQ] response. status=${response.status}`)
1577
+ // vte.cxからのset-cookieを転記
1578
+ this.setCookie(response);
1579
+ // レスポンスのエラーチェック
1580
+ await checkVtecxResponse(response);
1581
+ return await getJson(response);
1582
+ };
1583
+ /**
1584
+ * put data to bdb and post bigquery
1585
+ * @param feed entries (JSON)
1586
+ * @param uri parent key if not specified in entry
1587
+ * @param tablenames key:entity's prop name, value:BigQuery table name
1588
+ * @return true if successful
1589
+ */
1590
+ putBDBQ = async (feed, uri, tablenames) => {
1591
+ //console.log(`[vtecxnext putBDBQ] start. feed=${feed}`)
1592
+ // 入力チェック
1593
+ checkNotNull(feed, 'Feed');
1594
+ if (uri) {
1595
+ // 値の設定がある場合、キー入力値チェック
1596
+ checkUri(uri);
1597
+ }
1598
+ // リクエストデータ
1599
+ const reqFeed = 'feed' in feed ? feed : { 'feed': { 'entry': feed } };
1600
+ // テーブル名の指定がある場合は指定
1601
+ const tablenamesStr = editBqTableNames(tablenames);
1602
+ //console.log(`[putBDBQ] tableamesStr=${tablenamesStr}`)
1603
+ if (tablenamesStr) {
1604
+ reqFeed.feed['title'] = tablenamesStr;
1605
+ }
1606
+ // vte.cxへリクエスト
1607
+ const method = 'PUT';
1608
+ const url = `${SERVLETPATH_PROVIDER}${uri ? uri : '/'}?_bdbq`;
1609
+ let response;
1610
+ try {
1611
+ response = await this.requestVtecx(method, url, JSON.stringify(reqFeed));
1612
+ }
1613
+ catch (e) {
1614
+ throw newFetchError(e, true);
1615
+ }
1616
+ //console.log(`[vtecxnext putBDBQ] response. status=${response.status}`)
1617
+ // vte.cxからのset-cookieを転記
1618
+ this.setCookie(response);
1619
+ // レスポンスのエラーチェック
1620
+ await checkVtecxResponse(response);
1621
+ return await getJson(response);
1622
+ };
1623
+ /**
1624
+ * delete data from bdb and bigquery
1625
+ * @param keys delete keys
1626
+ * @param tablenames key:entity's prop name, value:BigQuery table name
1627
+ * @return true if successful
1628
+ */
1629
+ deleteBDBQ = async (keys, tablenames) => {
1630
+ //console.log(`[vtecxnext deleteBDBQ] start. keys=${keys}`)
1631
+ // 入力チェック
1632
+ checkNotNull(keys, 'Key');
1633
+ // テーブル名の指定がある場合は指定
1634
+ const tablenamesStr = editBqTableNames(tablenames);
1635
+ // キーを feed.link.___href にセットする
1636
+ const links = [];
1637
+ let idx = 0;
1638
+ for (const key of keys) {
1639
+ //console.log(`[vtecxnext deleteBDBQ] key=${key}`)
1640
+ links[idx] = { '___href': key };
1641
+ idx++;
1642
+ }
1643
+ const feed = { 'feed': {} };
1644
+ if (tablenamesStr) {
1645
+ feed.feed['title'] = tablenamesStr;
1646
+ }
1647
+ feed.feed['link'] = links;
1648
+ //console.log(`[vtecxnext deleteBDBQ] feed=${feed}`)
1649
+ // vte.cxへリクエスト
1650
+ const method = 'DELETE';
1651
+ const url = `${SERVLETPATH_PROVIDER}/?_bdbq`;
1652
+ let response;
1653
+ try {
1654
+ response = await this.requestVtecx(method, url, JSON.stringify(feed));
1655
+ }
1656
+ catch (e) {
1657
+ throw newFetchError(e, true);
1658
+ }
1659
+ //console.log(`[vtecxnext deleteBDBQ] response. status=${response.status}`)
1660
+ // vte.cxからのset-cookieを転記
1661
+ this.setCookie(response);
1662
+ // レスポンスのエラーチェック
1663
+ await checkVtecxResponse(response);
1664
+ return true;
1665
+ };
1544
1666
  /**
1545
1667
  * Execute a query SQL to the database and get the result.
1546
1668
  * @param sql query sql
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [