@plaidev/karte-action-sdk 1.1.199-28181330.3bffb640 → 1.1.199-28181334.2aca4feb
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hydrate/index.es.d.ts +27 -9
- package/dist/hydrate/index.es.js +35 -11
- package/dist/index.es.d.ts +27 -9
- package/dist/index.es.js +38 -14
- 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,42 @@ function request(url, data, cb) {
|
|
1332
1332
|
});
|
1333
1333
|
}
|
1334
1334
|
/** @internal */
|
1335
|
-
const loadActionTableRow = async (config, api_key, endpoint) => {
|
1336
|
-
return new Promise((resolve, reject) =>
|
1335
|
+
const loadActionTableRow = async (config, data, api_key, endpoint) => {
|
1336
|
+
return new Promise((resolve, reject) => {
|
1337
|
+
const key = data[config.query.key] ?? null;
|
1338
|
+
if (key == null) {
|
1339
|
+
console.warn('key is not found. key: ', config.query.key);
|
1340
|
+
return reject('key is not found.');
|
1341
|
+
}
|
1342
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => err ? reject(err) : resolve(data));
|
1343
|
+
});
|
1337
1344
|
};
|
1338
1345
|
/** @internal */
|
1339
|
-
const loadActionTableRows = async (config, api_key, endpoint) => {
|
1340
|
-
return new Promise((resolve, reject) =>
|
1346
|
+
const loadActionTableRows = async (config, data, api_key, endpoint) => {
|
1347
|
+
return new Promise((resolve, reject) => {
|
1348
|
+
const keys = config.query.key.map(key => data[key] ?? null);
|
1349
|
+
if (keys.some(key => key == null)) {
|
1350
|
+
keys.filter(key => key == null).forEach(key => console.warn('key is not found. key: ', key));
|
1351
|
+
return reject('key is not found.');
|
1352
|
+
}
|
1353
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(config.query.key, (err, data) => (err ? reject(err) : resolve(data)));
|
1354
|
+
});
|
1341
1355
|
};
|
1342
1356
|
/** @internal */
|
1343
|
-
const loadActionTableQuery = async (config, api_key, endpoint) => {
|
1344
|
-
return new Promise((resolve, reject) =>
|
1357
|
+
const loadActionTableQuery = async (config, data, api_key, endpoint) => {
|
1358
|
+
return new Promise((resolve, reject) => {
|
1359
|
+
const params = config.query.params.map(param => data[param] ?? null);
|
1360
|
+
if (params.some(param => param == null)) {
|
1361
|
+
params
|
1362
|
+
.filter(param => param == null)
|
1363
|
+
.forEach(param => console.warn('key is not found. param: ', param));
|
1364
|
+
return reject('key is not found.');
|
1365
|
+
}
|
1366
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, config.query.params, null, (err, data) => (err ? reject(err) : resolve(data)));
|
1367
|
+
});
|
1345
1368
|
};
|
1346
1369
|
/** @internal */
|
1347
|
-
const loadActionTable = async (config, api_key, endpoint) => {
|
1370
|
+
const loadActionTable = async (config, data, api_key, endpoint) => {
|
1348
1371
|
console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
|
1349
1372
|
const results = config.map(c => c.preview_value)
|
1350
1373
|
;
|
@@ -1357,8 +1380,8 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1357
1380
|
}, {});
|
1358
1381
|
};
|
1359
1382
|
/** @internal */
|
1360
|
-
async function setupActionTable(localVariablesQuery, apiKey) {
|
1361
|
-
const result = await loadActionTable(localVariablesQuery, apiKey);
|
1383
|
+
async function setupActionTable(localVariablesQuery, data, apiKey) {
|
1384
|
+
const result = await loadActionTable(localVariablesQuery, data, apiKey);
|
1362
1385
|
let success = false;
|
1363
1386
|
if (Object.keys(result).length === localVariablesQuery.length) {
|
1364
1387
|
setVariables(result);
|
@@ -1680,7 +1703,7 @@ function createModal(App, options = {
|
|
1680
1703
|
initActionTable(options.localVariablesQuery);
|
1681
1704
|
let actionTablePromise = null;
|
1682
1705
|
if (options.localVariablesQuery && data.api_key) {
|
1683
|
-
actionTablePromise = setupActionTable(options.localVariablesQuery, data.api_key);
|
1706
|
+
actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1684
1707
|
}
|
1685
1708
|
// NOTE: onCreateより前にListenする必要がある
|
1686
1709
|
window.addEventListener(ACTION_SHOW_EVENT, handleShow);
|
@@ -1870,7 +1893,8 @@ async function runScript$1(options = {
|
|
1870
1893
|
data,
|
1871
1894
|
};
|
1872
1895
|
initialize({ send: options.send, initialState: data.initial_state });
|
1873
|
-
|
1896
|
+
initActionTable(options.localVariablesQuery);
|
1897
|
+
const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1874
1898
|
if (!success)
|
1875
1899
|
return;
|
1876
1900
|
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,42 @@ function request(url, data, cb) {
|
|
1355
1355
|
});
|
1356
1356
|
}
|
1357
1357
|
/** @internal */
|
1358
|
-
const loadActionTableRow = async (config, api_key, endpoint) => {
|
1359
|
-
return new Promise((resolve, reject) =>
|
1358
|
+
const loadActionTableRow = async (config, data, api_key, endpoint) => {
|
1359
|
+
return new Promise((resolve, reject) => {
|
1360
|
+
const key = data[config.query.key] ?? null;
|
1361
|
+
if (key == null) {
|
1362
|
+
console.warn('key is not found. key: ', config.query.key);
|
1363
|
+
return reject('key is not found.');
|
1364
|
+
}
|
1365
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(key, (err, data) => err ? reject(err) : resolve(data));
|
1366
|
+
});
|
1360
1367
|
};
|
1361
1368
|
/** @internal */
|
1362
|
-
const loadActionTableRows = async (config, api_key, endpoint) => {
|
1363
|
-
return new Promise((resolve, reject) =>
|
1369
|
+
const loadActionTableRows = async (config, data, api_key, endpoint) => {
|
1370
|
+
return new Promise((resolve, reject) => {
|
1371
|
+
const keys = config.query.key.map(key => data[key] ?? null);
|
1372
|
+
if (keys.some(key => key == null)) {
|
1373
|
+
keys.filter(key => key == null).forEach(key => console.warn('key is not found. key: ', key));
|
1374
|
+
return reject('key is not found.');
|
1375
|
+
}
|
1376
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).get(config.query.key, (err, data) => (err ? reject(err) : resolve(data)));
|
1377
|
+
});
|
1364
1378
|
};
|
1365
1379
|
/** @internal */
|
1366
|
-
const loadActionTableQuery = async (config, api_key, endpoint) => {
|
1367
|
-
return new Promise((resolve, reject) =>
|
1380
|
+
const loadActionTableQuery = async (config, data, api_key, endpoint) => {
|
1381
|
+
return new Promise((resolve, reject) => {
|
1382
|
+
const params = config.query.params.map(param => data[param] ?? null);
|
1383
|
+
if (params.some(param => param == null)) {
|
1384
|
+
params
|
1385
|
+
.filter(param => param == null)
|
1386
|
+
.forEach(param => console.warn('key is not found. param: ', param));
|
1387
|
+
return reject('key is not found.');
|
1388
|
+
}
|
1389
|
+
return collection$1({ endpoint, api_key, table: config.query.table_name }).getByQuery(config.query.query_name, config.query.params, null, (err, data) => (err ? reject(err) : resolve(data)));
|
1390
|
+
});
|
1368
1391
|
};
|
1369
1392
|
/** @internal */
|
1370
|
-
const loadActionTable = async (config, api_key, endpoint) => {
|
1393
|
+
const loadActionTable = async (config, data, api_key, endpoint) => {
|
1371
1394
|
console.debug('[debug] loadActionTable', isPreview(), api_key, endpoint, JSON.stringify(config));
|
1372
1395
|
const results = await Promise.all(config
|
1373
1396
|
.filter(c => c.resolver === 'action-table-row' ||
|
@@ -1375,13 +1398,13 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1375
1398
|
c.resolver === 'action-table-query')
|
1376
1399
|
.map(async (c) => {
|
1377
1400
|
if (c.resolver === 'action-table-row') {
|
1378
|
-
return await loadActionTableRow(c, api_key, endpoint);
|
1401
|
+
return await loadActionTableRow(c, data, api_key, endpoint);
|
1379
1402
|
}
|
1380
1403
|
else if (c.resolver === 'action-table-rows') {
|
1381
|
-
return await loadActionTableRows(c, api_key, endpoint);
|
1404
|
+
return await loadActionTableRows(c, data, api_key, endpoint);
|
1382
1405
|
}
|
1383
1406
|
else if (c.resolver === 'action-table-query') {
|
1384
|
-
return await loadActionTableQuery(c, api_key, endpoint);
|
1407
|
+
return await loadActionTableQuery(c, data, api_key, endpoint);
|
1385
1408
|
}
|
1386
1409
|
}));
|
1387
1410
|
return config.reduce((acc, c, i) => {
|
@@ -1393,8 +1416,8 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1393
1416
|
}, {});
|
1394
1417
|
};
|
1395
1418
|
/** @internal */
|
1396
|
-
async function setupActionTable(localVariablesQuery, apiKey) {
|
1397
|
-
const result = await loadActionTable(localVariablesQuery, apiKey);
|
1419
|
+
async function setupActionTable(localVariablesQuery, data, apiKey) {
|
1420
|
+
const result = await loadActionTable(localVariablesQuery, data, apiKey);
|
1398
1421
|
let success = false;
|
1399
1422
|
if (Object.keys(result).length === localVariablesQuery.length) {
|
1400
1423
|
setVariables(result);
|
@@ -1739,7 +1762,7 @@ function createModal(App, options = {
|
|
1739
1762
|
initActionTable(options.localVariablesQuery);
|
1740
1763
|
let actionTablePromise = null;
|
1741
1764
|
if (options.localVariablesQuery && data.api_key) {
|
1742
|
-
actionTablePromise = setupActionTable(options.localVariablesQuery, data.api_key);
|
1765
|
+
actionTablePromise = setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1743
1766
|
}
|
1744
1767
|
// NOTE: onCreateより前にListenする必要がある
|
1745
1768
|
window.addEventListener(ACTION_SHOW_EVENT, handleShow);
|
@@ -1929,7 +1952,8 @@ async function runScript$1(options = {
|
|
1929
1952
|
data,
|
1930
1953
|
};
|
1931
1954
|
initialize({ send: options.send, initialState: data.initial_state });
|
1932
|
-
|
1955
|
+
initActionTable(options.localVariablesQuery);
|
1956
|
+
const { success } = await setupActionTable(options.localVariablesQuery, data, data.api_key);
|
1933
1957
|
if (!success)
|
1934
1958
|
return;
|
1935
1959
|
options.send('script_fired');
|