@neetru/sdk 2.3.1 → 2.3.2

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as NeetruClientConfig, N as NeetruClient } from './types-B6YJrynl.cjs';
2
- export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationsNamespace, P as Product, z as ProductNotification, B as ProductNotificationSeverity, F as ProductPlan, G as ProductStatus, R as RegisterWebhookInput, H as ResolvedConfig, S as SendNotificationInput, I as SignInOptions, K as SupportNamespace, O as SupportSeverity, Q as SupportStatus, T as SupportTicket, U as TelemetryEventAck, V as TelemetryEventInput, Y as UsageEventInput, Z as UsageNamespace, _ as UsageQuota, $ as VerifyTokenOptions, a0 as WebhookEndpoint, a1 as WebhookEvent, a2 as WebhookTestResult, a3 as WebhooksNamespace, a4 as createCheckoutNamespace, a5 as createNeetruDb, a6 as createNotificationsNamespace, a8 as createWebhooksNamespace } from './types-B6YJrynl.cjs';
1
+ import { o as NeetruClientConfig, N as NeetruClient } from './types-sGGN1vkg.cjs';
2
+ export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationsNamespace, P as Product, z as ProductNotification, B as ProductNotificationSeverity, F as ProductPlan, G as ProductStatus, R as RegisterWebhookInput, H as ResolvedConfig, S as SendNotificationInput, I as SignInOptions, K as SupportNamespace, O as SupportSeverity, Q as SupportStatus, T as SupportTicket, U as TelemetryEventAck, V as TelemetryEventInput, Y as UsageEventInput, Z as UsageNamespace, _ as UsageQuota, $ as VerifyTokenOptions, a0 as WebhookEndpoint, a1 as WebhookEvent, a2 as WebhookTestResult, a3 as WebhooksNamespace, a4 as createCheckoutNamespace, a5 as createNeetruDb, a6 as createNotificationsNamespace, a8 as createWebhooksNamespace } from './types-sGGN1vkg.cjs';
3
3
  export { createNeetruClient } from './auth.cjs';
4
4
  export { NeetruError, NeetruErrorCode } from './errors.cjs';
5
5
  export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery } from './collection-ref-DqAAhuhX.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as NeetruClientConfig, N as NeetruClient } from './types-DvhtZ4bi.js';
2
- export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationsNamespace, P as Product, z as ProductNotification, B as ProductNotificationSeverity, F as ProductPlan, G as ProductStatus, R as RegisterWebhookInput, H as ResolvedConfig, S as SendNotificationInput, I as SignInOptions, K as SupportNamespace, O as SupportSeverity, Q as SupportStatus, T as SupportTicket, U as TelemetryEventAck, V as TelemetryEventInput, Y as UsageEventInput, Z as UsageNamespace, _ as UsageQuota, $ as VerifyTokenOptions, a0 as WebhookEndpoint, a1 as WebhookEvent, a2 as WebhookTestResult, a3 as WebhooksNamespace, a4 as createCheckoutNamespace, a5 as createNeetruDb, a6 as createNotificationsNamespace, a8 as createWebhooksNamespace } from './types-DvhtZ4bi.js';
1
+ import { o as NeetruClientConfig, N as NeetruClient } from './types-CSC-RIdS.js';
2
+ export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationsNamespace, P as Product, z as ProductNotification, B as ProductNotificationSeverity, F as ProductPlan, G as ProductStatus, R as RegisterWebhookInput, H as ResolvedConfig, S as SendNotificationInput, I as SignInOptions, K as SupportNamespace, O as SupportSeverity, Q as SupportStatus, T as SupportTicket, U as TelemetryEventAck, V as TelemetryEventInput, Y as UsageEventInput, Z as UsageNamespace, _ as UsageQuota, $ as VerifyTokenOptions, a0 as WebhookEndpoint, a1 as WebhookEvent, a2 as WebhookTestResult, a3 as WebhooksNamespace, a4 as createCheckoutNamespace, a5 as createNeetruDb, a6 as createNotificationsNamespace, a8 as createWebhooksNamespace } from './types-CSC-RIdS.js';
3
3
  export { createNeetruClient } from './auth.js';
4
4
  export { NeetruError, NeetruErrorCode } from './errors.js';
5
5
  export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery } from './collection-ref-DqAAhuhX.js';
package/dist/index.mjs CHANGED
@@ -5367,11 +5367,54 @@ var MockDb = class {
5367
5367
  };
5368
5368
  return ref;
5369
5369
  }
5370
- async sql(_schema) {
5371
- throw new NeetruDbError(
5372
- "db_unavailable",
5373
- '[MockDb] sql() n\xE3o dispon\xEDvel no mock. Use createNeetruClient({ env: "dev" }) e `neetru dev` para o banco local.'
5374
- );
5370
+ /**
5371
+ * Implementa SQL in-memory via `pg-mem` + `drizzle-orm/node-postgres`.
5372
+ *
5373
+ * bug_a7f2ae25fda54129b52b6dd55aaa6050 (HIGH 26/05): antes lançava
5374
+ * `db_unavailable` sempre, bloqueando vitest server-side dos consumers
5375
+ * que refatoraram pra `client.db.sql()`. Agora carrega `pg-mem` lazy +
5376
+ * cria `NodePgDatabase` Drizzle apontando pra DB in-memory.
5377
+ *
5378
+ * Requer `pg-mem`, `drizzle-orm` e `pg` como devDependencies do consumer
5379
+ * (instale com `npm install -D pg-mem drizzle-orm pg`). Se ausentes, joga
5380
+ * `db_unavailable` com mensagem clara.
5381
+ *
5382
+ * Use `options.initSql` pra criar tabelas no test setup — sem isso o orm
5383
+ * funciona mas qualquer SELECT/INSERT em tabela inexistente vai falhar.
5384
+ */
5385
+ async sql(schema, options) {
5386
+ let pgMemMod;
5387
+ let drizzlePg;
5388
+ try {
5389
+ pgMemMod = await import('pg-mem');
5390
+ drizzlePg = await import('drizzle-orm/node-postgres');
5391
+ } catch {
5392
+ throw new NeetruDbError(
5393
+ "db_unavailable",
5394
+ "[MockDb] sql() requer pg-mem + drizzle-orm + pg como devDependencies do consumer. Rode: npm install -D pg-mem drizzle-orm pg."
5395
+ );
5396
+ }
5397
+ const memDb = pgMemMod.newDb({ noAstCoverageCheck: true });
5398
+ if (options?.initSql) {
5399
+ const ddls = Array.isArray(options.initSql) ? options.initSql : [options.initSql];
5400
+ for (const ddl of ddls) {
5401
+ memDb.public.none(ddl);
5402
+ }
5403
+ }
5404
+ const adapters = memDb.adapters.createPg();
5405
+ const PoolCtor = adapters.Pool;
5406
+ const pool = new PoolCtor();
5407
+ const orm = drizzlePg.drizzle(pool, { schema });
5408
+ return {
5409
+ orm,
5410
+ async transaction(fn, _opts) {
5411
+ return await orm.transaction(fn);
5412
+ },
5413
+ async close() {
5414
+ const p = pool;
5415
+ if (p.end) await p.end();
5416
+ }
5417
+ };
5375
5418
  }
5376
5419
  get syncState() {
5377
5420
  return {