@riffdb/better-auth 0.0.0-stage → 0.2.1
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/DESIGN.md +273 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +27 -0
- package/README.md +323 -2
- package/dist/adapter.d.ts +34 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +1600 -0
- package/dist/adapter.js.map +1 -0
- package/dist/generated/client.d.ts +2166 -0
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +2454 -0
- package/dist/generated/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-dispatch.d.ts +37 -0
- package/dist/plugin-dispatch.d.ts.map +1 -0
- package/dist/plugin-dispatch.js +293 -0
- package/dist/plugin-dispatch.js.map +1 -0
- package/dist/profile-contract.d.ts +63 -0
- package/dist/profile-contract.d.ts.map +1 -0
- package/dist/profile-contract.js +543 -0
- package/dist/profile-contract.js.map +1 -0
- package/dist/profile-plan.d.ts +69 -0
- package/dist/profile-plan.d.ts.map +1 -0
- package/dist/profile-plan.js +180 -0
- package/dist/profile-plan.js.map +1 -0
- package/dist/profile.d.ts +48 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +132 -0
- package/dist/profile.js.map +1 -0
- package/dist/profiles/custom-fields/profile.d.ts +3 -0
- package/dist/profiles/custom-fields/profile.d.ts.map +1 -0
- package/dist/profiles/custom-fields/profile.js +475 -0
- package/dist/profiles/custom-fields/profile.js.map +1 -0
- package/dist/profiles/custom-fields/src/generated/client.d.ts +2710 -0
- package/dist/profiles/custom-fields/src/generated/client.d.ts.map +1 -0
- package/dist/profiles/custom-fields/src/generated/client.js +2663 -0
- package/dist/profiles/custom-fields/src/generated/client.js.map +1 -0
- package/dist/profiles/runtime/profile.d.ts +3 -0
- package/dist/profiles/runtime/profile.d.ts.map +1 -0
- package/dist/profiles/runtime/profile.js +1065 -0
- package/dist/profiles/runtime/profile.js.map +1 -0
- package/dist/profiles/runtime/src/generated/client.d.ts +4274 -0
- package/dist/profiles/runtime/src/generated/client.d.ts.map +1 -0
- package/dist/profiles/runtime/src/generated/client.js +4607 -0
- package/dist/profiles/runtime/src/generated/client.js.map +1 -0
- package/dist/runtime-materialize.d.ts +10 -0
- package/dist/runtime-materialize.d.ts.map +1 -0
- package/dist/runtime-materialize.js +344 -0
- package/dist/runtime-materialize.js.map +1 -0
- package/dist/runtime-profile.d.ts +34 -0
- package/dist/runtime-profile.d.ts.map +1 -0
- package/dist/runtime-profile.js +203 -0
- package/dist/runtime-profile.js.map +1 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +12 -0
- package/dist/testing.js.map +1 -0
- package/generated/go/client.go +2250 -0
- package/generated/mcp/tools.json +13922 -0
- package/generated/python/client.py +4454 -0
- package/generated/riffdb.application.exact.json +1 -0
- package/generated/riffdb.contract.bundle +0 -0
- package/generated/rust/client.rs +6524 -0
- package/package.json +83 -4
- package/profiles/custom-fields/generated/go/client.go +2578 -0
- package/profiles/custom-fields/generated/mcp/tools.json +15998 -0
- package/profiles/custom-fields/generated/python/client.py +5141 -0
- package/profiles/custom-fields/generated/riffdb.application.exact.json +1 -0
- package/profiles/custom-fields/generated/riffdb.contract.bundle +0 -0
- package/profiles/custom-fields/generated/rust/client.rs +7980 -0
- package/profiles/custom-fields/profile.ts +474 -0
- package/profiles/custom-fields/riffdb/contract.riff +568 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_contains_asc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_contains_desc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/find_account_by_id.riffq +24 -0
- package/profiles/custom-fields/riffdb/queries/find_account_by_provider.riffq +26 -0
- package/profiles/custom-fields/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
- package/profiles/custom-fields/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
- package/profiles/custom-fields/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
- package/profiles/custom-fields/riffdb/queries/find_credential_account.riffq +25 -0
- package/profiles/custom-fields/riffdb/queries/find_expired_verification_ids.riffq +17 -0
- package/profiles/custom-fields/riffdb/queries/find_latest_verification.riffq +20 -0
- package/profiles/custom-fields/riffdb/queries/find_session_by_id.riffq +20 -0
- package/profiles/custom-fields/riffdb/queries/find_session_by_token.riffq +20 -0
- package/profiles/custom-fields/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
- package/profiles/custom-fields/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
- package/profiles/custom-fields/riffdb/queries/find_user_by_email.riffq +16 -0
- package/profiles/custom-fields/riffdb/queries/find_user_by_id.riffq +15 -0
- package/profiles/custom-fields/riffdb/queries/find_verification_by_id.riffq +19 -0
- package/profiles/custom-fields/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
- package/profiles/custom-fields/riffdb/queries/profile_account_with_user_by_provider.riffq +31 -0
- package/profiles/custom-fields/riffdb/queries/profile_session_with_user_by_id.riffq +14 -0
- package/profiles/custom-fields/riffdb/queries/profile_session_with_user_by_token.riffq +14 -0
- package/profiles/custom-fields/riffdb/queries/profile_sessions_with_users_by_token_set.riffq +25 -0
- package/profiles/custom-fields/riffdb/queries/profile_user_with_accounts_by_email.riffq +19 -0
- package/profiles/custom-fields/riffdb/queries/profile_user_with_accounts_by_id.riffq +19 -0
- package/profiles/custom-fields/riffdb.application.json +217 -0
- package/profiles/custom-fields/riffdb.application.lock.json +1 -0
- package/profiles/custom-fields/riffdb.toml +3 -0
- package/profiles/custom-fields/src/generated/client.ts +3096 -0
- package/profiles/organization-security/materialization.json +51 -0
- package/profiles/organization-security/riffdb/contract.riff +778 -0
- package/profiles/organization-security/riffdb/queries/find_account_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_invitation_by_email.riffq +17 -0
- package/profiles/organization-security/riffdb/queries/find_invitation_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_invitation_by_organization_id.riffq +17 -0
- package/profiles/organization-security/riffdb/queries/find_member_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_member_by_user_id.riffq +17 -0
- package/profiles/organization-security/riffdb/queries/find_organization_by_id.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_organization_by_slug.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_session_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_session_by_token.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_team_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_team_member_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_team_member_by_membership_key.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_team_member_by_team_id.riffq +17 -0
- package/profiles/organization-security/riffdb/queries/find_two_factor_by_id.riffq +18 -0
- package/profiles/organization-security/riffdb/queries/find_two_factor_by_secret.riffq +17 -0
- package/profiles/organization-security/riffdb/queries/find_user_by_email.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_user_by_id.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_verification_by_id.riffq +16 -0
- package/profiles/organization-security/riffdb/queries/find_verification_by_identifier.riffq +17 -0
- package/profiles/organization-security/riffdb.application.json +172 -0
- package/profiles/organization-security/riffdb.toml +7 -0
- package/profiles/organization-security.profile.json +980 -0
- package/profiles/runtime/generated/go/client.go +4511 -0
- package/profiles/runtime/generated/mcp/tools.json +30004 -0
- package/profiles/runtime/generated/python/client.py +9337 -0
- package/profiles/runtime/generated/riffdb.application.exact.json +1 -0
- package/profiles/runtime/generated/riffdb.contract.bundle +0 -0
- package/profiles/runtime/generated/rust/client.rs +13297 -0
- package/profiles/runtime/profile.ts +1064 -0
- package/profiles/runtime/riffdb/contract.riff +1053 -0
- package/profiles/runtime/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_contains_asc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_contains_desc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
- package/profiles/runtime/riffdb/queries/find_account_by_id.riffq +24 -0
- package/profiles/runtime/riffdb/queries/find_account_by_provider.riffq +26 -0
- package/profiles/runtime/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
- package/profiles/runtime/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
- package/profiles/runtime/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
- package/profiles/runtime/riffdb/queries/find_credential_account.riffq +25 -0
- package/profiles/runtime/riffdb/queries/find_expired_verification_ids.riffq +17 -0
- package/profiles/runtime/riffdb/queries/find_latest_verification.riffq +20 -0
- package/profiles/runtime/riffdb/queries/find_session_by_id.riffq +20 -0
- package/profiles/runtime/riffdb/queries/find_session_by_token.riffq +20 -0
- package/profiles/runtime/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
- package/profiles/runtime/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
- package/profiles/runtime/riffdb/queries/find_user_by_email.riffq +16 -0
- package/profiles/runtime/riffdb/queries/find_user_by_id.riffq +15 -0
- package/profiles/runtime/riffdb/queries/find_verification_by_id.riffq +19 -0
- package/profiles/runtime/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
- package/profiles/runtime/riffdb/queries/profile_account_with_user_by_provider.riffq +31 -0
- package/profiles/runtime/riffdb/queries/profile_invitation_by_email.riffq +17 -0
- package/profiles/runtime/riffdb/queries/profile_invitation_by_id.riffq +17 -0
- package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_email_status.riffq +19 -0
- package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_id.riffq +17 -0
- package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_status.riffq +18 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_id.riffq +27 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization.riffq +20 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization_created_at_asc.riffq +20 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization_created_at_desc.riffq +20 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization_role_asc.riffq +20 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization_role_desc.riffq +20 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_organization_user.riffq +28 -0
- package/profiles/runtime/riffdb/queries/profile_member_by_user.riffq +27 -0
- package/profiles/runtime/riffdb/queries/profile_organization_by_id.riffq +27 -0
- package/profiles/runtime/riffdb/queries/profile_organization_by_slug.riffq +27 -0
- package/profiles/runtime/riffdb/queries/profile_session_with_user_by_id.riffq +14 -0
- package/profiles/runtime/riffdb/queries/profile_session_with_user_by_token.riffq +14 -0
- package/profiles/runtime/riffdb/queries/profile_sessions_with_users_by_token_set.riffq +25 -0
- package/profiles/runtime/riffdb/queries/profile_two_factor_by_id.riffq +17 -0
- package/profiles/runtime/riffdb/queries/profile_two_factor_by_user.riffq +17 -0
- package/profiles/runtime/riffdb/queries/profile_user_with_accounts_by_email.riffq +19 -0
- package/profiles/runtime/riffdb/queries/profile_user_with_accounts_by_id.riffq +19 -0
- package/profiles/runtime/riffdb/queries/profile_users_by_id_set.riffq +8 -0
- package/profiles/runtime/riffdb.application.json +324 -0
- package/profiles/runtime/riffdb.application.lock.json +1 -0
- package/profiles/runtime/riffdb.toml +3 -0
- package/profiles/runtime/src/generated/client.ts +5186 -0
- package/riffdb/contract.riff +547 -0
- package/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
- package/riffdb/queries/admin_users_contains_asc.riffq +24 -0
- package/riffdb/queries/admin_users_contains_desc.riffq +24 -0
- package/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
- package/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
- package/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
- package/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
- package/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
- package/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
- package/riffdb/queries/find_account_by_id.riffq +24 -0
- package/riffdb/queries/find_account_by_provider.riffq +26 -0
- package/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
- package/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
- package/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
- package/riffdb/queries/find_credential_account.riffq +25 -0
- package/riffdb/queries/find_expired_verification_ids.riffq +17 -0
- package/riffdb/queries/find_latest_verification.riffq +20 -0
- package/riffdb/queries/find_session_by_id.riffq +20 -0
- package/riffdb/queries/find_session_by_token.riffq +20 -0
- package/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
- package/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
- package/riffdb/queries/find_user_by_email.riffq +16 -0
- package/riffdb/queries/find_user_by_id.riffq +15 -0
- package/riffdb/queries/find_verification_by_id.riffq +19 -0
- package/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
- package/riffdb.application.json +187 -0
- package/riffdb.application.lock.json +1 -0
- package/scripts/real-riffdb-runner.mjs +333 -0
- package/src/generated/client.ts +2746 -0
|
@@ -0,0 +1,2454 @@
|
|
|
1
|
+
// @generated by riffdb-query-module; do not edit.
|
|
2
|
+
export const QUERY_MODULE_HASH = "8dff3a38f6c0a915d7653e7571a2ef5795a89b452990d705f38fe0ac93b5ad9a";
|
|
3
|
+
export const CONTRACT_LINEAGE = "RiffDBBetterAuthCore";
|
|
4
|
+
export const CONTRACT_VERSION = 1;
|
|
5
|
+
export const CONTRACT_BUNDLE_HASH = "74fd255eefcf04f0b054dbb6c4a0bed43a7312d82f7755687c9229ee3206ddfc";
|
|
6
|
+
export const CONTRACT_DRIVER_IDENTITY = {
|
|
7
|
+
contractLineage: CONTRACT_LINEAGE,
|
|
8
|
+
contractVersion: BigInt(CONTRACT_VERSION),
|
|
9
|
+
contractBundleHash: CONTRACT_BUNDLE_HASH,
|
|
10
|
+
};
|
|
11
|
+
export function driverIdentity(role, database) {
|
|
12
|
+
return database === undefined ? { ...CONTRACT_DRIVER_IDENTITY, role } : { ...CONTRACT_DRIVER_IDENTITY, role, database };
|
|
13
|
+
}
|
|
14
|
+
export const APPLICATION_ERROR_REGISTRY = {
|
|
15
|
+
"RDB-APP-0001": ["application request is structurally invalid", "input", "correct_request", ["correct_input"]],
|
|
16
|
+
"RDB-INPUT-0101": ["application input is invalid", "input", "correct_request", ["correct_input"]],
|
|
17
|
+
"RDB-AUTH-0214": ["application operation is not authorized", "authorization", "obtain_permission", ["bind_application_role"]],
|
|
18
|
+
"RDB-CONTRACT-0101": ["application contract does not match", "contract", "refresh_contract", ["refresh_contract"]],
|
|
19
|
+
"RDB-QUERY-0101": ["RiffQL query is invalid", "query", "correct_request", ["correct_input"]],
|
|
20
|
+
"RDB-QUERY-0102": ["RiffQL query is unavailable", "query", "refresh_contract", ["pin_active_module"]],
|
|
21
|
+
"RDB-MODULE-0101": ["query module is unavailable", "module", "refresh_contract", ["pin_active_module"]],
|
|
22
|
+
"RDB-CURSOR-0101": ["query cursor is invalid or stale", "cursor", "correct_request", ["restart_from_first_page"]],
|
|
23
|
+
"RDB-RESOURCE-0101": ["application result exceeds the service limit", "resource", "correct_request", ["correct_input"]],
|
|
24
|
+
"RDB-STORAGE-0101": ["storage is temporarily unavailable", "storage", "retry", ["retry_later"]],
|
|
25
|
+
"RDB-UNCERTAIN-0101": ["command outcome is not yet known", "uncertainty", "resolve_with_same_idempotency_key", ["resolve_with_same_idempotency_key"]],
|
|
26
|
+
"RDB-APP-0002": ["application request was cancelled", "control", "none", []],
|
|
27
|
+
"RDB-APP-0003": ["application request deadline elapsed", "control", "retry", ["retry_later"]],
|
|
28
|
+
"RDB-INTERNAL-0001": ["an internal error occurred", "internal", "contact_operator", ["contact_operator_with_incident"]],
|
|
29
|
+
"RDB-COMMAND-0101": ["idempotency key was reused with different application input", "command", "correct_request", ["correct_input"]],
|
|
30
|
+
"RDB-COMMAND-0102": ["command execution failed", "command", "contact_operator", []],
|
|
31
|
+
"RDB-AUTH-0215": ["application capability is revoked", "authorization", "obtain_permission", ["bind_application_role"]],
|
|
32
|
+
"RDB-PROTOCOL-0101": ["the RiffDB peer returned an invalid application response", "protocol", "contact_operator", []],
|
|
33
|
+
"RDB-HISTORY-0101": ["observed history predates a database restore", "history", "correct_request", ["correct_input"]],
|
|
34
|
+
"RDB-HISTORY-0102": ["requested history has been pruned", "history", "correct_request", ["correct_input"]],
|
|
35
|
+
"RDB-CAPACITY-0101": ["service is over capacity", "capacity", "retry", ["retry_later"]],
|
|
36
|
+
"RDB-PROJECTION-0101": ["query projections cannot prove one common snapshot", "query", "retry", ["retry_later"]],
|
|
37
|
+
"RDB-PROJECTION-0102": ["the requested query snapshot has been retired", "query", "correct_request", ["restart_from_first_page"]],
|
|
38
|
+
"RDB-PROJECTION-0103": ["no query snapshot satisfies the requested freshness", "query", "retry", ["retry_later"]],
|
|
39
|
+
"RDB-PROJECTION-0104": ["nearest query requires a compiler-owned projected source", "query", "refresh_contract", ["pin_active_module"]],
|
|
40
|
+
"RDB-REP-0101": ["operation is unavailable in follower mode", "control", "correct_request", []],
|
|
41
|
+
"RDB-REP-0102": ["primary is durably fenced", "control", "contact_operator", []],
|
|
42
|
+
};
|
|
43
|
+
export class RiffDbApplicationError extends Error {
|
|
44
|
+
details;
|
|
45
|
+
name = "RiffDbApplicationError";
|
|
46
|
+
constructor(details) {
|
|
47
|
+
super(`${details.code}: ${details.message} [${details.operation}]`);
|
|
48
|
+
this.details = details;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const APPLICATION_OPERATIONS = new Set([
|
|
52
|
+
"DescribeContract", "CheckQuery", "ExplainQuery", "ExecuteQuery",
|
|
53
|
+
"DeployQueryModule", "GetQueryModule", "ExecuteCommand", "BatchCommand", "InspectVectorState",
|
|
54
|
+
]);
|
|
55
|
+
const SAFE_SYMBOL = /^[A-Za-z0-9_.-]{1,256}$/;
|
|
56
|
+
const UUID_V7 = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
57
|
+
export function decodeApplicationError(value) {
|
|
58
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
59
|
+
throw new Error("invalid RiffDB application error");
|
|
60
|
+
const input = value;
|
|
61
|
+
const code = input.code;
|
|
62
|
+
if (typeof code !== "string" || !(code in APPLICATION_ERROR_REGISTRY))
|
|
63
|
+
throw new Error("invalid RiffDB application error");
|
|
64
|
+
const rule = APPLICATION_ERROR_REGISTRY[code];
|
|
65
|
+
if (input.type !== "application" || input.message !== rule[0] || input.category !== rule[1]
|
|
66
|
+
|| input.recoveryAction !== rule[2] || typeof input.operation !== "string"
|
|
67
|
+
|| !APPLICATION_OPERATIONS.has(input.operation))
|
|
68
|
+
throw new Error("invalid RiffDB application error");
|
|
69
|
+
if (!Array.isArray(input.fixes) || input.fixes.length !== rule[3].length
|
|
70
|
+
|| input.fixes.some((fix, index) => fix !== rule[3][index]))
|
|
71
|
+
throw new Error("invalid RiffDB application error");
|
|
72
|
+
const symbolPath = input.symbolPath;
|
|
73
|
+
if (!Array.isArray(symbolPath) || symbolPath.length > 16
|
|
74
|
+
|| symbolPath.some((symbol) => typeof symbol !== "string" || !SAFE_SYMBOL.test(symbol)))
|
|
75
|
+
throw new Error("invalid RiffDB application error");
|
|
76
|
+
for (const key of ["contractLineage", "operationSymbol"]) {
|
|
77
|
+
if (input[key] !== undefined && (typeof input[key] !== "string" || !SAFE_SYMBOL.test(input[key])))
|
|
78
|
+
throw new Error("invalid RiffDB application error");
|
|
79
|
+
}
|
|
80
|
+
if ((input.contractLineage === undefined) !== (input.contractVersion === undefined)
|
|
81
|
+
|| (input.contractVersion !== undefined && (!Number.isSafeInteger(input.contractVersion) || input.contractVersion < 1)))
|
|
82
|
+
throw new Error("invalid RiffDB application error");
|
|
83
|
+
if (input.sourceSpan !== undefined) {
|
|
84
|
+
const span = input.sourceSpan;
|
|
85
|
+
if (typeof span !== "object" || span === null || !Number.isSafeInteger(span.start)
|
|
86
|
+
|| !Number.isSafeInteger(span.end) || span.start < 0
|
|
87
|
+
|| span.start > span.end || span.end > 262144)
|
|
88
|
+
throw new Error("invalid RiffDB application error");
|
|
89
|
+
}
|
|
90
|
+
for (const key of ["traceId", "incidentId"]) {
|
|
91
|
+
if (input[key] !== undefined && (typeof input[key] !== "string" || !UUID_V7.test(input[key])))
|
|
92
|
+
throw new Error("invalid RiffDB application error");
|
|
93
|
+
}
|
|
94
|
+
return new RiffDbApplicationError({
|
|
95
|
+
type: "application", code: code, message: rule[0],
|
|
96
|
+
category: rule[1], recoveryAction: rule[2], operation: input.operation,
|
|
97
|
+
symbolPath: symbolPath,
|
|
98
|
+
fixes: rule[3],
|
|
99
|
+
...(input.contractLineage === undefined ? {} : { contractLineage: input.contractLineage }),
|
|
100
|
+
...(input.contractVersion === undefined ? {} : { contractVersion: input.contractVersion }),
|
|
101
|
+
...(input.operationSymbol === undefined ? {} : { operationSymbol: input.operationSymbol }),
|
|
102
|
+
...(input.sourceSpan === undefined ? {} : { sourceSpan: input.sourceSpan }),
|
|
103
|
+
...(input.traceId === undefined ? {} : { traceId: input.traceId }),
|
|
104
|
+
...(input.incidentId === undefined ? {} : { incidentId: input.incidentId }),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export function acceptsIdentity(request, identity) {
|
|
108
|
+
return identity.contractLineage === request.contractLineage
|
|
109
|
+
&& identity.contractVersion === request.contractVersion
|
|
110
|
+
&& identity.contractBundleHash === request.contractBundleHash
|
|
111
|
+
&& identity.moduleHash === request.moduleHash
|
|
112
|
+
&& identity.queryName === request.queryName
|
|
113
|
+
&& identity.planHash === request.planHash;
|
|
114
|
+
}
|
|
115
|
+
export const MAX_COMMAND_BATCH_CONCURRENCY = 384;
|
|
116
|
+
export const DEFAULT_COMMAND_ATTEMPT_BUDGET = 3;
|
|
117
|
+
function compactPayload(value, expected) {
|
|
118
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || value.type !== expected)
|
|
119
|
+
throw new Error("invalid RiffDB compact value");
|
|
120
|
+
const keys = Object.keys(value);
|
|
121
|
+
if (expected === "null") {
|
|
122
|
+
if (keys.length !== 1)
|
|
123
|
+
throw new Error("invalid RiffDB compact value");
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (keys.length !== 2 || !Object.hasOwn(value, "value"))
|
|
127
|
+
throw new Error("invalid RiffDB compact value");
|
|
128
|
+
return value.value;
|
|
129
|
+
}
|
|
130
|
+
function compactString(value, expected, maximum) {
|
|
131
|
+
const payload = compactPayload(value, expected);
|
|
132
|
+
if (typeof payload !== "string" || new TextEncoder().encode(payload).length > maximum)
|
|
133
|
+
throw new Error("invalid RiffDB compact value");
|
|
134
|
+
return payload;
|
|
135
|
+
}
|
|
136
|
+
function compactInteger(value, expected) {
|
|
137
|
+
const payload = compactPayload(value, expected);
|
|
138
|
+
if (typeof payload !== "string" || !/^-?(?:0|[1-9][0-9]*)$/.test(payload))
|
|
139
|
+
throw new Error("invalid RiffDB compact value");
|
|
140
|
+
const parsed = BigInt(payload);
|
|
141
|
+
if ((expected === "i64" && (parsed < -9223372036854775808n || parsed > 9223372036854775807n))
|
|
142
|
+
|| (expected === "u64" && (parsed < 0n || parsed > 18446744073709551615n)))
|
|
143
|
+
throw new Error("invalid RiffDB compact value");
|
|
144
|
+
return parsed;
|
|
145
|
+
}
|
|
146
|
+
function compactTimestamp(value) {
|
|
147
|
+
const payload = compactPayload(value, "timestamp");
|
|
148
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
149
|
+
throw new Error("invalid RiffDB compact value");
|
|
150
|
+
const record = payload;
|
|
151
|
+
if (Object.keys(record).length !== 2 || typeof record.seconds !== "string" || !/^-?(?:0|[1-9][0-9]*)$/.test(record.seconds)
|
|
152
|
+
|| !Number.isInteger(record.nanos) || record.nanos < 0 || record.nanos >= 1_000_000_000)
|
|
153
|
+
throw new Error("invalid RiffDB compact value");
|
|
154
|
+
const seconds = BigInt(record.seconds);
|
|
155
|
+
if (seconds < -9223372036854775808n || seconds > 9223372036854775807n)
|
|
156
|
+
throw new Error("invalid RiffDB compact value");
|
|
157
|
+
return { seconds, nanos: record.nanos };
|
|
158
|
+
}
|
|
159
|
+
export const ADMIN_USERS_ALL_EMAIL_ASC_QUERY_PLAN_HASH = "056edbaabe43e1dc95f1f6af9838747f54d927a90d5bc9f2be045ae266d107d3";
|
|
160
|
+
export function isAdminUsersAllEmailAscFound(value) {
|
|
161
|
+
return value.outcome === "Found";
|
|
162
|
+
}
|
|
163
|
+
export function unwrapAdminUsersAllEmailAscFound(value) {
|
|
164
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
165
|
+
if (resolved.outcome !== "Found")
|
|
166
|
+
throw new Error(`expected AdminUsersAllEmailAsc outcome "Found", got "${resolved.outcome}"`);
|
|
167
|
+
return resolved;
|
|
168
|
+
}
|
|
169
|
+
export function adminUsersAllEmailAsc(parameters) {
|
|
170
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
171
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
172
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_all_email_asc", inputSchemaHash: "6f126f498c06a6648d15a6403e27e29890892d64f010ef3d89b3470124ebdd5f" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersAllEmailAsc", planHash: ADMIN_USERS_ALL_EMAIL_ASC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "minimum_email", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
173
|
+
}
|
|
174
|
+
export const ADMIN_USERS_CONTAINS_ASC_QUERY_PLAN_HASH = "b64d213477dd2275d98422a6c3460b0cae932dd96255fe9d565005e8afa37fc4";
|
|
175
|
+
export function isAdminUsersContainsAscFound(value) {
|
|
176
|
+
return value.outcome === "Found";
|
|
177
|
+
}
|
|
178
|
+
export function unwrapAdminUsersContainsAscFound(value) {
|
|
179
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
180
|
+
if (resolved.outcome !== "Found")
|
|
181
|
+
throw new Error(`expected AdminUsersContainsAsc outcome "Found", got "${resolved.outcome}"`);
|
|
182
|
+
return resolved;
|
|
183
|
+
}
|
|
184
|
+
export function adminUsersContainsAsc(parameters) {
|
|
185
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
186
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
187
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_contains_asc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersContainsAsc", planHash: ADMIN_USERS_CONTAINS_ASC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
188
|
+
}
|
|
189
|
+
export const ADMIN_USERS_CONTAINS_DESC_QUERY_PLAN_HASH = "57aba8cf311c301e985adc324f97b4d963a38e6efa6058a82e248854d75f2f05";
|
|
190
|
+
export function isAdminUsersContainsDescFound(value) {
|
|
191
|
+
return value.outcome === "Found";
|
|
192
|
+
}
|
|
193
|
+
export function unwrapAdminUsersContainsDescFound(value) {
|
|
194
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
195
|
+
if (resolved.outcome !== "Found")
|
|
196
|
+
throw new Error(`expected AdminUsersContainsDesc outcome "Found", got "${resolved.outcome}"`);
|
|
197
|
+
return resolved;
|
|
198
|
+
}
|
|
199
|
+
export function adminUsersContainsDesc(parameters) {
|
|
200
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
201
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
202
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_contains_desc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersContainsDesc", planHash: ADMIN_USERS_CONTAINS_DESC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
203
|
+
}
|
|
204
|
+
export const ADMIN_USERS_EMAIL_CONTAINS_CREATED_DESC_QUERY_PLAN_HASH = "7aede9eda624f5b4eb4280ca7b8a1421466ce30091177c9abab4f125987eb4ff";
|
|
205
|
+
export function isAdminUsersEmailContainsCreatedDescFound(value) {
|
|
206
|
+
return value.outcome === "Found";
|
|
207
|
+
}
|
|
208
|
+
export function unwrapAdminUsersEmailContainsCreatedDescFound(value) {
|
|
209
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
210
|
+
if (resolved.outcome !== "Found")
|
|
211
|
+
throw new Error(`expected AdminUsersEmailContainsCreatedDesc outcome "Found", got "${resolved.outcome}"`);
|
|
212
|
+
return resolved;
|
|
213
|
+
}
|
|
214
|
+
export function adminUsersEmailContainsCreatedDesc(parameters) {
|
|
215
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
216
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
217
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_email_contains_created_desc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersEmailContainsCreatedDesc", planHash: ADMIN_USERS_EMAIL_CONTAINS_CREATED_DESC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
218
|
+
}
|
|
219
|
+
export const ADMIN_USERS_EMAIL_CONTAINS_IMAGE_ASC_QUERY_PLAN_HASH = "453cb6c81f506a1f0ac99bed3cc85da59176d2cb83597d5812d771683a60cb4c";
|
|
220
|
+
export function isAdminUsersEmailContainsImageAscFound(value) {
|
|
221
|
+
return value.outcome === "Found";
|
|
222
|
+
}
|
|
223
|
+
export function unwrapAdminUsersEmailContainsImageAscFound(value) {
|
|
224
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
225
|
+
if (resolved.outcome !== "Found")
|
|
226
|
+
throw new Error(`expected AdminUsersEmailContainsImageAsc outcome "Found", got "${resolved.outcome}"`);
|
|
227
|
+
return resolved;
|
|
228
|
+
}
|
|
229
|
+
export function adminUsersEmailContainsImageAsc(parameters) {
|
|
230
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
231
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
232
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_email_contains_image_asc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersEmailContainsImageAsc", planHash: ADMIN_USERS_EMAIL_CONTAINS_IMAGE_ASC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
233
|
+
}
|
|
234
|
+
export const ADMIN_USERS_ENDS_WITH_ASC_QUERY_PLAN_HASH = "924c7acfdcf3f7970917ac611b6eafc9175ac69f735d9e1cc01414fcc6f0e696";
|
|
235
|
+
export function isAdminUsersEndsWithAscFound(value) {
|
|
236
|
+
return value.outcome === "Found";
|
|
237
|
+
}
|
|
238
|
+
export function unwrapAdminUsersEndsWithAscFound(value) {
|
|
239
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
240
|
+
if (resolved.outcome !== "Found")
|
|
241
|
+
throw new Error(`expected AdminUsersEndsWithAsc outcome "Found", got "${resolved.outcome}"`);
|
|
242
|
+
return resolved;
|
|
243
|
+
}
|
|
244
|
+
export function adminUsersEndsWithAsc(parameters) {
|
|
245
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
246
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
247
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_ends_with_asc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersEndsWithAsc", planHash: ADMIN_USERS_ENDS_WITH_ASC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
248
|
+
}
|
|
249
|
+
export const ADMIN_USERS_ENDS_WITH_DESC_QUERY_PLAN_HASH = "cab8ad8456533e4ce97388948e4f703cac6f2eebb641b83a91c3b005ece7fffb";
|
|
250
|
+
export function isAdminUsersEndsWithDescFound(value) {
|
|
251
|
+
return value.outcome === "Found";
|
|
252
|
+
}
|
|
253
|
+
export function unwrapAdminUsersEndsWithDescFound(value) {
|
|
254
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
255
|
+
if (resolved.outcome !== "Found")
|
|
256
|
+
throw new Error(`expected AdminUsersEndsWithDesc outcome "Found", got "${resolved.outcome}"`);
|
|
257
|
+
return resolved;
|
|
258
|
+
}
|
|
259
|
+
export function adminUsersEndsWithDesc(parameters) {
|
|
260
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
261
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
262
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_ends_with_desc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersEndsWithDesc", planHash: ADMIN_USERS_ENDS_WITH_DESC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
263
|
+
}
|
|
264
|
+
export const ADMIN_USERS_STARTS_WITH_ASC_QUERY_PLAN_HASH = "add0aed3dbd0caea0de2857133a857d49eb7bfc0e031d117270cc873137da5ec";
|
|
265
|
+
export function isAdminUsersStartsWithAscFound(value) {
|
|
266
|
+
return value.outcome === "Found";
|
|
267
|
+
}
|
|
268
|
+
export function unwrapAdminUsersStartsWithAscFound(value) {
|
|
269
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
270
|
+
if (resolved.outcome !== "Found")
|
|
271
|
+
throw new Error(`expected AdminUsersStartsWithAsc outcome "Found", got "${resolved.outcome}"`);
|
|
272
|
+
return resolved;
|
|
273
|
+
}
|
|
274
|
+
export function adminUsersStartsWithAsc(parameters) {
|
|
275
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
276
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
277
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_starts_with_asc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersStartsWithAsc", planHash: ADMIN_USERS_STARTS_WITH_ASC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
278
|
+
}
|
|
279
|
+
export const ADMIN_USERS_STARTS_WITH_DESC_QUERY_PLAN_HASH = "23c1561fb3956217e79d1b358be468e55c4021b887e927a4fb3c0484c92be872";
|
|
280
|
+
export function isAdminUsersStartsWithDescFound(value) {
|
|
281
|
+
return value.outcome === "Found";
|
|
282
|
+
}
|
|
283
|
+
export function unwrapAdminUsersStartsWithDescFound(value) {
|
|
284
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
285
|
+
if (resolved.outcome !== "Found")
|
|
286
|
+
throw new Error(`expected AdminUsersStartsWithDesc outcome "Found", got "${resolved.outcome}"`);
|
|
287
|
+
return resolved;
|
|
288
|
+
}
|
|
289
|
+
export function adminUsersStartsWithDesc(parameters) {
|
|
290
|
+
if (parameters.limit !== undefined && (!Number.isSafeInteger(parameters.limit) || parameters.limit < 1 || parameters.limit > 100))
|
|
291
|
+
throw new RangeError("limit must be an integer from 1 through 100");
|
|
292
|
+
return { driverOperation: { name: "riffdb_better_auth_core_admin_users_starts_with_desc", inputSchemaHash: "9ffe6e4d932b3572aefb9d58255932828b4b85445b0312722b3c8be772bdd11b" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "AdminUsersStartsWithDesc", planHash: ADMIN_USERS_STARTS_WITH_DESC_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "needle", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "optional", "value": { "kind": "uuid" } } }, { "name": "limit", "schema": { "kind": "limit", "maximum": 100 } }, { "name": "offset", "schema": { "kind": "u64" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }, { "name": "total", "schema": { "fields": [{ "name": "value", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
293
|
+
}
|
|
294
|
+
export const FIND_ACCOUNT_BY_ID_QUERY_PLAN_HASH = "14a08df3dd8a74ea0a5622804bf0c2424086ee73eb10ce57d7df336a7d25f5ba";
|
|
295
|
+
export const FIND_ACCOUNT_BY_ID_SECRET_OUTPUTS = [
|
|
296
|
+
{ query: "FindAccountById", entity: "Account", field: "access_token" },
|
|
297
|
+
{ query: "FindAccountById", entity: "Account", field: "refresh_token" },
|
|
298
|
+
{ query: "FindAccountById", entity: "Account", field: "id_token" },
|
|
299
|
+
{ query: "FindAccountById", entity: "Account", field: "password" },
|
|
300
|
+
];
|
|
301
|
+
export function isFindAccountByIdFound(value) {
|
|
302
|
+
return value.outcome === "Found";
|
|
303
|
+
}
|
|
304
|
+
export function unwrapFindAccountByIdFound(value) {
|
|
305
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
306
|
+
if (resolved.outcome !== "Found")
|
|
307
|
+
throw new Error(`expected FindAccountById outcome "Found", got "${resolved.outcome}"`);
|
|
308
|
+
return resolved;
|
|
309
|
+
}
|
|
310
|
+
export function redactFindAccountByIdResult(value) {
|
|
311
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_ACCOUNT_BY_ID_SECRET_OUTPUTS };
|
|
312
|
+
}
|
|
313
|
+
export function findAccountById(parameters) {
|
|
314
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_account_by_id", inputSchemaHash: "a8efd0b9fe4e36f92ca57a7c5351df748b4c2adbd0e363e2a5ffb66ff4d23bdc" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindAccountById", planHash: FIND_ACCOUNT_BY_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "id", "schema": { "kind": "uuid" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "accounts", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
315
|
+
}
|
|
316
|
+
export const FIND_ACCOUNT_BY_PROVIDER_QUERY_PLAN_HASH = "e6c4517a46d725780e79725ca3fdaba2208ef4b282d49f484121eee76c043831";
|
|
317
|
+
export const FIND_ACCOUNT_BY_PROVIDER_SECRET_OUTPUTS = [
|
|
318
|
+
{ query: "FindAccountByProvider", entity: "Account", field: "access_token" },
|
|
319
|
+
{ query: "FindAccountByProvider", entity: "Account", field: "refresh_token" },
|
|
320
|
+
{ query: "FindAccountByProvider", entity: "Account", field: "id_token" },
|
|
321
|
+
{ query: "FindAccountByProvider", entity: "Account", field: "password" },
|
|
322
|
+
];
|
|
323
|
+
export function isFindAccountByProviderFound(value) {
|
|
324
|
+
return value.outcome === "Found";
|
|
325
|
+
}
|
|
326
|
+
export function unwrapFindAccountByProviderFound(value) {
|
|
327
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
328
|
+
if (resolved.outcome !== "Found")
|
|
329
|
+
throw new Error(`expected FindAccountByProvider outcome "Found", got "${resolved.outcome}"`);
|
|
330
|
+
return resolved;
|
|
331
|
+
}
|
|
332
|
+
export function redactFindAccountByProviderResult(value) {
|
|
333
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_ACCOUNT_BY_PROVIDER_SECRET_OUTPUTS };
|
|
334
|
+
}
|
|
335
|
+
export function findAccountByProvider(parameters) {
|
|
336
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_account_by_provider", inputSchemaHash: "7e48e77594d132efa4753eee93934c2ef61f6d82313edff8f7c84c7d8d4112f2" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindAccountByProvider", planHash: FIND_ACCOUNT_BY_PROVIDER_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "accounts", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
337
|
+
}
|
|
338
|
+
export const FIND_ACCOUNTS_BY_USER_ID_QUERY_PLAN_HASH = "ccdc524ca64ad667c209de25b4ce977f43b53ffdd8eb1b70fedf29fc99f27da6";
|
|
339
|
+
export const FIND_ACCOUNTS_BY_USER_ID_SECRET_OUTPUTS = [
|
|
340
|
+
{ query: "FindAccountsByUserId", entity: "Account", field: "access_token" },
|
|
341
|
+
{ query: "FindAccountsByUserId", entity: "Account", field: "refresh_token" },
|
|
342
|
+
{ query: "FindAccountsByUserId", entity: "Account", field: "id_token" },
|
|
343
|
+
{ query: "FindAccountsByUserId", entity: "Account", field: "password" },
|
|
344
|
+
];
|
|
345
|
+
export function isFindAccountsByUserIdFound(value) {
|
|
346
|
+
return value.outcome === "Found";
|
|
347
|
+
}
|
|
348
|
+
export function unwrapFindAccountsByUserIdFound(value) {
|
|
349
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
350
|
+
if (resolved.outcome !== "Found")
|
|
351
|
+
throw new Error(`expected FindAccountsByUserId outcome "Found", got "${resolved.outcome}"`);
|
|
352
|
+
return resolved;
|
|
353
|
+
}
|
|
354
|
+
export function redactFindAccountsByUserIdResult(value) {
|
|
355
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_ACCOUNTS_BY_USER_ID_SECRET_OUTPUTS };
|
|
356
|
+
}
|
|
357
|
+
export function findAccountsByUserId(parameters) {
|
|
358
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_accounts_by_user_id", inputSchemaHash: "52291caa82b70870673211137e93f3ecda460cbe7b9fc465f0b9d7f30df05798" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindAccountsByUserId", planHash: FIND_ACCOUNTS_BY_USER_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "accounts", "schema": { "kind": "list", "maximum": 100, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
359
|
+
}
|
|
360
|
+
export const FIND_ACCOUNTS_BY_USER_PROVIDER_QUERY_PLAN_HASH = "21d13b3c30b4a4059f3c436e290d11c20f0f1d1154e05fb48ae3dd0da882526d";
|
|
361
|
+
export const FIND_ACCOUNTS_BY_USER_PROVIDER_SECRET_OUTPUTS = [
|
|
362
|
+
{ query: "FindAccountsByUserProvider", entity: "Account", field: "access_token" },
|
|
363
|
+
{ query: "FindAccountsByUserProvider", entity: "Account", field: "refresh_token" },
|
|
364
|
+
{ query: "FindAccountsByUserProvider", entity: "Account", field: "id_token" },
|
|
365
|
+
{ query: "FindAccountsByUserProvider", entity: "Account", field: "password" },
|
|
366
|
+
];
|
|
367
|
+
export function isFindAccountsByUserProviderFound(value) {
|
|
368
|
+
return value.outcome === "Found";
|
|
369
|
+
}
|
|
370
|
+
export function unwrapFindAccountsByUserProviderFound(value) {
|
|
371
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
372
|
+
if (resolved.outcome !== "Found")
|
|
373
|
+
throw new Error(`expected FindAccountsByUserProvider outcome "Found", got "${resolved.outcome}"`);
|
|
374
|
+
return resolved;
|
|
375
|
+
}
|
|
376
|
+
export function redactFindAccountsByUserProviderResult(value) {
|
|
377
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_ACCOUNTS_BY_USER_PROVIDER_SECRET_OUTPUTS };
|
|
378
|
+
}
|
|
379
|
+
export function findAccountsByUserProvider(parameters) {
|
|
380
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_accounts_by_user_provider", inputSchemaHash: "f389d8fa7caa4fcb96e1004158f88ce43ae9bccac48b8bf74087eab48c022df7" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindAccountsByUserProvider", planHash: FIND_ACCOUNTS_BY_USER_PROVIDER_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "accounts", "schema": { "kind": "list", "maximum": 8, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
381
|
+
}
|
|
382
|
+
export const FIND_ACTIVE_SESSIONS_BY_USER_ID_QUERY_PLAN_HASH = "de1e5232a64a32057699b5ac21f1b43e69d755a3c143595f906fe63e16147264";
|
|
383
|
+
export const FIND_ACTIVE_SESSIONS_BY_USER_ID_SECRET_OUTPUTS = [
|
|
384
|
+
{ query: "FindActiveSessionsByUserId", entity: "Session", field: "token" },
|
|
385
|
+
];
|
|
386
|
+
export function isFindActiveSessionsByUserIdFound(value) {
|
|
387
|
+
return value.outcome === "Found";
|
|
388
|
+
}
|
|
389
|
+
export function unwrapFindActiveSessionsByUserIdFound(value) {
|
|
390
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
391
|
+
if (resolved.outcome !== "Found")
|
|
392
|
+
throw new Error(`expected FindActiveSessionsByUserId outcome "Found", got "${resolved.outcome}"`);
|
|
393
|
+
return resolved;
|
|
394
|
+
}
|
|
395
|
+
export function redactFindActiveSessionsByUserIdResult(value) {
|
|
396
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_ACTIVE_SESSIONS_BY_USER_ID_SECRET_OUTPUTS };
|
|
397
|
+
}
|
|
398
|
+
export function findActiveSessionsByUserId(parameters) {
|
|
399
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_active_sessions_by_user_id", inputSchemaHash: "56f77f3deba14d9fd74810cf14012109ddc4ba2f58c27a400a180df31ee38feb" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindActiveSessionsByUserId", planHash: FIND_ACTIVE_SESSIONS_BY_USER_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "expires_after", "schema": { "kind": "timestamp" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "sessions", "schema": { "kind": "list", "maximum": 32, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
400
|
+
}
|
|
401
|
+
export const FIND_CREDENTIAL_ACCOUNT_QUERY_PLAN_HASH = "f968271d103a76cc6b2a5496f5cceffe4cff5aa39d2a370379b518d8e7d90771";
|
|
402
|
+
export const FIND_CREDENTIAL_ACCOUNT_SECRET_OUTPUTS = [
|
|
403
|
+
{ query: "FindCredentialAccount", entity: "Account", field: "access_token" },
|
|
404
|
+
{ query: "FindCredentialAccount", entity: "Account", field: "refresh_token" },
|
|
405
|
+
{ query: "FindCredentialAccount", entity: "Account", field: "id_token" },
|
|
406
|
+
{ query: "FindCredentialAccount", entity: "Account", field: "password" },
|
|
407
|
+
];
|
|
408
|
+
export function isFindCredentialAccountFound(value) {
|
|
409
|
+
return value.outcome === "Found";
|
|
410
|
+
}
|
|
411
|
+
export function unwrapFindCredentialAccountFound(value) {
|
|
412
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
413
|
+
if (resolved.outcome !== "Found")
|
|
414
|
+
throw new Error(`expected FindCredentialAccount outcome "Found", got "${resolved.outcome}"`);
|
|
415
|
+
return resolved;
|
|
416
|
+
}
|
|
417
|
+
export function redactFindCredentialAccountResult(value) {
|
|
418
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_CREDENTIAL_ACCOUNT_SECRET_OUTPUTS };
|
|
419
|
+
}
|
|
420
|
+
export function findCredentialAccount(parameters) {
|
|
421
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_credential_account", inputSchemaHash: "108a21aa464170aff1274c8f9af12f9c84d899483e63eb62f4fc9bed6e4fc040" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindCredentialAccount", planHash: FIND_CREDENTIAL_ACCOUNT_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "accounts", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "id", "schema": { "kind": "uuid" } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
422
|
+
}
|
|
423
|
+
export const FIND_EXPIRED_VERIFICATION_IDS_QUERY_PLAN_HASH = "6c799850ba3b2eb3222aac85a76f40492c46de76870075b029f3b4ac897ed8b9";
|
|
424
|
+
export function isFindExpiredVerificationIdsFound(value) {
|
|
425
|
+
return value.outcome === "Found";
|
|
426
|
+
}
|
|
427
|
+
export function unwrapFindExpiredVerificationIdsFound(value) {
|
|
428
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
429
|
+
if (resolved.outcome !== "Found")
|
|
430
|
+
throw new Error(`expected FindExpiredVerificationIds outcome "Found", got "${resolved.outcome}"`);
|
|
431
|
+
return resolved;
|
|
432
|
+
}
|
|
433
|
+
export function findExpiredVerificationIds(parameters) {
|
|
434
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_expired_verification_ids", inputSchemaHash: "b2397d3409885ae750a1d8b4d53bc6905e59348dfc79f0b4d2934981ad4cb1b2" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindExpiredVerificationIds", planHash: FIND_EXPIRED_VERIFICATION_IDS_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "expires_before", "schema": { "kind": "timestamp" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "verifications", "schema": { "kind": "list", "maximum": 32, "value": { "fields": [{ "name": "verification_id", "schema": { "kind": "uuid" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
435
|
+
}
|
|
436
|
+
export const FIND_LATEST_VERIFICATION_QUERY_PLAN_HASH = "b3832c0a8a316d3fcbc62b388fbe09ceb6624b55482195f7642553467cba6fcb";
|
|
437
|
+
export const FIND_LATEST_VERIFICATION_SECRET_OUTPUTS = [
|
|
438
|
+
{ query: "FindLatestVerification", entity: "Verification", field: "value" },
|
|
439
|
+
];
|
|
440
|
+
export function isFindLatestVerificationFound(value) {
|
|
441
|
+
return value.outcome === "Found";
|
|
442
|
+
}
|
|
443
|
+
export function unwrapFindLatestVerificationFound(value) {
|
|
444
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
445
|
+
if (resolved.outcome !== "Found")
|
|
446
|
+
throw new Error(`expected FindLatestVerification outcome "Found", got "${resolved.outcome}"`);
|
|
447
|
+
return resolved;
|
|
448
|
+
}
|
|
449
|
+
export function redactFindLatestVerificationResult(value) {
|
|
450
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_LATEST_VERIFICATION_SECRET_OUTPUTS };
|
|
451
|
+
}
|
|
452
|
+
export function findLatestVerification(parameters) {
|
|
453
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_latest_verification", inputSchemaHash: "414c00deb31dd873e434c8006a8caa9d2b360457abe0f8269440d6c761dfdc94" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindLatestVerification", planHash: FIND_LATEST_VERIFICATION_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "identifier", "schema": { "kind": "string" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "verifications", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "verification_id", "schema": { "kind": "uuid" } }, { "name": "identifier", "schema": { "kind": "string" } }, { "name": "value", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
454
|
+
}
|
|
455
|
+
export const FIND_SESSION_BY_ID_QUERY_PLAN_HASH = "c92eb2035c0e3ca7dedbaa42a4e2efe7bc4786a65213394da7f5d3beb579a2a1";
|
|
456
|
+
export const FIND_SESSION_BY_ID_SECRET_OUTPUTS = [
|
|
457
|
+
{ query: "FindSessionById", entity: "Session", field: "token" },
|
|
458
|
+
];
|
|
459
|
+
export function isFindSessionByIdFound(value) {
|
|
460
|
+
return value.outcome === "Found";
|
|
461
|
+
}
|
|
462
|
+
export function unwrapFindSessionByIdFound(value) {
|
|
463
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
464
|
+
if (resolved.outcome !== "Found")
|
|
465
|
+
throw new Error(`expected FindSessionById outcome "Found", got "${resolved.outcome}"`);
|
|
466
|
+
return resolved;
|
|
467
|
+
}
|
|
468
|
+
export function redactFindSessionByIdResult(value) {
|
|
469
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_SESSION_BY_ID_SECRET_OUTPUTS };
|
|
470
|
+
}
|
|
471
|
+
export function findSessionById(parameters) {
|
|
472
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_session_by_id", inputSchemaHash: "a8efd0b9fe4e36f92ca57a7c5351df748b4c2adbd0e363e2a5ffb66ff4d23bdc" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindSessionById", planHash: FIND_SESSION_BY_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "id", "schema": { "kind": "uuid" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "sessions", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
473
|
+
}
|
|
474
|
+
export const FIND_SESSION_BY_TOKEN_QUERY_PLAN_HASH = "a8a12334a3d34c30d54be828bdcc9b9b77223303c3f9681e4a602c92341876ec";
|
|
475
|
+
export const FIND_SESSION_BY_TOKEN_SECRET_OUTPUTS = [
|
|
476
|
+
{ query: "FindSessionByToken", entity: "Session", field: "token" },
|
|
477
|
+
];
|
|
478
|
+
export function isFindSessionByTokenFound(value) {
|
|
479
|
+
return value.outcome === "Found";
|
|
480
|
+
}
|
|
481
|
+
export function unwrapFindSessionByTokenFound(value) {
|
|
482
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
483
|
+
if (resolved.outcome !== "Found")
|
|
484
|
+
throw new Error(`expected FindSessionByToken outcome "Found", got "${resolved.outcome}"`);
|
|
485
|
+
return resolved;
|
|
486
|
+
}
|
|
487
|
+
export function redactFindSessionByTokenResult(value) {
|
|
488
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_SESSION_BY_TOKEN_SECRET_OUTPUTS };
|
|
489
|
+
}
|
|
490
|
+
export function findSessionByToken(parameters) {
|
|
491
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_session_by_token", inputSchemaHash: "0ff142e840e9d2d322c37be4688526fc1348f508cc4976856bd7e4d2570859e8" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindSessionByToken", planHash: FIND_SESSION_BY_TOKEN_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "sessions", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
492
|
+
}
|
|
493
|
+
export const FIND_SESSIONS_BY_TOKEN_SET_QUERY_PLAN_HASH = "7e23187b537599c4c2361d34ea866b5b719f63feda0135587b5ec6afd5ce62f6";
|
|
494
|
+
export const FIND_SESSIONS_BY_TOKEN_SET_TOKENS_MAX_ITEMS = 32;
|
|
495
|
+
export const FIND_SESSIONS_BY_TOKEN_SET_SECRET_OUTPUTS = [
|
|
496
|
+
{ query: "FindSessionsByTokenSet", entity: "Session", field: "token" },
|
|
497
|
+
];
|
|
498
|
+
export function isFindSessionsByTokenSetFound(value) {
|
|
499
|
+
return value.outcome === "Found";
|
|
500
|
+
}
|
|
501
|
+
export function unwrapFindSessionsByTokenSetFound(value) {
|
|
502
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
503
|
+
if (resolved.outcome !== "Found")
|
|
504
|
+
throw new Error(`expected FindSessionsByTokenSet outcome "Found", got "${resolved.outcome}"`);
|
|
505
|
+
return resolved;
|
|
506
|
+
}
|
|
507
|
+
export function redactFindSessionsByTokenSetResult(value) {
|
|
508
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_SESSIONS_BY_TOKEN_SET_SECRET_OUTPUTS };
|
|
509
|
+
}
|
|
510
|
+
export function findSessionsByTokenSet(parameters) {
|
|
511
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_sessions_by_token_set", inputSchemaHash: "6e07645237cd913d73a45bd7f863e3ca8d9ae09fdfecdb7494246fa80dea3899" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindSessionsByTokenSet", planHash: FIND_SESSIONS_BY_TOKEN_SET_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "tokens", "schema": { "kind": "list", "value": { "kind": "string" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "sessions", "schema": { "kind": "list", "maximum": 32, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
512
|
+
}
|
|
513
|
+
export const FIND_SESSIONS_BY_USER_ID_QUERY_PLAN_HASH = "a3277546d8b0c0059b850c368ae4925000c255e69b7ff005f4b3d2ef61b504af";
|
|
514
|
+
export const FIND_SESSIONS_BY_USER_ID_SECRET_OUTPUTS = [
|
|
515
|
+
{ query: "FindSessionsByUserId", entity: "Session", field: "token" },
|
|
516
|
+
];
|
|
517
|
+
export function isFindSessionsByUserIdFound(value) {
|
|
518
|
+
return value.outcome === "Found";
|
|
519
|
+
}
|
|
520
|
+
export function unwrapFindSessionsByUserIdFound(value) {
|
|
521
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
522
|
+
if (resolved.outcome !== "Found")
|
|
523
|
+
throw new Error(`expected FindSessionsByUserId outcome "Found", got "${resolved.outcome}"`);
|
|
524
|
+
return resolved;
|
|
525
|
+
}
|
|
526
|
+
export function redactFindSessionsByUserIdResult(value) {
|
|
527
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_SESSIONS_BY_USER_ID_SECRET_OUTPUTS };
|
|
528
|
+
}
|
|
529
|
+
export function findSessionsByUserId(parameters) {
|
|
530
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_sessions_by_user_id", inputSchemaHash: "52291caa82b70870673211137e93f3ecda460cbe7b9fc465f0b9d7f30df05798" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindSessionsByUserId", planHash: FIND_SESSIONS_BY_USER_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "sessions", "schema": { "kind": "list", "maximum": 32, "value": { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
531
|
+
}
|
|
532
|
+
export const FIND_USER_BY_EMAIL_QUERY_PLAN_HASH = "b167b8cb2fb5ce19685491b47da4e816665b840e0f0e463666f6302134472b9a";
|
|
533
|
+
export function isFindUserByEmailFound(value) {
|
|
534
|
+
return value.outcome === "Found";
|
|
535
|
+
}
|
|
536
|
+
export function unwrapFindUserByEmailFound(value) {
|
|
537
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
538
|
+
if (resolved.outcome !== "Found")
|
|
539
|
+
throw new Error(`expected FindUserByEmail outcome "Found", got "${resolved.outcome}"`);
|
|
540
|
+
return resolved;
|
|
541
|
+
}
|
|
542
|
+
function decodeFindUserByEmailCompact(value) {
|
|
543
|
+
if (value.outcome !== "Found" || value.resultName !== "users" || value.entity !== "User"
|
|
544
|
+
|| value.fields.length !== 8 || value.fields.some((field, index) => field !== ["created_at", "email", "email_verified", "image", "name", "revision", "updated_at", "user_id"][index])
|
|
545
|
+
|| value.rows.length > 1)
|
|
546
|
+
throw new Error("invalid RiffDB compact result");
|
|
547
|
+
return { outcome: "Found", users: value.rows.map((row) => {
|
|
548
|
+
if (row.length !== 8)
|
|
549
|
+
throw new Error("invalid RiffDB compact result");
|
|
550
|
+
return {
|
|
551
|
+
created_at: compactTimestamp(row[0]),
|
|
552
|
+
email: compactString(row[1], "string", 320),
|
|
553
|
+
email_verified: (() => { const value = compactPayload(row[2], "bool"); if (typeof value !== "boolean")
|
|
554
|
+
throw new Error("invalid RiffDB compact value"); return value; })(),
|
|
555
|
+
image: (row[3].type === "null" ? null : compactString(row[3], "string", 2048)),
|
|
556
|
+
name: compactString(row[4], "string", 256),
|
|
557
|
+
revision: compactInteger(row[5], "u64"),
|
|
558
|
+
updated_at: compactTimestamp(row[6]),
|
|
559
|
+
user_id: (() => { const value = compactString(row[7], "uuid", 36); if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value))
|
|
560
|
+
throw new Error("invalid RiffDB compact value"); return value; })(),
|
|
561
|
+
};
|
|
562
|
+
}) };
|
|
563
|
+
}
|
|
564
|
+
export function findUserByEmail(parameters) {
|
|
565
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_user_by_email", inputSchemaHash: "7d3b1da87ea1ee59893e110cd8f8a5eacb522a8fde24a7e8aa9b7c13340990b9" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindUserByEmail", planHash: FIND_USER_BY_EMAIL_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "email", "schema": { "kind": "string" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "users", "schema": { "kind": "list", "maximum": 1, "value": { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, compactDecoder: decodeFindUserByEmailCompact, decodeError: decodeApplicationError };
|
|
566
|
+
}
|
|
567
|
+
export const FIND_USER_BY_ID_QUERY_PLAN_HASH = "25d4a0a77d5df64ab6187528f9fac6b205a03c33e01c9ea6b573e8316b78b924";
|
|
568
|
+
export function isFindUserByIdFound(value) {
|
|
569
|
+
return value.outcome === "Found";
|
|
570
|
+
}
|
|
571
|
+
export function isFindUserByIdMissing(value) {
|
|
572
|
+
return value.outcome === "Missing";
|
|
573
|
+
}
|
|
574
|
+
export function unwrapFindUserByIdFound(value) {
|
|
575
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
576
|
+
if (resolved.outcome !== "Found")
|
|
577
|
+
throw new Error(`expected FindUserById outcome "Found", got "${resolved.outcome}"`);
|
|
578
|
+
return resolved;
|
|
579
|
+
}
|
|
580
|
+
export function findUserById(parameters) {
|
|
581
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_user_by_id", inputSchemaHash: "a8efd0b9fe4e36f92ca57a7c5351df748b4c2adbd0e363e2a5ffb66ff4d23bdc" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindUserById", planHash: FIND_USER_BY_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "id", "schema": { "kind": "uuid" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "user", "schema": { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" }, "Missing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
582
|
+
}
|
|
583
|
+
export const FIND_VERIFICATION_BY_ID_QUERY_PLAN_HASH = "54f07c7eba7d51857dd6473e39304dc798bf7084ca946dfa7f0203633a5133ac";
|
|
584
|
+
export const FIND_VERIFICATION_BY_ID_SECRET_OUTPUTS = [
|
|
585
|
+
{ query: "FindVerificationById", entity: "Verification", field: "value" },
|
|
586
|
+
];
|
|
587
|
+
export function isFindVerificationByIdFound(value) {
|
|
588
|
+
return value.outcome === "Found";
|
|
589
|
+
}
|
|
590
|
+
export function isFindVerificationByIdMissing(value) {
|
|
591
|
+
return value.outcome === "Missing";
|
|
592
|
+
}
|
|
593
|
+
export function unwrapFindVerificationByIdFound(value) {
|
|
594
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
595
|
+
if (resolved.outcome !== "Found")
|
|
596
|
+
throw new Error(`expected FindVerificationById outcome "Found", got "${resolved.outcome}"`);
|
|
597
|
+
return resolved;
|
|
598
|
+
}
|
|
599
|
+
export function redactFindVerificationByIdResult(value) {
|
|
600
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_VERIFICATION_BY_ID_SECRET_OUTPUTS };
|
|
601
|
+
}
|
|
602
|
+
export function findVerificationById(parameters) {
|
|
603
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_verification_by_id", inputSchemaHash: "a8efd0b9fe4e36f92ca57a7c5351df748b4c2adbd0e363e2a5ffb66ff4d23bdc" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindVerificationById", planHash: FIND_VERIFICATION_BY_ID_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "id", "schema": { "kind": "uuid" } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "verification", "schema": { "fields": [{ "name": "verification_id", "schema": { "kind": "uuid" } }, { "name": "identifier", "schema": { "kind": "string" } }, { "name": "value", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } }], "kind": "record" }, "Missing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
604
|
+
}
|
|
605
|
+
export const FIND_VERIFICATIONS_BY_IDENTIFIER_QUERY_PLAN_HASH = "4c768ae1d966454e9b791cd57a6311476947b5c457020943a50bc3cfee90765b";
|
|
606
|
+
export const FIND_VERIFICATIONS_BY_IDENTIFIER_SECRET_OUTPUTS = [
|
|
607
|
+
{ query: "FindVerificationsByIdentifier", entity: "Verification", field: "value" },
|
|
608
|
+
];
|
|
609
|
+
export function isFindVerificationsByIdentifierFound(value) {
|
|
610
|
+
return value.outcome === "Found";
|
|
611
|
+
}
|
|
612
|
+
export function unwrapFindVerificationsByIdentifierFound(value) {
|
|
613
|
+
const resolved = ("identity" in value && "applicationHead" in value && "value" in value ? value.value : value);
|
|
614
|
+
if (resolved.outcome !== "Found")
|
|
615
|
+
throw new Error(`expected FindVerificationsByIdentifier outcome "Found", got "${resolved.outcome}"`);
|
|
616
|
+
return resolved;
|
|
617
|
+
}
|
|
618
|
+
export function redactFindVerificationsByIdentifierResult(value) {
|
|
619
|
+
return { outcome: value.outcome, redactedSecretOutputs: FIND_VERIFICATIONS_BY_IDENTIFIER_SECRET_OUTPUTS };
|
|
620
|
+
}
|
|
621
|
+
export function findVerificationsByIdentifier(parameters) {
|
|
622
|
+
return { driverOperation: { name: "riffdb_better_auth_core_find_verifications_by_identifier", inputSchemaHash: "f61c6a3fd1f9b7496a437e77f166f72e9c36d27d832811ac96f146fa2999cc37" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, contractBundleHash: CONTRACT_BUNDLE_HASH, moduleHash: QUERY_MODULE_HASH, queryName: "FindVerificationsByIdentifier", planHash: FIND_VERIFICATIONS_BY_IDENTIFIER_QUERY_PLAN_HASH, parameters, parameterSchema: { "fields": [{ "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "identifier", "schema": { "kind": "string" } }, { "name": "after", "schema": { "kind": "optional", "value": { "kind": "cursor" } } }], "kind": "record" }, resultSchemas: { "Found": { "fields": [{ "name": "verifications", "schema": { "kind": "list", "maximum": 32, "value": { "fields": [{ "name": "verification_id", "schema": { "kind": "uuid" } }, { "name": "identifier", "schema": { "kind": "string" } }, { "name": "value", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "revision", "schema": { "kind": "u64" } }], "kind": "record" } } }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
623
|
+
}
|
|
624
|
+
export const CONSUME_VERIFICATION_SECRET_OUTPUTS = [
|
|
625
|
+
{ outcome: "VerificationConsumed", field: "value", entity: "Verification", sourceField: "value" },
|
|
626
|
+
];
|
|
627
|
+
export function isConsumeVerificationVerificationConsumed(value) {
|
|
628
|
+
return value.outcome === "VerificationConsumed";
|
|
629
|
+
}
|
|
630
|
+
export function isConsumeVerificationVerificationConsumeMissing(value) {
|
|
631
|
+
return value.outcome === "VerificationConsumeMissing";
|
|
632
|
+
}
|
|
633
|
+
export function redactConsumeVerificationOutcome(value) {
|
|
634
|
+
return { outcome: value.outcome, redactedSecretOutputs: CONSUME_VERIFICATION_SECRET_OUTPUTS };
|
|
635
|
+
}
|
|
636
|
+
export const CONSUME_VERIFICATION_PLAN_HASH = "22a3f3b01aeb537ae2b8b3f758aa19d8f8a6a58a0e284b3b347d1079972adef2";
|
|
637
|
+
export function consumeVerification(input) {
|
|
638
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
639
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
640
|
+
return { driverOperation: { name: "riffdb_better_auth_core_consume_verification", inputSchemaHash: "4e28ec5a411c2397de0d11fd9358879744a2b3f75c5855002b3cba62fb1d26c3" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "ConsumeVerification", planHash: CONSUME_VERIFICATION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "verification_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "VerificationConsumeMissing": { "fields": [], "kind": "record" }, "VerificationConsumed": { "fields": [{ "name": "value", "schema": { "kind": "string" }, "wireId": 1 }, { "name": "revision", "schema": { "kind": "u64" }, "wireId": 2 }, { "name": "created_at", "schema": { "kind": "timestamp" }, "wireId": 3 }, { "name": "expires_at", "schema": { "kind": "timestamp" }, "wireId": 4 }, { "name": "identifier", "schema": { "kind": "string" }, "wireId": 5 }, { "name": "updated_at", "schema": { "kind": "timestamp" }, "wireId": 6 }, { "name": "verification_id", "schema": { "kind": "uuid" }, "wireId": 7 }], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
641
|
+
}
|
|
642
|
+
export function isConsumeVerificationSetVerificationSetConsumed(value) {
|
|
643
|
+
return value.outcome === "VerificationSetConsumed";
|
|
644
|
+
}
|
|
645
|
+
export function isConsumeVerificationSetVerificationConsumeMissing(value) {
|
|
646
|
+
return value.outcome === "VerificationConsumeMissing";
|
|
647
|
+
}
|
|
648
|
+
export const CONSUME_VERIFICATION_SET_PLAN_HASH = "cc5e0d69851c61f11bbbca45ad00bec80b32687a94272379e133fbf854d59780";
|
|
649
|
+
export function consumeVerificationSet(input) {
|
|
650
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
651
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
652
|
+
return { driverOperation: { name: "riffdb_better_auth_core_consume_verification_set", inputSchemaHash: "ce88d8052f760625503f8a732f9813446ef7cc042d726ee1826c05c437c0929c" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "ConsumeVerificationSet", planHash: CONSUME_VERIFICATION_SET_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "verification_ids", "schema": { "kind": "list", "maximum": 32, "minimum": 1, "value": { "kind": "uuid" } } }], "kind": "record" }, outcomeSchemas: { "VerificationConsumeMissing": { "fields": [], "kind": "record" }, "VerificationSetConsumed": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
653
|
+
}
|
|
654
|
+
export function isConsumeVerificationSnapshotVerificationConsumed(value) {
|
|
655
|
+
return value.outcome === "VerificationConsumed";
|
|
656
|
+
}
|
|
657
|
+
export function isConsumeVerificationSnapshotVerificationConsumeStale(value) {
|
|
658
|
+
return value.outcome === "VerificationConsumeStale";
|
|
659
|
+
}
|
|
660
|
+
export function isConsumeVerificationSnapshotVerificationConsumeMissing(value) {
|
|
661
|
+
return value.outcome === "VerificationConsumeMissing";
|
|
662
|
+
}
|
|
663
|
+
export const CONSUME_VERIFICATION_SNAPSHOT_PLAN_HASH = "1a80a36f34b4699c972fc1e6f48cad3f85da54e202831a6986aea084db09788b";
|
|
664
|
+
export function consumeVerificationSnapshot(input) {
|
|
665
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
666
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
667
|
+
return { driverOperation: { name: "riffdb_better_auth_core_consume_verification_snapshot", inputSchemaHash: "d1ae264c5794d32e6619f9d52b77dd3a4cab39615dd48adb9a2a3b46ff92cd8c" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "ConsumeVerificationSnapshot", planHash: CONSUME_VERIFICATION_SNAPSHOT_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "verification_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }], "kind": "record" }, outcomeSchemas: { "VerificationConsumeMissing": { "fields": [], "kind": "record" }, "VerificationConsumeStale": { "fields": [], "kind": "record" }, "VerificationConsumed": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
668
|
+
}
|
|
669
|
+
export function isCreateAccountAccountCreated(value) {
|
|
670
|
+
return value.outcome === "AccountCreated";
|
|
671
|
+
}
|
|
672
|
+
export function isCreateAccountAccountUserMissing(value) {
|
|
673
|
+
return value.outcome === "AccountUserMissing";
|
|
674
|
+
}
|
|
675
|
+
export function isCreateAccountAccountAlreadyExists(value) {
|
|
676
|
+
return value.outcome === "AccountAlreadyExists";
|
|
677
|
+
}
|
|
678
|
+
export const CREATE_ACCOUNT_PLAN_HASH = "53f2e7b330780eb514a299ceb673da4f1eeaea81beb45253267a52e41a7fd0b2";
|
|
679
|
+
export function createAccount(input) {
|
|
680
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
681
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
682
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_account", inputSchemaHash: "9f59abcc35f23822a34f3504905acaae3df3c62c0f60e6bcb65bd8768279c4f9" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateAccount", planHash: CREATE_ACCOUNT_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "account_id", "schema": { "kind": "string" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }], "kind": "record" }, outcomeSchemas: { "AccountAlreadyExists": { "fields": [], "kind": "record" }, "AccountCreated": { "fields": [], "kind": "record" }, "AccountUserMissing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
683
|
+
}
|
|
684
|
+
export function isCreateOAuthUserGraphOAuthUserExists(value) {
|
|
685
|
+
return value.outcome === "OAuthUserExists";
|
|
686
|
+
}
|
|
687
|
+
export function isCreateOAuthUserGraphOAuthAccountExists(value) {
|
|
688
|
+
return value.outcome === "OAuthAccountExists";
|
|
689
|
+
}
|
|
690
|
+
export function isCreateOAuthUserGraphOAuthUserGraphCreated(value) {
|
|
691
|
+
return value.outcome === "OAuthUserGraphCreated";
|
|
692
|
+
}
|
|
693
|
+
export const CREATE_O_AUTH_USER_GRAPH_PLAN_HASH = "a30c6faca9666ff17536e1f4ec35f0306e970430a064e0d72a66adccefad7407";
|
|
694
|
+
export function createOAuthUserGraph(input) {
|
|
695
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
696
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
697
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_o_auth_user_graph", inputSchemaHash: "e7b044ec8cfadc80fc33bc06825e721bc65d5926299b0643cf1f7e4e75cf6f33" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateOAuthUserGraph", planHash: CREATE_O_AUTH_USER_GRAPH_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_name", "schema": { "kind": "string" } }, { "name": "account_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "user_email", "schema": { "kind": "string" } }, { "name": "user_image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_created_at", "schema": { "kind": "timestamp" } }, { "name": "user_updated_at", "schema": { "kind": "timestamp" } }, { "name": "account_created_at", "schema": { "kind": "timestamp" } }, { "name": "account_updated_at", "schema": { "kind": "timestamp" } }, { "name": "external_account_id", "schema": { "kind": "string" } }, { "name": "user_email_verified", "schema": { "kind": "bool" } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }], "kind": "record" }, outcomeSchemas: { "OAuthAccountExists": { "fields": [], "kind": "record" }, "OAuthUserExists": { "fields": [], "kind": "record" }, "OAuthUserGraphCreated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
698
|
+
}
|
|
699
|
+
export function isCreateSessionSessionCreated(value) {
|
|
700
|
+
return value.outcome === "SessionCreated";
|
|
701
|
+
}
|
|
702
|
+
export function isCreateSessionSessionUserMissing(value) {
|
|
703
|
+
return value.outcome === "SessionUserMissing";
|
|
704
|
+
}
|
|
705
|
+
export function isCreateSessionSessionAlreadyExists(value) {
|
|
706
|
+
return value.outcome === "SessionAlreadyExists";
|
|
707
|
+
}
|
|
708
|
+
export const CREATE_SESSION_PLAN_HASH = "c5e41496adb0a45f87503008fa43da87c6c729674bb1f521625ff16183059050";
|
|
709
|
+
export function createSession(input) {
|
|
710
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
711
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
712
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_session", inputSchemaHash: "90f15b4cdb6f49df5e37b625173a07170d7975bbb4e8a8d1419071cd4f8a9312" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateSession", planHash: CREATE_SESSION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "token", "schema": { "kind": "string" } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "SessionAlreadyExists": { "fields": [], "kind": "record" }, "SessionCreated": { "fields": [], "kind": "record" }, "SessionUserMissing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
713
|
+
}
|
|
714
|
+
export function isCreateSignupGraphSignupUserExists(value) {
|
|
715
|
+
return value.outcome === "SignupUserExists";
|
|
716
|
+
}
|
|
717
|
+
export function isCreateSignupGraphSignupGraphCreated(value) {
|
|
718
|
+
return value.outcome === "SignupGraphCreated";
|
|
719
|
+
}
|
|
720
|
+
export function isCreateSignupGraphSignupAccountExists(value) {
|
|
721
|
+
return value.outcome === "SignupAccountExists";
|
|
722
|
+
}
|
|
723
|
+
export function isCreateSignupGraphSignupSessionExists(value) {
|
|
724
|
+
return value.outcome === "SignupSessionExists";
|
|
725
|
+
}
|
|
726
|
+
export const CREATE_SIGNUP_GRAPH_PLAN_HASH = "01e4e118b1cc5c3a16c19259284cd0845e8a2e405fc02f81ab9b1fcafc79d0b8";
|
|
727
|
+
export function createSignupGraph(input) {
|
|
728
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
729
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
730
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_signup_graph", inputSchemaHash: "49ab048473688615ee1dd52f54c399de0a8da4accab6a7e8f109b3bdd0937c31" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateSignupGraph", planHash: CREATE_SIGNUP_GRAPH_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "user_name", "schema": { "kind": "string" } }, { "name": "account_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "session_id", "schema": { "kind": "uuid" } }, { "name": "user_email", "schema": { "kind": "string" } }, { "name": "user_image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "session_token", "schema": { "kind": "string" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "user_created_at", "schema": { "kind": "timestamp" } }, { "name": "user_updated_at", "schema": { "kind": "timestamp" } }, { "name": "account_password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "account_created_at", "schema": { "kind": "timestamp" } }, { "name": "account_updated_at", "schema": { "kind": "timestamp" } }, { "name": "session_created_at", "schema": { "kind": "timestamp" } }, { "name": "session_expires_at", "schema": { "kind": "timestamp" } }, { "name": "session_ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "session_updated_at", "schema": { "kind": "timestamp" } }, { "name": "session_user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "external_account_id", "schema": { "kind": "string" } }, { "name": "user_email_verified", "schema": { "kind": "bool" } }], "kind": "record" }, outcomeSchemas: { "SignupAccountExists": { "fields": [], "kind": "record" }, "SignupGraphCreated": { "fields": [], "kind": "record" }, "SignupSessionExists": { "fields": [], "kind": "record" }, "SignupUserExists": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
731
|
+
}
|
|
732
|
+
export function isCreateUserUserCreated(value) {
|
|
733
|
+
return value.outcome === "UserCreated";
|
|
734
|
+
}
|
|
735
|
+
export function isCreateUserUserAlreadyExists(value) {
|
|
736
|
+
return value.outcome === "UserAlreadyExists";
|
|
737
|
+
}
|
|
738
|
+
export const CREATE_USER_PLAN_HASH = "752d7d404aa418b5c1a08065ce9a8efbb28ab2b62f18969c98a13a06092fd8b3";
|
|
739
|
+
export function createUser(input) {
|
|
740
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
741
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
742
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_user", inputSchemaHash: "797c4a05358287284cac08b3b955bda7d19f1fb1fd7d682d3daf07b12d64ea2a" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateUser", planHash: CREATE_USER_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "UserAlreadyExists": { "fields": [], "kind": "record" }, "UserCreated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
743
|
+
}
|
|
744
|
+
export function isCreateVerificationVerificationCreated(value) {
|
|
745
|
+
return value.outcome === "VerificationCreated";
|
|
746
|
+
}
|
|
747
|
+
export function isCreateVerificationVerificationAlreadyExists(value) {
|
|
748
|
+
return value.outcome === "VerificationAlreadyExists";
|
|
749
|
+
}
|
|
750
|
+
export const CREATE_VERIFICATION_PLAN_HASH = "82bce005457b1fcf1d069a69304f7bf4e2eeb7d2718d5289dc9d25e197309e35";
|
|
751
|
+
export function createVerification(input) {
|
|
752
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
753
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
754
|
+
return { driverOperation: { name: "riffdb_better_auth_core_create_verification", inputSchemaHash: "1df4414485ef2e463cee868bb97850b7a189a8c72c6090a650a1a1e0bd96baef" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "CreateVerification", planHash: CREATE_VERIFICATION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "id", "schema": { "kind": "uuid" } }, { "name": "value", "schema": { "kind": "string" } }, { "name": "created_at", "schema": { "kind": "timestamp" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "identifier", "schema": { "kind": "string" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "VerificationAlreadyExists": { "fields": [], "kind": "record" }, "VerificationCreated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
755
|
+
}
|
|
756
|
+
export function isDeleteAccountAccountDeleted(value) {
|
|
757
|
+
return value.outcome === "AccountDeleted";
|
|
758
|
+
}
|
|
759
|
+
export function isDeleteAccountAccountMissing(value) {
|
|
760
|
+
return value.outcome === "AccountMissing";
|
|
761
|
+
}
|
|
762
|
+
export const DELETE_ACCOUNT_PLAN_HASH = "6429ebe6e70797c57c44a4738c8a511bbe5304e5bf58148dfc0c2721ffaff382";
|
|
763
|
+
export function deleteAccount(input) {
|
|
764
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
765
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
766
|
+
return { driverOperation: { name: "riffdb_better_auth_core_delete_account", inputSchemaHash: "8e512e4d77b1ced01a098641ce940e1440a4b63d4c3e2ddad9068a1faf9c2c11" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "DeleteAccount", planHash: DELETE_ACCOUNT_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "account_ids", "schema": { "kind": "list", "maximum": 32, "minimum": 1, "value": { "kind": "uuid" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "AccountDeleted": { "fields": [], "kind": "record" }, "AccountMissing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
767
|
+
}
|
|
768
|
+
export function isDeleteSessionSessionDeleted(value) {
|
|
769
|
+
return value.outcome === "SessionDeleted";
|
|
770
|
+
}
|
|
771
|
+
export function isDeleteSessionSessionMissing(value) {
|
|
772
|
+
return value.outcome === "SessionMissing";
|
|
773
|
+
}
|
|
774
|
+
export const DELETE_SESSION_PLAN_HASH = "a3901beb6c2d2754fd3d2c64252b6f5059cd1792c0a0560741c94da4668a0524";
|
|
775
|
+
export function deleteSession(input) {
|
|
776
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
777
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
778
|
+
return { driverOperation: { name: "riffdb_better_auth_core_delete_session", inputSchemaHash: "6eeb9f3b452bb70a9b0e955dcb9e9a0115db479f3297a5d3c8b243a6e34974f7" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "DeleteSession", planHash: DELETE_SESSION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "session_ids", "schema": { "kind": "list", "maximum": 32, "minimum": 1, "value": { "kind": "uuid" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "SessionDeleted": { "fields": [], "kind": "record" }, "SessionMissing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
779
|
+
}
|
|
780
|
+
export function isDeleteUserUserDeleted(value) {
|
|
781
|
+
return value.outcome === "UserDeleted";
|
|
782
|
+
}
|
|
783
|
+
export function isDeleteUserDeleteUserMissing(value) {
|
|
784
|
+
return value.outcome === "DeleteUserMissing";
|
|
785
|
+
}
|
|
786
|
+
export function isDeleteUserDeleteUserCascadeLimitExceeded(value) {
|
|
787
|
+
return value.outcome === "DeleteUserCascadeLimitExceeded";
|
|
788
|
+
}
|
|
789
|
+
export const DELETE_USER_PLAN_HASH = "f7195857c4f50a68b37ee0f8516c27dd03b08d5cd5ba45f53d9f9345d2f90985";
|
|
790
|
+
export function deleteUser(input) {
|
|
791
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
792
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
793
|
+
return { driverOperation: { name: "riffdb_better_auth_core_delete_user", inputSchemaHash: "c128e0333c57f08e3094e68459abbac53483952520e8381c0b79db903c36146d" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "DeleteUser", planHash: DELETE_USER_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_ids", "schema": { "kind": "list", "maximum": 1, "minimum": 1, "value": { "kind": "uuid" } } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "DeleteUserCascadeLimitExceeded": { "fields": [], "kind": "record" }, "DeleteUserMissing": { "fields": [], "kind": "record" }, "UserDeleted": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
794
|
+
}
|
|
795
|
+
export function isDeleteVerificationVerificationDeleted(value) {
|
|
796
|
+
return value.outcome === "VerificationDeleted";
|
|
797
|
+
}
|
|
798
|
+
export function isDeleteVerificationVerificationMissing(value) {
|
|
799
|
+
return value.outcome === "VerificationMissing";
|
|
800
|
+
}
|
|
801
|
+
export const DELETE_VERIFICATION_PLAN_HASH = "bffc0c5ef5ad2b602954492d043e833785ec3f9d6f0520fbc0f933422544ae6a";
|
|
802
|
+
export function deleteVerification(input) {
|
|
803
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
804
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
805
|
+
return { driverOperation: { name: "riffdb_better_auth_core_delete_verification", inputSchemaHash: "ce88d8052f760625503f8a732f9813446ef7cc042d726ee1826c05c437c0929c" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "DeleteVerification", planHash: DELETE_VERIFICATION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "verification_ids", "schema": { "kind": "list", "maximum": 32, "minimum": 1, "value": { "kind": "uuid" } } }], "kind": "record" }, outcomeSchemas: { "VerificationDeleted": { "fields": [], "kind": "record" }, "VerificationMissing": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
806
|
+
}
|
|
807
|
+
export function isResetCredentialPasswordPasswordAccountStale(value) {
|
|
808
|
+
return value.outcome === "PasswordAccountStale";
|
|
809
|
+
}
|
|
810
|
+
export function isResetCredentialPasswordPasswordAccountMissing(value) {
|
|
811
|
+
return value.outcome === "PasswordAccountMissing";
|
|
812
|
+
}
|
|
813
|
+
export function isResetCredentialPasswordCredentialPasswordReset(value) {
|
|
814
|
+
return value.outcome === "CredentialPasswordReset";
|
|
815
|
+
}
|
|
816
|
+
export function isResetCredentialPasswordPasswordProviderMismatch(value) {
|
|
817
|
+
return value.outcome === "PasswordProviderMismatch";
|
|
818
|
+
}
|
|
819
|
+
export function isResetCredentialPasswordVerificationConsumeStale(value) {
|
|
820
|
+
return value.outcome === "VerificationConsumeStale";
|
|
821
|
+
}
|
|
822
|
+
export function isResetCredentialPasswordVerificationConsumeMissing(value) {
|
|
823
|
+
return value.outcome === "VerificationConsumeMissing";
|
|
824
|
+
}
|
|
825
|
+
export const RESET_CREDENTIAL_PASSWORD_PLAN_HASH = "ed87f267831fb0823b0e9bbf51d7b302a715a95c0cea69faf7922c0e4e7f375e";
|
|
826
|
+
export function resetCredentialPassword(input) {
|
|
827
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
828
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
829
|
+
return { driverOperation: { name: "riffdb_better_auth_core_reset_credential_password", inputSchemaHash: "b9959320d1fe50eba09aa488169566453c4ed9a58c27a338455e204b7f0c708d" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "ResetCredentialPassword", planHash: RESET_CREDENTIAL_PASSWORD_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "password", "schema": { "kind": "string" } }, { "name": "account_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "account_revision", "schema": { "kind": "u64" } }, { "name": "verification_ids", "schema": { "kind": "list", "maximum": 1, "minimum": 1, "value": { "kind": "uuid" } } }, { "name": "external_account_id", "schema": { "kind": "string" } }, { "name": "verification_revision", "schema": { "kind": "u64" } }], "kind": "record" }, outcomeSchemas: { "CredentialPasswordReset": { "fields": [], "kind": "record" }, "PasswordAccountMissing": { "fields": [], "kind": "record" }, "PasswordAccountStale": { "fields": [], "kind": "record" }, "PasswordProviderMismatch": { "fields": [], "kind": "record" }, "VerificationConsumeMissing": { "fields": [], "kind": "record" }, "VerificationConsumeStale": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
830
|
+
}
|
|
831
|
+
export function isUpdateAccountAccountUpdated(value) {
|
|
832
|
+
return value.outcome === "AccountUpdated";
|
|
833
|
+
}
|
|
834
|
+
export function isUpdateAccountAccountUpdateStale(value) {
|
|
835
|
+
return value.outcome === "AccountUpdateStale";
|
|
836
|
+
}
|
|
837
|
+
export function isUpdateAccountAccountUpdateMissing(value) {
|
|
838
|
+
return value.outcome === "AccountUpdateMissing";
|
|
839
|
+
}
|
|
840
|
+
export const UPDATE_ACCOUNT_PLAN_HASH = "1556cd92effd135225904f0313f1cdf146ebe82f72621ebeccb2686c5442b849";
|
|
841
|
+
export function updateAccount(input) {
|
|
842
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
843
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
844
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_account", inputSchemaHash: "f623666040b60333eba3b4b46d5b1fe92158fcade5037f13b8ed0435e5c9471e" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateAccount", planHash: UPDATE_ACCOUNT_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "scope", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "id_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "account_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "provider_id", "schema": { "kind": "string" } }, { "name": "access_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "refresh_token", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }, { "name": "external_account_id", "schema": { "kind": "string" } }, { "name": "access_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }, { "name": "refresh_token_expires_at", "schema": { "kind": "optional", "value": { "kind": "timestamp" } } }], "kind": "record" }, outcomeSchemas: { "AccountUpdateMissing": { "fields": [], "kind": "record" }, "AccountUpdateStale": { "fields": [], "kind": "record" }, "AccountUpdated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
845
|
+
}
|
|
846
|
+
export function isUpdateAccountPasswordsPasswordAccountStale(value) {
|
|
847
|
+
return value.outcome === "PasswordAccountStale";
|
|
848
|
+
}
|
|
849
|
+
export function isUpdateAccountPasswordsPasswordAccountMissing(value) {
|
|
850
|
+
return value.outcome === "PasswordAccountMissing";
|
|
851
|
+
}
|
|
852
|
+
export function isUpdateAccountPasswordsAccountPasswordsUpdated(value) {
|
|
853
|
+
return value.outcome === "AccountPasswordsUpdated";
|
|
854
|
+
}
|
|
855
|
+
export function isUpdateAccountPasswordsPasswordProviderMismatch(value) {
|
|
856
|
+
return value.outcome === "PasswordProviderMismatch";
|
|
857
|
+
}
|
|
858
|
+
export const UPDATE_ACCOUNT_PASSWORDS_PLAN_HASH = "5f18c741b5e9c09203c67b5985af9d034fad670462ecdda32a0a1f031ef288f6";
|
|
859
|
+
export function updateAccountPasswords(input) {
|
|
860
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
861
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
862
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_account_passwords", inputSchemaHash: "f210cf13f349297bad0bd949bdfbb796e37ea4dfa24b99d6205942afdde0883c" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateAccountPasswords", planHash: UPDATE_ACCOUNT_PASSWORDS_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "updates", "schema": { "kind": "list", "maximum": 8, "minimum": 1, "value": { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" }, "wireId": 1 }, { "name": "password", "schema": { "kind": "optional", "value": { "kind": "string" } }, "wireId": 2 }, { "name": "account_id", "schema": { "kind": "uuid" }, "wireId": 3 }, { "name": "updated_at", "schema": { "kind": "timestamp" }, "wireId": 4 }, { "name": "provider_id", "schema": { "kind": "string" }, "wireId": 5 }, { "name": "organization_id", "schema": { "kind": "uuid" }, "wireId": 6 }, { "name": "expected_revision", "schema": { "kind": "u64" }, "wireId": 7 }], "kind": "record" } } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }], "kind": "record" }, outcomeSchemas: { "AccountPasswordsUpdated": { "fields": [], "kind": "record" }, "PasswordAccountMissing": { "fields": [], "kind": "record" }, "PasswordAccountStale": { "fields": [], "kind": "record" }, "PasswordProviderMismatch": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
863
|
+
}
|
|
864
|
+
export function isUpdateCredentialPasswordPasswordAccountStale(value) {
|
|
865
|
+
return value.outcome === "PasswordAccountStale";
|
|
866
|
+
}
|
|
867
|
+
export function isUpdateCredentialPasswordPasswordAccountMissing(value) {
|
|
868
|
+
return value.outcome === "PasswordAccountMissing";
|
|
869
|
+
}
|
|
870
|
+
export function isUpdateCredentialPasswordPasswordProviderMismatch(value) {
|
|
871
|
+
return value.outcome === "PasswordProviderMismatch";
|
|
872
|
+
}
|
|
873
|
+
export function isUpdateCredentialPasswordCredentialPasswordUpdated(value) {
|
|
874
|
+
return value.outcome === "CredentialPasswordUpdated";
|
|
875
|
+
}
|
|
876
|
+
export const UPDATE_CREDENTIAL_PASSWORD_PLAN_HASH = "08781a68739c705ab6ffe51a0de547605e1a7dd2fd2b8075445d40db923d1f15";
|
|
877
|
+
export function updateCredentialPassword(input) {
|
|
878
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
879
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
880
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_credential_password", inputSchemaHash: "5d4589d948081b8f0d4472fa359bd34ca0c05895eac4e6a99f9015f8f45cc2e7" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateCredentialPassword", planHash: UPDATE_CREDENTIAL_PASSWORD_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "password", "schema": { "kind": "string" } }, { "name": "account_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }, { "name": "external_account_id", "schema": { "kind": "string" } }], "kind": "record" }, outcomeSchemas: { "CredentialPasswordUpdated": { "fields": [], "kind": "record" }, "PasswordAccountMissing": { "fields": [], "kind": "record" }, "PasswordAccountStale": { "fields": [], "kind": "record" }, "PasswordProviderMismatch": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
881
|
+
}
|
|
882
|
+
export function isUpdateSessionSessionUpdated(value) {
|
|
883
|
+
return value.outcome === "SessionUpdated";
|
|
884
|
+
}
|
|
885
|
+
export function isUpdateSessionSessionUpdateStale(value) {
|
|
886
|
+
return value.outcome === "SessionUpdateStale";
|
|
887
|
+
}
|
|
888
|
+
export function isUpdateSessionSessionUpdateMissing(value) {
|
|
889
|
+
return value.outcome === "SessionUpdateMissing";
|
|
890
|
+
}
|
|
891
|
+
export const UPDATE_SESSION_PLAN_HASH = "4c1184c5c0a1f8b8935a8b96204ad839afe84e1752f2ba24cdf63feef4f7ce3a";
|
|
892
|
+
export function updateSession(input) {
|
|
893
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
894
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
895
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_session", inputSchemaHash: "4dc035dba6c54788232952ebe5eb225c8f1e8e542ea3b20ef188f85fbfb1a1a1" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateSession", planHash: UPDATE_SESSION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "ip_address", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "session_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "user_agent", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }], "kind": "record" }, outcomeSchemas: { "SessionUpdateMissing": { "fields": [], "kind": "record" }, "SessionUpdateStale": { "fields": [], "kind": "record" }, "SessionUpdated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
896
|
+
}
|
|
897
|
+
export function isUpdateUserUserUpdated(value) {
|
|
898
|
+
return value.outcome === "UserUpdated";
|
|
899
|
+
}
|
|
900
|
+
export function isUpdateUserUserUpdateStale(value) {
|
|
901
|
+
return value.outcome === "UserUpdateStale";
|
|
902
|
+
}
|
|
903
|
+
export function isUpdateUserUserUpdateMissing(value) {
|
|
904
|
+
return value.outcome === "UserUpdateMissing";
|
|
905
|
+
}
|
|
906
|
+
export const UPDATE_USER_PLAN_HASH = "cd0d3c8108976d4b2413f41fd68791b3e9276a763787f40b82bef17219091194";
|
|
907
|
+
export function updateUser(input) {
|
|
908
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
909
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
910
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_user", inputSchemaHash: "1c26635c0abf32530ed895a1dd615ef00b0a9c9177fafb4adedd7de97f7f5757" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateUser", planHash: UPDATE_USER_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "name", "schema": { "kind": "string" } }, { "name": "email", "schema": { "kind": "string" } }, { "name": "image", "schema": { "kind": "optional", "value": { "kind": "string" } } }, { "name": "user_id", "schema": { "kind": "uuid" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "email_verified", "schema": { "kind": "bool" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }], "kind": "record" }, outcomeSchemas: { "UserUpdateMissing": { "fields": [], "kind": "record" }, "UserUpdateStale": { "fields": [], "kind": "record" }, "UserUpdated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
911
|
+
}
|
|
912
|
+
export function isUpdateVerificationVerificationUpdated(value) {
|
|
913
|
+
return value.outcome === "VerificationUpdated";
|
|
914
|
+
}
|
|
915
|
+
export function isUpdateVerificationVerificationUpdateStale(value) {
|
|
916
|
+
return value.outcome === "VerificationUpdateStale";
|
|
917
|
+
}
|
|
918
|
+
export function isUpdateVerificationVerificationUpdateMissing(value) {
|
|
919
|
+
return value.outcome === "VerificationUpdateMissing";
|
|
920
|
+
}
|
|
921
|
+
export const UPDATE_VERIFICATION_PLAN_HASH = "b9ea963db584e7fd9dbce1069d982dc0f53ebb06b72b41b060578b284596018f";
|
|
922
|
+
export function updateVerification(input) {
|
|
923
|
+
const idempotencyKey = input.request_id && input.request_id.length > 0 ? input.request_id : globalThis.crypto.randomUUID();
|
|
924
|
+
const resolvedInput = input.request_id === idempotencyKey ? input : { ...input, request_id: idempotencyKey };
|
|
925
|
+
return { driverOperation: { name: "riffdb_better_auth_core_update_verification", inputSchemaHash: "4377bfd8aba7795661e686fbc5903e8116b2f9eba24bce9fcdd63cd4bb53e8c5" }, contractLineage: CONTRACT_LINEAGE, contractVersion: CONTRACT_VERSION, commandName: "UpdateVerification", planHash: UPDATE_VERIFICATION_PLAN_HASH, input: resolvedInput, idempotencyKey, inputSchema: { "fields": [{ "name": "value", "schema": { "kind": "string" } }, { "name": "expires_at", "schema": { "kind": "timestamp" } }, { "name": "request_id", "schema": { "kind": "uuid" } }, { "name": "updated_at", "schema": { "kind": "timestamp" } }, { "name": "organization_id", "schema": { "kind": "uuid" } }, { "name": "verification_id", "schema": { "kind": "uuid" } }, { "name": "expected_revision", "schema": { "kind": "u64" } }], "kind": "record" }, outcomeSchemas: { "VerificationUpdateMissing": { "fields": [], "kind": "record" }, "VerificationUpdateStale": { "fields": [], "kind": "record" }, "VerificationUpdated": { "fields": [], "kind": "record" } }, decodeError: decodeApplicationError };
|
|
926
|
+
}
|
|
927
|
+
export class RiffDBBetterAuthCoreClient {
|
|
928
|
+
transport;
|
|
929
|
+
commandAttemptBudget;
|
|
930
|
+
trackCausalWrites;
|
|
931
|
+
lastCommitSeq;
|
|
932
|
+
constructor(transport, commandAttemptBudget = DEFAULT_COMMAND_ATTEMPT_BUDGET, defaultReadAfterCommit, trackCausalWrites = true) {
|
|
933
|
+
this.transport = transport;
|
|
934
|
+
this.commandAttemptBudget = commandAttemptBudget;
|
|
935
|
+
this.trackCausalWrites = trackCausalWrites;
|
|
936
|
+
if (!Number.isInteger(commandAttemptBudget) || commandAttemptBudget < 1)
|
|
937
|
+
throw new Error("invalid command attempt budget");
|
|
938
|
+
if (defaultReadAfterCommit !== undefined && defaultReadAfterCommit < 0n)
|
|
939
|
+
throw new Error("invalid read-after-commit sequence");
|
|
940
|
+
this.lastCommitSeq = defaultReadAfterCommit;
|
|
941
|
+
}
|
|
942
|
+
static fromTransport(transport, commandAttemptBudget = DEFAULT_COMMAND_ATTEMPT_BUDGET) {
|
|
943
|
+
return new RiffDBBetterAuthCoreClient(transport, commandAttemptBudget);
|
|
944
|
+
}
|
|
945
|
+
static driverIdentity(role, database) {
|
|
946
|
+
return driverIdentity(role, database);
|
|
947
|
+
}
|
|
948
|
+
static async connect(driver, options) {
|
|
949
|
+
const identity = driverIdentity(options.role, options.database);
|
|
950
|
+
const transport = typeof driver === "function" ? await driver({ socketPath: options.socketPath, identity }) : await driver.connect({ socketPath: options.socketPath, identity });
|
|
951
|
+
return new RiffDBBetterAuthCoreClient(transport, options.commandAttemptBudget ?? DEFAULT_COMMAND_ATTEMPT_BUDGET);
|
|
952
|
+
}
|
|
953
|
+
static async connectFromEnv(driver, options = {}) {
|
|
954
|
+
const { commandAttemptBudget, ...envOptions } = options;
|
|
955
|
+
const connectInput = { ...envOptions, identity: CONTRACT_DRIVER_IDENTITY };
|
|
956
|
+
const transport = typeof driver === "function" ? await driver(connectInput) : await driver.connectFromEnv(connectInput);
|
|
957
|
+
return new RiffDBBetterAuthCoreClient(transport, commandAttemptBudget ?? DEFAULT_COMMAND_ATTEMPT_BUDGET);
|
|
958
|
+
}
|
|
959
|
+
withReadAfterCommit(commitSequence) {
|
|
960
|
+
return new RiffDBBetterAuthCoreClient(this.transport, this.commandAttemptBudget, commitSequence, this.trackCausalWrites);
|
|
961
|
+
}
|
|
962
|
+
causalSession(initialCommitSequence) {
|
|
963
|
+
return new RiffDBBetterAuthCoreClient(this.transport, this.commandAttemptBudget, initialCommitSequence ?? this.lastCommitSeq, true);
|
|
964
|
+
}
|
|
965
|
+
get lastCommitSequence() {
|
|
966
|
+
return this.lastCommitSeq;
|
|
967
|
+
}
|
|
968
|
+
async adminUsersAllEmailAsc(parameters, options = {}) {
|
|
969
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
970
|
+
const request = adminUsersAllEmailAsc(parameters);
|
|
971
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
972
|
+
if (!acceptsIdentity(request, result.identity))
|
|
973
|
+
throw new Error("RiffDB application identity mismatch");
|
|
974
|
+
return result;
|
|
975
|
+
}
|
|
976
|
+
async adminUsersAllEmailAscAfterCommit(parameters, commitSequence, options = {}) {
|
|
977
|
+
return this.adminUsersAllEmailAsc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
978
|
+
}
|
|
979
|
+
async adminUsersContainsAsc(parameters, options = {}) {
|
|
980
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
981
|
+
const request = adminUsersContainsAsc(parameters);
|
|
982
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
983
|
+
if (!acceptsIdentity(request, result.identity))
|
|
984
|
+
throw new Error("RiffDB application identity mismatch");
|
|
985
|
+
return result;
|
|
986
|
+
}
|
|
987
|
+
async adminUsersContainsAscAfterCommit(parameters, commitSequence, options = {}) {
|
|
988
|
+
return this.adminUsersContainsAsc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
989
|
+
}
|
|
990
|
+
async adminUsersContainsDesc(parameters, options = {}) {
|
|
991
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
992
|
+
const request = adminUsersContainsDesc(parameters);
|
|
993
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
994
|
+
if (!acceptsIdentity(request, result.identity))
|
|
995
|
+
throw new Error("RiffDB application identity mismatch");
|
|
996
|
+
return result;
|
|
997
|
+
}
|
|
998
|
+
async adminUsersContainsDescAfterCommit(parameters, commitSequence, options = {}) {
|
|
999
|
+
return this.adminUsersContainsDesc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1000
|
+
}
|
|
1001
|
+
async adminUsersEmailContainsCreatedDesc(parameters, options = {}) {
|
|
1002
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1003
|
+
const request = adminUsersEmailContainsCreatedDesc(parameters);
|
|
1004
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1005
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1006
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1007
|
+
return result;
|
|
1008
|
+
}
|
|
1009
|
+
async adminUsersEmailContainsCreatedDescAfterCommit(parameters, commitSequence, options = {}) {
|
|
1010
|
+
return this.adminUsersEmailContainsCreatedDesc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1011
|
+
}
|
|
1012
|
+
async adminUsersEmailContainsImageAsc(parameters, options = {}) {
|
|
1013
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1014
|
+
const request = adminUsersEmailContainsImageAsc(parameters);
|
|
1015
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1016
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1017
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1018
|
+
return result;
|
|
1019
|
+
}
|
|
1020
|
+
async adminUsersEmailContainsImageAscAfterCommit(parameters, commitSequence, options = {}) {
|
|
1021
|
+
return this.adminUsersEmailContainsImageAsc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1022
|
+
}
|
|
1023
|
+
async adminUsersEndsWithAsc(parameters, options = {}) {
|
|
1024
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1025
|
+
const request = adminUsersEndsWithAsc(parameters);
|
|
1026
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1027
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1028
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
async adminUsersEndsWithAscAfterCommit(parameters, commitSequence, options = {}) {
|
|
1032
|
+
return this.adminUsersEndsWithAsc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1033
|
+
}
|
|
1034
|
+
async adminUsersEndsWithDesc(parameters, options = {}) {
|
|
1035
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1036
|
+
const request = adminUsersEndsWithDesc(parameters);
|
|
1037
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1038
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1039
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1040
|
+
return result;
|
|
1041
|
+
}
|
|
1042
|
+
async adminUsersEndsWithDescAfterCommit(parameters, commitSequence, options = {}) {
|
|
1043
|
+
return this.adminUsersEndsWithDesc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1044
|
+
}
|
|
1045
|
+
async adminUsersStartsWithAsc(parameters, options = {}) {
|
|
1046
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1047
|
+
const request = adminUsersStartsWithAsc(parameters);
|
|
1048
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1049
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1050
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1051
|
+
return result;
|
|
1052
|
+
}
|
|
1053
|
+
async adminUsersStartsWithAscAfterCommit(parameters, commitSequence, options = {}) {
|
|
1054
|
+
return this.adminUsersStartsWithAsc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1055
|
+
}
|
|
1056
|
+
async adminUsersStartsWithDesc(parameters, options = {}) {
|
|
1057
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1058
|
+
const request = adminUsersStartsWithDesc(parameters);
|
|
1059
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1060
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1061
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1062
|
+
return result;
|
|
1063
|
+
}
|
|
1064
|
+
async adminUsersStartsWithDescAfterCommit(parameters, commitSequence, options = {}) {
|
|
1065
|
+
return this.adminUsersStartsWithDesc(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1066
|
+
}
|
|
1067
|
+
async findAccountById(parameters, options = {}) {
|
|
1068
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1069
|
+
const request = findAccountById(parameters);
|
|
1070
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1071
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1072
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1073
|
+
return result;
|
|
1074
|
+
}
|
|
1075
|
+
async findAccountByIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1076
|
+
return this.findAccountById(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1077
|
+
}
|
|
1078
|
+
async findAccountByProvider(parameters, options = {}) {
|
|
1079
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1080
|
+
const request = findAccountByProvider(parameters);
|
|
1081
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1082
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1083
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1084
|
+
return result;
|
|
1085
|
+
}
|
|
1086
|
+
async findAccountByProviderAfterCommit(parameters, commitSequence, options = {}) {
|
|
1087
|
+
return this.findAccountByProvider(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1088
|
+
}
|
|
1089
|
+
async findAccountsByUserId(parameters, options = {}) {
|
|
1090
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1091
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1092
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1093
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1094
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1095
|
+
const request = findAccountsByUserId(routedParameters);
|
|
1096
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1097
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1098
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1099
|
+
return result;
|
|
1100
|
+
}
|
|
1101
|
+
async findAccountsByUserIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1102
|
+
return this.findAccountsByUserId(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1103
|
+
}
|
|
1104
|
+
async *findAccountsByUserIdPages(parameters, maxPages = 64, options = {}) {
|
|
1105
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1106
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1107
|
+
let currentParameters = parameters;
|
|
1108
|
+
let currentOptions = options;
|
|
1109
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1110
|
+
const page = await this.findAccountsByUserId(currentParameters, currentOptions);
|
|
1111
|
+
yield page;
|
|
1112
|
+
if (page.nextCursor === undefined)
|
|
1113
|
+
return;
|
|
1114
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1115
|
+
currentParameters = restParameters;
|
|
1116
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
async findAccountsByUserProvider(parameters, options = {}) {
|
|
1120
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1121
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1122
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1123
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1124
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1125
|
+
const request = findAccountsByUserProvider(routedParameters);
|
|
1126
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1127
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1128
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1129
|
+
return result;
|
|
1130
|
+
}
|
|
1131
|
+
async findAccountsByUserProviderAfterCommit(parameters, commitSequence, options = {}) {
|
|
1132
|
+
return this.findAccountsByUserProvider(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1133
|
+
}
|
|
1134
|
+
async *findAccountsByUserProviderPages(parameters, maxPages = 64, options = {}) {
|
|
1135
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1136
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1137
|
+
let currentParameters = parameters;
|
|
1138
|
+
let currentOptions = options;
|
|
1139
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1140
|
+
const page = await this.findAccountsByUserProvider(currentParameters, currentOptions);
|
|
1141
|
+
yield page;
|
|
1142
|
+
if (page.nextCursor === undefined)
|
|
1143
|
+
return;
|
|
1144
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1145
|
+
currentParameters = restParameters;
|
|
1146
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
async findActiveSessionsByUserId(parameters, options = {}) {
|
|
1150
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1151
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1152
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1153
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1154
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1155
|
+
const request = findActiveSessionsByUserId(routedParameters);
|
|
1156
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1157
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1158
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1159
|
+
return result;
|
|
1160
|
+
}
|
|
1161
|
+
async findActiveSessionsByUserIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1162
|
+
return this.findActiveSessionsByUserId(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1163
|
+
}
|
|
1164
|
+
async *findActiveSessionsByUserIdPages(parameters, maxPages = 64, options = {}) {
|
|
1165
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1166
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1167
|
+
let currentParameters = parameters;
|
|
1168
|
+
let currentOptions = options;
|
|
1169
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1170
|
+
const page = await this.findActiveSessionsByUserId(currentParameters, currentOptions);
|
|
1171
|
+
yield page;
|
|
1172
|
+
if (page.nextCursor === undefined)
|
|
1173
|
+
return;
|
|
1174
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1175
|
+
currentParameters = restParameters;
|
|
1176
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
async findCredentialAccount(parameters, options = {}) {
|
|
1180
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1181
|
+
const request = findCredentialAccount(parameters);
|
|
1182
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1183
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1184
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1185
|
+
return result;
|
|
1186
|
+
}
|
|
1187
|
+
async findCredentialAccountAfterCommit(parameters, commitSequence, options = {}) {
|
|
1188
|
+
return this.findCredentialAccount(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1189
|
+
}
|
|
1190
|
+
async findExpiredVerificationIds(parameters, options = {}) {
|
|
1191
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1192
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1193
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1194
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1195
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1196
|
+
const request = findExpiredVerificationIds(routedParameters);
|
|
1197
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1198
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1199
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1200
|
+
return result;
|
|
1201
|
+
}
|
|
1202
|
+
async findExpiredVerificationIdsAfterCommit(parameters, commitSequence, options = {}) {
|
|
1203
|
+
return this.findExpiredVerificationIds(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1204
|
+
}
|
|
1205
|
+
async *findExpiredVerificationIdsPages(parameters, maxPages = 64, options = {}) {
|
|
1206
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1207
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1208
|
+
let currentParameters = parameters;
|
|
1209
|
+
let currentOptions = options;
|
|
1210
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1211
|
+
const page = await this.findExpiredVerificationIds(currentParameters, currentOptions);
|
|
1212
|
+
yield page;
|
|
1213
|
+
if (page.nextCursor === undefined)
|
|
1214
|
+
return;
|
|
1215
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1216
|
+
currentParameters = restParameters;
|
|
1217
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
async findLatestVerification(parameters, options = {}) {
|
|
1221
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1222
|
+
const request = findLatestVerification(parameters);
|
|
1223
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1224
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1225
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1226
|
+
return result;
|
|
1227
|
+
}
|
|
1228
|
+
async findLatestVerificationAfterCommit(parameters, commitSequence, options = {}) {
|
|
1229
|
+
return this.findLatestVerification(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1230
|
+
}
|
|
1231
|
+
async findSessionById(parameters, options = {}) {
|
|
1232
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1233
|
+
const request = findSessionById(parameters);
|
|
1234
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1235
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1236
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1237
|
+
return result;
|
|
1238
|
+
}
|
|
1239
|
+
async findSessionByIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1240
|
+
return this.findSessionById(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1241
|
+
}
|
|
1242
|
+
async findSessionByToken(parameters, options = {}) {
|
|
1243
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1244
|
+
const request = findSessionByToken(parameters);
|
|
1245
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1246
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1247
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1248
|
+
return result;
|
|
1249
|
+
}
|
|
1250
|
+
async findSessionByTokenAfterCommit(parameters, commitSequence, options = {}) {
|
|
1251
|
+
return this.findSessionByToken(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1252
|
+
}
|
|
1253
|
+
async findSessionsByTokenSet(parameters, options = {}) {
|
|
1254
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1255
|
+
const request = findSessionsByTokenSet(parameters);
|
|
1256
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1257
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1258
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1259
|
+
return result;
|
|
1260
|
+
}
|
|
1261
|
+
async findSessionsByTokenSetAfterCommit(parameters, commitSequence, options = {}) {
|
|
1262
|
+
return this.findSessionsByTokenSet(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1263
|
+
}
|
|
1264
|
+
async findSessionsByTokenSetAll(parameters, maxPages = 64, options = {}) {
|
|
1265
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1266
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1267
|
+
if (options.cursor !== undefined)
|
|
1268
|
+
throw new Error("findSessionsByTokenSetAll does not accept an initial cursor");
|
|
1269
|
+
const items = Array.from(new Set(parameters.tokens));
|
|
1270
|
+
if (items.length === 0)
|
|
1271
|
+
throw new RangeError("tokens must contain at least 1 item");
|
|
1272
|
+
const merged = [];
|
|
1273
|
+
let latestIdentity;
|
|
1274
|
+
let pinnedHead = options.readAfterCommit ?? this.lastCommitSeq;
|
|
1275
|
+
let highestHead = 0n;
|
|
1276
|
+
let pagesRemaining = maxPages;
|
|
1277
|
+
for (let offset = 0; offset < items.length; offset += FIND_SESSIONS_BY_TOKEN_SET_TOKENS_MAX_ITEMS) {
|
|
1278
|
+
const chunk = items.slice(offset, offset + FIND_SESSIONS_BY_TOKEN_SET_TOKENS_MAX_ITEMS);
|
|
1279
|
+
let chunkCursor = undefined;
|
|
1280
|
+
while (true) {
|
|
1281
|
+
if (pagesRemaining < 1)
|
|
1282
|
+
throw new RangeError("findSessionsByTokenSetAll exceeded maxPages (1..=1024)");
|
|
1283
|
+
pagesRemaining -= 1;
|
|
1284
|
+
const chunkOptions = { ...options, ...(pinnedHead === undefined ? {} : { readAfterCommit: pinnedHead }), ...(chunkCursor === undefined ? {} : { cursor: chunkCursor }) };
|
|
1285
|
+
const page = await this.findSessionsByTokenSet({ ...parameters, tokens: chunk }, chunkOptions);
|
|
1286
|
+
const found = unwrapFindSessionsByTokenSetFound(page);
|
|
1287
|
+
merged.push(...found.sessions);
|
|
1288
|
+
latestIdentity = page.identity;
|
|
1289
|
+
if (page.applicationHead > highestHead)
|
|
1290
|
+
highestHead = page.applicationHead;
|
|
1291
|
+
if (pinnedHead === undefined || page.applicationHead > pinnedHead)
|
|
1292
|
+
pinnedHead = page.applicationHead;
|
|
1293
|
+
if (page.nextCursor === undefined)
|
|
1294
|
+
break;
|
|
1295
|
+
chunkCursor = page.nextCursor;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
return { identity: latestIdentity, value: { outcome: "Found", sessions: merged }, applicationHead: highestHead };
|
|
1299
|
+
}
|
|
1300
|
+
async findSessionsByUserId(parameters, options = {}) {
|
|
1301
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1302
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1303
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1304
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1305
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1306
|
+
const request = findSessionsByUserId(routedParameters);
|
|
1307
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1308
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1309
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1310
|
+
return result;
|
|
1311
|
+
}
|
|
1312
|
+
async findSessionsByUserIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1313
|
+
return this.findSessionsByUserId(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1314
|
+
}
|
|
1315
|
+
async *findSessionsByUserIdPages(parameters, maxPages = 64, options = {}) {
|
|
1316
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1317
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1318
|
+
let currentParameters = parameters;
|
|
1319
|
+
let currentOptions = options;
|
|
1320
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1321
|
+
const page = await this.findSessionsByUserId(currentParameters, currentOptions);
|
|
1322
|
+
yield page;
|
|
1323
|
+
if (page.nextCursor === undefined)
|
|
1324
|
+
return;
|
|
1325
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1326
|
+
currentParameters = restParameters;
|
|
1327
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
async findUserByEmail(parameters, options = {}) {
|
|
1331
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1332
|
+
const request = findUserByEmail(parameters);
|
|
1333
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1334
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1335
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1336
|
+
return result;
|
|
1337
|
+
}
|
|
1338
|
+
async findUserByEmailAfterCommit(parameters, commitSequence, options = {}) {
|
|
1339
|
+
return this.findUserByEmail(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1340
|
+
}
|
|
1341
|
+
async findUserById(parameters, options = {}) {
|
|
1342
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1343
|
+
const request = findUserById(parameters);
|
|
1344
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1345
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1346
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1347
|
+
return result;
|
|
1348
|
+
}
|
|
1349
|
+
async findUserByIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1350
|
+
return this.findUserById(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1351
|
+
}
|
|
1352
|
+
async findVerificationById(parameters, options = {}) {
|
|
1353
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1354
|
+
const request = findVerificationById(parameters);
|
|
1355
|
+
const result = await this.transport.executeNamedQuery(request, effectiveOptions);
|
|
1356
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1357
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1358
|
+
return result;
|
|
1359
|
+
}
|
|
1360
|
+
async findVerificationByIdAfterCommit(parameters, commitSequence, options = {}) {
|
|
1361
|
+
return this.findVerificationById(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1362
|
+
}
|
|
1363
|
+
async findVerificationsByIdentifier(parameters, options = {}) {
|
|
1364
|
+
const effectiveOptions = this.lastCommitSeq !== undefined && options.readAfterCommit === undefined ? { ...options, readAfterCommit: this.lastCommitSeq } : options;
|
|
1365
|
+
const { after: generatedCursor, ...routedParameters } = parameters;
|
|
1366
|
+
if (generatedCursor != null && options.cursor !== undefined)
|
|
1367
|
+
throw new Error("generated cursor conflicts with query options");
|
|
1368
|
+
const routedOptions = generatedCursor == null ? effectiveOptions : { ...effectiveOptions, cursor: generatedCursor };
|
|
1369
|
+
const request = findVerificationsByIdentifier(routedParameters);
|
|
1370
|
+
const result = await this.transport.executeNamedQuery(request, routedOptions);
|
|
1371
|
+
if (!acceptsIdentity(request, result.identity))
|
|
1372
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1373
|
+
return result;
|
|
1374
|
+
}
|
|
1375
|
+
async findVerificationsByIdentifierAfterCommit(parameters, commitSequence, options = {}) {
|
|
1376
|
+
return this.findVerificationsByIdentifier(parameters, { ...options, readAfterCommit: commitSequence });
|
|
1377
|
+
}
|
|
1378
|
+
async *findVerificationsByIdentifierPages(parameters, maxPages = 64, options = {}) {
|
|
1379
|
+
if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1024)
|
|
1380
|
+
throw new RangeError("maxPages must be an integer from 1 through 1024");
|
|
1381
|
+
let currentParameters = parameters;
|
|
1382
|
+
let currentOptions = options;
|
|
1383
|
+
for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {
|
|
1384
|
+
const page = await this.findVerificationsByIdentifier(currentParameters, currentOptions);
|
|
1385
|
+
yield page;
|
|
1386
|
+
if (page.nextCursor === undefined)
|
|
1387
|
+
return;
|
|
1388
|
+
const { after: _ignoredCursor, ...restParameters } = currentParameters;
|
|
1389
|
+
currentParameters = restParameters;
|
|
1390
|
+
currentOptions = { ...currentOptions, cursor: page.nextCursor };
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
async consumeVerification(input) {
|
|
1394
|
+
const result = await this.transport.executeCommand(consumeVerification(input), this.commandAttemptBudget);
|
|
1395
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CONSUME_VERIFICATION_PLAN_HASH)
|
|
1396
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1397
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1398
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1399
|
+
}
|
|
1400
|
+
return result;
|
|
1401
|
+
}
|
|
1402
|
+
async consumeVerificationBatch(inputs, options) {
|
|
1403
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1404
|
+
throw new Error("invalid command batch bounds");
|
|
1405
|
+
const start = options.checkpoint ?? 0;
|
|
1406
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1407
|
+
throw new Error("invalid command batch checkpoint");
|
|
1408
|
+
if (start === inputs.length)
|
|
1409
|
+
return { items: [], checkpoint: start };
|
|
1410
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1411
|
+
const normalizedInputs = inputs.map((input) => consumeVerification(input).input);
|
|
1412
|
+
const result = await this.transport.executeCommandBatch(consumeVerification(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1413
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1414
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CONSUME_VERIFICATION_PLAN_HASH)
|
|
1415
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1416
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1417
|
+
} return item; });
|
|
1418
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1419
|
+
return { items, checkpoint: result.checkpoint };
|
|
1420
|
+
}
|
|
1421
|
+
const items = [];
|
|
1422
|
+
let next = start;
|
|
1423
|
+
let completed = start;
|
|
1424
|
+
let checkpoint = start;
|
|
1425
|
+
const completedAfterCheckpoint = new Set();
|
|
1426
|
+
const worker = async () => { while (true) {
|
|
1427
|
+
const index = next++;
|
|
1428
|
+
if (index >= inputs.length)
|
|
1429
|
+
return;
|
|
1430
|
+
try {
|
|
1431
|
+
items.push({ index, result: await this.consumeVerification(inputs[index]) });
|
|
1432
|
+
}
|
|
1433
|
+
catch (error) {
|
|
1434
|
+
items.push({ index, error });
|
|
1435
|
+
}
|
|
1436
|
+
completed += 1;
|
|
1437
|
+
completedAfterCheckpoint.add(index);
|
|
1438
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1439
|
+
checkpoint += 1;
|
|
1440
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1441
|
+
} };
|
|
1442
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1443
|
+
items.sort((left, right) => left.index - right.index);
|
|
1444
|
+
return { items, checkpoint };
|
|
1445
|
+
}
|
|
1446
|
+
async consumeVerificationSet(input) {
|
|
1447
|
+
const result = await this.transport.executeCommand(consumeVerificationSet(input), this.commandAttemptBudget);
|
|
1448
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CONSUME_VERIFICATION_SET_PLAN_HASH)
|
|
1449
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1450
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1451
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1452
|
+
}
|
|
1453
|
+
return result;
|
|
1454
|
+
}
|
|
1455
|
+
async consumeVerificationSetBatch(inputs, options) {
|
|
1456
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1457
|
+
throw new Error("invalid command batch bounds");
|
|
1458
|
+
const start = options.checkpoint ?? 0;
|
|
1459
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1460
|
+
throw new Error("invalid command batch checkpoint");
|
|
1461
|
+
if (start === inputs.length)
|
|
1462
|
+
return { items: [], checkpoint: start };
|
|
1463
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1464
|
+
const normalizedInputs = inputs.map((input) => consumeVerificationSet(input).input);
|
|
1465
|
+
const result = await this.transport.executeCommandBatch(consumeVerificationSet(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1466
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1467
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CONSUME_VERIFICATION_SET_PLAN_HASH)
|
|
1468
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1469
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1470
|
+
} return item; });
|
|
1471
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1472
|
+
return { items, checkpoint: result.checkpoint };
|
|
1473
|
+
}
|
|
1474
|
+
const items = [];
|
|
1475
|
+
let next = start;
|
|
1476
|
+
let completed = start;
|
|
1477
|
+
let checkpoint = start;
|
|
1478
|
+
const completedAfterCheckpoint = new Set();
|
|
1479
|
+
const worker = async () => { while (true) {
|
|
1480
|
+
const index = next++;
|
|
1481
|
+
if (index >= inputs.length)
|
|
1482
|
+
return;
|
|
1483
|
+
try {
|
|
1484
|
+
items.push({ index, result: await this.consumeVerificationSet(inputs[index]) });
|
|
1485
|
+
}
|
|
1486
|
+
catch (error) {
|
|
1487
|
+
items.push({ index, error });
|
|
1488
|
+
}
|
|
1489
|
+
completed += 1;
|
|
1490
|
+
completedAfterCheckpoint.add(index);
|
|
1491
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1492
|
+
checkpoint += 1;
|
|
1493
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1494
|
+
} };
|
|
1495
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1496
|
+
items.sort((left, right) => left.index - right.index);
|
|
1497
|
+
return { items, checkpoint };
|
|
1498
|
+
}
|
|
1499
|
+
async consumeVerificationSnapshot(input) {
|
|
1500
|
+
const result = await this.transport.executeCommand(consumeVerificationSnapshot(input), this.commandAttemptBudget);
|
|
1501
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CONSUME_VERIFICATION_SNAPSHOT_PLAN_HASH)
|
|
1502
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1503
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1504
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1505
|
+
}
|
|
1506
|
+
return result;
|
|
1507
|
+
}
|
|
1508
|
+
async consumeVerificationSnapshotBatch(inputs, options) {
|
|
1509
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1510
|
+
throw new Error("invalid command batch bounds");
|
|
1511
|
+
const start = options.checkpoint ?? 0;
|
|
1512
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1513
|
+
throw new Error("invalid command batch checkpoint");
|
|
1514
|
+
if (start === inputs.length)
|
|
1515
|
+
return { items: [], checkpoint: start };
|
|
1516
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1517
|
+
const normalizedInputs = inputs.map((input) => consumeVerificationSnapshot(input).input);
|
|
1518
|
+
const result = await this.transport.executeCommandBatch(consumeVerificationSnapshot(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1519
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1520
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CONSUME_VERIFICATION_SNAPSHOT_PLAN_HASH)
|
|
1521
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1522
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1523
|
+
} return item; });
|
|
1524
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1525
|
+
return { items, checkpoint: result.checkpoint };
|
|
1526
|
+
}
|
|
1527
|
+
const items = [];
|
|
1528
|
+
let next = start;
|
|
1529
|
+
let completed = start;
|
|
1530
|
+
let checkpoint = start;
|
|
1531
|
+
const completedAfterCheckpoint = new Set();
|
|
1532
|
+
const worker = async () => { while (true) {
|
|
1533
|
+
const index = next++;
|
|
1534
|
+
if (index >= inputs.length)
|
|
1535
|
+
return;
|
|
1536
|
+
try {
|
|
1537
|
+
items.push({ index, result: await this.consumeVerificationSnapshot(inputs[index]) });
|
|
1538
|
+
}
|
|
1539
|
+
catch (error) {
|
|
1540
|
+
items.push({ index, error });
|
|
1541
|
+
}
|
|
1542
|
+
completed += 1;
|
|
1543
|
+
completedAfterCheckpoint.add(index);
|
|
1544
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1545
|
+
checkpoint += 1;
|
|
1546
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1547
|
+
} };
|
|
1548
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1549
|
+
items.sort((left, right) => left.index - right.index);
|
|
1550
|
+
return { items, checkpoint };
|
|
1551
|
+
}
|
|
1552
|
+
async createAccount(input) {
|
|
1553
|
+
const result = await this.transport.executeCommand(createAccount(input), this.commandAttemptBudget);
|
|
1554
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_ACCOUNT_PLAN_HASH)
|
|
1555
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1556
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1557
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1558
|
+
}
|
|
1559
|
+
return result;
|
|
1560
|
+
}
|
|
1561
|
+
async createAccountBatch(inputs, options) {
|
|
1562
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1563
|
+
throw new Error("invalid command batch bounds");
|
|
1564
|
+
const start = options.checkpoint ?? 0;
|
|
1565
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1566
|
+
throw new Error("invalid command batch checkpoint");
|
|
1567
|
+
if (start === inputs.length)
|
|
1568
|
+
return { items: [], checkpoint: start };
|
|
1569
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1570
|
+
const normalizedInputs = inputs.map((input) => createAccount(input).input);
|
|
1571
|
+
const result = await this.transport.executeCommandBatch(createAccount(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1572
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1573
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_ACCOUNT_PLAN_HASH)
|
|
1574
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1575
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1576
|
+
} return item; });
|
|
1577
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1578
|
+
return { items, checkpoint: result.checkpoint };
|
|
1579
|
+
}
|
|
1580
|
+
const items = [];
|
|
1581
|
+
let next = start;
|
|
1582
|
+
let completed = start;
|
|
1583
|
+
let checkpoint = start;
|
|
1584
|
+
const completedAfterCheckpoint = new Set();
|
|
1585
|
+
const worker = async () => { while (true) {
|
|
1586
|
+
const index = next++;
|
|
1587
|
+
if (index >= inputs.length)
|
|
1588
|
+
return;
|
|
1589
|
+
try {
|
|
1590
|
+
items.push({ index, result: await this.createAccount(inputs[index]) });
|
|
1591
|
+
}
|
|
1592
|
+
catch (error) {
|
|
1593
|
+
items.push({ index, error });
|
|
1594
|
+
}
|
|
1595
|
+
completed += 1;
|
|
1596
|
+
completedAfterCheckpoint.add(index);
|
|
1597
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1598
|
+
checkpoint += 1;
|
|
1599
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1600
|
+
} };
|
|
1601
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1602
|
+
items.sort((left, right) => left.index - right.index);
|
|
1603
|
+
return { items, checkpoint };
|
|
1604
|
+
}
|
|
1605
|
+
async createOAuthUserGraph(input) {
|
|
1606
|
+
const result = await this.transport.executeCommand(createOAuthUserGraph(input), this.commandAttemptBudget);
|
|
1607
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_O_AUTH_USER_GRAPH_PLAN_HASH)
|
|
1608
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1609
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1610
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1611
|
+
}
|
|
1612
|
+
return result;
|
|
1613
|
+
}
|
|
1614
|
+
async createOAuthUserGraphBatch(inputs, options) {
|
|
1615
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1616
|
+
throw new Error("invalid command batch bounds");
|
|
1617
|
+
const start = options.checkpoint ?? 0;
|
|
1618
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1619
|
+
throw new Error("invalid command batch checkpoint");
|
|
1620
|
+
if (start === inputs.length)
|
|
1621
|
+
return { items: [], checkpoint: start };
|
|
1622
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1623
|
+
const normalizedInputs = inputs.map((input) => createOAuthUserGraph(input).input);
|
|
1624
|
+
const result = await this.transport.executeCommandBatch(createOAuthUserGraph(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1625
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1626
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_O_AUTH_USER_GRAPH_PLAN_HASH)
|
|
1627
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1628
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1629
|
+
} return item; });
|
|
1630
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1631
|
+
return { items, checkpoint: result.checkpoint };
|
|
1632
|
+
}
|
|
1633
|
+
const items = [];
|
|
1634
|
+
let next = start;
|
|
1635
|
+
let completed = start;
|
|
1636
|
+
let checkpoint = start;
|
|
1637
|
+
const completedAfterCheckpoint = new Set();
|
|
1638
|
+
const worker = async () => { while (true) {
|
|
1639
|
+
const index = next++;
|
|
1640
|
+
if (index >= inputs.length)
|
|
1641
|
+
return;
|
|
1642
|
+
try {
|
|
1643
|
+
items.push({ index, result: await this.createOAuthUserGraph(inputs[index]) });
|
|
1644
|
+
}
|
|
1645
|
+
catch (error) {
|
|
1646
|
+
items.push({ index, error });
|
|
1647
|
+
}
|
|
1648
|
+
completed += 1;
|
|
1649
|
+
completedAfterCheckpoint.add(index);
|
|
1650
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1651
|
+
checkpoint += 1;
|
|
1652
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1653
|
+
} };
|
|
1654
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1655
|
+
items.sort((left, right) => left.index - right.index);
|
|
1656
|
+
return { items, checkpoint };
|
|
1657
|
+
}
|
|
1658
|
+
async createSession(input) {
|
|
1659
|
+
const result = await this.transport.executeCommand(createSession(input), this.commandAttemptBudget);
|
|
1660
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_SESSION_PLAN_HASH)
|
|
1661
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1662
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1663
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1664
|
+
}
|
|
1665
|
+
return result;
|
|
1666
|
+
}
|
|
1667
|
+
async createSessionBatch(inputs, options) {
|
|
1668
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1669
|
+
throw new Error("invalid command batch bounds");
|
|
1670
|
+
const start = options.checkpoint ?? 0;
|
|
1671
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1672
|
+
throw new Error("invalid command batch checkpoint");
|
|
1673
|
+
if (start === inputs.length)
|
|
1674
|
+
return { items: [], checkpoint: start };
|
|
1675
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1676
|
+
const normalizedInputs = inputs.map((input) => createSession(input).input);
|
|
1677
|
+
const result = await this.transport.executeCommandBatch(createSession(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1678
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1679
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_SESSION_PLAN_HASH)
|
|
1680
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1681
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1682
|
+
} return item; });
|
|
1683
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1684
|
+
return { items, checkpoint: result.checkpoint };
|
|
1685
|
+
}
|
|
1686
|
+
const items = [];
|
|
1687
|
+
let next = start;
|
|
1688
|
+
let completed = start;
|
|
1689
|
+
let checkpoint = start;
|
|
1690
|
+
const completedAfterCheckpoint = new Set();
|
|
1691
|
+
const worker = async () => { while (true) {
|
|
1692
|
+
const index = next++;
|
|
1693
|
+
if (index >= inputs.length)
|
|
1694
|
+
return;
|
|
1695
|
+
try {
|
|
1696
|
+
items.push({ index, result: await this.createSession(inputs[index]) });
|
|
1697
|
+
}
|
|
1698
|
+
catch (error) {
|
|
1699
|
+
items.push({ index, error });
|
|
1700
|
+
}
|
|
1701
|
+
completed += 1;
|
|
1702
|
+
completedAfterCheckpoint.add(index);
|
|
1703
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1704
|
+
checkpoint += 1;
|
|
1705
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1706
|
+
} };
|
|
1707
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1708
|
+
items.sort((left, right) => left.index - right.index);
|
|
1709
|
+
return { items, checkpoint };
|
|
1710
|
+
}
|
|
1711
|
+
async createSignupGraph(input) {
|
|
1712
|
+
const result = await this.transport.executeCommand(createSignupGraph(input), this.commandAttemptBudget);
|
|
1713
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_SIGNUP_GRAPH_PLAN_HASH)
|
|
1714
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1715
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1716
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1717
|
+
}
|
|
1718
|
+
return result;
|
|
1719
|
+
}
|
|
1720
|
+
async createSignupGraphBatch(inputs, options) {
|
|
1721
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1722
|
+
throw new Error("invalid command batch bounds");
|
|
1723
|
+
const start = options.checkpoint ?? 0;
|
|
1724
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1725
|
+
throw new Error("invalid command batch checkpoint");
|
|
1726
|
+
if (start === inputs.length)
|
|
1727
|
+
return { items: [], checkpoint: start };
|
|
1728
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1729
|
+
const normalizedInputs = inputs.map((input) => createSignupGraph(input).input);
|
|
1730
|
+
const result = await this.transport.executeCommandBatch(createSignupGraph(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1731
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1732
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_SIGNUP_GRAPH_PLAN_HASH)
|
|
1733
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1734
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1735
|
+
} return item; });
|
|
1736
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1737
|
+
return { items, checkpoint: result.checkpoint };
|
|
1738
|
+
}
|
|
1739
|
+
const items = [];
|
|
1740
|
+
let next = start;
|
|
1741
|
+
let completed = start;
|
|
1742
|
+
let checkpoint = start;
|
|
1743
|
+
const completedAfterCheckpoint = new Set();
|
|
1744
|
+
const worker = async () => { while (true) {
|
|
1745
|
+
const index = next++;
|
|
1746
|
+
if (index >= inputs.length)
|
|
1747
|
+
return;
|
|
1748
|
+
try {
|
|
1749
|
+
items.push({ index, result: await this.createSignupGraph(inputs[index]) });
|
|
1750
|
+
}
|
|
1751
|
+
catch (error) {
|
|
1752
|
+
items.push({ index, error });
|
|
1753
|
+
}
|
|
1754
|
+
completed += 1;
|
|
1755
|
+
completedAfterCheckpoint.add(index);
|
|
1756
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1757
|
+
checkpoint += 1;
|
|
1758
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1759
|
+
} };
|
|
1760
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1761
|
+
items.sort((left, right) => left.index - right.index);
|
|
1762
|
+
return { items, checkpoint };
|
|
1763
|
+
}
|
|
1764
|
+
async createUser(input) {
|
|
1765
|
+
const result = await this.transport.executeCommand(createUser(input), this.commandAttemptBudget);
|
|
1766
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_USER_PLAN_HASH)
|
|
1767
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1768
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1769
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1770
|
+
}
|
|
1771
|
+
return result;
|
|
1772
|
+
}
|
|
1773
|
+
async createUserBatch(inputs, options) {
|
|
1774
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1775
|
+
throw new Error("invalid command batch bounds");
|
|
1776
|
+
const start = options.checkpoint ?? 0;
|
|
1777
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1778
|
+
throw new Error("invalid command batch checkpoint");
|
|
1779
|
+
if (start === inputs.length)
|
|
1780
|
+
return { items: [], checkpoint: start };
|
|
1781
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1782
|
+
const normalizedInputs = inputs.map((input) => createUser(input).input);
|
|
1783
|
+
const result = await this.transport.executeCommandBatch(createUser(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1784
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1785
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_USER_PLAN_HASH)
|
|
1786
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1787
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1788
|
+
} return item; });
|
|
1789
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1790
|
+
return { items, checkpoint: result.checkpoint };
|
|
1791
|
+
}
|
|
1792
|
+
const items = [];
|
|
1793
|
+
let next = start;
|
|
1794
|
+
let completed = start;
|
|
1795
|
+
let checkpoint = start;
|
|
1796
|
+
const completedAfterCheckpoint = new Set();
|
|
1797
|
+
const worker = async () => { while (true) {
|
|
1798
|
+
const index = next++;
|
|
1799
|
+
if (index >= inputs.length)
|
|
1800
|
+
return;
|
|
1801
|
+
try {
|
|
1802
|
+
items.push({ index, result: await this.createUser(inputs[index]) });
|
|
1803
|
+
}
|
|
1804
|
+
catch (error) {
|
|
1805
|
+
items.push({ index, error });
|
|
1806
|
+
}
|
|
1807
|
+
completed += 1;
|
|
1808
|
+
completedAfterCheckpoint.add(index);
|
|
1809
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1810
|
+
checkpoint += 1;
|
|
1811
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1812
|
+
} };
|
|
1813
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1814
|
+
items.sort((left, right) => left.index - right.index);
|
|
1815
|
+
return { items, checkpoint };
|
|
1816
|
+
}
|
|
1817
|
+
async createVerification(input) {
|
|
1818
|
+
const result = await this.transport.executeCommand(createVerification(input), this.commandAttemptBudget);
|
|
1819
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== CREATE_VERIFICATION_PLAN_HASH)
|
|
1820
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1821
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1822
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1823
|
+
}
|
|
1824
|
+
return result;
|
|
1825
|
+
}
|
|
1826
|
+
async createVerificationBatch(inputs, options) {
|
|
1827
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1828
|
+
throw new Error("invalid command batch bounds");
|
|
1829
|
+
const start = options.checkpoint ?? 0;
|
|
1830
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1831
|
+
throw new Error("invalid command batch checkpoint");
|
|
1832
|
+
if (start === inputs.length)
|
|
1833
|
+
return { items: [], checkpoint: start };
|
|
1834
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1835
|
+
const normalizedInputs = inputs.map((input) => createVerification(input).input);
|
|
1836
|
+
const result = await this.transport.executeCommandBatch(createVerification(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1837
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1838
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== CREATE_VERIFICATION_PLAN_HASH)
|
|
1839
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1840
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1841
|
+
} return item; });
|
|
1842
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1843
|
+
return { items, checkpoint: result.checkpoint };
|
|
1844
|
+
}
|
|
1845
|
+
const items = [];
|
|
1846
|
+
let next = start;
|
|
1847
|
+
let completed = start;
|
|
1848
|
+
let checkpoint = start;
|
|
1849
|
+
const completedAfterCheckpoint = new Set();
|
|
1850
|
+
const worker = async () => { while (true) {
|
|
1851
|
+
const index = next++;
|
|
1852
|
+
if (index >= inputs.length)
|
|
1853
|
+
return;
|
|
1854
|
+
try {
|
|
1855
|
+
items.push({ index, result: await this.createVerification(inputs[index]) });
|
|
1856
|
+
}
|
|
1857
|
+
catch (error) {
|
|
1858
|
+
items.push({ index, error });
|
|
1859
|
+
}
|
|
1860
|
+
completed += 1;
|
|
1861
|
+
completedAfterCheckpoint.add(index);
|
|
1862
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1863
|
+
checkpoint += 1;
|
|
1864
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1865
|
+
} };
|
|
1866
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1867
|
+
items.sort((left, right) => left.index - right.index);
|
|
1868
|
+
return { items, checkpoint };
|
|
1869
|
+
}
|
|
1870
|
+
async deleteAccount(input) {
|
|
1871
|
+
const result = await this.transport.executeCommand(deleteAccount(input), this.commandAttemptBudget);
|
|
1872
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== DELETE_ACCOUNT_PLAN_HASH)
|
|
1873
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1874
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1875
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1876
|
+
}
|
|
1877
|
+
return result;
|
|
1878
|
+
}
|
|
1879
|
+
async deleteAccountBatch(inputs, options) {
|
|
1880
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1881
|
+
throw new Error("invalid command batch bounds");
|
|
1882
|
+
const start = options.checkpoint ?? 0;
|
|
1883
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1884
|
+
throw new Error("invalid command batch checkpoint");
|
|
1885
|
+
if (start === inputs.length)
|
|
1886
|
+
return { items: [], checkpoint: start };
|
|
1887
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1888
|
+
const normalizedInputs = inputs.map((input) => deleteAccount(input).input);
|
|
1889
|
+
const result = await this.transport.executeCommandBatch(deleteAccount(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1890
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1891
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== DELETE_ACCOUNT_PLAN_HASH)
|
|
1892
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1893
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1894
|
+
} return item; });
|
|
1895
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1896
|
+
return { items, checkpoint: result.checkpoint };
|
|
1897
|
+
}
|
|
1898
|
+
const items = [];
|
|
1899
|
+
let next = start;
|
|
1900
|
+
let completed = start;
|
|
1901
|
+
let checkpoint = start;
|
|
1902
|
+
const completedAfterCheckpoint = new Set();
|
|
1903
|
+
const worker = async () => { while (true) {
|
|
1904
|
+
const index = next++;
|
|
1905
|
+
if (index >= inputs.length)
|
|
1906
|
+
return;
|
|
1907
|
+
try {
|
|
1908
|
+
items.push({ index, result: await this.deleteAccount(inputs[index]) });
|
|
1909
|
+
}
|
|
1910
|
+
catch (error) {
|
|
1911
|
+
items.push({ index, error });
|
|
1912
|
+
}
|
|
1913
|
+
completed += 1;
|
|
1914
|
+
completedAfterCheckpoint.add(index);
|
|
1915
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1916
|
+
checkpoint += 1;
|
|
1917
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1918
|
+
} };
|
|
1919
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1920
|
+
items.sort((left, right) => left.index - right.index);
|
|
1921
|
+
return { items, checkpoint };
|
|
1922
|
+
}
|
|
1923
|
+
async deleteSession(input) {
|
|
1924
|
+
const result = await this.transport.executeCommand(deleteSession(input), this.commandAttemptBudget);
|
|
1925
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== DELETE_SESSION_PLAN_HASH)
|
|
1926
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1927
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1928
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1929
|
+
}
|
|
1930
|
+
return result;
|
|
1931
|
+
}
|
|
1932
|
+
async deleteSessionBatch(inputs, options) {
|
|
1933
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1934
|
+
throw new Error("invalid command batch bounds");
|
|
1935
|
+
const start = options.checkpoint ?? 0;
|
|
1936
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1937
|
+
throw new Error("invalid command batch checkpoint");
|
|
1938
|
+
if (start === inputs.length)
|
|
1939
|
+
return { items: [], checkpoint: start };
|
|
1940
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1941
|
+
const normalizedInputs = inputs.map((input) => deleteSession(input).input);
|
|
1942
|
+
const result = await this.transport.executeCommandBatch(deleteSession(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1943
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1944
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== DELETE_SESSION_PLAN_HASH)
|
|
1945
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1946
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
1947
|
+
} return item; });
|
|
1948
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
1949
|
+
return { items, checkpoint: result.checkpoint };
|
|
1950
|
+
}
|
|
1951
|
+
const items = [];
|
|
1952
|
+
let next = start;
|
|
1953
|
+
let completed = start;
|
|
1954
|
+
let checkpoint = start;
|
|
1955
|
+
const completedAfterCheckpoint = new Set();
|
|
1956
|
+
const worker = async () => { while (true) {
|
|
1957
|
+
const index = next++;
|
|
1958
|
+
if (index >= inputs.length)
|
|
1959
|
+
return;
|
|
1960
|
+
try {
|
|
1961
|
+
items.push({ index, result: await this.deleteSession(inputs[index]) });
|
|
1962
|
+
}
|
|
1963
|
+
catch (error) {
|
|
1964
|
+
items.push({ index, error });
|
|
1965
|
+
}
|
|
1966
|
+
completed += 1;
|
|
1967
|
+
completedAfterCheckpoint.add(index);
|
|
1968
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
1969
|
+
checkpoint += 1;
|
|
1970
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
1971
|
+
} };
|
|
1972
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
1973
|
+
items.sort((left, right) => left.index - right.index);
|
|
1974
|
+
return { items, checkpoint };
|
|
1975
|
+
}
|
|
1976
|
+
async deleteUser(input) {
|
|
1977
|
+
const result = await this.transport.executeCommand(deleteUser(input), this.commandAttemptBudget);
|
|
1978
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== DELETE_USER_PLAN_HASH)
|
|
1979
|
+
throw new Error("RiffDB application identity mismatch");
|
|
1980
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
1981
|
+
this.lastCommitSeq = result.commitSequence;
|
|
1982
|
+
}
|
|
1983
|
+
return result;
|
|
1984
|
+
}
|
|
1985
|
+
async deleteUserBatch(inputs, options) {
|
|
1986
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
1987
|
+
throw new Error("invalid command batch bounds");
|
|
1988
|
+
const start = options.checkpoint ?? 0;
|
|
1989
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
1990
|
+
throw new Error("invalid command batch checkpoint");
|
|
1991
|
+
if (start === inputs.length)
|
|
1992
|
+
return { items: [], checkpoint: start };
|
|
1993
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
1994
|
+
const normalizedInputs = inputs.map((input) => deleteUser(input).input);
|
|
1995
|
+
const result = await this.transport.executeCommandBatch(deleteUser(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
1996
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
1997
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== DELETE_USER_PLAN_HASH)
|
|
1998
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
1999
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2000
|
+
} return item; });
|
|
2001
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2002
|
+
return { items, checkpoint: result.checkpoint };
|
|
2003
|
+
}
|
|
2004
|
+
const items = [];
|
|
2005
|
+
let next = start;
|
|
2006
|
+
let completed = start;
|
|
2007
|
+
let checkpoint = start;
|
|
2008
|
+
const completedAfterCheckpoint = new Set();
|
|
2009
|
+
const worker = async () => { while (true) {
|
|
2010
|
+
const index = next++;
|
|
2011
|
+
if (index >= inputs.length)
|
|
2012
|
+
return;
|
|
2013
|
+
try {
|
|
2014
|
+
items.push({ index, result: await this.deleteUser(inputs[index]) });
|
|
2015
|
+
}
|
|
2016
|
+
catch (error) {
|
|
2017
|
+
items.push({ index, error });
|
|
2018
|
+
}
|
|
2019
|
+
completed += 1;
|
|
2020
|
+
completedAfterCheckpoint.add(index);
|
|
2021
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2022
|
+
checkpoint += 1;
|
|
2023
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2024
|
+
} };
|
|
2025
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2026
|
+
items.sort((left, right) => left.index - right.index);
|
|
2027
|
+
return { items, checkpoint };
|
|
2028
|
+
}
|
|
2029
|
+
async deleteVerification(input) {
|
|
2030
|
+
const result = await this.transport.executeCommand(deleteVerification(input), this.commandAttemptBudget);
|
|
2031
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== DELETE_VERIFICATION_PLAN_HASH)
|
|
2032
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2033
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2034
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2035
|
+
}
|
|
2036
|
+
return result;
|
|
2037
|
+
}
|
|
2038
|
+
async deleteVerificationBatch(inputs, options) {
|
|
2039
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2040
|
+
throw new Error("invalid command batch bounds");
|
|
2041
|
+
const start = options.checkpoint ?? 0;
|
|
2042
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2043
|
+
throw new Error("invalid command batch checkpoint");
|
|
2044
|
+
if (start === inputs.length)
|
|
2045
|
+
return { items: [], checkpoint: start };
|
|
2046
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2047
|
+
const normalizedInputs = inputs.map((input) => deleteVerification(input).input);
|
|
2048
|
+
const result = await this.transport.executeCommandBatch(deleteVerification(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2049
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2050
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== DELETE_VERIFICATION_PLAN_HASH)
|
|
2051
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2052
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2053
|
+
} return item; });
|
|
2054
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2055
|
+
return { items, checkpoint: result.checkpoint };
|
|
2056
|
+
}
|
|
2057
|
+
const items = [];
|
|
2058
|
+
let next = start;
|
|
2059
|
+
let completed = start;
|
|
2060
|
+
let checkpoint = start;
|
|
2061
|
+
const completedAfterCheckpoint = new Set();
|
|
2062
|
+
const worker = async () => { while (true) {
|
|
2063
|
+
const index = next++;
|
|
2064
|
+
if (index >= inputs.length)
|
|
2065
|
+
return;
|
|
2066
|
+
try {
|
|
2067
|
+
items.push({ index, result: await this.deleteVerification(inputs[index]) });
|
|
2068
|
+
}
|
|
2069
|
+
catch (error) {
|
|
2070
|
+
items.push({ index, error });
|
|
2071
|
+
}
|
|
2072
|
+
completed += 1;
|
|
2073
|
+
completedAfterCheckpoint.add(index);
|
|
2074
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2075
|
+
checkpoint += 1;
|
|
2076
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2077
|
+
} };
|
|
2078
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2079
|
+
items.sort((left, right) => left.index - right.index);
|
|
2080
|
+
return { items, checkpoint };
|
|
2081
|
+
}
|
|
2082
|
+
async resetCredentialPassword(input) {
|
|
2083
|
+
const result = await this.transport.executeCommand(resetCredentialPassword(input), this.commandAttemptBudget);
|
|
2084
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== RESET_CREDENTIAL_PASSWORD_PLAN_HASH)
|
|
2085
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2086
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2087
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2088
|
+
}
|
|
2089
|
+
return result;
|
|
2090
|
+
}
|
|
2091
|
+
async resetCredentialPasswordBatch(inputs, options) {
|
|
2092
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2093
|
+
throw new Error("invalid command batch bounds");
|
|
2094
|
+
const start = options.checkpoint ?? 0;
|
|
2095
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2096
|
+
throw new Error("invalid command batch checkpoint");
|
|
2097
|
+
if (start === inputs.length)
|
|
2098
|
+
return { items: [], checkpoint: start };
|
|
2099
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2100
|
+
const normalizedInputs = inputs.map((input) => resetCredentialPassword(input).input);
|
|
2101
|
+
const result = await this.transport.executeCommandBatch(resetCredentialPassword(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2102
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2103
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== RESET_CREDENTIAL_PASSWORD_PLAN_HASH)
|
|
2104
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2105
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2106
|
+
} return item; });
|
|
2107
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2108
|
+
return { items, checkpoint: result.checkpoint };
|
|
2109
|
+
}
|
|
2110
|
+
const items = [];
|
|
2111
|
+
let next = start;
|
|
2112
|
+
let completed = start;
|
|
2113
|
+
let checkpoint = start;
|
|
2114
|
+
const completedAfterCheckpoint = new Set();
|
|
2115
|
+
const worker = async () => { while (true) {
|
|
2116
|
+
const index = next++;
|
|
2117
|
+
if (index >= inputs.length)
|
|
2118
|
+
return;
|
|
2119
|
+
try {
|
|
2120
|
+
items.push({ index, result: await this.resetCredentialPassword(inputs[index]) });
|
|
2121
|
+
}
|
|
2122
|
+
catch (error) {
|
|
2123
|
+
items.push({ index, error });
|
|
2124
|
+
}
|
|
2125
|
+
completed += 1;
|
|
2126
|
+
completedAfterCheckpoint.add(index);
|
|
2127
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2128
|
+
checkpoint += 1;
|
|
2129
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2130
|
+
} };
|
|
2131
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2132
|
+
items.sort((left, right) => left.index - right.index);
|
|
2133
|
+
return { items, checkpoint };
|
|
2134
|
+
}
|
|
2135
|
+
async updateAccount(input) {
|
|
2136
|
+
const result = await this.transport.executeCommand(updateAccount(input), this.commandAttemptBudget);
|
|
2137
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_ACCOUNT_PLAN_HASH)
|
|
2138
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2139
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2140
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2141
|
+
}
|
|
2142
|
+
return result;
|
|
2143
|
+
}
|
|
2144
|
+
async updateAccountBatch(inputs, options) {
|
|
2145
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2146
|
+
throw new Error("invalid command batch bounds");
|
|
2147
|
+
const start = options.checkpoint ?? 0;
|
|
2148
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2149
|
+
throw new Error("invalid command batch checkpoint");
|
|
2150
|
+
if (start === inputs.length)
|
|
2151
|
+
return { items: [], checkpoint: start };
|
|
2152
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2153
|
+
const normalizedInputs = inputs.map((input) => updateAccount(input).input);
|
|
2154
|
+
const result = await this.transport.executeCommandBatch(updateAccount(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2155
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2156
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_ACCOUNT_PLAN_HASH)
|
|
2157
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2158
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2159
|
+
} return item; });
|
|
2160
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2161
|
+
return { items, checkpoint: result.checkpoint };
|
|
2162
|
+
}
|
|
2163
|
+
const items = [];
|
|
2164
|
+
let next = start;
|
|
2165
|
+
let completed = start;
|
|
2166
|
+
let checkpoint = start;
|
|
2167
|
+
const completedAfterCheckpoint = new Set();
|
|
2168
|
+
const worker = async () => { while (true) {
|
|
2169
|
+
const index = next++;
|
|
2170
|
+
if (index >= inputs.length)
|
|
2171
|
+
return;
|
|
2172
|
+
try {
|
|
2173
|
+
items.push({ index, result: await this.updateAccount(inputs[index]) });
|
|
2174
|
+
}
|
|
2175
|
+
catch (error) {
|
|
2176
|
+
items.push({ index, error });
|
|
2177
|
+
}
|
|
2178
|
+
completed += 1;
|
|
2179
|
+
completedAfterCheckpoint.add(index);
|
|
2180
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2181
|
+
checkpoint += 1;
|
|
2182
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2183
|
+
} };
|
|
2184
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2185
|
+
items.sort((left, right) => left.index - right.index);
|
|
2186
|
+
return { items, checkpoint };
|
|
2187
|
+
}
|
|
2188
|
+
async updateAccountPasswords(input) {
|
|
2189
|
+
const result = await this.transport.executeCommand(updateAccountPasswords(input), this.commandAttemptBudget);
|
|
2190
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_ACCOUNT_PASSWORDS_PLAN_HASH)
|
|
2191
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2192
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2193
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2194
|
+
}
|
|
2195
|
+
return result;
|
|
2196
|
+
}
|
|
2197
|
+
async updateAccountPasswordsBatch(inputs, options) {
|
|
2198
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2199
|
+
throw new Error("invalid command batch bounds");
|
|
2200
|
+
const start = options.checkpoint ?? 0;
|
|
2201
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2202
|
+
throw new Error("invalid command batch checkpoint");
|
|
2203
|
+
if (start === inputs.length)
|
|
2204
|
+
return { items: [], checkpoint: start };
|
|
2205
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2206
|
+
const normalizedInputs = inputs.map((input) => updateAccountPasswords(input).input);
|
|
2207
|
+
const result = await this.transport.executeCommandBatch(updateAccountPasswords(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2208
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2209
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_ACCOUNT_PASSWORDS_PLAN_HASH)
|
|
2210
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2211
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2212
|
+
} return item; });
|
|
2213
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2214
|
+
return { items, checkpoint: result.checkpoint };
|
|
2215
|
+
}
|
|
2216
|
+
const items = [];
|
|
2217
|
+
let next = start;
|
|
2218
|
+
let completed = start;
|
|
2219
|
+
let checkpoint = start;
|
|
2220
|
+
const completedAfterCheckpoint = new Set();
|
|
2221
|
+
const worker = async () => { while (true) {
|
|
2222
|
+
const index = next++;
|
|
2223
|
+
if (index >= inputs.length)
|
|
2224
|
+
return;
|
|
2225
|
+
try {
|
|
2226
|
+
items.push({ index, result: await this.updateAccountPasswords(inputs[index]) });
|
|
2227
|
+
}
|
|
2228
|
+
catch (error) {
|
|
2229
|
+
items.push({ index, error });
|
|
2230
|
+
}
|
|
2231
|
+
completed += 1;
|
|
2232
|
+
completedAfterCheckpoint.add(index);
|
|
2233
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2234
|
+
checkpoint += 1;
|
|
2235
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2236
|
+
} };
|
|
2237
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2238
|
+
items.sort((left, right) => left.index - right.index);
|
|
2239
|
+
return { items, checkpoint };
|
|
2240
|
+
}
|
|
2241
|
+
async updateCredentialPassword(input) {
|
|
2242
|
+
const result = await this.transport.executeCommand(updateCredentialPassword(input), this.commandAttemptBudget);
|
|
2243
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_CREDENTIAL_PASSWORD_PLAN_HASH)
|
|
2244
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2245
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2246
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2247
|
+
}
|
|
2248
|
+
return result;
|
|
2249
|
+
}
|
|
2250
|
+
async updateCredentialPasswordBatch(inputs, options) {
|
|
2251
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2252
|
+
throw new Error("invalid command batch bounds");
|
|
2253
|
+
const start = options.checkpoint ?? 0;
|
|
2254
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2255
|
+
throw new Error("invalid command batch checkpoint");
|
|
2256
|
+
if (start === inputs.length)
|
|
2257
|
+
return { items: [], checkpoint: start };
|
|
2258
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2259
|
+
const normalizedInputs = inputs.map((input) => updateCredentialPassword(input).input);
|
|
2260
|
+
const result = await this.transport.executeCommandBatch(updateCredentialPassword(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2261
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2262
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_CREDENTIAL_PASSWORD_PLAN_HASH)
|
|
2263
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2264
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2265
|
+
} return item; });
|
|
2266
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2267
|
+
return { items, checkpoint: result.checkpoint };
|
|
2268
|
+
}
|
|
2269
|
+
const items = [];
|
|
2270
|
+
let next = start;
|
|
2271
|
+
let completed = start;
|
|
2272
|
+
let checkpoint = start;
|
|
2273
|
+
const completedAfterCheckpoint = new Set();
|
|
2274
|
+
const worker = async () => { while (true) {
|
|
2275
|
+
const index = next++;
|
|
2276
|
+
if (index >= inputs.length)
|
|
2277
|
+
return;
|
|
2278
|
+
try {
|
|
2279
|
+
items.push({ index, result: await this.updateCredentialPassword(inputs[index]) });
|
|
2280
|
+
}
|
|
2281
|
+
catch (error) {
|
|
2282
|
+
items.push({ index, error });
|
|
2283
|
+
}
|
|
2284
|
+
completed += 1;
|
|
2285
|
+
completedAfterCheckpoint.add(index);
|
|
2286
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2287
|
+
checkpoint += 1;
|
|
2288
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2289
|
+
} };
|
|
2290
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2291
|
+
items.sort((left, right) => left.index - right.index);
|
|
2292
|
+
return { items, checkpoint };
|
|
2293
|
+
}
|
|
2294
|
+
async updateSession(input) {
|
|
2295
|
+
const result = await this.transport.executeCommand(updateSession(input), this.commandAttemptBudget);
|
|
2296
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_SESSION_PLAN_HASH)
|
|
2297
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2298
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2299
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2300
|
+
}
|
|
2301
|
+
return result;
|
|
2302
|
+
}
|
|
2303
|
+
async updateSessionBatch(inputs, options) {
|
|
2304
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2305
|
+
throw new Error("invalid command batch bounds");
|
|
2306
|
+
const start = options.checkpoint ?? 0;
|
|
2307
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2308
|
+
throw new Error("invalid command batch checkpoint");
|
|
2309
|
+
if (start === inputs.length)
|
|
2310
|
+
return { items: [], checkpoint: start };
|
|
2311
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2312
|
+
const normalizedInputs = inputs.map((input) => updateSession(input).input);
|
|
2313
|
+
const result = await this.transport.executeCommandBatch(updateSession(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2314
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2315
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_SESSION_PLAN_HASH)
|
|
2316
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2317
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2318
|
+
} return item; });
|
|
2319
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2320
|
+
return { items, checkpoint: result.checkpoint };
|
|
2321
|
+
}
|
|
2322
|
+
const items = [];
|
|
2323
|
+
let next = start;
|
|
2324
|
+
let completed = start;
|
|
2325
|
+
let checkpoint = start;
|
|
2326
|
+
const completedAfterCheckpoint = new Set();
|
|
2327
|
+
const worker = async () => { while (true) {
|
|
2328
|
+
const index = next++;
|
|
2329
|
+
if (index >= inputs.length)
|
|
2330
|
+
return;
|
|
2331
|
+
try {
|
|
2332
|
+
items.push({ index, result: await this.updateSession(inputs[index]) });
|
|
2333
|
+
}
|
|
2334
|
+
catch (error) {
|
|
2335
|
+
items.push({ index, error });
|
|
2336
|
+
}
|
|
2337
|
+
completed += 1;
|
|
2338
|
+
completedAfterCheckpoint.add(index);
|
|
2339
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2340
|
+
checkpoint += 1;
|
|
2341
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2342
|
+
} };
|
|
2343
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2344
|
+
items.sort((left, right) => left.index - right.index);
|
|
2345
|
+
return { items, checkpoint };
|
|
2346
|
+
}
|
|
2347
|
+
async updateUser(input) {
|
|
2348
|
+
const result = await this.transport.executeCommand(updateUser(input), this.commandAttemptBudget);
|
|
2349
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_USER_PLAN_HASH)
|
|
2350
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2351
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2352
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2353
|
+
}
|
|
2354
|
+
return result;
|
|
2355
|
+
}
|
|
2356
|
+
async updateUserBatch(inputs, options) {
|
|
2357
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2358
|
+
throw new Error("invalid command batch bounds");
|
|
2359
|
+
const start = options.checkpoint ?? 0;
|
|
2360
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2361
|
+
throw new Error("invalid command batch checkpoint");
|
|
2362
|
+
if (start === inputs.length)
|
|
2363
|
+
return { items: [], checkpoint: start };
|
|
2364
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2365
|
+
const normalizedInputs = inputs.map((input) => updateUser(input).input);
|
|
2366
|
+
const result = await this.transport.executeCommandBatch(updateUser(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2367
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2368
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_USER_PLAN_HASH)
|
|
2369
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2370
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2371
|
+
} return item; });
|
|
2372
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2373
|
+
return { items, checkpoint: result.checkpoint };
|
|
2374
|
+
}
|
|
2375
|
+
const items = [];
|
|
2376
|
+
let next = start;
|
|
2377
|
+
let completed = start;
|
|
2378
|
+
let checkpoint = start;
|
|
2379
|
+
const completedAfterCheckpoint = new Set();
|
|
2380
|
+
const worker = async () => { while (true) {
|
|
2381
|
+
const index = next++;
|
|
2382
|
+
if (index >= inputs.length)
|
|
2383
|
+
return;
|
|
2384
|
+
try {
|
|
2385
|
+
items.push({ index, result: await this.updateUser(inputs[index]) });
|
|
2386
|
+
}
|
|
2387
|
+
catch (error) {
|
|
2388
|
+
items.push({ index, error });
|
|
2389
|
+
}
|
|
2390
|
+
completed += 1;
|
|
2391
|
+
completedAfterCheckpoint.add(index);
|
|
2392
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2393
|
+
checkpoint += 1;
|
|
2394
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2395
|
+
} };
|
|
2396
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2397
|
+
items.sort((left, right) => left.index - right.index);
|
|
2398
|
+
return { items, checkpoint };
|
|
2399
|
+
}
|
|
2400
|
+
async updateVerification(input) {
|
|
2401
|
+
const result = await this.transport.executeCommand(updateVerification(input), this.commandAttemptBudget);
|
|
2402
|
+
if (result.contractVersion !== CONTRACT_VERSION || result.planHash !== UPDATE_VERIFICATION_PLAN_HASH)
|
|
2403
|
+
throw new Error("RiffDB application identity mismatch");
|
|
2404
|
+
if (this.trackCausalWrites && result.commitSequence !== undefined && result.commitSequence > 0n && (this.lastCommitSeq === undefined || result.commitSequence > this.lastCommitSeq)) {
|
|
2405
|
+
this.lastCommitSeq = result.commitSequence;
|
|
2406
|
+
}
|
|
2407
|
+
return result;
|
|
2408
|
+
}
|
|
2409
|
+
async updateVerificationBatch(inputs, options) {
|
|
2410
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > MAX_COMMAND_BATCH_CONCURRENCY || inputs.length < 1 || inputs.length > 4096)
|
|
2411
|
+
throw new Error("invalid command batch bounds");
|
|
2412
|
+
const start = options.checkpoint ?? 0;
|
|
2413
|
+
if (!Number.isInteger(start) || start < 0 || start > inputs.length)
|
|
2414
|
+
throw new Error("invalid command batch checkpoint");
|
|
2415
|
+
if (start === inputs.length)
|
|
2416
|
+
return { items: [], checkpoint: start };
|
|
2417
|
+
if (this.transport.executeCommandBatch !== undefined) {
|
|
2418
|
+
const normalizedInputs = inputs.map((input) => updateVerification(input).input);
|
|
2419
|
+
const result = await this.transport.executeCommandBatch(updateVerification(normalizedInputs[start]), normalizedInputs, options.concurrency, start, this.commandAttemptBudget);
|
|
2420
|
+
const items = result.items.map((item) => { if (item.result === undefined)
|
|
2421
|
+
return item; if (item.result.contractVersion !== CONTRACT_VERSION || item.result.planHash !== UPDATE_VERIFICATION_PLAN_HASH)
|
|
2422
|
+
throw new Error("RiffDB application identity mismatch"); if (this.trackCausalWrites && item.result.commitSequence !== undefined && item.result.commitSequence > 0n && (this.lastCommitSeq === undefined || item.result.commitSequence > this.lastCommitSeq)) {
|
|
2423
|
+
this.lastCommitSeq = item.result.commitSequence;
|
|
2424
|
+
} return item; });
|
|
2425
|
+
options.onProgress?.({ completed: result.checkpoint, total: inputs.length, checkpoint: result.checkpoint });
|
|
2426
|
+
return { items, checkpoint: result.checkpoint };
|
|
2427
|
+
}
|
|
2428
|
+
const items = [];
|
|
2429
|
+
let next = start;
|
|
2430
|
+
let completed = start;
|
|
2431
|
+
let checkpoint = start;
|
|
2432
|
+
const completedAfterCheckpoint = new Set();
|
|
2433
|
+
const worker = async () => { while (true) {
|
|
2434
|
+
const index = next++;
|
|
2435
|
+
if (index >= inputs.length)
|
|
2436
|
+
return;
|
|
2437
|
+
try {
|
|
2438
|
+
items.push({ index, result: await this.updateVerification(inputs[index]) });
|
|
2439
|
+
}
|
|
2440
|
+
catch (error) {
|
|
2441
|
+
items.push({ index, error });
|
|
2442
|
+
}
|
|
2443
|
+
completed += 1;
|
|
2444
|
+
completedAfterCheckpoint.add(index);
|
|
2445
|
+
while (completedAfterCheckpoint.delete(checkpoint))
|
|
2446
|
+
checkpoint += 1;
|
|
2447
|
+
options.onProgress?.({ completed, total: inputs.length, checkpoint });
|
|
2448
|
+
} };
|
|
2449
|
+
await Promise.all(Array.from({ length: Math.min(options.concurrency, inputs.length - start) }, worker));
|
|
2450
|
+
items.sort((left, right) => left.index - right.index);
|
|
2451
|
+
return { items, checkpoint };
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
//# sourceMappingURL=client.js.map
|