@plaidev/karte-action-sdk 1.1.199-28181330.3bffb640 → 1.1.199-28181545.5e6123f1
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/dist/hydrate/index.es.d.ts +27 -9
- package/dist/hydrate/index.es.js +35 -14
- package/dist/index.es.d.ts +27 -9
- package/dist/index.es.js +38 -17
- package/package.json +1 -1
@@ -265,13 +265,21 @@ type ActionTableQueryRequestConfig = VariableQuery & {
|
|
265
265
|
/** @internal */
|
266
266
|
type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsRequestConfig | ActionTableQueryRequestConfig;
|
267
267
|
/** @internal */
|
268
|
-
declare const loadActionTableRow: (config: ActionTableRowRequestConfig,
|
268
|
+
declare const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
|
269
|
+
[key: string]: any;
|
270
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
269
271
|
/** @internal */
|
270
|
-
declare const loadActionTableRows: (config: ActionTableRowsRequestConfig,
|
272
|
+
declare const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
|
273
|
+
[key: string]: any;
|
274
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
271
275
|
/** @internal */
|
272
|
-
declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig,
|
276
|
+
declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
|
277
|
+
[key: string]: any;
|
278
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
273
279
|
/** @internal */
|
274
|
-
declare const loadActionTable: (config: Array<VariableQuery>,
|
280
|
+
declare const loadActionTable: (config: Array<VariableQuery>, data: {
|
281
|
+
[key: string]: any;
|
282
|
+
}, api_key: string, endpoint?: string) => Promise<{
|
275
283
|
[key: string]: any;
|
276
284
|
}>;
|
277
285
|
/**
|
@@ -1711,17 +1719,27 @@ declare namespace widget {
|
|
1711
1719
|
/** @internal */
|
1712
1720
|
type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsRequestConfig | ActionTableQueryRequestConfig;
|
1713
1721
|
/** @internal */
|
1714
|
-
const loadActionTableRow: (config: ActionTableRowRequestConfig,
|
1722
|
+
const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
|
1723
|
+
[key: string]: any;
|
1724
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1715
1725
|
/** @internal */
|
1716
|
-
const loadActionTableRows: (config: ActionTableRowsRequestConfig,
|
1726
|
+
const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
|
1727
|
+
[key: string]: any;
|
1728
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1717
1729
|
/** @internal */
|
1718
|
-
const loadActionTableQuery: (config: ActionTableQueryRequestConfig,
|
1730
|
+
const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
|
1731
|
+
[key: string]: any;
|
1732
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1719
1733
|
/** @internal */
|
1720
|
-
const loadActionTable: (config: Array<VariableQuery>,
|
1734
|
+
const loadActionTable: (config: Array<VariableQuery>, data: {
|
1735
|
+
[key: string]: any;
|
1736
|
+
}, api_key: string, endpoint?: string) => Promise<{
|
1721
1737
|
[key: string]: any;
|
1722
1738
|
}>;
|
1723
1739
|
/** @internal */
|
1724
|
-
function setupActionTable(localVariablesQuery: Array<VariableQuery>,
|
1740
|
+
function setupActionTable(localVariablesQuery: Array<VariableQuery>, data: {
|
1741
|
+
[key: string]: any;
|
1742
|
+
}, apiKey: string): Promise<{
|
1725
1743
|
success: boolean;
|
1726
1744
|
}>;
|
1727
1745
|
/** @internal */
|
package/dist/hydrate/index.es.js
CHANGED
@@ -1332,19 +1332,39 @@ function request(url, data, cb) {
|
|
1332
1332
|
});
|
1333
1333
|
}
|
1334
1334
|
/** @internal */
|
1335
|
-
const loadActionTableRow = async (config, api_key, endpoint) => {
|
1336
|
-
|
1337
|
-
|
1335
|
+
const loadActionTableRow = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1336
|
+
const key = data[config.query.key] ?? null;
|
1337
|
+
if (key == null) {
|
1338
|
+
console.warn('key is not found. key: ', config.query.key);
|
1339
|
+
return reject('key is not found.');
|
1340
|
+
}
|
1341
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => err ? reject(err) : resolve(data));
|
1342
|
+
});
|
1338
1343
|
/** @internal */
|
1339
|
-
const loadActionTableRows = async (config, api_key, endpoint) => {
|
1340
|
-
|
1341
|
-
|
1344
|
+
const loadActionTableRows = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1345
|
+
if (config.query.key == null) {
|
1346
|
+
console.warn('key is not defined.');
|
1347
|
+
return reject('key is not defined.');
|
1348
|
+
}
|
1349
|
+
const originalKeys = Array.isArray(config.query.key) ? config.query.key : [config.query.key];
|
1350
|
+
const keys = originalKeys.map(key => data[key] ?? null);
|
1351
|
+
if (keys.some(key => key == null)) {
|
1352
|
+
keys.forEach((key, i) => key == null && console.warn('key is not found. key: ', config.query.key[i]));
|
1353
|
+
return reject('key is not found.');
|
1354
|
+
}
|
1355
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => (err ? reject(err) : resolve(data)));
|
1356
|
+
});
|
1342
1357
|
/** @internal */
|
1343
|
-
const loadActionTableQuery = async (config, api_key, endpoint) => {
|
1344
|
-
|
1345
|
-
|
1358
|
+
const loadActionTableQuery = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1359
|
+
const params = config.query.params?.map(param => data[param] ?? null);
|
1360
|
+
if (params.some(param => param == null)) {
|
1361
|
+
params.forEach((param, i) => param == null && console.warn('key is not found. param: ', config.query.params[i]));
|
1362
|
+
return reject('key is not found.');
|
1363
|
+
}
|
1364
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => (err ? reject(err) : resolve(data)));
|
1365
|
+
});
|
1346
1366
|
/** @internal */
|
1347
|
-
const loadActionTable = async (config, api_key, endpoint) => {
|
1367
|
+
const loadActionTable = async (config, data, api_key, endpoint) => {
|
1348
1368
|
console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
|
1349
1369
|
const results = config.map(c => c.preview_value)
|
1350
1370
|
;
|
@@ -1357,8 +1377,8 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1357
1377
|
}, {});
|
1358
1378
|
};
|
1359
1379
|
/** @internal */
|
1360
|
-
async function setupActionTable(localVariablesQuery, apiKey) {
|
1361
|
-
const result = await loadActionTable(localVariablesQuery, apiKey);
|
1380
|
+
async function setupActionTable(localVariablesQuery, data, apiKey) {
|
1381
|
+
const result = await loadActionTable(localVariablesQuery, data, apiKey);
|
1362
1382
|
let success = false;
|
1363
1383
|
if (Object.keys(result).length === localVariablesQuery.length) {
|
1364
1384
|
setVariables(result);
|
@@ -1680,7 +1700,7 @@ function createModal(App, options = {
|
|
1680
1700
|
initActionTable(options.localVariablesQuery);
|
1681
1701
|
let actionTablePromise = null;
|
1682
1702
|
if (options.localVariablesQuery && data.api_key) {
|
1683
|
-
actionTablePromise = setupActionTable(options.localVariablesQuery, data.api_key);
|
1703
|
+
actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1684
1704
|
}
|
1685
1705
|
// NOTE: onCreateより前にListenする必要がある
|
1686
1706
|
window.addEventListener(ACTION_SHOW_EVENT, handleShow);
|
@@ -1870,7 +1890,8 @@ async function runScript$1(options = {
|
|
1870
1890
|
data,
|
1871
1891
|
};
|
1872
1892
|
initialize({ send: options.send, initialState: data.initial_state });
|
1873
|
-
|
1893
|
+
initActionTable(options.localVariablesQuery);
|
1894
|
+
const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1874
1895
|
if (!success)
|
1875
1896
|
return;
|
1876
1897
|
options.send('script_fired');
|
package/dist/index.es.d.ts
CHANGED
@@ -265,13 +265,21 @@ type ActionTableQueryRequestConfig = VariableQuery & {
|
|
265
265
|
/** @internal */
|
266
266
|
type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsRequestConfig | ActionTableQueryRequestConfig;
|
267
267
|
/** @internal */
|
268
|
-
declare const loadActionTableRow: (config: ActionTableRowRequestConfig,
|
268
|
+
declare const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
|
269
|
+
[key: string]: any;
|
270
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
269
271
|
/** @internal */
|
270
|
-
declare const loadActionTableRows: (config: ActionTableRowsRequestConfig,
|
272
|
+
declare const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
|
273
|
+
[key: string]: any;
|
274
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
271
275
|
/** @internal */
|
272
|
-
declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig,
|
276
|
+
declare const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
|
277
|
+
[key: string]: any;
|
278
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
273
279
|
/** @internal */
|
274
|
-
declare const loadActionTable: (config: Array<VariableQuery>,
|
280
|
+
declare const loadActionTable: (config: Array<VariableQuery>, data: {
|
281
|
+
[key: string]: any;
|
282
|
+
}, api_key: string, endpoint?: string) => Promise<{
|
275
283
|
[key: string]: any;
|
276
284
|
}>;
|
277
285
|
/**
|
@@ -1711,17 +1719,27 @@ declare namespace widget {
|
|
1711
1719
|
/** @internal */
|
1712
1720
|
type ActionTableRequestConfig = ActionTableRowRequestConfig | ActionTableRowsRequestConfig | ActionTableQueryRequestConfig;
|
1713
1721
|
/** @internal */
|
1714
|
-
const loadActionTableRow: (config: ActionTableRowRequestConfig,
|
1722
|
+
const loadActionTableRow: (config: ActionTableRowRequestConfig, data: {
|
1723
|
+
[key: string]: any;
|
1724
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1715
1725
|
/** @internal */
|
1716
|
-
const loadActionTableRows: (config: ActionTableRowsRequestConfig,
|
1726
|
+
const loadActionTableRows: (config: ActionTableRowsRequestConfig, data: {
|
1727
|
+
[key: string]: any;
|
1728
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1717
1729
|
/** @internal */
|
1718
|
-
const loadActionTableQuery: (config: ActionTableQueryRequestConfig,
|
1730
|
+
const loadActionTableQuery: (config: ActionTableQueryRequestConfig, data: {
|
1731
|
+
[key: string]: any;
|
1732
|
+
}, api_key: string, endpoint?: string) => Promise<unknown>;
|
1719
1733
|
/** @internal */
|
1720
|
-
const loadActionTable: (config: Array<VariableQuery>,
|
1734
|
+
const loadActionTable: (config: Array<VariableQuery>, data: {
|
1735
|
+
[key: string]: any;
|
1736
|
+
}, api_key: string, endpoint?: string) => Promise<{
|
1721
1737
|
[key: string]: any;
|
1722
1738
|
}>;
|
1723
1739
|
/** @internal */
|
1724
|
-
function setupActionTable(localVariablesQuery: Array<VariableQuery>,
|
1740
|
+
function setupActionTable(localVariablesQuery: Array<VariableQuery>, data: {
|
1741
|
+
[key: string]: any;
|
1742
|
+
}, apiKey: string): Promise<{
|
1725
1743
|
success: boolean;
|
1726
1744
|
}>;
|
1727
1745
|
/** @internal */
|
package/dist/index.es.js
CHANGED
@@ -1355,19 +1355,39 @@ function request(url, data, cb) {
|
|
1355
1355
|
});
|
1356
1356
|
}
|
1357
1357
|
/** @internal */
|
1358
|
-
const loadActionTableRow = async (config, api_key, endpoint) => {
|
1359
|
-
|
1360
|
-
|
1358
|
+
const loadActionTableRow = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1359
|
+
const key = data[config.query.key] ?? null;
|
1360
|
+
if (key == null) {
|
1361
|
+
console.warn('key is not found. key: ', config.query.key);
|
1362
|
+
return reject('key is not found.');
|
1363
|
+
}
|
1364
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => err ? reject(err) : resolve(data));
|
1365
|
+
});
|
1361
1366
|
/** @internal */
|
1362
|
-
const loadActionTableRows = async (config, api_key, endpoint) => {
|
1363
|
-
|
1364
|
-
|
1367
|
+
const loadActionTableRows = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1368
|
+
if (config.query.key == null) {
|
1369
|
+
console.warn('key is not defined.');
|
1370
|
+
return reject('key is not defined.');
|
1371
|
+
}
|
1372
|
+
const originalKeys = Array.isArray(config.query.key) ? config.query.key : [config.query.key];
|
1373
|
+
const keys = originalKeys.map(key => data[key] ?? null);
|
1374
|
+
if (keys.some(key => key == null)) {
|
1375
|
+
keys.forEach((key, i) => key == null && console.warn('key is not found. key: ', config.query.key[i]));
|
1376
|
+
return reject('key is not found.');
|
1377
|
+
}
|
1378
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(keys, (err, data) => (err ? reject(err) : resolve(data)));
|
1379
|
+
});
|
1365
1380
|
/** @internal */
|
1366
|
-
const loadActionTableQuery = async (config, api_key, endpoint) => {
|
1367
|
-
|
1368
|
-
|
1381
|
+
const loadActionTableQuery = async (config, data, api_key, endpoint) => new Promise((resolve, reject) => {
|
1382
|
+
const params = config.query.params?.map(param => data[param] ?? null);
|
1383
|
+
if (params.some(param => param == null)) {
|
1384
|
+
params.forEach((param, i) => param == null && console.warn('key is not found. param: ', config.query.params[i]));
|
1385
|
+
return reject('key is not found.');
|
1386
|
+
}
|
1387
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, params, null, (err, data) => (err ? reject(err) : resolve(data)));
|
1388
|
+
});
|
1369
1389
|
/** @internal */
|
1370
|
-
const loadActionTable = async (config, api_key, endpoint) => {
|
1390
|
+
const loadActionTable = async (config, data, api_key, endpoint) => {
|
1371
1391
|
console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
|
1372
1392
|
const results = await Promise.all(config
|
1373
1393
|
.filter(c => c.resolver === 'action-table-row' ||
|
@@ -1375,13 +1395,13 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1375
1395
|
c.resolver === 'action-table-query')
|
1376
1396
|
.map(async (c) => {
|
1377
1397
|
if (c.resolver === 'action-table-row') {
|
1378
|
-
return await loadActionTableRow(c, api_key, endpoint);
|
1398
|
+
return await loadActionTableRow(c, data, api_key, endpoint);
|
1379
1399
|
}
|
1380
1400
|
else if (c.resolver === 'action-table-rows') {
|
1381
|
-
return await loadActionTableRows(c, api_key, endpoint);
|
1401
|
+
return await loadActionTableRows(c, data, api_key, endpoint);
|
1382
1402
|
}
|
1383
1403
|
else if (c.resolver === 'action-table-query') {
|
1384
|
-
return await loadActionTableQuery(c, api_key, endpoint);
|
1404
|
+
return await loadActionTableQuery(c, data, api_key, endpoint);
|
1385
1405
|
}
|
1386
1406
|
}));
|
1387
1407
|
return config.reduce((acc, c, i) => {
|
@@ -1393,8 +1413,8 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1393
1413
|
}, {});
|
1394
1414
|
};
|
1395
1415
|
/** @internal */
|
1396
|
-
async function setupActionTable(localVariablesQuery, apiKey) {
|
1397
|
-
const result = await loadActionTable(localVariablesQuery, apiKey);
|
1416
|
+
async function setupActionTable(localVariablesQuery, data, apiKey) {
|
1417
|
+
const result = await loadActionTable(localVariablesQuery, data, apiKey);
|
1398
1418
|
let success = false;
|
1399
1419
|
if (Object.keys(result).length === localVariablesQuery.length) {
|
1400
1420
|
setVariables(result);
|
@@ -1739,7 +1759,7 @@ function createModal(App, options = {
|
|
1739
1759
|
initActionTable(options.localVariablesQuery);
|
1740
1760
|
let actionTablePromise = null;
|
1741
1761
|
if (options.localVariablesQuery && data.api_key) {
|
1742
|
-
actionTablePromise = setupActionTable(options.localVariablesQuery, data.api_key);
|
1762
|
+
actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1743
1763
|
}
|
1744
1764
|
// NOTE: onCreateより前にListenする必要がある
|
1745
1765
|
window.addEventListener(ACTION_SHOW_EVENT, handleShow);
|
@@ -1929,7 +1949,8 @@ async function runScript$1(options = {
|
|
1929
1949
|
data,
|
1930
1950
|
};
|
1931
1951
|
initialize({ send: options.send, initialState: data.initial_state });
|
1932
|
-
|
1952
|
+
initActionTable(options.localVariablesQuery);
|
1953
|
+
const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1933
1954
|
if (!success)
|
1934
1955
|
return;
|
1935
1956
|
options.send('script_fired');
|