@secondlayer/shared 3.0.0-alpha.0 → 3.0.0-beta.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/src/crypto/secrets.js +47 -3
- package/dist/src/crypto/secrets.js.map +5 -4
- package/dist/src/crypto/standard-webhooks.d.ts +33 -0
- package/dist/src/crypto/standard-webhooks.js +77 -0
- package/dist/src/crypto/standard-webhooks.js.map +10 -0
- package/dist/src/db/index.d.ts +74 -1
- package/dist/src/db/queries/account-spend-caps.d.ts +65 -0
- package/dist/src/db/queries/account-usage.d.ts +65 -0
- package/dist/src/db/queries/accounts.d.ts +65 -0
- package/dist/src/db/queries/integrity.d.ts +65 -0
- package/dist/src/db/queries/projects.d.ts +65 -0
- package/dist/src/db/queries/provisioning-audit.d.ts +65 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +65 -0
- package/dist/src/db/queries/subgraphs.d.ts +65 -0
- package/dist/src/db/queries/subscriptions.d.ts +475 -0
- package/dist/src/db/queries/subscriptions.js +264 -0
- package/dist/src/db/queries/subscriptions.js.map +13 -0
- package/dist/src/db/queries/tenant-compute-addons.d.ts +65 -0
- package/dist/src/db/queries/tenants.d.ts +65 -0
- package/dist/src/db/queries/tenants.js +47 -3
- package/dist/src/db/queries/tenants.js.map +5 -4
- package/dist/src/db/queries/usage.d.ts +65 -0
- package/dist/src/db/schema.d.ts +74 -1
- package/dist/src/index.d.ts +74 -1
- package/dist/src/node/local-client.d.ts +65 -0
- package/migrations/0057_subscriptions.ts +137 -0
- package/package.json +7 -11
|
@@ -277,6 +277,9 @@ interface Database {
|
|
|
277
277
|
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
278
|
account_spend_caps: AccountSpendCapsTable;
|
|
279
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
280
283
|
}
|
|
281
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
282
285
|
interface TenantsTable {
|
|
@@ -356,6 +359,68 @@ interface ProvisioningAuditLogTable {
|
|
|
356
359
|
}
|
|
357
360
|
type Project = Selectable<ProjectsTable>;
|
|
358
361
|
type TeamInvitation = Selectable<TeamInvitationsTable>;
|
|
362
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
363
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
364
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
365
|
+
interface SubscriptionsTable {
|
|
366
|
+
id: Generated<string>;
|
|
367
|
+
account_id: string;
|
|
368
|
+
project_id: string | null;
|
|
369
|
+
name: string;
|
|
370
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
371
|
+
subgraph_name: string;
|
|
372
|
+
table_name: string;
|
|
373
|
+
filter: Generated<unknown>;
|
|
374
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
375
|
+
runtime: SubscriptionRuntime | null;
|
|
376
|
+
url: string;
|
|
377
|
+
signing_secret_enc: Buffer;
|
|
378
|
+
auth_config: Generated<unknown>;
|
|
379
|
+
max_retries: Generated<number>;
|
|
380
|
+
timeout_ms: Generated<number>;
|
|
381
|
+
concurrency: Generated<number>;
|
|
382
|
+
circuit_failures: Generated<number>;
|
|
383
|
+
circuit_opened_at: Date | null;
|
|
384
|
+
last_delivery_at: Date | null;
|
|
385
|
+
last_success_at: Date | null;
|
|
386
|
+
last_error: string | null;
|
|
387
|
+
created_at: Generated<Date>;
|
|
388
|
+
updated_at: Generated<Date>;
|
|
389
|
+
}
|
|
390
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
391
|
+
interface SubscriptionOutboxTable {
|
|
392
|
+
id: Generated<string>;
|
|
393
|
+
subscription_id: string;
|
|
394
|
+
subgraph_name: string;
|
|
395
|
+
table_name: string;
|
|
396
|
+
block_height: number | bigint;
|
|
397
|
+
tx_id: string | null;
|
|
398
|
+
row_pk: unknown;
|
|
399
|
+
event_type: string;
|
|
400
|
+
payload: unknown;
|
|
401
|
+
dedup_key: string;
|
|
402
|
+
attempt: Generated<number>;
|
|
403
|
+
next_attempt_at: Generated<Date>;
|
|
404
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
405
|
+
is_replay: Generated<boolean>;
|
|
406
|
+
delivered_at: Date | null;
|
|
407
|
+
failed_at: Date | null;
|
|
408
|
+
locked_by: string | null;
|
|
409
|
+
locked_until: Date | null;
|
|
410
|
+
created_at: Generated<Date>;
|
|
411
|
+
}
|
|
412
|
+
interface SubscriptionDeliveriesTable {
|
|
413
|
+
id: Generated<string>;
|
|
414
|
+
outbox_id: string;
|
|
415
|
+
subscription_id: string;
|
|
416
|
+
attempt: number;
|
|
417
|
+
status_code: number | null;
|
|
418
|
+
response_headers: unknown | null;
|
|
419
|
+
response_body: string | null;
|
|
420
|
+
error_message: string | null;
|
|
421
|
+
duration_ms: number | null;
|
|
422
|
+
dispatched_at: Generated<Date>;
|
|
423
|
+
}
|
|
359
424
|
declare function getProjectsByAccount(db: Kysely<Database>, accountId: string): Promise<Project[]>;
|
|
360
425
|
declare function getProjectBySlug(db: Kysely<Database>, accountId: string, slug: string): Promise<Project | undefined>;
|
|
361
426
|
declare function getTeamMembers(db: Kysely<Database>, projectId: string): Promise<Array<{
|
|
@@ -277,6 +277,9 @@ interface Database {
|
|
|
277
277
|
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
278
|
account_spend_caps: AccountSpendCapsTable;
|
|
279
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
280
283
|
}
|
|
281
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
282
285
|
interface TenantsTable {
|
|
@@ -355,6 +358,68 @@ interface ProvisioningAuditLogTable {
|
|
|
355
358
|
created_at: Generated<Date>;
|
|
356
359
|
}
|
|
357
360
|
type ProvisioningAuditLog = Selectable<ProvisioningAuditLogTable>;
|
|
361
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
362
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
363
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
364
|
+
interface SubscriptionsTable {
|
|
365
|
+
id: Generated<string>;
|
|
366
|
+
account_id: string;
|
|
367
|
+
project_id: string | null;
|
|
368
|
+
name: string;
|
|
369
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
370
|
+
subgraph_name: string;
|
|
371
|
+
table_name: string;
|
|
372
|
+
filter: Generated<unknown>;
|
|
373
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
374
|
+
runtime: SubscriptionRuntime | null;
|
|
375
|
+
url: string;
|
|
376
|
+
signing_secret_enc: Buffer;
|
|
377
|
+
auth_config: Generated<unknown>;
|
|
378
|
+
max_retries: Generated<number>;
|
|
379
|
+
timeout_ms: Generated<number>;
|
|
380
|
+
concurrency: Generated<number>;
|
|
381
|
+
circuit_failures: Generated<number>;
|
|
382
|
+
circuit_opened_at: Date | null;
|
|
383
|
+
last_delivery_at: Date | null;
|
|
384
|
+
last_success_at: Date | null;
|
|
385
|
+
last_error: string | null;
|
|
386
|
+
created_at: Generated<Date>;
|
|
387
|
+
updated_at: Generated<Date>;
|
|
388
|
+
}
|
|
389
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
390
|
+
interface SubscriptionOutboxTable {
|
|
391
|
+
id: Generated<string>;
|
|
392
|
+
subscription_id: string;
|
|
393
|
+
subgraph_name: string;
|
|
394
|
+
table_name: string;
|
|
395
|
+
block_height: number | bigint;
|
|
396
|
+
tx_id: string | null;
|
|
397
|
+
row_pk: unknown;
|
|
398
|
+
event_type: string;
|
|
399
|
+
payload: unknown;
|
|
400
|
+
dedup_key: string;
|
|
401
|
+
attempt: Generated<number>;
|
|
402
|
+
next_attempt_at: Generated<Date>;
|
|
403
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
404
|
+
is_replay: Generated<boolean>;
|
|
405
|
+
delivered_at: Date | null;
|
|
406
|
+
failed_at: Date | null;
|
|
407
|
+
locked_by: string | null;
|
|
408
|
+
locked_until: Date | null;
|
|
409
|
+
created_at: Generated<Date>;
|
|
410
|
+
}
|
|
411
|
+
interface SubscriptionDeliveriesTable {
|
|
412
|
+
id: Generated<string>;
|
|
413
|
+
outbox_id: string;
|
|
414
|
+
subscription_id: string;
|
|
415
|
+
attempt: number;
|
|
416
|
+
status_code: number | null;
|
|
417
|
+
response_headers: unknown | null;
|
|
418
|
+
response_body: string | null;
|
|
419
|
+
error_message: string | null;
|
|
420
|
+
duration_ms: number | null;
|
|
421
|
+
dispatched_at: Generated<Date>;
|
|
422
|
+
}
|
|
358
423
|
/**
|
|
359
424
|
* Provisioning audit trail — every lifecycle event that mutates a tenant
|
|
360
425
|
* lands here. Write on both happy and sad paths so we can reconstruct
|
|
@@ -277,6 +277,9 @@ interface Database {
|
|
|
277
277
|
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
278
|
account_spend_caps: AccountSpendCapsTable;
|
|
279
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
280
283
|
}
|
|
281
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
282
285
|
interface TenantsTable {
|
|
@@ -354,6 +357,68 @@ interface ProvisioningAuditLogTable {
|
|
|
354
357
|
error: string | null;
|
|
355
358
|
created_at: Generated<Date>;
|
|
356
359
|
}
|
|
360
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
361
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
362
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
363
|
+
interface SubscriptionsTable {
|
|
364
|
+
id: Generated<string>;
|
|
365
|
+
account_id: string;
|
|
366
|
+
project_id: string | null;
|
|
367
|
+
name: string;
|
|
368
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
369
|
+
subgraph_name: string;
|
|
370
|
+
table_name: string;
|
|
371
|
+
filter: Generated<unknown>;
|
|
372
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
373
|
+
runtime: SubscriptionRuntime | null;
|
|
374
|
+
url: string;
|
|
375
|
+
signing_secret_enc: Buffer;
|
|
376
|
+
auth_config: Generated<unknown>;
|
|
377
|
+
max_retries: Generated<number>;
|
|
378
|
+
timeout_ms: Generated<number>;
|
|
379
|
+
concurrency: Generated<number>;
|
|
380
|
+
circuit_failures: Generated<number>;
|
|
381
|
+
circuit_opened_at: Date | null;
|
|
382
|
+
last_delivery_at: Date | null;
|
|
383
|
+
last_success_at: Date | null;
|
|
384
|
+
last_error: string | null;
|
|
385
|
+
created_at: Generated<Date>;
|
|
386
|
+
updated_at: Generated<Date>;
|
|
387
|
+
}
|
|
388
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
389
|
+
interface SubscriptionOutboxTable {
|
|
390
|
+
id: Generated<string>;
|
|
391
|
+
subscription_id: string;
|
|
392
|
+
subgraph_name: string;
|
|
393
|
+
table_name: string;
|
|
394
|
+
block_height: number | bigint;
|
|
395
|
+
tx_id: string | null;
|
|
396
|
+
row_pk: unknown;
|
|
397
|
+
event_type: string;
|
|
398
|
+
payload: unknown;
|
|
399
|
+
dedup_key: string;
|
|
400
|
+
attempt: Generated<number>;
|
|
401
|
+
next_attempt_at: Generated<Date>;
|
|
402
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
403
|
+
is_replay: Generated<boolean>;
|
|
404
|
+
delivered_at: Date | null;
|
|
405
|
+
failed_at: Date | null;
|
|
406
|
+
locked_by: string | null;
|
|
407
|
+
locked_until: Date | null;
|
|
408
|
+
created_at: Generated<Date>;
|
|
409
|
+
}
|
|
410
|
+
interface SubscriptionDeliveriesTable {
|
|
411
|
+
id: Generated<string>;
|
|
412
|
+
outbox_id: string;
|
|
413
|
+
subscription_id: string;
|
|
414
|
+
attempt: number;
|
|
415
|
+
status_code: number | null;
|
|
416
|
+
response_headers: unknown | null;
|
|
417
|
+
response_body: string | null;
|
|
418
|
+
error_message: string | null;
|
|
419
|
+
duration_ms: number | null;
|
|
420
|
+
dispatched_at: Generated<Date>;
|
|
421
|
+
}
|
|
357
422
|
interface GapRange {
|
|
358
423
|
start: number;
|
|
359
424
|
end: number;
|
|
@@ -277,6 +277,9 @@ interface Database {
|
|
|
277
277
|
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
278
|
account_spend_caps: AccountSpendCapsTable;
|
|
279
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
280
283
|
}
|
|
281
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
282
285
|
interface TenantsTable {
|
|
@@ -355,6 +358,68 @@ interface ProvisioningAuditLogTable {
|
|
|
355
358
|
created_at: Generated<Date>;
|
|
356
359
|
}
|
|
357
360
|
type Subgraph = Selectable<SubgraphsTable>;
|
|
361
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
362
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
363
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
364
|
+
interface SubscriptionsTable {
|
|
365
|
+
id: Generated<string>;
|
|
366
|
+
account_id: string;
|
|
367
|
+
project_id: string | null;
|
|
368
|
+
name: string;
|
|
369
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
370
|
+
subgraph_name: string;
|
|
371
|
+
table_name: string;
|
|
372
|
+
filter: Generated<unknown>;
|
|
373
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
374
|
+
runtime: SubscriptionRuntime | null;
|
|
375
|
+
url: string;
|
|
376
|
+
signing_secret_enc: Buffer;
|
|
377
|
+
auth_config: Generated<unknown>;
|
|
378
|
+
max_retries: Generated<number>;
|
|
379
|
+
timeout_ms: Generated<number>;
|
|
380
|
+
concurrency: Generated<number>;
|
|
381
|
+
circuit_failures: Generated<number>;
|
|
382
|
+
circuit_opened_at: Date | null;
|
|
383
|
+
last_delivery_at: Date | null;
|
|
384
|
+
last_success_at: Date | null;
|
|
385
|
+
last_error: string | null;
|
|
386
|
+
created_at: Generated<Date>;
|
|
387
|
+
updated_at: Generated<Date>;
|
|
388
|
+
}
|
|
389
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
390
|
+
interface SubscriptionOutboxTable {
|
|
391
|
+
id: Generated<string>;
|
|
392
|
+
subscription_id: string;
|
|
393
|
+
subgraph_name: string;
|
|
394
|
+
table_name: string;
|
|
395
|
+
block_height: number | bigint;
|
|
396
|
+
tx_id: string | null;
|
|
397
|
+
row_pk: unknown;
|
|
398
|
+
event_type: string;
|
|
399
|
+
payload: unknown;
|
|
400
|
+
dedup_key: string;
|
|
401
|
+
attempt: Generated<number>;
|
|
402
|
+
next_attempt_at: Generated<Date>;
|
|
403
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
404
|
+
is_replay: Generated<boolean>;
|
|
405
|
+
delivered_at: Date | null;
|
|
406
|
+
failed_at: Date | null;
|
|
407
|
+
locked_by: string | null;
|
|
408
|
+
locked_until: Date | null;
|
|
409
|
+
created_at: Generated<Date>;
|
|
410
|
+
}
|
|
411
|
+
interface SubscriptionDeliveriesTable {
|
|
412
|
+
id: Generated<string>;
|
|
413
|
+
outbox_id: string;
|
|
414
|
+
subscription_id: string;
|
|
415
|
+
attempt: number;
|
|
416
|
+
status_code: number | null;
|
|
417
|
+
response_headers: unknown | null;
|
|
418
|
+
response_body: string | null;
|
|
419
|
+
error_message: string | null;
|
|
420
|
+
duration_ms: number | null;
|
|
421
|
+
dispatched_at: Generated<Date>;
|
|
422
|
+
}
|
|
358
423
|
/**
|
|
359
424
|
* Convert a subgraph name to its PostgreSQL schema name.
|
|
360
425
|
* Every tenant DB has its own isolated schema namespace, so there's no
|