@things-factory/saas 10.1.240 → 10.1.241

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.
Files changed (76) hide show
  1. package/README.md +11 -11
  2. package/dist-client/entity360/saas-account-360.d.ts +0 -1
  3. package/dist-client/entity360/saas-account-360.js +18 -71
  4. package/dist-client/entity360/saas-account-360.js.map +1 -1
  5. package/dist-client/index.d.ts +0 -3
  6. package/dist-client/index.js +0 -3
  7. package/dist-client/index.js.map +1 -1
  8. package/dist-client/pages/saas-account-list.d.ts +1 -1
  9. package/dist-client/pages/saas-account-list.js +5 -14
  10. package/dist-client/pages/saas-account-list.js.map +1 -1
  11. package/dist-client/pages/saas-account-page.d.ts +3 -5
  12. package/dist-client/pages/saas-account-page.js +30 -55
  13. package/dist-client/pages/saas-account-page.js.map +1 -1
  14. package/dist-client/route.d.ts +1 -1
  15. package/dist-client/route.js +0 -3
  16. package/dist-client/route.js.map +1 -1
  17. package/dist-client/tsconfig.tsbuildinfo +1 -1
  18. package/dist-client/words.d.ts +0 -13
  19. package/dist-client/words.js +0 -17
  20. package/dist-client/words.js.map +1 -1
  21. package/dist-server/service/checks.d.ts +1 -9
  22. package/dist-server/service/checks.js +2 -18
  23. package/dist-server/service/checks.js.map +1 -1
  24. package/dist-server/service/index.d.ts +1 -6
  25. package/dist-server/service/index.js +1 -9
  26. package/dist-server/service/index.js.map +1 -1
  27. package/dist-server/service/saas-account.d.ts +0 -4
  28. package/dist-server/service/saas-account.js +1 -16
  29. package/dist-server/service/saas-account.js.map +1 -1
  30. package/dist-server/service/saas-mutation.d.ts +1 -10
  31. package/dist-server/service/saas-mutation.js +1 -86
  32. package/dist-server/service/saas-mutation.js.map +1 -1
  33. package/dist-server/service/saas-query.d.ts +2 -51
  34. package/dist-server/service/saas-query.js +2 -65
  35. package/dist-server/service/saas-query.js.map +1 -1
  36. package/dist-server/service/saas-rules.d.ts +3 -141
  37. package/dist-server/service/saas-rules.js +10 -213
  38. package/dist-server/service/saas-rules.js.map +1 -1
  39. package/dist-server/service/saas-service.d.ts +2 -125
  40. package/dist-server/service/saas-service.js +50 -438
  41. package/dist-server/service/saas-service.js.map +1 -1
  42. package/dist-server/service/saas-subscription.d.ts +4 -5
  43. package/dist-server/service/saas-subscription.js +11 -21
  44. package/dist-server/service/saas-subscription.js.map +1 -1
  45. package/dist-server/service/saas-sync.d.ts +0 -35
  46. package/dist-server/service/saas-sync.js +0 -60
  47. package/dist-server/service/saas-sync.js.map +1 -1
  48. package/dist-server/service/saas-type.d.ts +0 -93
  49. package/dist-server/service/saas-type.js +3 -351
  50. package/dist-server/service/saas-type.js.map +1 -1
  51. package/dist-server/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +10 -10
  53. package/translations/en.json +3 -81
  54. package/translations/es.json +3 -81
  55. package/translations/ja.json +3 -81
  56. package/translations/ko.json +3 -81
  57. package/translations/ms.json +3 -81
  58. package/translations/zh.json +3 -81
  59. package/dist-client/components/saas-bill-editor.d.ts +0 -59
  60. package/dist-client/components/saas-bill-editor.js +0 -211
  61. package/dist-client/components/saas-bill-editor.js.map +0 -1
  62. package/dist-client/components/saas-candidates.d.ts +0 -33
  63. package/dist-client/components/saas-candidates.js +0 -157
  64. package/dist-client/components/saas-candidates.js.map +0 -1
  65. package/dist-client/pages/saas-cost-trend.d.ts +0 -23
  66. package/dist-client/pages/saas-cost-trend.js +0 -219
  67. package/dist-client/pages/saas-cost-trend.js.map +0 -1
  68. package/dist-server/service/saas-bill.d.ts +0 -42
  69. package/dist-server/service/saas-bill.js +0 -165
  70. package/dist-server/service/saas-bill.js.map +0 -1
  71. package/dist-server/service/saas-hidden-vendor.d.ts +0 -19
  72. package/dist-server/service/saas-hidden-vendor.js +0 -53
  73. package/dist-server/service/saas-hidden-vendor.js.map +0 -1
  74. package/dist-server/service/saas-trend-type.d.ts +0 -9
  75. package/dist-server/service/saas-trend-type.js +0 -37
  76. package/dist-server/service/saas-trend-type.js.map +0 -1
