@opentabs-dev/opentabs-plugin-ynab 0.0.83 → 0.0.85
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/adapter.iife.js +53 -78
- package/dist/adapter.iife.js.map +3 -3
- package/dist/tools/get-account.d.ts.map +1 -1
- package/dist/tools/get-account.js +6 -9
- package/dist/tools/get-account.js.map +1 -1
- package/dist/tools/get-month.d.ts.map +1 -1
- package/dist/tools/get-month.js +2 -7
- package/dist/tools/get-month.js.map +1 -1
- package/dist/tools/get-transaction.d.ts.map +1 -1
- package/dist/tools/get-transaction.js +2 -7
- package/dist/tools/get-transaction.js.map +1 -1
- package/dist/tools/list-accounts.d.ts.map +1 -1
- package/dist/tools/list-accounts.js +6 -9
- package/dist/tools/list-accounts.js.map +1 -1
- package/dist/tools/list-categories.d.ts.map +1 -1
- package/dist/tools/list-categories.js +2 -7
- package/dist/tools/list-categories.js.map +1 -1
- package/dist/tools/list-months.d.ts.map +1 -1
- package/dist/tools/list-months.js +2 -7
- package/dist/tools/list-months.js.map +1 -1
- package/dist/tools/list-payees.d.ts.map +1 -1
- package/dist/tools/list-payees.js +2 -7
- package/dist/tools/list-payees.js.map +1 -1
- package/dist/tools/list-scheduled-transactions.d.ts.map +1 -1
- package/dist/tools/list-scheduled-transactions.js +2 -7
- package/dist/tools/list-scheduled-transactions.js.map +1 -1
- package/dist/tools/list-transactions.d.ts.map +1 -1
- package/dist/tools/list-transactions.js +2 -7
- package/dist/tools/list-transactions.js.map +1 -1
- package/dist/tools/schemas.d.ts +11 -7
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +8 -8
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools.json +1 -1
- package/dist/ynab-api.d.ts +3 -1
- package/dist/ynab-api.d.ts.map +1 -1
- package/dist/ynab-api.js +30 -13
- package/dist/ynab-api.js.map +1 -1
- package/package.json +3 -3
package/dist/adapter.iife.js
CHANGED
|
@@ -345,12 +345,10 @@
|
|
|
345
345
|
if (!user?.id) return null;
|
|
346
346
|
const planId = extractPlanId();
|
|
347
347
|
if (!planId) return null;
|
|
348
|
-
const appVersion = getPageGlobal("YNAB_CLIENT_CONSTANTS.YNAB_APP_VERSION") ?? "26.33.1";
|
|
349
348
|
const deviceId = cached2?.deviceId ?? generateDeviceId();
|
|
350
349
|
const auth = {
|
|
351
350
|
sessionToken,
|
|
352
351
|
deviceId,
|
|
353
|
-
appVersion,
|
|
354
352
|
userId: user.id,
|
|
355
353
|
planId
|
|
356
354
|
};
|
|
@@ -370,17 +368,25 @@
|
|
|
370
368
|
var getHeaders = () => {
|
|
371
369
|
const auth = getAuth();
|
|
372
370
|
if (!auth) throw ToolError.auth("Not authenticated \u2014 please log in to YNAB.");
|
|
373
|
-
|
|
371
|
+
const appVersion = getPageGlobal("YNAB_CLIENT_CONSTANTS.YNAB_APP_VERSION");
|
|
372
|
+
const headers = {
|
|
374
373
|
"X-Session-Token": auth.sessionToken,
|
|
375
374
|
"X-YNAB-Device-Id": auth.deviceId,
|
|
376
375
|
"X-YNAB-Device-OS": "web",
|
|
377
|
-
"X-YNAB-Device-App-Version": auth.appVersion,
|
|
378
376
|
"X-Requested-With": "XMLHttpRequest",
|
|
379
377
|
Accept: "application/json, text/javascript, */*; q=0.01"
|
|
380
378
|
};
|
|
379
|
+
if (appVersion) headers["X-YNAB-Device-App-Version"] = appVersion;
|
|
380
|
+
return headers;
|
|
381
381
|
};
|
|
382
382
|
var handleApiError = async (response, context) => {
|
|
383
383
|
const errorBody = (await response.text().catch(() => "")).substring(0, 512);
|
|
384
|
+
if (response.status === 426) {
|
|
385
|
+
clearAuthCache("ynab");
|
|
386
|
+
throw ToolError.auth(
|
|
387
|
+
"YNAB requires an app update (426). The session has been cleared \u2014 please reload the YNAB tab and try again."
|
|
388
|
+
);
|
|
389
|
+
}
|
|
384
390
|
if (response.status === 429) {
|
|
385
391
|
const retryAfter = response.headers.get("Retry-After");
|
|
386
392
|
const retryMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
|
|
@@ -422,20 +428,30 @@
|
|
|
422
428
|
}
|
|
423
429
|
return data;
|
|
424
430
|
};
|
|
431
|
+
var BUDGET_SCHEMA_VERSION = 41;
|
|
432
|
+
var syncBudget = async (planId) => catalog("syncBudgetData", {
|
|
433
|
+
budget_version_id: planId,
|
|
434
|
+
sync_type: "delta",
|
|
435
|
+
starting_device_knowledge: 0,
|
|
436
|
+
ending_device_knowledge: 0,
|
|
437
|
+
device_knowledge_of_server: 0,
|
|
438
|
+
calculated_entities_included: false,
|
|
439
|
+
schema_version: BUDGET_SCHEMA_VERSION,
|
|
440
|
+
schema_version_of_knowledge: BUDGET_SCHEMA_VERSION,
|
|
441
|
+
changed_entities: {}
|
|
442
|
+
});
|
|
425
443
|
var syncWrite = async (planId, changedEntities) => {
|
|
426
|
-
const readResult = await
|
|
427
|
-
budget_version_id: planId,
|
|
428
|
-
starting_device_knowledge: 0,
|
|
429
|
-
ending_device_knowledge: 0,
|
|
430
|
-
device_knowledge_of_server: 0
|
|
431
|
-
});
|
|
444
|
+
const readResult = await syncBudget(planId);
|
|
432
445
|
const serverKnowledge = readResult.current_server_knowledge ?? 0;
|
|
433
446
|
return catalog("syncBudgetData", {
|
|
434
447
|
budget_version_id: planId,
|
|
448
|
+
sync_type: "delta",
|
|
435
449
|
starting_device_knowledge: 0,
|
|
436
450
|
ending_device_knowledge: 1,
|
|
437
451
|
device_knowledge_of_server: serverKnowledge,
|
|
438
452
|
calculated_entities_included: false,
|
|
453
|
+
schema_version: BUDGET_SCHEMA_VERSION,
|
|
454
|
+
schema_version_of_knowledge: BUDGET_SCHEMA_VERSION,
|
|
439
455
|
changed_entities: changedEntities
|
|
440
456
|
});
|
|
441
457
|
};
|
|
@@ -14390,16 +14406,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14390
14406
|
currency_iso_code: currencyIsoCode
|
|
14391
14407
|
};
|
|
14392
14408
|
};
|
|
14393
|
-
var mapAccount = (a) => ({
|
|
14409
|
+
var mapAccount = (a, calc) => ({
|
|
14394
14410
|
id: a.id ?? "",
|
|
14395
|
-
name: a.
|
|
14396
|
-
type: a.
|
|
14411
|
+
name: a.account_name ?? "",
|
|
14412
|
+
type: a.account_type ?? "",
|
|
14397
14413
|
on_budget: a.on_budget ?? false,
|
|
14398
|
-
closed: a.
|
|
14399
|
-
balance: formatMilliunits(
|
|
14400
|
-
balance_milliunits:
|
|
14401
|
-
cleared_balance: formatMilliunits(
|
|
14402
|
-
uncleared_balance: formatMilliunits(
|
|
14414
|
+
closed: a.is_closed === true,
|
|
14415
|
+
balance: formatMilliunits((calc?.cleared_balance ?? 0) + (calc?.uncleared_balance ?? 0)),
|
|
14416
|
+
balance_milliunits: (calc?.cleared_balance ?? 0) + (calc?.uncleared_balance ?? 0),
|
|
14417
|
+
cleared_balance: formatMilliunits(calc?.cleared_balance ?? 0),
|
|
14418
|
+
uncleared_balance: formatMilliunits(calc?.uncleared_balance ?? 0),
|
|
14403
14419
|
note: a.note ?? ""
|
|
14404
14420
|
});
|
|
14405
14421
|
var mapCategoryGroup = (g) => ({
|
|
@@ -14547,14 +14563,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14547
14563
|
}),
|
|
14548
14564
|
handle: async (params) => {
|
|
14549
14565
|
const planId = getPlanId();
|
|
14550
|
-
const result = await
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
});
|
|
14556
|
-
const raw = result.changed_entities?.be_accounts ?? [];
|
|
14557
|
-
let accounts = raw.filter((a) => !a.is_tombstone).map(mapAccount);
|
|
14566
|
+
const result = await syncBudget(planId);
|
|
14567
|
+
const entities = result.changed_entities;
|
|
14568
|
+
const raw = entities?.be_accounts ?? [];
|
|
14569
|
+
const calcMap = new Map((entities?.be_account_calculations ?? []).map((c) => [c.entities_account_id, c]));
|
|
14570
|
+
let accounts = raw.filter((a) => !a.is_tombstone).map((a) => mapAccount(a, calcMap.get(a.id)));
|
|
14558
14571
|
if (!params.include_closed) {
|
|
14559
14572
|
accounts = accounts.filter((a) => !a.closed);
|
|
14560
14573
|
}
|
|
@@ -14578,18 +14591,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14578
14591
|
}),
|
|
14579
14592
|
handle: async (params) => {
|
|
14580
14593
|
const planId = getPlanId();
|
|
14581
|
-
const result = await
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
device_knowledge_of_server: 0
|
|
14586
|
-
});
|
|
14587
|
-
const raw = result.changed_entities?.be_accounts ?? [];
|
|
14594
|
+
const result = await syncBudget(planId);
|
|
14595
|
+
const entities = result.changed_entities;
|
|
14596
|
+
const raw = entities?.be_accounts ?? [];
|
|
14597
|
+
const calcMap = new Map((entities?.be_account_calculations ?? []).map((c) => [c.entities_account_id, c]));
|
|
14588
14598
|
const account = raw.find((a) => a.id === params.account_id && !a.is_tombstone);
|
|
14589
14599
|
if (!account) {
|
|
14590
14600
|
throw ToolError.notFound(`Account not found: ${params.account_id}`);
|
|
14591
14601
|
}
|
|
14592
|
-
return { account: mapAccount(account) };
|
|
14602
|
+
return { account: mapAccount(account, calcMap.get(account.id)) };
|
|
14593
14603
|
}
|
|
14594
14604
|
});
|
|
14595
14605
|
|
|
@@ -14610,12 +14620,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14610
14620
|
}),
|
|
14611
14621
|
handle: async (params) => {
|
|
14612
14622
|
const planId = getPlanId();
|
|
14613
|
-
const result = await
|
|
14614
|
-
budget_version_id: planId,
|
|
14615
|
-
starting_device_knowledge: 0,
|
|
14616
|
-
ending_device_knowledge: 0,
|
|
14617
|
-
device_knowledge_of_server: 0
|
|
14618
|
-
});
|
|
14623
|
+
const result = await syncBudget(planId);
|
|
14619
14624
|
const entities = result.changed_entities;
|
|
14620
14625
|
const rawGroups = (entities?.be_master_categories ?? []).filter((g) => !g.is_tombstone);
|
|
14621
14626
|
const rawCategories = (entities?.be_subcategories ?? []).filter((c) => !c.is_tombstone);
|
|
@@ -14709,12 +14714,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14709
14714
|
}),
|
|
14710
14715
|
handle: async () => {
|
|
14711
14716
|
const planId = getPlanId();
|
|
14712
|
-
const result = await
|
|
14713
|
-
budget_version_id: planId,
|
|
14714
|
-
starting_device_knowledge: 0,
|
|
14715
|
-
ending_device_knowledge: 0,
|
|
14716
|
-
device_knowledge_of_server: 0
|
|
14717
|
-
});
|
|
14717
|
+
const result = await syncBudget(planId);
|
|
14718
14718
|
const raw = result.changed_entities?.be_payees ?? [];
|
|
14719
14719
|
const payees = raw.filter((p) => !p.is_tombstone).map(mapPayee);
|
|
14720
14720
|
return { payees };
|
|
@@ -14738,12 +14738,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14738
14738
|
}),
|
|
14739
14739
|
handle: async (params) => {
|
|
14740
14740
|
const planId = getPlanId();
|
|
14741
|
-
const result = await
|
|
14742
|
-
budget_version_id: planId,
|
|
14743
|
-
starting_device_knowledge: 0,
|
|
14744
|
-
ending_device_knowledge: 0,
|
|
14745
|
-
device_knowledge_of_server: 0
|
|
14746
|
-
});
|
|
14741
|
+
const result = await syncBudget(planId);
|
|
14747
14742
|
const raw = result.changed_entities?.be_transactions ?? [];
|
|
14748
14743
|
let transactions = raw.filter((t) => !t.is_tombstone).map(mapTransaction);
|
|
14749
14744
|
if (params.account_id) {
|
|
@@ -14775,12 +14770,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14775
14770
|
}),
|
|
14776
14771
|
handle: async (params) => {
|
|
14777
14772
|
const planId = getPlanId();
|
|
14778
|
-
const result = await
|
|
14779
|
-
budget_version_id: planId,
|
|
14780
|
-
starting_device_knowledge: 0,
|
|
14781
|
-
ending_device_knowledge: 0,
|
|
14782
|
-
device_knowledge_of_server: 0
|
|
14783
|
-
});
|
|
14773
|
+
const result = await syncBudget(planId);
|
|
14784
14774
|
const entities = result.changed_entities;
|
|
14785
14775
|
const raw = entities?.be_transactions ?? [];
|
|
14786
14776
|
const tx = raw.find((t) => t.id === params.transaction_id && !t.is_tombstone);
|
|
@@ -14944,12 +14934,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14944
14934
|
}),
|
|
14945
14935
|
handle: async () => {
|
|
14946
14936
|
const planId = getPlanId();
|
|
14947
|
-
const result = await
|
|
14948
|
-
budget_version_id: planId,
|
|
14949
|
-
starting_device_knowledge: 0,
|
|
14950
|
-
ending_device_knowledge: 0,
|
|
14951
|
-
device_knowledge_of_server: 0
|
|
14952
|
-
});
|
|
14937
|
+
const result = await syncBudget(planId);
|
|
14953
14938
|
const raw = result.changed_entities?.be_scheduled_transactions ?? [];
|
|
14954
14939
|
const scheduledTransactions = raw.filter((s) => !s.is_tombstone).map(mapScheduledTransaction).sort((a, b) => a.date_next.localeCompare(b.date_next));
|
|
14955
14940
|
return { scheduled_transactions: scheduledTransactions };
|
|
@@ -14970,12 +14955,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14970
14955
|
}),
|
|
14971
14956
|
handle: async () => {
|
|
14972
14957
|
const planId = getPlanId();
|
|
14973
|
-
const result = await
|
|
14974
|
-
budget_version_id: planId,
|
|
14975
|
-
starting_device_knowledge: 0,
|
|
14976
|
-
ending_device_knowledge: 0,
|
|
14977
|
-
device_knowledge_of_server: 0
|
|
14978
|
-
});
|
|
14958
|
+
const result = await syncBudget(planId);
|
|
14979
14959
|
const entities = result.changed_entities;
|
|
14980
14960
|
const rawMonths = entities?.be_monthly_budgets ?? [];
|
|
14981
14961
|
const rawCalcs = entities?.be_monthly_budget_calculations ?? [];
|
|
@@ -15009,12 +14989,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15009
14989
|
}),
|
|
15010
14990
|
handle: async (params) => {
|
|
15011
14991
|
const planId = getPlanId();
|
|
15012
|
-
const result = await
|
|
15013
|
-
budget_version_id: planId,
|
|
15014
|
-
starting_device_knowledge: 0,
|
|
15015
|
-
ending_device_knowledge: 0,
|
|
15016
|
-
device_knowledge_of_server: 0
|
|
15017
|
-
});
|
|
14992
|
+
const result = await syncBudget(planId);
|
|
15018
14993
|
const entities = result.changed_entities;
|
|
15019
14994
|
const rawMonths = entities?.be_monthly_budgets ?? [];
|
|
15020
14995
|
const monthData = rawMonths.find((m) => m.month === params.month && !m.is_tombstone);
|
|
@@ -15094,7 +15069,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15094
15069
|
};
|
|
15095
15070
|
var src_default = new YnabPlugin();
|
|
15096
15071
|
|
|
15097
|
-
// dist/
|
|
15072
|
+
// dist/_adapter_entry_331af839-0591-41a5-afc4-b832c8b79610.ts
|
|
15098
15073
|
if (!globalThis.__openTabs) {
|
|
15099
15074
|
globalThis.__openTabs = {};
|
|
15100
15075
|
} else {
|
|
@@ -15310,5 +15285,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15310
15285
|
};
|
|
15311
15286
|
delete src_default.onDeactivate;
|
|
15312
15287
|
}
|
|
15313
|
-
})();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["ynab"]){var a=o.adapters["ynab"];a.__adapterHash="
|
|
15288
|
+
})();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["ynab"]){var a=o.adapters["ynab"];a.__adapterHash="0559e5ad8503b3f1094920c7c7fb557b8f9e39f79aa5dd2919a91ca6b0f29c1e";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"ynab",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
|
|
15314
15289
|
//# sourceMappingURL=adapter.iife.js.map
|