@opengeni/db 1.0.2 → 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 (86) hide show
  1. package/dist/artifact-catalog.d.ts +12 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/capability-reconciliation.js +2 -2
  4. package/dist/{chunk-KH3TYDGY.js → chunk-3GAR5UN3.js} +2 -2
  5. package/dist/{chunk-UEQQ2WWU.js → chunk-3TGYFFZR.js} +3 -26
  6. package/dist/chunk-3TGYFFZR.js.map +1 -0
  7. package/dist/{chunk-F3YMVRF4.js → chunk-6EIEGHPK.js} +4 -4
  8. package/dist/{chunk-OQZOGCLG.js → chunk-CONWNUSL.js} +2 -2
  9. package/dist/{chunk-7S53WLPI.js → chunk-CYP72JTQ.js} +11 -4
  10. package/dist/{chunk-7S53WLPI.js.map → chunk-CYP72JTQ.js.map} +1 -1
  11. package/dist/{chunk-LDTQGYD2.js → chunk-FWQNHNOU.js} +54 -2
  12. package/dist/chunk-FWQNHNOU.js.map +1 -0
  13. package/dist/{chunk-KEDWSSNP.js → chunk-GDN5TSZP.js} +2 -2
  14. package/dist/{chunk-PQGTWFRF.js → chunk-JICUP7ZR.js} +2 -2
  15. package/dist/{chunk-NLSG7GGA.js → chunk-JLVWBIEM.js} +3 -3
  16. package/dist/{chunk-Y77PVZZD.js → chunk-LXPFNG4L.js} +2 -2
  17. package/dist/{chunk-56MYWKQV.js → chunk-O2Y5E5M3.js} +68 -32
  18. package/dist/chunk-O2Y5E5M3.js.map +1 -0
  19. package/dist/{chunk-7POTLB24.js → chunk-QFJNEXFL.js} +2 -2
  20. package/dist/{chunk-MACELCXG.js → chunk-UCIMHNII.js} +101 -21
  21. package/dist/chunk-UCIMHNII.js.map +1 -0
  22. package/dist/{chunk-OMHBVHX7.js → chunk-VDPCIFKL.js} +5 -5
  23. package/dist/{chunk-N5QCKHYL.js → chunk-YOYILDLY.js} +87 -19
  24. package/dist/chunk-YOYILDLY.js.map +1 -0
  25. package/dist/connect-attempts.js +3 -3
  26. package/dist/credit-balances.d.ts +18 -0
  27. package/dist/credit-promotion-policy.d.ts +10 -0
  28. package/dist/editable-artifact-durable-export.js +2 -2
  29. package/dist/editable-artifacts.js +3 -3
  30. package/dist/index.d.ts +35 -10
  31. package/dist/index.js +2432 -2255
  32. package/dist/index.js.map +1 -1
  33. package/dist/managed-auth-session-sets.js +3 -3
  34. package/dist/managed-user-setup.d.ts +1 -0
  35. package/dist/mcp-operations.js +2 -2
  36. package/dist/organization-integration-policy.js +3 -3
  37. package/dist/organization-membership-lifecycle.d.ts +1 -0
  38. package/dist/persistence-errors.d.ts +9 -6
  39. package/dist/provision-roles.js +1 -1
  40. package/dist/retained-provider-commands.js +6 -6
  41. package/dist/runtime-posture.d.ts +7 -6
  42. package/dist/schema.d.ts +214 -2
  43. package/dist/schema.js +5 -1
  44. package/dist/session-background-commands.js +4 -4
  45. package/dist/session-command-output.js +5 -5
  46. package/dist/session-event-slices.js +3 -3
  47. package/dist/session-mcp-credential-rotation.js +5 -5
  48. package/dist/session-tenancy.d.ts +6 -1
  49. package/dist/session-tenancy.js +3 -5
  50. package/dist/video-generation.js +3 -3
  51. package/dist/workspace-tool-defaults.js +4 -4
  52. package/drizzle/0610_artifact_catalog_pins.sql +165 -0
  53. package/drizzle/0611_universal_session_tenancy_activation.sql +166 -0
  54. package/drizzle/0612_scheduled_model_unavailable_refusal.sql +21 -0
  55. package/drizzle/0613_model_scoped_promotional_credits.sql +238 -0
  56. package/drizzle/0614_quiescence_command_containment.sql +7 -0
  57. package/drizzle/0615_credit_promotion_policy_validation.sql +63 -0
  58. package/package.json +7 -7
  59. package/src/artifact-catalog.ts +31 -5
  60. package/src/credit-balances.ts +109 -0
  61. package/src/credit-promotion-policy.ts +12 -0
  62. package/src/database.ts +81 -42
  63. package/src/index.ts +295 -79
  64. package/src/managed-user-setup.ts +8 -0
  65. package/src/organization-membership-lifecycle.ts +8 -0
  66. package/src/persistence-errors.ts +17 -6
  67. package/src/provision-roles.ts +25 -0
  68. package/src/runtime-posture-cli.ts +0 -2
  69. package/src/runtime-posture.ts +86 -27
  70. package/src/schema.ts +57 -1
  71. package/src/session-tenancy.ts +9 -31
  72. package/src/video-generation.ts +2 -7
  73. package/dist/chunk-56MYWKQV.js.map +0 -1
  74. package/dist/chunk-LDTQGYD2.js.map +0 -1
  75. package/dist/chunk-MACELCXG.js.map +0 -1
  76. package/dist/chunk-N5QCKHYL.js.map +0 -1
  77. package/dist/chunk-UEQQ2WWU.js.map +0 -1
  78. /package/dist/{chunk-KH3TYDGY.js.map → chunk-3GAR5UN3.js.map} +0 -0
  79. /package/dist/{chunk-F3YMVRF4.js.map → chunk-6EIEGHPK.js.map} +0 -0
  80. /package/dist/{chunk-OQZOGCLG.js.map → chunk-CONWNUSL.js.map} +0 -0
  81. /package/dist/{chunk-KEDWSSNP.js.map → chunk-GDN5TSZP.js.map} +0 -0
  82. /package/dist/{chunk-PQGTWFRF.js.map → chunk-JICUP7ZR.js.map} +0 -0
  83. /package/dist/{chunk-NLSG7GGA.js.map → chunk-JLVWBIEM.js.map} +0 -0
  84. /package/dist/{chunk-Y77PVZZD.js.map → chunk-LXPFNG4L.js.map} +0 -0
  85. /package/dist/{chunk-7POTLB24.js.map → chunk-QFJNEXFL.js.map} +0 -0
  86. /package/dist/{chunk-OMHBVHX7.js.map → chunk-VDPCIFKL.js.map} +0 -0