@@ -1 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,CAAC,EAAE,EAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAS,CAAC,CAAA;QACzF,MAAM,CAAC,OAAO,EAAE,CAAA;IAClB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,eAAe,CAAC,EAAiB,EAAE,MAAc,EAAE,IAAS,EAAE,OAAoB,EAAE,KAAa;IACrH,MAAM,OAAO,GAAqB,EAAE,CAAA;IACpC,MAAM,SAAS,GAAa,EAAE,CAAA;IAC9B,KAAK,MAAM,KAAK,IAAI,OAAO;QACzB,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QACnE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,IAAI,KAAK,6BAA6B;gBAAE,MAAM,KAAK,CAAA;YAC9D,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QACrC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAC/B,CAAC","sourcesContent":["import { Employee } from '@things-factory/organization'\nimport { Domain, Refusal } from '@things-factory/shell'\nimport { EntityManager, In } from 'typeorm'\n\nimport { SaasAccount } from './saas-account'\nimport { SaasBill } from './saas-bill'\nimport { SaasAccountStatus, SaasBilling, SaasSubscriptionStatus } from './saas-rules'\nimport { SaasSeat } from './saas-seat'\nimport { saveSaasBill, saveSaasSeats, saveSaasSubscriptions } from './saas-service'\nimport { SaasSubscription } from './saas-subscription'\n\n/*\n * Seats as a vendor's tenant says (ADR-0177 개정 2) - what a Microsoft 365 tenant bought and who holds each, read by a\n * scenario (integration-msgraph `msgraph-license-assignments`) and handed here. Only quantities, renewal days, trials and\n * seats change: a plan's name, billing, price and status are a person's.\n */\n\nexport interface LicenseFacts {\n tenantId?: string | null\n domains?: string[] | null\n skus: { skuId: string; name: string; enabled: number; consumed: number; renewalOn?: string | null; trial?: boolean | null }[]\n users: { login: string; mail?: string | null; name?: string | null; enabled?: boolean | null; skuIds: string[] }[]\n}\n\nexport interface LicenseSyncResult {\n accountId: string\n accountName: string\n subscriptions: number\n created: number\n opened: number\n closed: number\n /** Open seats held as names that took their employee. */\n linked: number\n /** Logins no employee's mail matched - held as names. */\n unmatched: string[]\n}\n\nconst lower = (value?: string | null) => String(value ?? '').trim().toLowerCase()\n\n/** The account a vendor's names are: the one whose identifier is one of them - a tenant id, a sign-in domain, an organization id. */\nasync function accountOfVendor(tx: EntityManager, domain: Domain, vendorNames: (string | null | undefined)[]): Promise<SaasAccount> {\n const names = new Set(vendorNames.map(lower).filter(Boolean))\n const accounts = (await tx.getRepository(SaasAccount).find({ where: { domain: { id: domain.id }, status: SaasAccountStatus.ACTIVE } as any })).filter(\n one => names.has(lower(one.identifier))\n )\n if (!accounts.length)\n throw new Refusal('saas-sync-account-not-found', { names: [...names].join(', ') }, 'No account has the vendor id or one of its domains as its identifier')\n if (accounts.length > 1)\n throw new Refusal('saas-sync-account-ambiguous', { names: accounts.map(one => one.name).join(', ') }, 'Two accounts have the vendor as their identifier')\n return accounts[0]\n}\n\nexport async function syncSaasLicenses(tx: EntityManager, domain: Domain, user: any, facts: LicenseFacts, today: string): Promise<LicenseSyncResult> {\n const account = await accountOfVendor(tx, domain, [facts.tenantId, ...(facts.domains ?? [])])\n if (account.parentId) throw new Refusal('saas-subscription-on-sub-account', {}, 'An account under another is billed by its parent - subscribe there')\n\n /* Whose mail a login is: an employee's - the mails on their contact card (organization keeps the work mail there), and their user account's. */\n const employees = await tx.getRepository(Employee).find({ where: { domain: { id: domain.id } } as any, relations: ['user', 'contact'] })\n const byMail = new Map<string, Employee>()\n for (const one of employees) {\n const mails = [one.user?.email, ...((one.contact?.items ?? []) as any[]).filter(item => item?.type === 'email').map(item => item.value)]\n for (const mail of mails) if (lower(mail)) byMail.set(lower(mail), one)\n }\n const employeeOf = (holder: LicenseFacts['users'][number]) => byMail.get(lower(holder.mail)) ?? byMail.get(lower(holder.login))\n\n const result: LicenseSyncResult = { accountId: account.id, accountName: account.name, subscriptions: 0, created: 0, opened: 0, closed: 0, linked: 0, unmatched: [] }\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any })\n for (const sku of facts.skus) {\n let sub = subs.find(one => one.vendorKey === sku.skuId)\n const holders = facts.users.filter(one => one.skuIds.includes(sku.skuId))\n if (!sub) {\n if (!sku.consumed && !holders.length) continue\n ;[sub] = await saveSaasSubscriptions(tx, domain, user, 'all', account.id, [\n {\n cuFlag: '+',\n name: sku.name,\n billing: SaasBilling.SEAT,\n vendorKey: sku.skuId,\n quantity: Math.max(sku.enabled, holders.length, 1),\n startOn: today,\n status: SaasSubscriptionStatus.ACTIVE,\n ...(sku.renewalOn ? { renewalOn: sku.renewalOn } : {}),\n trial: !!sku.trial\n }\n ])\n result.created++\n } else {\n /* The quantity, the renewal day and being a trial are the tenant's facts; the rest stays the person's. */\n const change: Record<string, any> = {}\n if (sku.enabled > 0 && Number(sub.quantity) !== sku.enabled) change.quantity = sku.enabled\n if (sku.renewalOn && sub.renewalOn !== sku.renewalOn) change.renewalOn = sku.renewalOn\n if (sku.trial !== undefined && sku.trial !== null && !!sub.trial !== !!sku.trial) change.trial = !!sku.trial\n if (Object.keys(change).length) await saveSaasSubscriptions(tx, domain, user, 'all', account.id, [{ id: sub.id, cuFlag: 'M', ...change }])\n }\n result.subscriptions++\n\n const seats = await tx.getRepository(SaasSeat).find({ where: { domain: { id: domain.id }, subscription: { id: sub.id } } as any })\n const synced = seats.filter(one => one.login)\n /* The first sync does not know since when a seat is held. */\n const since = synced.length ? today : null\n const open = synced.filter(one => !one.untilOn || one.untilOn > today)\n const now = new Set(holders.map(one => lower(one.login)))\n const patches: Record<string, any>[] = []\n for (const holder of holders) {\n const employee = employeeOf(holder)\n if (!employee) result.unmatched.push(holder.login)\n const held = open.find(one => lower(one.login) === lower(holder.login))\n if (held) {\n /* A seat held as a name takes its employee once their mail is known - every sync looks again. */\n if (employee && held.employeeId !== employee.id) {\n patches.push({ id: held.id, cuFlag: 'M', employeeId: employee.id, holder: null })\n result.linked++\n }\n continue\n }\n patches.push({ cuFlag: '+', login: holder.login, employeeId: employee?.id ?? null, holder: employee ? null : holder.name || holder.login, fromOn: since })\n result.opened++\n }\n for (const seat of open)\n if (!now.has(lower(seat.login))) {\n patches.push({ id: seat.id, cuFlag: 'M', untilOn: seat.fromOn && seat.fromOn > today ? seat.fromOn : today })\n result.closed++\n }\n if (patches.length) await saveSaasSeats(tx, domain, user, 'all', sub.id, patches)\n }\n result.unmatched = [...new Set(result.unmatched)]\n return result\n}\n\n/* ----------------------------------------------------------------------------------------------------------------- */\n/* Bills as a vendor's cost report says (ADR-0177 개정 3) */\n\nexport interface CostFacts {\n /** The vendor's id for the account - an Anthropic organization id. */\n vendorAccount: string\n vendorName?: string | null\n currency: string\n months: { month: string; lines: { label: string; amount: number }[] }[]\n}\n\nexport interface CostSyncResult {\n accountId: string\n accountName: string\n written: number\n /** Months a person wrote the bill of - left as they are. */\n kept: string[]\n}\n\n/**\n * Write each closed month's bill from the vendor's cost report, a line a model, all on the account's usage subscription\n * for the vendor (made when there is none: usage, `vendorKey` the vendor account). A month whose bill a person wrote is\n * kept; one a sync wrote is rewritten. The report's currency must be the account's.\n */\nexport async function syncSaasCosts(tx: EntityManager, domain: Domain, user: any, facts: CostFacts, today: string): Promise<CostSyncResult> {\n const account = await accountOfVendor(tx, domain, [facts.vendorAccount])\n if (account.parentId) throw new Refusal('saas-bill-on-sub-account', {}, 'An account under another is billed by its parent')\n if (String(facts.currency).toUpperCase() !== account.currency)\n throw new Refusal('saas-sync-currency-differs', { currency: facts.currency, account: account.currency }, `The vendor bills in ${facts.currency}; the account is in ${account.currency} - set the account's currency`)\n\n const months = facts.months.filter(one => one.month < today.slice(0, 7) && one.lines.some(line => Number(line.amount)))\n const result: CostSyncResult = { accountId: account.id, accountName: account.name, written: 0, kept: [] }\n if (!months.length) return result\n\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any })\n let usage = subs.find(one => one.vendorKey === facts.vendorAccount)\n if (!usage)\n [usage] = await saveSaasSubscriptions(tx, domain, user, 'all', account.id, [\n { cuFlag: '+', name: `${facts.vendorName || account.name} API`, billing: SaasBilling.USAGE, vendorKey: facts.vendorAccount, startOn: `${months[0].month}-01`, status: SaasSubscriptionStatus.ACTIVE }\n ])\n\n const bills = await tx.getRepository(SaasBill).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any })\n for (const one of months) {\n const bill = bills.find(old => old.month === one.month)\n if (bill && !bill.synced) {\n result.kept.push(one.month)\n continue\n }\n const saved = await saveSaasBill(tx, domain, user, 'all', account.id, {\n id: bill?.id ?? null,\n month: one.month,\n lines: one.lines.filter(line => Number(line.amount)).map(line => ({ subscriptionId: usage!.id, label: line.label, amount: Number(line.amount) }))\n })\n await tx.getRepository(SaasBill).update({ id: saved.id } as any, { synced: true } as any)\n result.written++\n }\n return result\n}\n\n/**\n * Several accounts' cost reports at once - an AWS organization gives one an account. A vendor account no subscription\n * account names is passed over and told (an organization holds accounts the domain does not keep); any other refusal\n * stops the sync.\n */\nexport async function syncSaasCostsOf(tx: EntityManager, domain: Domain, user: any, reports: CostFacts[], today: string): Promise<{ results: CostSyncResult[]; unmatched: string[] }> {\n const results: CostSyncResult[] = []\n const unmatched: string[] = []\n for (const facts of reports)\n try {\n results.push(await syncSaasCosts(tx, domain, user, facts, today))\n } catch (error: any) {\n if (error?.code !== 'saas-sync-account-not-found') throw error\n unmatched.push(facts.vendorAccount)\n }\n return { results, unmatched }\n}\n"]}
1
+ {"version":3,"file":"saas-sync.js","sourceRoot":"","sources":["../../server/service/saas-sync.ts"],"names":[],"mappings":";;AAmDA,4CA2EC;AA9HD,+DAAuD;AACvD,iDAAuD;AAGvD,iDAA4C;AAC5C,6CAA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G,MAAM,CAAC,MAAM,EAAE,CAAA;YACjB,CAAC;QACH,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IACnF,CAAC;IACD,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IACjD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { Employee } from '@things-factory/organization'\nimport { Domain, Refusal } from '@things-factory/shell'\nimport { EntityManager, In } from 'typeorm'\n\nimport { SaasAccount } from './saas-account'\nimport { SaasAccountStatus, SaasBilling, SaasSubscriptionStatus } from './saas-rules'\nimport { SaasSeat } from './saas-seat'\nimport { saveSaasSeats, saveSaasSubscriptions } from './saas-service'\nimport { SaasSubscription } from './saas-subscription'\n\n/*\n * Seats as a vendor's tenant says (ADR-0177 개정 2) - what a Microsoft 365 tenant bought and who holds each, read by a\n * scenario (integration-msgraph `msgraph-license-assignments`) and handed here. Only quantities, renewal days, trials and\n * seats change: a plan's name, billing, price and status are a person's.\n */\n\nexport interface LicenseFacts {\n tenantId?: string | null\n domains?: string[] | null\n skus: { skuId: string; name: string; enabled: number; consumed: number; renewalOn?: string | null; trial?: boolean | null }[]\n users: { login: string; mail?: string | null; name?: string | null; enabled?: boolean | null; skuIds: string[] }[]\n}\n\nexport interface LicenseSyncResult {\n accountId: string\n accountName: string\n subscriptions: number\n created: number\n opened: number\n closed: number\n /** Open seats held as names that took their employee. */\n linked: number\n /** Logins no employee's mail matched - held as names. */\n unmatched: string[]\n}\n\nconst lower = (value?: string | null) => String(value ?? '').trim().toLowerCase()\n\n/** The account a vendor's names are: the one whose identifier is one of them - a tenant id, a sign-in domain, an organization id. */\nasync function accountOfVendor(tx: EntityManager, domain: Domain, vendorNames: (string | null | undefined)[]): Promise<SaasAccount> {\n const names = new Set(vendorNames.map(lower).filter(Boolean))\n const accounts = (await tx.getRepository(SaasAccount).find({ where: { domain: { id: domain.id }, status: SaasAccountStatus.ACTIVE } as any })).filter(\n one => names.has(lower(one.identifier))\n )\n if (!accounts.length)\n throw new Refusal('saas-sync-account-not-found', { names: [...names].join(', ') }, 'No account has the vendor id or one of its domains as its identifier')\n if (accounts.length > 1)\n throw new Refusal('saas-sync-account-ambiguous', { names: accounts.map(one => one.name).join(', ') }, 'Two accounts have the vendor as their identifier')\n return accounts[0]\n}\n\nexport async function syncSaasLicenses(tx: EntityManager, domain: Domain, user: any, facts: LicenseFacts, today: string): Promise<LicenseSyncResult> {\n const account = await accountOfVendor(tx, domain, [facts.tenantId, ...(facts.domains ?? [])])\n if (account.parentId) throw new Refusal('saas-subscription-on-sub-account', {}, 'An account under another is billed by its parent - subscribe there')\n\n /* Whose mail a login is: an employee's - the mails on their contact card (organization keeps the work mail there), and their user account's. */\n const employees = await tx.getRepository(Employee).find({ where: { domain: { id: domain.id } } as any, relations: ['user', 'contact'] })\n const byMail = new Map<string, Employee>()\n for (const one of employees) {\n const mails = [one.user?.email, ...((one.contact?.items ?? []) as any[]).filter(item => item?.type === 'email').map(item => item.value)]\n for (const mail of mails) if (lower(mail)) byMail.set(lower(mail), one)\n }\n const employeeOf = (holder: LicenseFacts['users'][number]) => byMail.get(lower(holder.mail)) ?? byMail.get(lower(holder.login))\n\n const result: LicenseSyncResult = { accountId: account.id, accountName: account.name, subscriptions: 0, created: 0, opened: 0, closed: 0, linked: 0, unmatched: [] }\n const subs = await tx.getRepository(SaasSubscription).find({ where: { domain: { id: domain.id }, account: { id: account.id } } as any })\n for (const sku of facts.skus) {\n let sub = subs.find(one => one.vendorKey === sku.skuId)\n const holders = facts.users.filter(one => one.skuIds.includes(sku.skuId))\n if (!sub) {\n if (!sku.consumed && !holders.length) continue\n ;[sub] = await saveSaasSubscriptions(tx, domain, user, 'all', account.id, [\n {\n cuFlag: '+',\n name: sku.name,\n billing: SaasBilling.SEAT,\n vendorKey: sku.skuId,\n quantity: Math.max(sku.enabled, holders.length, 1),\n startOn: today,\n status: SaasSubscriptionStatus.ACTIVE,\n ...(sku.renewalOn ? { renewalOn: sku.renewalOn } : {}),\n trial: !!sku.trial\n }\n ])\n result.created++\n } else {\n /* The quantity, the renewal day and being a trial are the tenant's facts; the rest stays the person's. */\n const change: Record<string, any> = {}\n if (sku.enabled > 0 && Number(sub.quantity) !== sku.enabled) change.quantity = sku.enabled\n if (sku.renewalOn && sub.renewalOn !== sku.renewalOn) change.renewalOn = sku.renewalOn\n if (sku.trial !== undefined && sku.trial !== null && !!sub.trial !== !!sku.trial) change.trial = !!sku.trial\n if (Object.keys(change).length) await saveSaasSubscriptions(tx, domain, user, 'all', account.id, [{ id: sub.id, cuFlag: 'M', ...change }])\n }\n result.subscriptions++\n\n const seats = await tx.getRepository(SaasSeat).find({ where: { domain: { id: domain.id }, subscription: { id: sub.id } } as any })\n const synced = seats.filter(one => one.login)\n /* The first sync does not know since when a seat is held. */\n const since = synced.length ? today : null\n const open = synced.filter(one => !one.untilOn || one.untilOn > today)\n const now = new Set(holders.map(one => lower(one.login)))\n const patches: Record<string, any>[] = []\n for (const holder of holders) {\n const employee = employeeOf(holder)\n if (!employee) result.unmatched.push(holder.login)\n const held = open.find(one => lower(one.login) === lower(holder.login))\n if (held) {\n /* A seat held as a name takes its employee once their mail is known - every sync looks again. */\n if (employee && held.employeeId !== employee.id) {\n patches.push({ id: held.id, cuFlag: 'M', employeeId: employee.id, holder: null })\n result.linked++\n }\n continue\n }\n patches.push({ cuFlag: '+', login: holder.login, employeeId: employee?.id ?? null, holder: employee ? null : holder.name || holder.login, fromOn: since })\n result.opened++\n }\n for (const seat of open)\n if (!now.has(lower(seat.login))) {\n patches.push({ id: seat.id, cuFlag: 'M', untilOn: seat.fromOn && seat.fromOn > today ? seat.fromOn : today })\n result.closed++\n }\n if (patches.length) await saveSaasSeats(tx, domain, user, 'all', sub.id, patches)\n }\n result.unmatched = [...new Set(result.unmatched)]\n return result\n}\n"]}
@@ -12,9 +12,7 @@ export declare class SaasAccountPatch {
12
12
  billingEmail?: string;
13
13
  paymentAccountId?: string;
14
14
  currency?: string;
15
- billingDay?: number;
16
15
  secretLocation?: string;
17
- increaseAlertRate?: number;
18
16
  status?: SaasAccountStatus;
19
17
  closedOn?: string;
20
18
  description?: string;
@@ -26,9 +24,6 @@ export declare class SaasSubscriptionPatch {
26
24
  billing?: SaasBilling;
27
25
  quantity?: number;
28
26
  unitPrice?: number;
29
- amount?: number;
30
- budget?: number;
31
- everyMonths?: number;
32
27
  startOn?: string;
33
28
  renewalOn?: string;
34
29
  autoRenew?: boolean;
@@ -48,60 +43,10 @@ export declare class SaasSeatPatch {
48
43
  untilOn?: string;
49
44
  description?: string;
50
45
  }
51
- export declare class SaasBillLineInput {
52
- subscriptionId?: string;
53
- label?: string;
54
- amount: number;
55
- }
56
- export declare class SaasBillInput {
57
- id?: string;
58
- month: string;
59
- billedOn?: string;
60
- description?: string;
61
- lines: SaasBillLineInput[];
62
- }
63
46
  export declare class SaasAccountList {
64
47
  items: SaasAccount[];
65
48
  total: number;
66
49
  }
67
- export declare class SaasTrendSeries {
68
- key: string;
69
- accountId?: string;
70
- accountName?: string;
71
- subscriptionId?: string;
72
- name?: string;
73
- currency: string;
74
- amounts: number[];
75
- total: number;
76
- monthOverMonth?: number;
77
- yearOverYear?: number;
78
- }
79
- export declare class SaasDepartmentSeries {
80
- key: string;
81
- departmentId?: string;
82
- name?: string;
83
- currency: string;
84
- amounts: number[];
85
- total: number;
86
- }
87
- export declare class SaasAlert {
88
- kind: string;
89
- accountId: string;
90
- accountName?: string;
91
- subscriptionId?: string;
92
- subscriptionName?: string;
93
- month: string;
94
- amount: number;
95
- limit: number;
96
- }
97
- export declare class SaasCostTrend {
98
- months: string[];
99
- all: SaasTrendSeries[];
100
- accounts: SaasTrendSeries[];
101
- subscriptions: SaasTrendSeries[];
102
- departments: SaasDepartmentSeries[];
103
- alerts: SaasAlert[];
104
- }
105
50
  export declare class SaasChange {
106
51
  subject: string;
107
52
  factKind: string;
@@ -111,20 +56,6 @@ export declare class SaasChange {
111
56
  at: Date;
112
57
  changedBy?: string;
113
58
  }
114
- export declare class SaasCandidate {
115
- key: string;
116
- counterpartyId?: string;
117
- counterpartyName: string;
118
- months: number;
119
- average: number;
120
- firstDate: string;
121
- lastDate: string;
122
- lastAmount: number;
123
- currency: string;
124
- paymentAccountId?: string;
125
- billingDay?: number;
126
- hidden: boolean;
127
- }
128
59
  export declare class SaasLicenseSkuInput {
129
60
  skuId: string;
130
61
  name: string;
@@ -156,27 +87,3 @@ export declare class SaasLicenseSync {
156
87
  linked: number;
157
88
  unmatched: string[];
158
89
  }
159
- export declare class SaasCostLineInput {
160
- label: string;
161
- amount: number;
162
- }
163
- export declare class SaasCostMonthInput {
164
- month: string;
165
- lines: SaasCostLineInput[];
166
- }
167
- export declare class SaasCostsInput {
168
- vendorAccount: string;
169
- vendorName?: string;
170
- currency: string;
171
- months: SaasCostMonthInput[];
172
- }
173
- export declare class SaasCostSync {
174
- accountId: string;
175
- accountName: string;
176
- written: number;
177
- kept: string[];
178
- }
179
- export declare class SaasCostSyncs {
180
- results: SaasCostSync[];
181
- unmatched: string[];
182
- }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SaasCostSyncs = exports.SaasCostSync = exports.SaasCostsInput = exports.SaasCostMonthInput = exports.SaasCostLineInput = exports.SaasLicenseSync = exports.SaasLicensesInput = exports.SaasLicenseUserInput = exports.SaasLicenseSkuInput = exports.SaasCandidate = exports.SaasChange = exports.SaasCostTrend = exports.SaasAlert = exports.SaasDepartmentSeries = exports.SaasTrendSeries = exports.SaasAccountList = exports.SaasBillInput = exports.SaasBillLineInput = exports.SaasSeatPatch = exports.SaasSubscriptionPatch = exports.SaasAccountPatch = void 0;
3
+ exports.SaasLicenseSync = exports.SaasLicensesInput = exports.SaasLicenseUserInput = exports.SaasLicenseSkuInput = exports.SaasChange = exports.SaasAccountList = exports.SaasSeatPatch = exports.SaasSubscriptionPatch = exports.SaasAccountPatch = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const saas_account_1 = require("./saas-account");
@@ -49,21 +49,13 @@ tslib_1.__decorate([
49
49
  tslib_1.__metadata("design:type", String)
50
50
  ], SaasAccountPatch.prototype, "paymentAccountId", void 0);
51
51
  tslib_1.__decorate([
52
- (0, type_graphql_1.Field)({ nullable: true, description: 'The currency it is billed in' }),
52
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The currency its prices are in' }),
53
53
  tslib_1.__metadata("design:type", String)
54
54
  ], SaasAccountPatch.prototype, "currency", void 0);
55
- tslib_1.__decorate([
56
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'The day of the month the bill is paid' }),
57
- tslib_1.__metadata("design:type", Number)
58
- ], SaasAccountPatch.prototype, "billingDay", void 0);
59
55
  tslib_1.__decorate([
60
56
  (0, type_graphql_1.Field)({ nullable: true, description: 'Where its secrets are kept' }),
61
57
  tslib_1.__metadata("design:type", String)
62
58
  ], SaasAccountPatch.prototype, "secretLocation", void 0);
63
- tslib_1.__decorate([
64
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'A rise over the month before told above this part' }),
65
- tslib_1.__metadata("design:type", Number)
66
- ], SaasAccountPatch.prototype, "increaseAlertRate", void 0);
67
59
  tslib_1.__decorate([
68
60
  (0, type_graphql_1.Field)(type => saas_rules_1.SaasAccountStatus, { nullable: true, description: 'In use or closed' }),
69
61
  tslib_1.__metadata("design:type", String)
@@ -103,21 +95,9 @@ tslib_1.__decorate([
103
95
  tslib_1.__metadata("design:type", Number)
104
96
  ], SaasSubscriptionPatch.prototype, "quantity", void 0);
105
97
  tslib_1.__decorate([
106
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The price of one seat for one billing' }),
98
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The price of one seat or unit, or the fee - for reference' }),
107
99
  tslib_1.__metadata("design:type", Number)
108
100
  ], SaasSubscriptionPatch.prototype, "unitPrice", void 0);
109
- tslib_1.__decorate([
110
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'What one billing costs' }),
111
- tslib_1.__metadata("design:type", Number)
112
- ], SaasSubscriptionPatch.prototype, "amount", void 0);
113
- tslib_1.__decorate([
114
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'What a month of usage may cost' }),
115
- tslib_1.__metadata("design:type", Number)
116
- ], SaasSubscriptionPatch.prototype, "budget", void 0);
117
- tslib_1.__decorate([
118
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'Billed every so many months' }),
119
- tslib_1.__metadata("design:type", Number)
120
- ], SaasSubscriptionPatch.prototype, "everyMonths", void 0);
121
101
  tslib_1.__decorate([
122
102
  (0, type_graphql_1.Field)({ nullable: true, description: 'The day it started - YYYY-MM-DD' }),
123
103
  tslib_1.__metadata("design:type", String)
@@ -191,50 +171,6 @@ tslib_1.__decorate([
191
171
  exports.SaasSeatPatch = SaasSeatPatch = tslib_1.__decorate([
192
172
  (0, type_graphql_1.InputType)({ description: 'A row of the seats grid of a subscription' })
193
173
  ], SaasSeatPatch);
194
- let SaasBillLineInput = class SaasBillLineInput {
195
- };
196
- exports.SaasBillLineInput = SaasBillLineInput;
197
- tslib_1.__decorate([
198
- (0, type_graphql_1.Field)({ nullable: true, description: 'The subscription it is for; empty for tax and credits' }),
199
- tslib_1.__metadata("design:type", String)
200
- ], SaasBillLineInput.prototype, "subscriptionId", void 0);
201
- tslib_1.__decorate([
202
- (0, type_graphql_1.Field)({ nullable: true, description: 'What the bill calls it' }),
203
- tslib_1.__metadata("design:type", String)
204
- ], SaasBillLineInput.prototype, "label", void 0);
205
- tslib_1.__decorate([
206
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What it cost; a credit below zero' }),
207
- tslib_1.__metadata("design:type", Number)
208
- ], SaasBillLineInput.prototype, "amount", void 0);
209
- exports.SaasBillLineInput = SaasBillLineInput = tslib_1.__decorate([
210
- (0, type_graphql_1.InputType)({ description: 'A line of a bill' })
211
- ], SaasBillLineInput);
212
- let SaasBillInput = class SaasBillInput {
213
- };
214
- exports.SaasBillInput = SaasBillInput;
215
- tslib_1.__decorate([
216
- (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'The bill; empty for a new one' }),
217
- tslib_1.__metadata("design:type", String)
218
- ], SaasBillInput.prototype, "id", void 0);
219
- tslib_1.__decorate([
220
- (0, type_graphql_1.Field)({ description: 'The month it bills - YYYY-MM' }),
221
- tslib_1.__metadata("design:type", String)
222
- ], SaasBillInput.prototype, "month", void 0);
223
- tslib_1.__decorate([
224
- (0, type_graphql_1.Field)({ nullable: true, description: 'The day the vendor billed it - YYYY-MM-DD' }),
225
- tslib_1.__metadata("design:type", String)
226
- ], SaasBillInput.prototype, "billedOn", void 0);
227
- tslib_1.__decorate([
228
- (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
229
- tslib_1.__metadata("design:type", String)
230
- ], SaasBillInput.prototype, "description", void 0);
231
- tslib_1.__decorate([
232
- (0, type_graphql_1.Field)(type => [SaasBillLineInput], { description: 'Its lines' }),
233
- tslib_1.__metadata("design:type", Array)
234
- ], SaasBillInput.prototype, "lines", void 0);
235
- exports.SaasBillInput = SaasBillInput = tslib_1.__decorate([
236
- (0, type_graphql_1.InputType)({ description: 'A bill of an account for a month, its lines whole' })
237
- ], SaasBillInput);
238
174
  let SaasAccountList = class SaasAccountList {
239
175
  };
240
176
  exports.SaasAccountList = SaasAccountList;
@@ -249,150 +185,6 @@ tslib_1.__decorate([
249
185
  exports.SaasAccountList = SaasAccountList = tslib_1.__decorate([
250
186
  (0, type_graphql_1.ObjectType)({ description: 'A page of accounts' })
251
187
  ], SaasAccountList);
252
- let SaasTrendSeries = class SaasTrendSeries {
253
- };
254
- exports.SaasTrendSeries = SaasTrendSeries;
255
- tslib_1.__decorate([
256
- (0, type_graphql_1.Field)({ description: 'What the series is of' }),
257
- tslib_1.__metadata("design:type", String)
258
- ], SaasTrendSeries.prototype, "key", void 0);
259
- tslib_1.__decorate([
260
- (0, type_graphql_1.Field)({ nullable: true, description: 'The account' }),
261
- tslib_1.__metadata("design:type", String)
262
- ], SaasTrendSeries.prototype, "accountId", void 0);
263
- tslib_1.__decorate([
264
- (0, type_graphql_1.Field)({ nullable: true, description: "The account's name" }),
265
- tslib_1.__metadata("design:type", String)
266
- ], SaasTrendSeries.prototype, "accountName", void 0);
267
- tslib_1.__decorate([
268
- (0, type_graphql_1.Field)({ nullable: true, description: 'The subscription; empty for the lines on none' }),
269
- tslib_1.__metadata("design:type", String)
270
- ], SaasTrendSeries.prototype, "subscriptionId", void 0);
271
- tslib_1.__decorate([
272
- (0, type_graphql_1.Field)({ nullable: true, description: 'The account or subscription name' }),
273
- tslib_1.__metadata("design:type", String)
274
- ], SaasTrendSeries.prototype, "name", void 0);
275
- tslib_1.__decorate([
276
- (0, type_graphql_1.Field)({ description: 'The currency the amounts are in' }),
277
- tslib_1.__metadata("design:type", String)
278
- ], SaasTrendSeries.prototype, "currency", void 0);
279
- tslib_1.__decorate([
280
- (0, type_graphql_1.Field)(type => [type_graphql_1.Float], { description: 'One amount a month, in the order of the months' }),
281
- tslib_1.__metadata("design:type", Array)
282
- ], SaasTrendSeries.prototype, "amounts", void 0);
283
- tslib_1.__decorate([
284
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'The months together' }),
285
- tslib_1.__metadata("design:type", Number)
286
- ], SaasTrendSeries.prototype, "total", void 0);
287
- tslib_1.__decorate([
288
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The last month over the one before, as a part' }),
289
- tslib_1.__metadata("design:type", Number)
290
- ], SaasTrendSeries.prototype, "monthOverMonth", void 0);
291
- tslib_1.__decorate([
292
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The last month over the same month a year before, as a part' }),
293
- tslib_1.__metadata("design:type", Number)
294
- ], SaasTrendSeries.prototype, "yearOverYear", void 0);
295
- exports.SaasTrendSeries = SaasTrendSeries = tslib_1.__decorate([
296
- (0, type_graphql_1.ObjectType)({ description: 'A series of the cost trend - all, an account or a subscription, in one currency' })
297
- ], SaasTrendSeries);
298
- let SaasDepartmentSeries = class SaasDepartmentSeries {
299
- };
300
- exports.SaasDepartmentSeries = SaasDepartmentSeries;
301
- tslib_1.__decorate([
302
- (0, type_graphql_1.Field)({ description: 'What the series is of' }),
303
- tslib_1.__metadata("design:type", String)
304
- ], SaasDepartmentSeries.prototype, "key", void 0);
305
- tslib_1.__decorate([
306
- (0, type_graphql_1.Field)({ nullable: true, description: 'The department; empty for cost no department is named for' }),
307
- tslib_1.__metadata("design:type", String)
308
- ], SaasDepartmentSeries.prototype, "departmentId", void 0);
309
- tslib_1.__decorate([
310
- (0, type_graphql_1.Field)({ nullable: true, description: "The department's name" }),
311
- tslib_1.__metadata("design:type", String)
312
- ], SaasDepartmentSeries.prototype, "name", void 0);
313
- tslib_1.__decorate([
314
- (0, type_graphql_1.Field)({ description: 'The currency the amounts are in' }),
315
- tslib_1.__metadata("design:type", String)
316
- ], SaasDepartmentSeries.prototype, "currency", void 0);
317
- tslib_1.__decorate([
318
- (0, type_graphql_1.Field)(type => [type_graphql_1.Float], { description: 'One amount a month' }),
319
- tslib_1.__metadata("design:type", Array)
320
- ], SaasDepartmentSeries.prototype, "amounts", void 0);
321
- tslib_1.__decorate([
322
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'The months together' }),
323
- tslib_1.__metadata("design:type", Number)
324
- ], SaasDepartmentSeries.prototype, "total", void 0);
325
- exports.SaasDepartmentSeries = SaasDepartmentSeries = tslib_1.__decorate([
326
- (0, type_graphql_1.ObjectType)({ description: 'A department’s part of the cost, in one currency' })
327
- ], SaasDepartmentSeries);
328
- let SaasAlert = class SaasAlert {
329
- };
330
- exports.SaasAlert = SaasAlert;
331
- tslib_1.__decorate([
332
- (0, type_graphql_1.Field)({ description: 'usage-over-budget, bill-increased or seat-bill-differs' }),
333
- tslib_1.__metadata("design:type", String)
334
- ], SaasAlert.prototype, "kind", void 0);
335
- tslib_1.__decorate([
336
- (0, type_graphql_1.Field)({ description: 'The account' }),
337
- tslib_1.__metadata("design:type", String)
338
- ], SaasAlert.prototype, "accountId", void 0);
339
- tslib_1.__decorate([
340
- (0, type_graphql_1.Field)({ nullable: true, description: "The account's name" }),
341
- tslib_1.__metadata("design:type", String)
342
- ], SaasAlert.prototype, "accountName", void 0);
343
- tslib_1.__decorate([
344
- (0, type_graphql_1.Field)({ nullable: true, description: 'The subscription' }),
345
- tslib_1.__metadata("design:type", String)
346
- ], SaasAlert.prototype, "subscriptionId", void 0);
347
- tslib_1.__decorate([
348
- (0, type_graphql_1.Field)({ nullable: true, description: "The subscription's name" }),
349
- tslib_1.__metadata("design:type", String)
350
- ], SaasAlert.prototype, "subscriptionName", void 0);
351
- tslib_1.__decorate([
352
- (0, type_graphql_1.Field)({ description: 'The month of the bill' }),
353
- tslib_1.__metadata("design:type", String)
354
- ], SaasAlert.prototype, "month", void 0);
355
- tslib_1.__decorate([
356
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What was billed' }),
357
- tslib_1.__metadata("design:type", Number)
358
- ], SaasAlert.prototype, "amount", void 0);
359
- tslib_1.__decorate([
360
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What it was told against - the budget, the rise allowed, seats times price' }),
361
- tslib_1.__metadata("design:type", Number)
362
- ], SaasAlert.prototype, "limit", void 0);
363
- exports.SaasAlert = SaasAlert = tslib_1.__decorate([
364
- (0, type_graphql_1.ObjectType)({ description: 'Something in the latest bills worth telling' })
365
- ], SaasAlert);
366
- let SaasCostTrend = class SaasCostTrend {
367
- };
368
- exports.SaasCostTrend = SaasCostTrend;
369
- tslib_1.__decorate([
370
- (0, type_graphql_1.Field)(type => [String], { description: 'The months, YYYY-MM' }),
371
- tslib_1.__metadata("design:type", Array)
372
- ], SaasCostTrend.prototype, "months", void 0);
373
- tslib_1.__decorate([
374
- (0, type_graphql_1.Field)(type => [SaasTrendSeries], { description: 'Everything, one series a currency' }),
375
- tslib_1.__metadata("design:type", Array)
376
- ], SaasCostTrend.prototype, "all", void 0);
377
- tslib_1.__decorate([
378
- (0, type_graphql_1.Field)(type => [SaasTrendSeries], { description: 'One series an account' }),
379
- tslib_1.__metadata("design:type", Array)
380
- ], SaasCostTrend.prototype, "accounts", void 0);
381
- tslib_1.__decorate([
382
- (0, type_graphql_1.Field)(type => [SaasTrendSeries], { description: 'One series a subscription' }),
383
- tslib_1.__metadata("design:type", Array)
384
- ], SaasCostTrend.prototype, "subscriptions", void 0);
385
- tslib_1.__decorate([
386
- (0, type_graphql_1.Field)(type => [SaasDepartmentSeries], { description: 'One series a department' }),
387
- tslib_1.__metadata("design:type", Array)
388
- ], SaasCostTrend.prototype, "departments", void 0);
389
- tslib_1.__decorate([
390
- (0, type_graphql_1.Field)(type => [SaasAlert], { description: 'What the latest month’s bills are worth telling' }),
391
- tslib_1.__metadata("design:type", Array)
392
- ], SaasCostTrend.prototype, "alerts", void 0);
393
- exports.SaasCostTrend = SaasCostTrend = tslib_1.__decorate([
394
- (0, type_graphql_1.ObjectType)({ description: 'The cost trend of the subscriptions from their bills' })
395
- ], SaasCostTrend);
396
188
  let SaasChange = class SaasChange {
397
189
  };
398
190
  exports.SaasChange = SaasChange;
@@ -427,60 +219,6 @@ tslib_1.__decorate([
427
219
  exports.SaasChange = SaasChange = tslib_1.__decorate([
428
220
  (0, type_graphql_1.ObjectType)({ description: 'What moved on an account or one of its subscriptions' })
429
221
  ], SaasChange);
430
- let SaasCandidate = class SaasCandidate {
431
- };
432
- exports.SaasCandidate = SaasCandidate;
433
- tslib_1.__decorate([
434
- (0, type_graphql_1.Field)({ description: 'Whom it is - the counterparty id, or name: and the written name for lines no counterparty is linked to' }),
435
- tslib_1.__metadata("design:type", String)
436
- ], SaasCandidate.prototype, "key", void 0);
437
- tslib_1.__decorate([
438
- (0, type_graphql_1.Field)({ nullable: true, description: 'The vendor - a counterparty id; empty when the lines only name it' }),
439
- tslib_1.__metadata("design:type", String)
440
- ], SaasCandidate.prototype, "counterpartyId", void 0);
441
- tslib_1.__decorate([
442
- (0, type_graphql_1.Field)({ description: "The vendor's name - the counterparty's, or the one written on the lines" }),
443
- tslib_1.__metadata("design:type", String)
444
- ], SaasCandidate.prototype, "counterpartyName", void 0);
445
- tslib_1.__decorate([
446
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The months of the last twelve money went out to it in' }),
447
- tslib_1.__metadata("design:type", Number)
448
- ], SaasCandidate.prototype, "months", void 0);
449
- tslib_1.__decorate([
450
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What went out a month, on average over those months' }),
451
- tslib_1.__metadata("design:type", Number)
452
- ], SaasCandidate.prototype, "average", void 0);
453
- tslib_1.__decorate([
454
- (0, type_graphql_1.Field)({ description: 'The first day money went out to it in the window - YYYY-MM-DD' }),
455
- tslib_1.__metadata("design:type", String)
456
- ], SaasCandidate.prototype, "firstDate", void 0);
457
- tslib_1.__decorate([
458
- (0, type_graphql_1.Field)({ description: 'The last day money went out to it - YYYY-MM-DD' }),
459
- tslib_1.__metadata("design:type", String)
460
- ], SaasCandidate.prototype, "lastDate", void 0);
461
- tslib_1.__decorate([
462
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'How much went out that day' }),
463
- tslib_1.__metadata("design:type", Number)
464
- ], SaasCandidate.prototype, "lastAmount", void 0);
465
- tslib_1.__decorate([
466
- (0, type_graphql_1.Field)({ description: 'The currency' }),
467
- tslib_1.__metadata("design:type", String)
468
- ], SaasCandidate.prototype, "currency", void 0);
469
- tslib_1.__decorate([
470
- (0, type_graphql_1.Field)({ nullable: true, description: 'The bank account or card it went out of most - an id' }),
471
- tslib_1.__metadata("design:type", String)
472
- ], SaasCandidate.prototype, "paymentAccountId", void 0);
473
- tslib_1.__decorate([
474
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'The day of the month it went out on most; 31 for the last day' }),
475
- tslib_1.__metadata("design:type", Number)
476
- ], SaasCandidate.prototype, "billingDay", void 0);
477
- tslib_1.__decorate([
478
- (0, type_graphql_1.Field)({ description: 'Whether a keeper hid it from the candidates' }),
479
- tslib_1.__metadata("design:type", Boolean)
480
- ], SaasCandidate.prototype, "hidden", void 0);
481
- exports.SaasCandidate = SaasCandidate = tslib_1.__decorate([
482
- (0, type_graphql_1.ObjectType)({ description: 'A vendor the books show paid month after month that is no account yet (ADR-0177 amendment 1)' })
483
- ], SaasCandidate);
484
222
  let SaasLicenseSkuInput = class SaasLicenseSkuInput {
485
223
  };
