@opengeni/db 1.1.0 → 1.2.0

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 (77) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/capability-reconciliation.js +2 -2
  3. package/dist/{chunk-J4WFOVBV.js → chunk-3GAR5UN3.js} +2 -2
  4. package/dist/{chunk-Z5HJXH3X.js → chunk-3TGYFFZR.js} +2 -2
  5. package/dist/{chunk-GLA5YCQS.js → chunk-6EIEGHPK.js} +4 -4
  6. package/dist/{chunk-BLUQG54M.js → chunk-CONWNUSL.js} +2 -2
  7. package/dist/{chunk-EKXCF3FH.js → chunk-CYP72JTQ.js} +11 -4
  8. package/dist/{chunk-EKXCF3FH.js.map → chunk-CYP72JTQ.js.map} +1 -1
  9. package/dist/{chunk-VOB6TXSJ.js → chunk-FWQNHNOU.js} +39 -2
  10. package/dist/chunk-FWQNHNOU.js.map +1 -0
  11. package/dist/{chunk-7Z7ALFRE.js → chunk-GDN5TSZP.js} +2 -2
  12. package/dist/{chunk-M3SWH4MU.js → chunk-JICUP7ZR.js} +2 -2
  13. package/dist/{chunk-KJVOBLFC.js → chunk-JLVWBIEM.js} +3 -3
  14. package/dist/{chunk-BZV5ZDRY.js → chunk-LXPFNG4L.js} +2 -2
  15. package/dist/{chunk-SKYRM7R7.js → chunk-O2Y5E5M3.js} +68 -32
  16. package/dist/chunk-O2Y5E5M3.js.map +1 -0
  17. package/dist/{chunk-M2YGXCCQ.js → chunk-QFJNEXFL.js} +2 -2
  18. package/dist/{chunk-CIGHXFPD.js → chunk-UCIMHNII.js} +101 -21
  19. package/dist/chunk-UCIMHNII.js.map +1 -0
  20. package/dist/{chunk-ODKYBA3C.js → chunk-VDPCIFKL.js} +5 -5
  21. package/dist/{chunk-T5NHDEZW.js → chunk-YOYILDLY.js} +26 -1
  22. package/dist/chunk-YOYILDLY.js.map +1 -0
  23. package/dist/connect-attempts.js +3 -3
  24. package/dist/credit-balances.d.ts +18 -0
  25. package/dist/credit-promotion-policy.d.ts +10 -0
  26. package/dist/editable-artifact-durable-export.js +2 -2
  27. package/dist/editable-artifacts.js +3 -3
  28. package/dist/index.d.ts +21 -5
  29. package/dist/index.js +2369 -2247
  30. package/dist/index.js.map +1 -1
  31. package/dist/managed-auth-session-sets.js +3 -3
  32. package/dist/managed-user-setup.d.ts +1 -0
  33. package/dist/mcp-operations.js +2 -2
  34. package/dist/organization-integration-policy.js +3 -3
  35. package/dist/organization-membership-lifecycle.d.ts +1 -0
  36. package/dist/persistence-errors.d.ts +9 -6
  37. package/dist/provision-roles.js +1 -1
  38. package/dist/retained-provider-commands.js +6 -6
  39. package/dist/runtime-posture.d.ts +4 -4
  40. package/dist/schema.d.ts +121 -2
  41. package/dist/schema.js +3 -1
  42. package/dist/session-background-commands.js +4 -4
  43. package/dist/session-command-output.js +5 -5
  44. package/dist/session-event-slices.js +3 -3
  45. package/dist/session-mcp-credential-rotation.js +5 -5
  46. package/dist/session-tenancy.js +3 -3
  47. package/dist/video-generation.js +3 -3
  48. package/dist/workspace-tool-defaults.js +4 -4
  49. package/drizzle/0613_model_scoped_promotional_credits.sql +238 -0
  50. package/drizzle/0614_quiescence_command_containment.sql +7 -0
  51. package/drizzle/0615_credit_promotion_policy_validation.sql +63 -0
  52. package/package.json +7 -7
  53. package/src/credit-balances.ts +109 -0
  54. package/src/credit-promotion-policy.ts +12 -0
  55. package/src/database.ts +81 -42
  56. package/src/index.ts +201 -60
  57. package/src/managed-user-setup.ts +8 -0
  58. package/src/organization-membership-lifecycle.ts +8 -0
  59. package/src/persistence-errors.ts +17 -6
  60. package/src/provision-roles.ts +9 -0
  61. package/src/runtime-posture.ts +22 -0
  62. package/src/schema.ts +40 -1
  63. package/src/video-generation.ts +2 -7
  64. package/dist/chunk-CIGHXFPD.js.map +0 -1
  65. package/dist/chunk-SKYRM7R7.js.map +0 -1
  66. package/dist/chunk-T5NHDEZW.js.map +0 -1
  67. package/dist/chunk-VOB6TXSJ.js.map +0 -1
  68. /package/dist/{chunk-J4WFOVBV.js.map → chunk-3GAR5UN3.js.map} +0 -0
  69. /package/dist/{chunk-Z5HJXH3X.js.map → chunk-3TGYFFZR.js.map} +0 -0
  70. /package/dist/{chunk-GLA5YCQS.js.map → chunk-6EIEGHPK.js.map} +0 -0
  71. /package/dist/{chunk-BLUQG54M.js.map → chunk-CONWNUSL.js.map} +0 -0
  72. /package/dist/{chunk-7Z7ALFRE.js.map → chunk-GDN5TSZP.js.map} +0 -0
  73. /package/dist/{chunk-M3SWH4MU.js.map → chunk-JICUP7ZR.js.map} +0 -0
  74. /package/dist/{chunk-KJVOBLFC.js.map → chunk-JLVWBIEM.js.map} +0 -0
  75. /package/dist/{chunk-BZV5ZDRY.js.map → chunk-LXPFNG4L.js.map} +0 -0
  76. /package/dist/{chunk-M2YGXCCQ.js.map → chunk-QFJNEXFL.js.map} +0 -0
  77. /package/dist/{chunk-ODKYBA3C.js.map → chunk-VDPCIFKL.js.map} +0 -0
