@mdbase-dev/connect 0.1.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +696 -0
- package/dist/advanced.d.ts +9 -0
- package/dist/advanced.js +6 -0
- package/dist/application-contract.d.ts +22 -0
- package/dist/application-contract.js +75 -0
- package/dist/application-identity.d.ts +34 -0
- package/dist/application-identity.js +148 -0
- package/dist/application-session.d.ts +167 -0
- package/dist/application-session.js +722 -0
- package/dist/async.d.ts +1 -0
- package/dist/async.js +19 -0
- package/dist/authority-proof.d.ts +3 -0
- package/dist/authority-proof.js +24 -0
- package/dist/authority-sync-request.d.ts +3 -0
- package/dist/authority-sync-request.js +20 -0
- package/dist/authorization-refresh.d.ts +14 -0
- package/dist/authorization-refresh.js +41 -0
- package/dist/authorization-types.d.ts +7 -0
- package/dist/authorization-types.js +1 -0
- package/dist/authorization-url.d.ts +5 -0
- package/dist/authorization-url.js +34 -0
- package/dist/base64.d.ts +3 -0
- package/dist/base64.js +21 -0
- package/dist/browser/integrity.json +4 -0
- package/dist/browser/mdbase-connect.min.js +3 -0
- package/dist/browser/mdbase-connect.min.js.sha384 +1 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +5 -0
- package/dist/capabilities.d.ts +24 -0
- package/dist/capabilities.js +91 -0
- package/dist/collection-client.d.ts +66 -0
- package/dist/collection-client.js +686 -0
- package/dist/connect-authorization-helpers.d.ts +4 -0
- package/dist/connect-authorization-helpers.js +25 -0
- package/dist/connect-options.d.ts +35 -0
- package/dist/connect-options.js +1 -0
- package/dist/connect.d.ts +66 -0
- package/dist/connect.js +711 -0
- package/dist/connection-file-transport.d.ts +34 -0
- package/dist/connection-file-transport.js +85 -0
- package/dist/connection-index.d.ts +3 -0
- package/dist/connection-index.js +20 -0
- package/dist/connection-notifications.d.ts +31 -0
- package/dist/connection-notifications.js +197 -0
- package/dist/connection-transport-internals.d.ts +24 -0
- package/dist/connection-transport-internals.js +1 -0
- package/dist/connection-transport.d.ts +64 -0
- package/dist/connection-transport.js +725 -0
- package/dist/connection-types.d.ts +38 -0
- package/dist/connection-types.js +1 -0
- package/dist/connection.d.ts +175 -0
- package/dist/connection.js +606 -0
- package/dist/crypto-entry.d.ts +7 -0
- package/dist/crypto-entry.js +4 -0
- package/dist/crypto.d.ts +63 -0
- package/dist/crypto.js +409 -0
- package/dist/direct-access.d.ts +3 -0
- package/dist/direct-access.js +29 -0
- package/dist/errors.d.ts +45 -0
- package/dist/errors.js +142 -0
- package/dist/external-store.d.ts +10 -0
- package/dist/external-store.js +10 -0
- package/dist/file-crypto.d.ts +25 -0
- package/dist/file-crypto.js +132 -0
- package/dist/file-sha256.d.ts +12 -0
- package/dist/file-sha256.js +143 -0
- package/dist/file-stream-source.d.ts +17 -0
- package/dist/file-stream-source.js +157 -0
- package/dist/file-transfer-internals.d.ts +23 -0
- package/dist/file-transfer-internals.js +228 -0
- package/dist/files.d.ts +115 -0
- package/dist/files.js +563 -0
- package/dist/fresh-encrypted-request.d.ts +4 -0
- package/dist/fresh-encrypted-request.js +28 -0
- package/dist/grant-key-leases.d.ts +24 -0
- package/dist/grant-key-leases.js +144 -0
- package/dist/hosted-file-request.d.ts +6 -0
- package/dist/hosted-file-request.js +63 -0
- package/dist/hosted-operation-response.d.ts +5 -0
- package/dist/hosted-operation-response.js +26 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +10 -0
- package/dist/internal-types.d.ts +100 -0
- package/dist/internal-types.js +1 -0
- package/dist/local-file-transport.d.ts +37 -0
- package/dist/local-file-transport.js +457 -0
- package/dist/mdbase-connect.d.ts +28 -0
- package/dist/mdbase-connect.js +53 -0
- package/dist/notifications.d.ts +48 -0
- package/dist/notifications.js +52 -0
- package/dist/operation-helpers.d.ts +27 -0
- package/dist/operation-helpers.js +144 -0
- package/dist/operation-types.d.ts +707 -0
- package/dist/operation-types.js +1 -0
- package/dist/outcomes.d.ts +51 -0
- package/dist/outcomes.js +194 -0
- package/dist/pending-mutation-store.d.ts +13 -0
- package/dist/pending-mutation-store.js +64 -0
- package/dist/pending-recovery-transports.d.ts +5 -0
- package/dist/pending-recovery-transports.js +52 -0
- package/dist/popup-authorization.d.ts +31 -0
- package/dist/popup-authorization.js +100 -0
- package/dist/query-pagination.d.ts +6 -0
- package/dist/query-pagination.js +119 -0
- package/dist/request-budget.d.ts +34 -0
- package/dist/request-budget.js +104 -0
- package/dist/request-coordinator.d.ts +29 -0
- package/dist/request-coordinator.js +213 -0
- package/dist/retired-grant-keys.d.ts +9 -0
- package/dist/retired-grant-keys.js +56 -0
- package/dist/runtime-utils.d.ts +52 -0
- package/dist/runtime-utils.js +368 -0
- package/dist/saved-view-pagination.d.ts +6 -0
- package/dist/saved-view-pagination.js +76 -0
- package/dist/selection.d.ts +48 -0
- package/dist/selection.js +112 -0
- package/dist/session.d.ts +114 -0
- package/dist/session.js +569 -0
- package/dist/shared-operation.d.ts +7 -0
- package/dist/shared-operation.js +41 -0
- package/dist/stored-token.d.ts +10 -0
- package/dist/stored-token.js +64 -0
- package/dist/structured-readiness.d.ts +77 -0
- package/dist/structured-readiness.js +126 -0
- package/dist/token-response.d.ts +12 -0
- package/dist/token-response.js +81 -0
- package/dist/transient-retry.d.ts +22 -0
- package/dist/transient-retry.js +59 -0
- package/dist/watch-policy.d.ts +8 -0
- package/dist/watch-policy.js +12 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sha384-qa5e6QDDjQFkjqKf4HstaDjyvJmQnvu4PkubKmMs2QIDou3qqMn+uYWQG2Z0ImA2
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ApplicationCapabilityRequirements, type LegacyApplicationCapabilityRequirements } from "@mdbase-dev/connect-protocol";
|
|
2
|
+
import type { MdbaseApplicationCapabilityId as ApplicationCapabilityId, MdbaseApplicationManifest as MdbaseAppManifest } from "./application-contract.js";
|
|
3
|
+
import type { MdbaseConnectionInfo } from "./connection-types.js";
|
|
4
|
+
export type MdbaseCapabilityState = "available" | "requires_authorization" | "requires_setup" | "temporarily_unavailable" | "unsupported";
|
|
5
|
+
export interface MdbaseCapabilityEvidence {
|
|
6
|
+
source: "application" | "authorization" | "authority" | "runtime";
|
|
7
|
+
fact: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MdbaseEffectiveCapability {
|
|
10
|
+
id: ApplicationCapabilityId;
|
|
11
|
+
requirement: "required" | "optional";
|
|
12
|
+
state: MdbaseCapabilityState;
|
|
13
|
+
operations: string[];
|
|
14
|
+
missingOperations: string[];
|
|
15
|
+
evidence: MdbaseCapabilityEvidence[];
|
|
16
|
+
reason?: string;
|
|
17
|
+
details?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface MdbaseEffectiveCapabilities {
|
|
20
|
+
contractVersion: 1 | 2;
|
|
21
|
+
values: Partial<Record<ApplicationCapabilityId, MdbaseEffectiveCapability>>;
|
|
22
|
+
requiredAvailable: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function effectiveCapabilities(requirements: ApplicationCapabilityRequirements | LegacyApplicationCapabilityRequirements, manifest: MdbaseAppManifest, connection: MdbaseConnectionInfo): MdbaseEffectiveCapabilities;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { capabilityOperationsForContractVersion } from "@mdbase-dev/connect-protocol";
|
|
2
|
+
export function effectiveCapabilities(requirements, manifest, connection) {
|
|
3
|
+
const required = new Set(requirements.required);
|
|
4
|
+
const declared = [...new Set([...requirements.required, ...(requirements.optional ?? [])])];
|
|
5
|
+
const values = {};
|
|
6
|
+
for (const id of declared) {
|
|
7
|
+
values[id] = effectiveCapability(id, required.has(id), connection, requirements.contract_version, manifest);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
contractVersion: requirements.contract_version,
|
|
11
|
+
values,
|
|
12
|
+
requiredAvailable: requirements.required.every((id) => values[id]?.state === "available")
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function effectiveCapability(id, required, connection, version, manifest) {
|
|
16
|
+
const operations = capabilityOperationsForContractVersion(version, id) ?? [];
|
|
17
|
+
const missingOperations = operations.filter((operation) => !connection.operations.includes(operation));
|
|
18
|
+
const base = {
|
|
19
|
+
id,
|
|
20
|
+
requirement: required ? "required" : "optional",
|
|
21
|
+
operations,
|
|
22
|
+
missingOperations,
|
|
23
|
+
evidence: [{
|
|
24
|
+
source: "application",
|
|
25
|
+
fact: `${required ? "Required" : "Optional"} in capability contract v${version}.`
|
|
26
|
+
}]
|
|
27
|
+
};
|
|
28
|
+
if (missingOperations.length > 0) {
|
|
29
|
+
return {
|
|
30
|
+
...base,
|
|
31
|
+
state: "requires_authorization",
|
|
32
|
+
evidence: [...base.evidence, {
|
|
33
|
+
source: "authorization",
|
|
34
|
+
fact: `Missing ${missingOperations.join(", ")}.`
|
|
35
|
+
}],
|
|
36
|
+
reason: "The current grant does not include every operation for this capability."
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (connection.scope.access !== "full_collection") {
|
|
40
|
+
return {
|
|
41
|
+
...base,
|
|
42
|
+
state: "requires_authorization",
|
|
43
|
+
reason: "The current grant uses legacy contract scope and must be reauthorized for the entire collection.",
|
|
44
|
+
evidence: [...base.evidence, {
|
|
45
|
+
source: "authorization",
|
|
46
|
+
fact: "Legacy contract scope is compatibility evidence, not active data authority."
|
|
47
|
+
}]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Compatibility readiness is deliberately limited to v1 aliases. V2 needs
|
|
51
|
+
// structured file/notification/runtime evidence, not these legacy shortcuts.
|
|
52
|
+
if (version === 1 && id.startsWith("files.")) {
|
|
53
|
+
const action = id.slice("files.".length);
|
|
54
|
+
if (!connection.fileCapability?.actions.includes(action)) {
|
|
55
|
+
return {
|
|
56
|
+
...base,
|
|
57
|
+
state: connection.fileCapability ? "requires_authorization" : "unsupported",
|
|
58
|
+
reason: connection.fileCapability ? `The current file grant does not include ${action}.` : "This connection has no file capability."
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (version === 1 && id === "notifications.background-delivery" && (manifest.notifications?.criteria.length ?? 0) === 0) {
|
|
63
|
+
return { ...base, state: "requires_setup", reason: "The application manifest declares no notification criteria." };
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...base,
|
|
67
|
+
state: "available",
|
|
68
|
+
evidence: [...base.evidence, {
|
|
69
|
+
source: "authorization",
|
|
70
|
+
fact: operations.length > 0
|
|
71
|
+
? `Granted operations: ${operations.join(", ")}.`
|
|
72
|
+
: "No record operation is required."
|
|
73
|
+
}, {
|
|
74
|
+
source: "authority",
|
|
75
|
+
fact: connection.authority.kind === "hosted"
|
|
76
|
+
? "Backed by a durable hosted mdbase authority."
|
|
77
|
+
: "Backed by a user-operated mdbase connector."
|
|
78
|
+
}],
|
|
79
|
+
...(id === "offline.replica" || (version === 1 && id === "sync.offline-replica")
|
|
80
|
+
? {
|
|
81
|
+
details: {
|
|
82
|
+
durability: "device",
|
|
83
|
+
writes: "queued",
|
|
84
|
+
authority: connection.authority.kind
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
...(version === 1 && id === "notifications.background-delivery"
|
|
89
|
+
? { details: { delivery: "authority", payload: "opaque" } } : {})
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CollectionOperation, CollectionTypeDocument, JsonObject } from "@mdbase-dev/connect-protocol";
|
|
2
|
+
import { type CollectionChangesProblemCode, type CollectionDescriptionProblemCode, type CollectionMutationProblemCode, type CollectionQueryProblemCode, type CollectionReadProblemCode, type CollectionTypeProblemCode, type ConnectOutcome } from "./outcomes.js";
|
|
3
|
+
import type { ChangesInput, CollectionChange, CollectionChangesPage, CollectionDescription, CollectionSetupApplyResult, CollectionSetupAssessment, AssessCollectionSetupInput, AssessTypePackInput, ApplyCollectionSetupInput, ApplyTypePackInput, CreateInput, CreateTypeInput, CreateViewSourceInput, DeleteInput, DeletePreflightResult, DeleteResult, DeleteViewSourceInput, DeleteViewSourceResult, ExecuteViewInput, MdbaseCollectionTransport, MdbaseDesiredTimer, MdbaseTimer, MdbaseTimerList, MdbaseTimerReconciliation, ConnectRequestOptions, QueryAllOptions, QueryInput, QueryPage, QueryPagesOptions, QueryResult, ReadInput, ReadTypeInput, ReadViewSourceInput, RenameInput, RenamePreflightResult, RenameResult, RecordDocument, SavedViewExecution, SavedViewPage, SavedViewPagesOptions, SavedViewList, SavedViewSourceDocument, TypePackApplyResult, TypePackAssessment, UpdateInput, UpdateTypeInput, UpdateViewSourceInput, WatchOptions } from "./operation-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Typed collection operations independent of OAuth, HTTP, or storage.
|
|
6
|
+
*
|
|
7
|
+
* Application code can use this surface against Connect, the developer
|
|
8
|
+
* sandbox, or another provider without changing its record logic.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MdbaseCollectionClient<Frontmatter extends JsonObject = JsonObject> {
|
|
11
|
+
private readonly transport;
|
|
12
|
+
private readonly requestTimeoutMs;
|
|
13
|
+
constructor(transport: MdbaseCollectionTransport, requestTimeoutMs?: number | null);
|
|
14
|
+
operation<Result>(operation: CollectionOperation, input: unknown, options?: ConnectRequestOptions): Promise<ConnectOutcome<Result>>;
|
|
15
|
+
describe(options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionDescription, CollectionDescriptionProblemCode>>;
|
|
16
|
+
changes(input?: ChangesInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionChangesPage, CollectionChangesProblemCode>>;
|
|
17
|
+
read(input: ReadInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<RecordDocument<Frontmatter>, CollectionReadProblemCode>>;
|
|
18
|
+
query(input?: QueryInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<QueryResult<Frontmatter>, CollectionQueryProblemCode>>;
|
|
19
|
+
queryPages(input?: QueryInput, options?: QueryPagesOptions<Frontmatter>): AsyncGenerator<ConnectOutcome<QueryPage<Frontmatter>, CollectionQueryProblemCode>>;
|
|
20
|
+
queryAll(input?: QueryInput, options?: QueryAllOptions<Frontmatter>): Promise<ConnectOutcome<QueryResult<Frontmatter>, CollectionQueryProblemCode>>;
|
|
21
|
+
listViews(options?: ConnectRequestOptions): Promise<ConnectOutcome<SavedViewList, CollectionReadProblemCode>>;
|
|
22
|
+
executeView(input: ExecuteViewInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<SavedViewExecution<Frontmatter>, CollectionReadProblemCode>>;
|
|
23
|
+
executeViewPages(input: ExecuteViewInput, options?: SavedViewPagesOptions<Frontmatter>): AsyncGenerator<ConnectOutcome<SavedViewPage<Frontmatter>, CollectionReadProblemCode>>;
|
|
24
|
+
readViewSource(input: ReadViewSourceInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<SavedViewSourceDocument, CollectionReadProblemCode>>;
|
|
25
|
+
createViewSource(input: CreateViewSourceInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<SavedViewSourceDocument, CollectionMutationProblemCode>>;
|
|
26
|
+
updateViewSource(input: UpdateViewSourceInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<SavedViewSourceDocument, CollectionMutationProblemCode>>;
|
|
27
|
+
deleteViewSource(input: DeleteViewSourceInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<DeleteViewSourceResult, CollectionMutationProblemCode>>;
|
|
28
|
+
create(input: CreateInput<Frontmatter>, options?: ConnectRequestOptions): Promise<ConnectOutcome<RecordDocument<Frontmatter>, CollectionMutationProblemCode>>;
|
|
29
|
+
update(input: UpdateInput<Frontmatter>, options?: ConnectRequestOptions): Promise<ConnectOutcome<RecordDocument<Frontmatter>, CollectionMutationProblemCode>>;
|
|
30
|
+
delete(input: DeleteInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<DeleteResult, CollectionMutationProblemCode>>;
|
|
31
|
+
preflightDelete(input: DeleteInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<DeletePreflightResult, CollectionMutationProblemCode>>;
|
|
32
|
+
rename(input: RenameInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<RenameResult, CollectionMutationProblemCode>>;
|
|
33
|
+
preflightRename(input: RenameInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<RenamePreflightResult, CollectionMutationProblemCode>>;
|
|
34
|
+
validate(input?: JsonObject, options?: ConnectRequestOptions): Promise<ConnectOutcome<JsonObject, CollectionReadProblemCode>>;
|
|
35
|
+
readType(input: ReadTypeInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionTypeDocument, CollectionTypeProblemCode>>;
|
|
36
|
+
createType(input: CreateTypeInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionTypeDocument, CollectionTypeProblemCode>>;
|
|
37
|
+
updateType(input: UpdateTypeInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionTypeDocument, CollectionTypeProblemCode>>;
|
|
38
|
+
assessTypePack(input: AssessTypePackInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<TypePackAssessment, CollectionTypeProblemCode>>;
|
|
39
|
+
applyTypePack(input: ApplyTypePackInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<TypePackApplyResult, CollectionTypeProblemCode>>;
|
|
40
|
+
assessCollectionSetup(input: AssessCollectionSetupInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionSetupAssessment, CollectionTypeProblemCode>>;
|
|
41
|
+
applyCollectionSetup(input: ApplyCollectionSetupInput, options?: ConnectRequestOptions): Promise<ConnectOutcome<CollectionSetupApplyResult, CollectionTypeProblemCode>>;
|
|
42
|
+
listTimers(namespace: string, options?: ConnectRequestOptions): Promise<ConnectOutcome<MdbaseTimerList, CollectionReadProblemCode>>;
|
|
43
|
+
putTimer(input: {
|
|
44
|
+
namespace: string;
|
|
45
|
+
criterionId: string;
|
|
46
|
+
timer: MdbaseDesiredTimer;
|
|
47
|
+
}, options?: ConnectRequestOptions): Promise<ConnectOutcome<MdbaseTimer, CollectionMutationProblemCode>>;
|
|
48
|
+
cancelTimer(input: {
|
|
49
|
+
namespace: string;
|
|
50
|
+
id: string;
|
|
51
|
+
generation?: number;
|
|
52
|
+
}, options?: ConnectRequestOptions): Promise<ConnectOutcome<{
|
|
53
|
+
namespace: string;
|
|
54
|
+
id: string;
|
|
55
|
+
cancelled: boolean;
|
|
56
|
+
}, CollectionMutationProblemCode>>;
|
|
57
|
+
reconcileTimers(input: {
|
|
58
|
+
namespace: string;
|
|
59
|
+
criterionId: string;
|
|
60
|
+
timers: MdbaseDesiredTimer[];
|
|
61
|
+
}, options?: ConnectRequestOptions): Promise<ConnectOutcome<MdbaseTimerReconciliation, CollectionMutationProblemCode>>;
|
|
62
|
+
watch(options?: WatchOptions): AsyncGenerator<ConnectOutcome<CollectionChange, CollectionChangesProblemCode>>;
|
|
63
|
+
private rawOperation;
|
|
64
|
+
private releaseQueryCursor;
|
|
65
|
+
private envelopeOperation;
|
|
66
|
+
}
|