@plaidev/karte-action-sdk 1.1.229-28646430.813d5148 → 1.1.229-28646443.12e5acc3

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.
@@ -166,6 +166,7 @@ type SystemConfig = {
166
166
  * API キー
167
167
  */
168
168
  apiKey?: string;
169
+ collection_endpoint?: string;
169
170
  /**
170
171
  * 接客ID
171
172
  */
@@ -182,6 +183,8 @@ type ActionHookLog = {
182
183
  */
183
184
  type ActionRunnerContext = {
184
185
  api_key: string;
186
+ // TODO: edgejsのリリース状況によっては入ってこない可能性があるためoptionalにしているが、リリース完了後にrequiredに変更する
187
+ collection_endpoint?: string;
185
188
  target?: "web" | "native";
186
189
  };
187
190
  type ActionTableResult = number | string | boolean | Date | null | undefined;
@@ -199,7 +202,7 @@ type ActionTableQueryParams = {
199
202
  type CollectionConfig = {
200
203
  api_key: string;
201
204
  table: string;
202
- endpoint?: string;
205
+ collection_endpoint?: string;
203
206
  };
204
207
  /**
205
208
  * アクションテーブルを管理するメソッドを取得する
@@ -262,19 +265,19 @@ type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsReq
262
265
  /** @internal */
263
266
  declare const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
264
267
  [key: string]: any;
265
- }, api_key: string, endpoint?: string) => Promise<unknown>;
268
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
266
269
  /** @internal */
267
270
  declare const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
268
271
  [key: string]: any;
269
- }, api_key: string, endpoint?: string) => Promise<unknown>;
272
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
270
273
  /** @internal */
271
274
  declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
272
275
  [key: string]: any;
273
- }, api_key: string, endpoint?: string) => Promise<unknown>;
276
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
274
277
  /** @internal */
275
278
  declare const loadActionTable: (config: Array<VariableQuery>, data: {
276
279
  [key: string]: any;
277
- }, api_key: string, endpoint?: string) => Promise<{
280
+ }, api_key: string, collection_endpoint?: string) => Promise<{
278
281
  [key: string]: any;
279
282
  }>;
280
283
  /**
@@ -1729,6 +1732,7 @@ declare namespace widget {
1729
1732
  * API キー
1730
1733
  */
1731
1734
  apiKey?: string;
1735
+ collection_endpoint?: string;
1732
1736
  /**
1733
1737
  * 接客ID
1734
1738
  */
@@ -1745,6 +1749,8 @@ declare namespace widget {
1745
1749
  */
1746
1750
  type ActionRunnerContext = {
1747
1751
  api_key: string;
1752
+ // TODO: edgejsのリリース状況によっては入ってこない可能性があるためoptionalにしているが、リリース完了後にrequiredに変更する
1753
+ collection_endpoint?: string;
1748
1754
  target?: "web" | "native";
1749
1755
  };
1750
1756
  type ActionTableResult = number | string | boolean | Date | null | undefined;
@@ -1762,7 +1768,7 @@ declare namespace widget {
1762
1768
  type CollectionConfig = {
1763
1769
  api_key: string;
1764
1770
  table: string;
1765
- endpoint?: string;
1771
+ collection_endpoint?: string;
1766
1772
  };
1767
1773
  /**
1768
1774
  * アクションテーブルを管理するメソッドを取得する
@@ -1825,25 +1831,25 @@ declare namespace widget {
1825
1831
  /** @internal */
1826
1832
  const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
1827
1833
  [key: string]: any;
1828
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1834
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1829
1835
  /** @internal */
1830
1836
  const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
1831
1837
  [key: string]: any;
1832
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1838
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1833
1839
  /** @internal */
1834
1840
  const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
1835
1841
  [key: string]: any;
1836
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1842
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1837
1843
  /** @internal */
1838
1844
  const loadActionTable: (config: Array<VariableQuery>, data: {
1839
1845
  [key: string]: any;
1840
- }, api_key: string, endpoint?: string) => Promise<{
1846
+ }, api_key: string, collection_endpoint?: string) => Promise<{
1841
1847
  [key: string]: any;
1842
1848
  }>;
1843
1849
  /** @internal */
1844
1850
  function setupActionTable(localVariablesQuery: Array<VariableQuery>, data: {
1845
1851
  [key: string]: any;
1846
- }, apiKey: string): Promise<{
1852
+ }, apiKey: string, collection_endpoint: string): Promise<{
1847
1853
  success: boolean;
1848
1854
  }>;