@@ -82,6 +82,7 @@ __export(schema_exports, {
82
82
  connections: () => connections,
83
83
  connectorActionPolicies: () => connectorActionPolicies,
84
84
  connectorActionRequests: () => connectorActionRequests,
85
+ creditDebitAllocations: () => creditDebitAllocations,
85
86
  creditLedgerEntries: () => creditLedgerEntries,
86
87
  deploymentModelCatalog: () => deploymentModelCatalog,
87
88
  deviceEnrollmentRequests: () => deviceEnrollmentRequests,
@@ -15229,7 +15230,7 @@ var sandboxLeases = pgTable23(
15229
15230
  // Why an enrolled drain contains its commands (0547); cleared with the
15230
15231
  // enrollment. Null for a pre-0547 enrollment: settle with neutral wording.
15231
15232
  commandContainmentReason: text23("command_containment_reason", {
15232
- enum: ["idle_containment", "provider_deadline_containment"]
15233
+ enum: ["idle_containment", "provider_deadline_containment", "quiescence_containment"]
15233
15234
  }),
15234
15235
  liveness: text23("liveness", { enum: sandboxLeaseLivenessValues }).notNull().default("cold"),
15235
15236
  refcount: integer20("refcount").notNull().default(0),
@@ -17793,6 +17794,8 @@ var creditLedgerEntries = pgTable23(
17793
17794
  }),
17794
17795
  type: text23("type").notNull(),
17795
17796
  amountMicros: bigint15("amount_micros", { mode: "number" }).notNull(),
17797
+ /** Null preserves the unrestricted terms of legacy credits. */
17798
+ eligibleModelIds: text23("eligible_model_ids").array(),
17796
17799
  currency: text23("currency").notNull().default("usd"),
17797
17800
  sourceType: text23("source_type"),
17798
17801
  sourceId: text23("source_id"),
@@ -17803,6 +17806,17 @@ var creditLedgerEntries = pgTable23(
17803
17806
  },
17804
17807
  (table) => ({
17805
17808
  idempotency: uniqueIndex22("credit_ledger_entries_idempotency_idx").on(table.idempotencyKey),
17809
+ idAccount: uniqueIndex22("credit_ledger_entries_id_account_idx").on(table.id, table.accountId),
17810
+ scopedGrants: index21("credit_ledger_scoped_grants_idx").on(table.accountId, table.createdAt, table.id).where(sql19`${table.eligibleModelIds} is not null`),
17811
+ scopeValid: check13(
17812
+ "credit_ledger_scope_valid",
17813
+ sql19`${table.eligibleModelIds} is null or (
17814
+ ${table.type} = 'grant' and ${table.amountMicros} > 0
17815
+ and cardinality(${table.eligibleModelIds}) between 1 and 40
17816
+ and array_position(${table.eligibleModelIds}, null) is null
17817
+ and array_position(${table.eligibleModelIds}, '') is null
17818
+ )`
17819
+ ),
17806
17820
  modelDebitPeriod: index21("credit_ledger_entries_model_debit_period_idx").on(table.accountId, table.occurredAt, table.workspaceId).where(
17807
17821
  sql19`${table.type}='model_usage_debit' and ${table.sourceType}='model_response' and ${table.amountMicros}<0`
17808
17822
  ),
@@ -17812,6 +17826,28 @@ var creditLedgerEntries = pgTable23(
17812
17826
  )
17813
17827
  })
17814
17828
  );
17829
+ var creditDebitAllocations = pgTable23(
17830
+ "credit_debit_allocations",
17831
+ {
17832
+ accountId: uuid22("account_id").notNull(),
17833
+ debitEntryId: uuid22("debit_entry_id").notNull(),
17834
+ grantEntryId: uuid22("grant_entry_id").notNull(),
17835
+ amountMicros: bigint15("amount_micros", { mode: "number" }).notNull()
17836
+ },
17837
+ (table) => ({
17838
+ pk: primaryKey10({ columns: [table.debitEntryId, table.grantEntryId] }),
17839
+ debit: foreignKey({
17840
+ columns: [table.debitEntryId, table.accountId],
17841
+ foreignColumns: [creditLedgerEntries.id, creditLedgerEntries.accountId]
17842
+ }).onDelete("cascade"),
17843
+ grant: foreignKey({
17844
+ columns: [table.grantEntryId, table.accountId],
17845
+ foreignColumns: [creditLedgerEntries.id, creditLedgerEntries.accountId]
17846
+ }).onDelete("cascade"),
17847
+ grantIndex: index21("credit_debit_allocations_grant_idx").on(table.accountId, table.grantEntryId),
17848
+ positive: check13("credit_debit_allocations_positive", sql19`${table.amountMicros} > 0`)
17849
+ })
17850
+ );
17815
17851
  var usageAllowanceAttributionReceipts = opengeniPrivateSchema.table(
17816
17852
  "usage_allowance_attribution_receipts",
17817
17853
  {
@@ -19752,6 +19788,7 @@ export {
19752
19788
  hostExportConsumers,
19753
19789
  hostExportDeadLetters,
19754
19790
  creditLedgerEntries,
19791
+ creditDebitAllocations,
19755
19792
  usageAllowanceAttributionReceipts,
19756
19793
  workspaceAllowanceClearReceipts,
19757
19794
  workspaceUsageAllowances,
@@ -19804,4 +19841,4 @@ export {
19804
19841
  feedbackSubmissions,
19805
19842
  schema_exports
19806
19843
  };
19807
- //# sourceMappingURL=chunk-VOB6TXSJ.js.map
19844
+ //# sourceMappingURL=chunk-FWQNHNOU.js.map