486
224
  exports.SaasLicenseSkuInput = SaasLicenseSkuInput;
@@ -597,90 +335,4 @@ tslib_1.__decorate([
597
335
  exports.SaasLicenseSync = SaasLicenseSync = tslib_1.__decorate([
598
336
  (0, type_graphql_1.ObjectType)({ description: 'What a sync of a vendor tenant changed' })
599
337
  ], SaasLicenseSync);
600
- let SaasCostLineInput = class SaasCostLineInput {
601
- };
602
- exports.SaasCostLineInput = SaasCostLineInput;
603
- tslib_1.__decorate([
604
- (0, type_graphql_1.Field)({ description: 'What it is for - a model' }),
605
- tslib_1.__metadata("design:type", String)
606
- ], SaasCostLineInput.prototype, "label", void 0);
607
- tslib_1.__decorate([
608
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'What it cost, in the report currency' }),
609
- tslib_1.__metadata("design:type", Number)
610
- ], SaasCostLineInput.prototype, "amount", void 0);
611
- exports.SaasCostLineInput = SaasCostLineInput = tslib_1.__decorate([
612
- (0, type_graphql_1.InputType)({ description: 'A line of a month a vendor cost report gives (ADR-0177 amendment 3)' })
613
- ], SaasCostLineInput);
614
- let SaasCostMonthInput = class SaasCostMonthInput {
615
- };
616
- exports.SaasCostMonthInput = SaasCostMonthInput;
617
- tslib_1.__decorate([
618
- (0, type_graphql_1.Field)({ description: 'The month - YYYY-MM' }),
619
- tslib_1.__metadata("design:type", String)
620
- ], SaasCostMonthInput.prototype, "month", void 0);
621
- tslib_1.__decorate([
622
- (0, type_graphql_1.Field)(type => [SaasCostLineInput], { description: 'Its lines' }),
623
- tslib_1.__metadata("design:type", Array)
624
- ], SaasCostMonthInput.prototype, "lines", void 0);
625
- exports.SaasCostMonthInput = SaasCostMonthInput = tslib_1.__decorate([
626
- (0, type_graphql_1.InputType)({ description: 'A month of a vendor cost report' })
627
- ], SaasCostMonthInput);
628
- let SaasCostsInput = class SaasCostsInput {
629
- };
630
- exports.SaasCostsInput = SaasCostsInput;
631
- tslib_1.__decorate([
632
- (0, type_graphql_1.Field)({ description: "The vendor's id for the account - an Anthropic organization id" }),
633
- tslib_1.__metadata("design:type", String)
634
- ], SaasCostsInput.prototype, "vendorAccount", void 0);
635
- tslib_1.__decorate([
636
- (0, type_graphql_1.Field)({ nullable: true, description: "The vendor's name for the account" }),
637
- tslib_1.__metadata("design:type", String)
638
- ], SaasCostsInput.prototype, "vendorName", void 0);
639
- tslib_1.__decorate([
640
- (0, type_graphql_1.Field)({ description: 'The currency of the amounts' }),
641
- tslib_1.__metadata("design:type", String)
642
- ], SaasCostsInput.prototype, "currency", void 0);
643
- tslib_1.__decorate([
644
- (0, type_graphql_1.Field)(type => [SaasCostMonthInput], { description: 'The months' }),
645
- tslib_1.__metadata("design:type", Array)
646
- ], SaasCostsInput.prototype, "months", void 0);
647
- exports.SaasCostsInput = SaasCostsInput = tslib_1.__decorate([
648
- (0, type_graphql_1.InputType)({ description: "What a vendor's cost report says, month by month, as a scenario read it" })
649
- ], SaasCostsInput);
650
- let SaasCostSync = class SaasCostSync {
651
- };
652
- exports.SaasCostSync = SaasCostSync;
653
- tslib_1.__decorate([
654
- (0, type_graphql_1.Field)({ description: 'The account' }),
655
- tslib_1.__metadata("design:type", String)
656
- ], SaasCostSync.prototype, "accountId", void 0);
657
- tslib_1.__decorate([
658
- (0, type_graphql_1.Field)({ description: "The account's name" }),
659
- tslib_1.__metadata("design:type", String)
660
- ], SaasCostSync.prototype, "accountName", void 0);
661
- tslib_1.__decorate([
662
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Bills written' }),
663
- tslib_1.__metadata("design:type", Number)
664
- ], SaasCostSync.prototype, "written", void 0);
665
- tslib_1.__decorate([
666
- (0, type_graphql_1.Field)(type => [String], { description: 'Months whose bill a person wrote - kept' }),
667
- tslib_1.__metadata("design:type", Array)
668
- ], SaasCostSync.prototype, "kept", void 0);
669
- exports.SaasCostSync = SaasCostSync = tslib_1.__decorate([
670
- (0, type_graphql_1.ObjectType)({ description: 'What a sync of a vendor cost report wrote' })
671
- ], SaasCostSync);
672
- let SaasCostSyncs = class SaasCostSyncs {
673
- };
674
- exports.SaasCostSyncs = SaasCostSyncs;
675
- tslib_1.__decorate([
676
- (0, type_graphql_1.Field)(type => [SaasCostSync], { description: 'The accounts written' }),
677
- tslib_1.__metadata("design:type", Array)
678
- ], SaasCostSyncs.prototype, "results", void 0);
679
- tslib_1.__decorate([
680
- (0, type_graphql_1.Field)(type => [String], { description: 'Vendor accounts no subscription account names - passed over' }),
681
- tslib_1.__metadata("design:type", Array)
682
- ], SaasCostSyncs.prototype, "unmatched", void 0);
683
- exports.SaasCostSyncs = SaasCostSyncs = tslib_1.__decorate([
684
- (0, type_graphql_1.ObjectType)({ description: 'What a sync of vendor cost reports wrote, an account each' })
685
- ], SaasCostSyncs);
686
338
  //# sourceMappingURL=saas-type.js.map