@resvary/sqlite 0.5.0 → 0.7.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.
- package/LICENSE +13 -13
- package/README.md +19 -15
- package/dist/credit.d.ts +12 -3
- package/dist/credit.d.ts.map +1 -1
- package/dist/credit.js +501 -197
- package/dist/credit.js.map +1 -1
- package/dist/filesystem.d.ts +3 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +31 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -130
- package/dist/index.js.map +1 -1
- package/package.json +46 -40
package/LICENSE
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Copyright 2025-2026 horn111
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|
|
1
|
+
Copyright 2025-2026 horn111
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
# @resvary/sqlite
|
|
2
|
-
|
|
3
|
-
SQLite persistence for Resvary credits, usage receipts, and stablecoin payment receipts.
|
|
4
|
-
|
|
5
|
-
```typescript
|
|
6
|
-
import { CreditLedger } from '@resvary/sdk/credits';
|
|
7
|
-
import { createSqliteCreditStore } from '@resvary/sqlite';
|
|
8
|
-
|
|
9
|
-
const store = createSqliteCreditStore({ path: '.resvary/resvary.sqlite' });
|
|
10
|
-
const credits = new CreditLedger({ projectId: 'my_ai_product', store });
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# @resvary/sqlite
|
|
2
|
+
|
|
3
|
+
SQLite persistence for Resvary credits, usage receipts, and stablecoin payment receipts.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { CreditLedger } from '@resvary/sdk/credits';
|
|
7
|
+
import { createSqliteCreditStore } from '@resvary/sqlite';
|
|
8
|
+
|
|
9
|
+
const store = createSqliteCreditStore({ path: '.resvary/resvary.sqlite' });
|
|
10
|
+
const credits = new CreditLedger({ projectId: 'my_ai_product', store });
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
On POSIX systems, newly created database directories use mode `0700`, while the database,
|
|
14
|
+
WAL, and shared-memory files use mode `0600`. On Windows, run the process under a dedicated
|
|
15
|
+
service account and restrict the database directory with NTFS ACLs.
|
|
16
|
+
|
|
17
|
+
The existing `createSqliteReceiptStore` remains available for payment invoices, receipts, webhook deliveries, and Arc watcher cursors. Both stores can use the same file.
|
|
18
|
+
|
|
19
|
+
Requires Node.js 24+ and local filesystem access. The credit store uses WAL, `BEGIN IMMEDIATE`, rollback-safe writes, and versioned schema metadata. Opening schema v4 with version 0.7 applies schema v5 automatically and backfills balances and open reservations into verified legacy lots.
|
package/dist/credit.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { CreditAccount, CreditBalanceFilter, CreditGrant, CreditOutboxEvent, CreditReservation, CreditReservationFilter,
|
|
1
|
+
import type { CreditAccount, CreditBalanceFilter, CreditGrant, CreditGrantPolicy, CreditLot, CreditLotAllocation, CreditLotFilter, CreditOutboxEvent, CreditReservation, CreditReservationFilter, CreditPolicyStore, CreditPolicyStoreTransaction, IdempotencyRecord, FundingIntent, FundingTransaction, GrantPolicyApplication, GrantPolicyApplicationFilter, LedgerEntry, MeterDefinition, OutboxEventFilter, OutboxDeliveryStore, ClaimOutboxEventsInput, FailOutboxEventInput, PriceVersion, UsageEvent, UsageReceipt } from '@resvary/sdk/credits';
|
|
2
2
|
export interface SqliteCreditStoreConfig {
|
|
3
3
|
path: string;
|
|
4
4
|
createDirectory?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare class SqliteCreditStore implements
|
|
6
|
+
export declare class SqliteCreditStore implements CreditPolicyStore, OutboxDeliveryStore {
|
|
7
7
|
private readonly db;
|
|
8
8
|
private transactionTail;
|
|
9
9
|
constructor(config: SqliteCreditStoreConfig);
|
|
10
|
-
transaction<T>(handler: (transaction:
|
|
10
|
+
transaction<T>(handler: (transaction: CreditPolicyStoreTransaction) => Promise<T>): Promise<T>;
|
|
11
11
|
getAccount(id: string): Promise<CreditAccount | undefined>;
|
|
12
12
|
getAccountByCustomer(projectId: string, customerId: string): Promise<CreditAccount | undefined>;
|
|
13
13
|
listAccounts(filter?: CreditBalanceFilter): Promise<CreditAccount[]>;
|
|
@@ -32,6 +32,14 @@ export declare class SqliteCreditStore implements CreditStore, OutboxDeliverySto
|
|
|
32
32
|
getFundingTransactionByExternalPayment(rail: FundingTransaction['rail'], network: string, externalPaymentId: string): Promise<FundingTransaction | undefined>;
|
|
33
33
|
getFundingTransactionByTxHash(network: string, txHash: `0x${string}`): Promise<FundingTransaction | undefined>;
|
|
34
34
|
listFundingTransactions(fundingIntentId?: string): Promise<FundingTransaction[]>;
|
|
35
|
+
getGrantPolicy(id: string): Promise<CreditGrantPolicy | undefined>;
|
|
36
|
+
listGrantPolicies(projectId?: string): Promise<CreditGrantPolicy[]>;
|
|
37
|
+
getCreditLot(id: string): Promise<CreditLot | undefined>;
|
|
38
|
+
listCreditLots(filter?: CreditLotFilter): Promise<CreditLot[]>;
|
|
39
|
+
listCreditLotAllocations(reservationId?: string): Promise<CreditLotAllocation[]>;
|
|
40
|
+
getGrantPolicyApplication(id: string): Promise<GrantPolicyApplication | undefined>;
|
|
41
|
+
getGrantPolicyApplicationByIdentity(policyId: string, accountId: string, periodKey: string): Promise<GrantPolicyApplication | undefined>;
|
|
42
|
+
listGrantPolicyApplications(filter?: GrantPolicyApplicationFilter): Promise<GrantPolicyApplication[]>;
|
|
35
43
|
claimOutboxEvents(input: ClaimOutboxEventsInput): Promise<CreditOutboxEvent[]>;
|
|
36
44
|
completeOutboxEvent(eventId: string, workerId: string, deliveredAt: number, attemptCount?: number): Promise<void>;
|
|
37
45
|
failOutboxEvent(input: FailOutboxEventInput): Promise<void>;
|
|
@@ -42,6 +50,7 @@ export declare class SqliteCreditStore implements CreditStore, OutboxDeliverySto
|
|
|
42
50
|
private migrateFundingV2;
|
|
43
51
|
private migrateOutboxV3;
|
|
44
52
|
private migrateFundingTransactionHashV4;
|
|
53
|
+
private migrateCreditLotsV5;
|
|
45
54
|
}
|
|
46
55
|
export declare function createSqliteCreditStore(config: SqliteCreditStoreConfig): SqliteCreditStore;
|
|
47
56
|
//# sourceMappingURL=credit.d.ts.map
|
package/dist/credit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit.d.ts","sourceRoot":"","sources":["../src/credit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credit.d.ts","sourceRoot":"","sources":["../src/credit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,u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