1849
1855
  /** @internal */
@@ -1335,9 +1335,7 @@ function showOnTime(props, show = NOOP) {
1335
1335
  /**
1336
1336
  * アクションテーブルに関連するコードの管理
1337
1337
  */
1338
- const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
1339
- ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
1340
- : 'https://action-table.karte.io/collection';
1338
+ const DEFAULT_COLLECTION_ENDPOINT = 'https://action-table.karte.io/collection';
1341
1339
  /**
1342
1340
  * アクションテーブルを管理するメソッドを取得する
1343
1341
  *
@@ -1348,7 +1346,7 @@ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__
1348
1346
  * @public
1349
1347
  */
1350
1348
  function collection$1(config) {
1351
- const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1349
+ const endpoint = config.collection_endpoint || DEFAULT_COLLECTION_ENDPOINT;
1352
1350
  const api_key = config.api_key;
1353
1351
  const table = config.table;
1354
1352
  return {
@@ -1430,7 +1428,7 @@ function request(url, data, cb) {
1430
1428
  });
1431
1429
  }
1432
1430
  /** @internal */
1433
- const loadActionTableRow = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1431
+ const loadActionTableRow = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1434
1432
  const defaultValue = config.query.default_value ?? null;
1435
1433
  const key = data[config.query.key] ?? null;
1436
1434
  if (key == null) {
@@ -1440,7 +1438,7 @@ const loadActionTableRow = async (config, data, api_key, endpoint) => new Promis
1440
1438
  }
1441
1439
  return reject('key is not found.');
1442
1440
  }
1443
- return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => {
1441
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => {
1444
1442
  if (err) {
1445
1443
  if (defaultValue != null) {
1446
1444
  return resolve(defaultValue);
@@ -1460,7 +1458,7 @@ const loadActionTableRow = async (config, data, api_key, endpoint) => new Promis
1460
1458
  });
1461
1459
  });
1462
1460
  /** @internal */
1463
- const loadActionTableRows = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1461
+ const loadActionTableRows = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1464
1462
  if (config.query.keys == null) {
1465
1463
  console.warn('key is not defined.');
1466
1464
  return reject('key is not defined.');
@@ -1483,7 +1481,7 @@ const loadActionTableRows = async (config, data, api_key, endpoint) => new Promi
1483
1481
  }
1484
1482
  return reject('key is not found.');
1485
1483
  }