@@ -15,6 +15,7 @@ __export(schema_exports, {
15
15
  agentRunStates: () => agentRunStates,
16
16
  agentUpdateStatusValues: () => agentUpdateStatusValues,
17
17
  apiKeys: () => apiKeys,
18
+ artifactCatalogPins: () => artifactCatalogPins,
18
19
  attachedBrowserDevices: () => attachedBrowserDevices,
19
20
  attachedBrowserInventories: () => attachedBrowserInventories,
20
21
  auditEvents: () => auditEvents,
@@ -81,6 +82,7 @@ __export(schema_exports, {
81
82
  connections: () => connections,
82
83
  connectorActionPolicies: () => connectorActionPolicies,
83
84
  connectorActionRequests: () => connectorActionRequests,
85
+ creditDebitAllocations: () => creditDebitAllocations,
84
86
  creditLedgerEntries: () => creditLedgerEntries,
85
87
  deploymentModelCatalog: () => deploymentModelCatalog,
86
88
  deviceEnrollmentRequests: () => deviceEnrollmentRequests,
@@ -11922,6 +11924,19 @@ var sandboxFilePublications = opengeniPrivateSchema.table(
11922
11924
  )
11923
11925
  })
11924
11926
  );
11927
+ var artifactCatalogPins = opengeniPrivateSchema.table(
11928
+ "artifact_catalog_pins",
11929
+ {
11930
+ accountId: uuid22("account_id").notNull(),
11931
+ workspaceId: uuid22("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
11932
+ kind: text23("kind").notNull(),
11933
+ artifactId: text23("artifact_id").notNull(),
11934
+ pinnedAt: timestamp23("pinned_at", { withTimezone: true }).notNull().defaultNow()
11935
+ },
11936
+ (table) => ({
11937
+ pk: primaryKey10({ columns: [table.accountId, table.workspaceId, table.kind, table.artifactId] })
11938
+ })
11939
+ );
11925
11940
  var slackFileUploadOperations = opengeniPrivateSchema.table(
11926
11941
  "slack_file_upload_operations",
11927
11942
  {
@@ -15215,7 +15230,7 @@ var sandboxLeases = pgTable23(
15215
15230
  // Why an enrolled drain contains its commands (0547); cleared with the
15216
15231
  // enrollment. Null for a pre-0547 enrollment: settle with neutral wording.
15217
15232
  commandContainmentReason: text23("command_containment_reason", {
15218
- enum: ["idle_containment", "provider_deadline_containment"]
15233
+ enum: ["idle_containment", "provider_deadline_containment", "quiescence_containment"]
15219
15234
  }),
15220
15235
  liveness: text23("liveness", { enum: sandboxLeaseLivenessValues }).notNull().default("cold"),
15221
15236
  refcount: integer20("refcount").notNull().default(0),
@@ -17779,6 +17794,8 @@ var creditLedgerEntries = pgTable23(
17779
17794
  }),
17780
17795
  type: text23("type").notNull(),
17781
17796
  amountMicros: bigint15("amount_micros", { mode: "number" }).notNull(),
17797
+ /** Null preserves the unrestricted terms of legacy credits. */
17798
+ eligibleModelIds: text23("eligible_model_ids").array(),
17782
17799
  currency: text23("currency").notNull().default("usd"),
17783
17800
  sourceType: text23("source_type"),
17784
17801
  sourceId: text23("source_id"),
@@ -17789,6 +17806,17 @@ var creditLedgerEntries = pgTable23(
17789
17806
  },
17790
17807
  (table) => ({
17791
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
+ ),
17792
17820
  modelDebitPeriod: index21("credit_ledger_entries_model_debit_period_idx").on(table.accountId, table.occurredAt, table.workspaceId).where(
17793
17821
  sql19`${table.type}='model_usage_debit' and ${table.sourceType}='model_response' and ${table.amountMicros}<0`
17794
17822
  ),
@@ -17798,6 +17826,28 @@ var creditLedgerEntries = pgTable23(
17798
17826
  )
17799
17827
  })
17800
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
+ );
17801
17851
  var usageAllowanceAttributionReceipts = opengeniPrivateSchema.table(
17802
17852
  "usage_allowance_attribution_receipts",
17803
17853
  {
@@ -19640,6 +19690,7 @@ export {
19640
19690
  sessionMcpServers,
19641
19691
  files,
19642
19692
  sandboxFilePublications,
19693
+ artifactCatalogPins,
19643
19694
  slackFileUploadOperations,
19644
19695
  fileUploads,
19645
19696
  generatedImageArtifacts,
@@ -19737,6 +19788,7 @@ export {
19737
19788
  hostExportConsumers,
19738
19789
  hostExportDeadLetters,
19739
19790
  creditLedgerEntries,
19791
+ creditDebitAllocations,
19740
19792
  usageAllowanceAttributionReceipts,
19741
19793
  workspaceAllowanceClearReceipts,
19742
19794
  workspaceUsageAllowances,
@@ -19789,4 +19841,4 @@ export {
19789
19841
  feedbackSubmissions,
19790
19842
  schema_exports
19791
19843
  };
19792
- //# sourceMappingURL=chunk-LDTQGYD2.js.map
19844
+ //# sourceMappingURL=chunk-FWQNHNOU.js.map