1486
- return collection$1({ endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => {
1484
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => {
1487
1485
  if (err) {
1488
1486
  if (defaultValue != null) {
1489
1487
  return resolve(defaultValue);
@@ -1503,7 +1501,7 @@ const loadActionTableRows = async (config, data, api_key, endpoint) => new Promi
1503
1501
  });
1504
1502
  });
1505
1503
  /** @internal */
1506
- const loadActionTableQuery = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1504
+ const loadActionTableQuery = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1507
1505
  if (config.query.params == null) {
1508
1506
  console.warn('key is not defined.');
1509
1507
  return reject('key is not defined.');
@@ -1525,7 +1523,7 @@ const loadActionTableQuery = async (config, data, api_key, endpoint) => new Prom
1525
1523
  }
1526
1524
  return reject('key is not found.');
1527
1525
  }
1528
- return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => {
1526
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => {
1529
1527
  if (err) {
1530
1528
  if (defaultValue != null) {
1531
1529
  return resolve(defaultValue);
@@ -1545,8 +1543,8 @@ const loadActionTableQuery = async (config, data, api_key, endpoint) => new Prom
1545
1543
  });
1546
1544
  });
1547
1545
  /** @internal */
1548
- const loadActionTable = async (config, data, api_key, endpoint) => {
1549
- console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
1546
+ const loadActionTable = async (config, data, api_key, collection_endpoint) => {
1547
+ console.debug('[debug] loadActionTable', isPreview(), api_key, collection_endpoint, JSON.stringify(config));
1550
1548
  const results = config.map(c => c.preview_value)
1551
1549
  ;
1552
1550
  return config.reduce((acc, c, i) => {
@@ -1558,8 +1556,8 @@ const loadActionTable = async (config, data, api_key, endpoint) => {
1558
1556
  }, {});
1559
1557
  };
1560
1558
  /** @internal */
1561
- async function setupActionTable(localVariablesQuery, data, apiKey) {
1562
- const result = await loadActionTable(localVariablesQuery, data, apiKey);
1559
+ async function setupActionTable(localVariablesQuery, data, apiKey, collection_endpoint) {
1560
+ const result = await loadActionTable(localVariablesQuery, data, apiKey, collection_endpoint);
1563
1561
  let success = false;
1564
1562
  if (Object.keys(result).length === localVariablesQuery.length) {
1565
1563
  setVariables(result);
@@ -1775,7 +1773,7 @@ function createModal(App, options = {
1775
1773
  variables: {},
1776
1774
  localVariablesQuery: undefined,
1777
1775
  karteTemplate: {},
1778
- context: { api_key: '' },
1776
+ context: { api_key: '', collection_endpoint: undefined },
1779
1777
  }) {
1780
1778
  let app = null;
1781
1779
  const data = getVariables();
@@ -1882,7 +1880,7 @@ function createModal(App, options = {
1882
1880
  initActionTable(options.localVariablesQuery);
1883
1881
  let actionTablePromise = null;
1884
1882
  if (options.localVariablesQuery && data.api_key) {
1885
- actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
1883
+ actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key, options.context.collection_endpoint);
1886
1884
  }
1887
1885
  // NOTE: onCreateより前にListenする必要がある
1888
1886
  window.addEventListener(ACTION_SHOW_EVENT, handleShow);
@@ -2057,14 +2055,14 @@ async function runScript$1(options = {
2057
2055
  variables: {},
2058
2056
  localVariablesQuery: undefined,
2059
2057
  karteTemplate: {},
2060
- context: { api_key: '' },
2058
+ context: { api_key: '', collection_endpoint: undefined },
2061
2059
  }) {
2062
2060
  if (!options.onCreate)
2063
2061
  return;
2064
2062
  let data = getVariables();
2065
2063
  initialize({ send: options.send, initialState: data.initial_state });
2066
2064
  initActionTable(options.localVariablesQuery);
2067
- const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
2065
+ const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key, options.context.collection_endpoint);
2068
2066
  if (!success)
2069
2067
  return;
2070
2068
  // Action Tableの取得結果を反映する
@@ -2150,6 +2148,15 @@ async function loadGlobalStyle(href) {
2150
2148
  *
2151
2149
  * アクションのCreate, Destroyの状態はここで管理する。
2152
2150
  */
2151
+ const emptyOptions = {
2152
+ send: () => { },
2153
+ publish: () => { },
2154
+ props: {},
2155
+ variables: {},
2156
+ localVariablesQuery: undefined,
2157
+ karteTemplate: {},
2158
+ context: { api_key: '', collection_endpoint: undefined },
2159
+ };
2153
2160
  /**
2154
2161
  * アクションを作成する
2155
2162
  *
@@ -2160,15 +2167,9 @@ async function loadGlobalStyle(href) {
2160
2167
  *
2161
2168
  * @public
2162
2169
  */
2163
- function create(App, options = {
2164
- send: () => { },
2165
- publish: () => { },
2166
- props: {},
2167
- variables: {},
2168
- localVariablesQuery: undefined,
2169
- karteTemplate: {},
2170
- context: { api_key: '' },
2171
- }) {
2170
+ function create(App, options) {
2171
+ // TSの型検査が効かない場所やエラーを無視している箇所があるため、念の為
2172
+ options = { ...emptyOptions, ...options };
2172
2173
  setVariables({
2173
2174
  ...options.props,
2174
2175
  ...options.variables,
@@ -2196,6 +2197,7 @@ function create(App, options = {
2196
2197
  setSystem({
2197
2198
  // @ts-ignore
2198
2199
  apiKey: data.api_key || null,
2200
+ collection_endpoint: options.context.collection_endpoint,
2199
2201
  shortenId: data.shorten_id || null,
2200
2202
  campaignId: data.campaign_id || null,
2201
2203
  });
@@ -2751,7 +2753,11 @@ const storage = {
2751
2753
  function collection(table) {
2752
2754
  const systemConfig = getSystem();
2753
2755
  const collectionName = table.replace(/^v2\//, '');
2754
- return collection$1({ api_key: systemConfig.apiKey || 'mock', table: collectionName });
2756
+ return collection$1({
2757
+ api_key: systemConfig.apiKey || 'mock',
2758
+ collection_endpoint: systemConfig.collection_endpoint,
2759
+ table: collectionName,
2760
+ });
2755
2761
  }
2756
2762
 
2757
2763
  var widget = /*#__PURE__*/Object.freeze({
@@ -166,6 +166,7 @@ type SystemConfig = {
166
166
  * API キー
167
167
  */
168
168
  apiKey?: string;
169
+ collection_endpoint?: string;
169
170
  /**
170
171
  * 接客ID
171
172
  */
@@ -182,6 +183,8 @@ type ActionHookLog = {
182
183
  */
183
184
  type ActionRunnerContext = {
184
185
  api_key: string;
186
+ // TODO: edgejsのリリース状況によっては入ってこない可能性があるためoptionalにしているが、リリース完了後にrequiredに変更する
187
+ collection_endpoint?: string;
185
188
  target?: "web" | "native";
186
189
  };
187
190
  type ActionTableResult = number | string | boolean | Date | null | undefined;
@@ -199,7 +202,7 @@ type ActionTableQueryParams = {
199
202
  type CollectionConfig = {
200
203
  api_key: string;
201
204
  table: string;
202
- endpoint?: string;
205
+ collection_endpoint?: string;
203
206
  };
204
207
  /**
205
208
  * アクションテーブルを管理するメソッドを取得する
@@ -262,19 +265,19 @@ type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsReq
262
265
  /** @internal */
263
266
  declare const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
264
267
  [key: string]: any;
265
- }, api_key: string, endpoint?: string) => Promise<unknown>;
268
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
266
269
  /** @internal */
267
270
  declare const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
268
271
  [key: string]: any;
269
- }, api_key: string, endpoint?: string) => Promise<unknown>;
272
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
270
273
  /** @internal */
271
274
  declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
272
275
  [key: string]: any;
273
- }, api_key: string, endpoint?: string) => Promise<unknown>;
276
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
274
277
  /** @internal */
275
278
  declare const loadActionTable: (config: Array<VariableQuery>, data: {
276
279
  [key: string]: any;
277
- }, api_key: string, endpoint?: string) => Promise<{
280
+ }, api_key: string, collection_endpoint?: string) => Promise<{
278
281
  [key: string]: any;
279
282
  }>;
280
283
  /**
@@ -1729,6 +1732,7 @@ declare namespace widget {
1729
1732
  * API キー
1730
1733
  */
1731
1734
  apiKey?: string;
1735
+ collection_endpoint?: string;
1732
1736
  /**
1733
1737
  * 接客ID
1734
1738
  */
@@ -1745,6 +1749,8 @@ declare namespace widget {
1745
1749
  */
1746
1750
  type ActionRunnerContext = {
1747
1751
  api_key: string;
1752
+ // TODO: edgejsのリリース状況によっては入ってこない可能性があるためoptionalにしているが、リリース完了後にrequiredに変更する
1753
+ collection_endpoint?: string;
1748
1754
  target?: "web" | "native";
1749
1755
  };
1750
1756
  type ActionTableResult = number | string | boolean | Date | null | undefined;
@@ -1762,7 +1768,7 @@ declare namespace widget {
1762
1768
  type CollectionConfig = {
1763
1769
  api_key: string;
1764
1770
  table: string;
1765
- endpoint?: string;
1771
+ collection_endpoint?: string;
1766
1772
  };
1767
1773
  /**
1768
1774
  * アクションテーブルを管理するメソッドを取得する
@@ -1825,25 +1831,25 @@ declare namespace widget {
1825
1831
  /** @internal */
1826
1832
  const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
1827
1833
  [key: string]: any;
1828
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1834
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1829
1835
  /** @internal */
1830
1836
  const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
1831
1837
  [key: string]: any;
1832
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1838
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1833
1839
  /** @internal */
1834
1840
  const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
1835
1841
  [key: string]: any;
1836
- }, api_key: string, endpoint?: string) => Promise<unknown>;
1842
+ }, api_key: string, collection_endpoint?: string) => Promise<unknown>;
1837
1843
  /** @internal */
1838
1844
  const loadActionTable: (config: Array<VariableQuery>, data: {
1839
1845
  [key: string]: any;
1840
- }, api_key: string, endpoint?: string) => Promise<{
1846
+ }, api_key: string, collection_endpoint?: string) => Promise<{
1841
1847
  [key: string]: any;
1842
1848
  }>;
1843
1849
  /** @internal */
1844
1850
  function setupActionTable(localVariablesQuery: Array<VariableQuery>, data: {
1845
1851
  [key: string]: any;
1846
- }, apiKey: string): Promise<{
1852
+ }, apiKey: string, collection_endpoint: string): Promise<{
1847
1853
  success: boolean;
1848
1854
  }>;
1849
1855
  /** @internal */
package/dist/index.es.js CHANGED
@@ -1363,9 +1363,7 @@ function checkAndDo(checkFn, fn, ...conditionFns) {
1363
1363
  /**
1364
1364
  * アクションテーブルに関連するコードの管理
1365
1365
  */
1366
- const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
1367
- ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
1368
- : 'https://action-table.karte.io/collection';
1366
+ const DEFAULT_COLLECTION_ENDPOINT = 'https://action-table.karte.io/collection';
1369
1367
  /**
1370
1368
  * アクションテーブルを管理するメソッドを取得する
1371
1369
  *
@@ -1376,7 +1374,7 @@ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__
1376
1374
  * @public
1377
1375
  */
1378
1376
  function collection$1(config) {
1379
- const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1377
+ const endpoint = config.collection_endpoint || DEFAULT_COLLECTION_ENDPOINT;
1380
1378
  const api_key = config.api_key;
1381
1379
  const table = config.table;
1382
1380
  return {
@@ -1458,7 +1456,7 @@ function request(url, data, cb) {
1458
1456
  });
1459
1457
  }
1460
1458
  /** @internal */
1461
- const loadActionTableRow = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1459
+ const loadActionTableRow = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1462
1460
  const defaultValue = config.query.default_value ?? null;
1463
1461
  const key = data[config.query.key] ?? null;
1464
1462
  if (key == null) {
@@ -1468,7 +1466,7 @@ const loadActionTableRow = async (config, data, api_key, endpoint) => new Promis
1468
1466
  }
1469
1467
  return reject('key is not found.');
1470
1468
  }
1471
- return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => {
1469
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => {
1472
1470
  if (err) {
1473
1471
  if (defaultValue != null) {
1474
1472
  return resolve(defaultValue);
@@ -1488,7 +1486,7 @@ const loadActionTableRow = async (config, data, api_key, endpoint) => new Promis
1488
1486
  });
1489
1487
  });
1490
1488
  /** @internal */
1491
- const loadActionTableRows = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1489
+ const loadActionTableRows = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1492
1490
  if (config.query.keys == null) {
1493
1491
  console.warn('key is not defined.');
1494
1492
  return reject('key is not defined.');
@@ -1511,7 +1509,7 @@ const loadActionTableRows = async (config, data, api_key, endpoint) => new Promi
1511
1509
  }
1512
1510
  return reject('key is not found.');
1513
1511
  }
1514
- return collection$1({ endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => {
1512
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => {
1515
1513
  if (err) {
1516
1514
  if (defaultValue != null) {
1517
1515
  return resolve(defaultValue);
@@ -1531,7 +1529,7 @@ const loadActionTableRows = async (config, data, api_key, endpoint) => new Promi
1531
1529
  });
1532
1530
  });
1533
1531
  /** @internal */
1534
- const loadActionTableQuery = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
1532
+ const loadActionTableQuery = async (config, data, api_key, collection_endpoint) => new Promise((resolve, reject) => {
1535
1533
  if (config.query.params == null) {
1536
1534
  console.warn('key is not defined.');
1537
1535
  return reject('key is not defined.');
@@ -1553,7 +1551,7 @@ const loadActionTableQuery = async (config, data, api_key, endpoint) => new Prom
1553
1551
  }
1554
1552
  return reject('key is not found.');
1555
1553
  }
1556
- return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => {
1554
+ return collection$1({ collection_endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => {
1557
1555
  if (err) {
1558
1556
  if (defaultValue != null) {
1559
1557
  return resolve(defaultValue);
@@ -1573,21 +1571,21 @@ const loadActionTableQuery = async (config, data, api_key, endpoint) => new Prom
1573
1571
  });
1574
1572
  });
1575
1573
  /** @internal */
1576
- const loadActionTable = async (config, data, api_key, endpoint) => {
1577
- console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
1574
+ const loadActionTable = async (config, data, api_key, collection_endpoint) => {
1575
+ console.debug('[debug] loadActionTable', isPreview(), api_key, collection_endpoint, JSON.stringify(config));
1578
1576
  const results = await Promise.all(config
1579
1577
  .filter(c => c.resolver === 'action-table-row' ||
1580
1578
  c.resolver === 'action-table-rows' ||
1581
1579
  c.resolver === 'action-table-query')
1582
1580
  .map(async (c) => {
1583
1581
  if (c.resolver === 'action-table-row') {
1584
- return await loadActionTableRow(c, data, api_key, endpoint);
1582
+ return await loadActionTableRow(c, data, api_key, collection_endpoint);
1585
1583
  }
1586
1584
  else if (c.resolver === 'action-table-rows') {
1587
- return await loadActionTableRows(c, data, api_key, endpoint);
1585
+ return await loadActionTableRows(c, data, api_key, collection_endpoint);
1588
1586
  }
1589
1587
  else if (c.resolver === 'action-table-query') {
1590
- return await loadActionTableQuery(c, data, api_key, endpoint);
1588
+ return await loadActionTableQuery(c, data, api_key, collection_endpoint);
1591
1589
  }
1592
1590
  }));
1593
1591
  return config.reduce((acc, c, i) => {
@@ -1599,8 +1597,8 @@ const loadActionTable = async (config, data, api_key, endpoint) => {
1599
1597
  }, {});
1600
1598
  };
1601
1599
  /** @internal */
1602
- async function setupActionTable(localVariablesQuery, data, apiKey) {
1603
- const result = await loadActionTable(localVariablesQuery, data, apiKey);
1600
+ async function setupActionTable(localVariablesQuery, data, apiKey, collection_endpoint) {
1601
+ const result = await loadActionTable(localVariablesQuery, data, apiKey, collection_endpoint);
1604
1602
  let success = false;
1605
1603
  if (Object.keys(result).length === localVariablesQuery.length) {
1606
1604
  setVariables(result);
@@ -1816,7 +1814,7 @@ function createModal(App, options = {
1816
1814
  variables: {},
1817
1815
  localVariablesQuery: undefined,
1818
1816
  karteTemplate: {},
1819
- context: { api_key: '' },
1817
+ context: { api_key: '', collection_endpoint: undefined },
1820
1818
  }) {
1821
1819
  let app = null;
1822
1820
  const data = getVariables();
@@ -1946,7 +1944,7 @@ function createModal(App, options = {
1946
1944
  initActionTable(options.localVariablesQuery);
1947
1945
  let actionTablePromise = null;
1948
1946
  if (options.localVariablesQuery && data.api_key) {
1949
- actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
1947
+ actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key, options.context.collection_endpoint);
1950
1948
  }
1951
1949
  // NOTE: onCreateより前にListenする必要がある
1952
1950
  window.addEventListener(ACTION_SHOW_EVENT, handleShow);
@@ -2121,14 +2119,14 @@ async function runScript$1(options = {
2121
2119
  variables: {},
2122
2120
  localVariablesQuery: undefined,
2123
2121
  karteTemplate: {},
2124
- context: { api_key: '' },
2122
+ context: { api_key: '', collection_endpoint: undefined },
2125
2123
  }) {
2126
2124
  if (!options.onCreate)
2127
2125
  return;
2128
2126
  let data = getVariables();
2129
2127
  initialize({ send: options.send, initialState: data.initial_state });
2130
2128
  initActionTable(options.localVariablesQuery);
2131
- const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
2129
+ const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key, options.context.collection_endpoint);
2132
2130
  if (!success)
2133
2131
  return;
2134
2132
  // Action Tableの取得結果を反映する
@@ -2214,6 +2212,15 @@ async function loadGlobalStyle(href) {
2214
2212
  *
2215
2213
  * アクションのCreate, Destroyの状態はここで管理する。
2216
2214
  */
2215
+ const emptyOptions = {
2216
+ send: () => { },
2217
+ publish: () => { },
2218
+ props: {},
2219
+ variables: {},
2220
+ localVariablesQuery: undefined,
2221
+ karteTemplate: {},
2222
+ context: { api_key: '', collection_endpoint: undefined },
2223
+ };
2217
2224
  /**
2218
2225
  * アクションを作成する
2219
2226
  *
@@ -2224,15 +2231,9 @@ async function loadGlobalStyle(href) {
2224
2231
  *
2225
2232
  * @public
2226
2233
  */
2227
- function create(App, options = {
2228
- send: () => { },
2229
- publish: () => { },
2230
- props: {},
2231
- variables: {},
2232
- localVariablesQuery: undefined,
2233
- karteTemplate: {},
2234
- context: { api_key: '' },
2235
- }) {
2234
+ function create(App, options) {
2235
+ // TSの型検査が効かない場所やエラーを無視している箇所があるため、念の為
2236
+ options = { ...emptyOptions, ...options };
2236
2237
  setVariables({
2237
2238
  ...options.props,
2238
2239
  ...options.variables,
@@ -2260,6 +2261,7 @@ function create(App, options = {
2260
2261
  setSystem({
2261
2262
  // @ts-ignore
2262
2263
  apiKey: data.api_key || null,
2264
+ collection_endpoint: options.context.collection_endpoint,
2263
2265
  shortenId: data.shorten_id || null,
2264
2266
  campaignId: data.campaign_id || null,
2265
2267
  });
@@ -2813,7 +2815,11 @@ const storage = {
2813
2815
  function collection(table) {
2814
2816
  const systemConfig = getSystem();
2815
2817
  const collectionName = table.replace(/^v2\//, '');
2816
- return collection$1({ api_key: systemConfig.apiKey || 'mock', table: collectionName });
2818
+ return collection$1({
2819
+ api_key: systemConfig.apiKey || 'mock',
2820
+ collection_endpoint: systemConfig.collection_endpoint,
2821
+ table: collectionName,
2822
+ });
2817
2823
  }
2818
2824
 
2819
2825
  var widget = /*#__PURE__*/Object.freeze({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.229-28646430.813d5148",
3
+ "version": "1.1.229-28646443.12e5acc3",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",